List profiles in reverse to minimize caps

This commit is contained in:
Sebastian Dröge 2012-10-03 10:06:02 +02:00
parent fc5a18c091
commit 86176bd2a2

View file

@ -124,7 +124,8 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
"systemstream", G_TYPE_BOOLEAN, FALSE,
"parsed", G_TYPE_BOOLEAN, TRUE, NULL);
for (j = 0; j < type->n_profile_levels; j++) {
if (type->n_profile_levels) {
for (j = type->n_profile_levels - 1; j >= 0; j--) {
const gchar *profile, *level;
gint k;
GValue va = { 0, };
@ -141,7 +142,7 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
continue;
}
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
for (k = 1; k <= type->profile_levels[j].level && k != 0; k <<= 1) {
level = gst_amc_mpeg4_level_to_string (k);
if (!level)
continue;
@ -159,6 +160,7 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
gst_caps_merge_structure (ret, tmp2);
have_profile_level = TRUE;
}
}
if (!have_profile_level) {
gst_caps_merge_structure (ret, tmp);
@ -178,7 +180,8 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
"parsed", G_TYPE_BOOLEAN, TRUE,
"variant", G_TYPE_STRING, "itu", NULL);
for (j = 0; j < type->n_profile_levels; j++) {
if (type->n_profile_levels) {
for (j = type->n_profile_levels - 1; j >= 0; j--) {
gint profile, level;
gint k;
GValue va = { 0, };
@ -196,7 +199,7 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
continue;
}
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
for (k = 1; k <= type->profile_levels[j].level && k != 0; k <<= 1) {
level = gst_amc_h263_level_to_gst_id (k);
if (level == -1)
continue;
@ -213,6 +216,7 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
gst_caps_merge_structure (ret, tmp2);
have_profile_level = TRUE;
}
}
if (!have_profile_level) {
gst_caps_merge_structure (ret, tmp);
@ -233,7 +237,8 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
"stream-format", G_TYPE_STRING, "byte-stream",
"alignment", G_TYPE_STRING, "au", NULL);
for (j = 0; j < type->n_profile_levels; j++) {
if (type->n_profile_levels) {
for (j = type->n_profile_levels - 1; j >= 0; j--) {
const gchar *profile, *alternative = NULL, *level;
gint k;
GValue va = { 0, };
@ -252,7 +257,7 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
continue;
}
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
for (k = 1; k <= type->profile_levels[j].level && k != 0; k <<= 1) {
level = gst_amc_avc_level_to_string (k);
if (!level)
continue;
@ -271,13 +276,15 @@ create_sink_caps (const GstAmcCodecInfo * codec_info)
if (alternative) {
tmp2 = gst_structure_copy (tmp);
gst_structure_set (tmp2, "profile", G_TYPE_STRING, alternative, NULL);
gst_structure_set (tmp2, "profile", G_TYPE_STRING, alternative,
NULL);
gst_structure_set_value (tmp2, "level", &va);
g_value_unset (&va);
gst_caps_merge_structure (ret, tmp2);
}
have_profile_level = TRUE;
}
}
if (!have_profile_level) {
gst_caps_merge_structure (ret, tmp);