mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-27 11:32:51 +00:00
List profiles in reverse to minimize caps
This commit is contained in:
parent
fc5a18c091
commit
86176bd2a2
1 changed files with 98 additions and 91 deletions
|
@ -124,40 +124,42 @@ 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++) {
|
||||
const gchar *profile, *level;
|
||||
gint k;
|
||||
GValue va = { 0, };
|
||||
GValue v = { 0, };
|
||||
if (type->n_profile_levels) {
|
||||
for (j = type->n_profile_levels - 1; j >= 0; j--) {
|
||||
const gchar *profile, *level;
|
||||
gint k;
|
||||
GValue va = { 0, };
|
||||
GValue v = { 0, };
|
||||
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
|
||||
profile =
|
||||
gst_amc_mpeg4_profile_to_string (type->profile_levels[j].profile);
|
||||
if (!profile) {
|
||||
GST_ERROR ("Unable to map MPEG4 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
|
||||
level = gst_amc_mpeg4_level_to_string (k);
|
||||
if (!level)
|
||||
profile =
|
||||
gst_amc_mpeg4_profile_to_string (type->profile_levels[j].profile);
|
||||
if (!profile) {
|
||||
GST_ERROR ("Unable to map MPEG4 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_value_set_string (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
for (k = 1; k <= type->profile_levels[j].level && k != 0; k <<= 1) {
|
||||
level = gst_amc_mpeg4_level_to_string (k);
|
||||
if (!level)
|
||||
continue;
|
||||
|
||||
g_value_set_string (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
}
|
||||
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_STRING, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
have_profile_level = TRUE;
|
||||
}
|
||||
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_STRING, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
have_profile_level = TRUE;
|
||||
}
|
||||
|
||||
if (!have_profile_level) {
|
||||
|
@ -178,40 +180,42 @@ 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++) {
|
||||
gint profile, level;
|
||||
gint k;
|
||||
GValue va = { 0, };
|
||||
GValue v = { 0, };
|
||||
if (type->n_profile_levels) {
|
||||
for (j = type->n_profile_levels - 1; j >= 0; j--) {
|
||||
gint profile, level;
|
||||
gint k;
|
||||
GValue va = { 0, };
|
||||
GValue v = { 0, };
|
||||
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_UINT);
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_UINT);
|
||||
|
||||
profile =
|
||||
gst_amc_h263_profile_to_gst_id (type->profile_levels[j].profile);
|
||||
profile =
|
||||
gst_amc_h263_profile_to_gst_id (type->profile_levels[j].profile);
|
||||
|
||||
if (profile == -1) {
|
||||
GST_ERROR ("Unable to map h263 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
|
||||
level = gst_amc_h263_level_to_gst_id (k);
|
||||
if (level == -1)
|
||||
if (profile == -1) {
|
||||
GST_ERROR ("Unable to map h263 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_value_set_uint (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
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;
|
||||
|
||||
g_value_set_uint (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
}
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_UINT, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
have_profile_level = TRUE;
|
||||
}
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_UINT, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
have_profile_level = TRUE;
|
||||
}
|
||||
|
||||
if (!have_profile_level) {
|
||||
|
@ -233,50 +237,53 @@ 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++) {
|
||||
const gchar *profile, *alternative = NULL, *level;
|
||||
gint k;
|
||||
GValue va = { 0, };
|
||||
GValue v = { 0, };
|
||||
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, };
|
||||
GValue v = { 0, };
|
||||
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
g_value_init (&va, GST_TYPE_LIST);
|
||||
g_value_init (&v, G_TYPE_STRING);
|
||||
|
||||
profile =
|
||||
gst_amc_avc_profile_to_string (type->profile_levels[j].profile,
|
||||
&alternative);
|
||||
profile =
|
||||
gst_amc_avc_profile_to_string (type->profile_levels[j].profile,
|
||||
&alternative);
|
||||
|
||||
if (!profile) {
|
||||
GST_ERROR ("Unable to map H264 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (k = type->profile_levels[j].level; k > 0; k >>= 1) {
|
||||
level = gst_amc_avc_level_to_string (k);
|
||||
if (!level)
|
||||
if (!profile) {
|
||||
GST_ERROR ("Unable to map H264 profile 0x%08x",
|
||||
type->profile_levels[j].profile);
|
||||
continue;
|
||||
}
|
||||
|
||||
g_value_set_string (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
}
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_STRING, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
if (!alternative)
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
for (k = 1; k <= type->profile_levels[j].level && k != 0; k <<= 1) {
|
||||
level = gst_amc_avc_level_to_string (k);
|
||||
if (!level)
|
||||
continue;
|
||||
|
||||
if (alternative) {
|
||||
g_value_set_string (&v, level);
|
||||
gst_value_list_append_value (&va, &v);
|
||||
g_value_reset (&v);
|
||||
}
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_STRING, alternative, NULL);
|
||||
gst_structure_set (tmp2, "profile", G_TYPE_STRING, profile, NULL);
|
||||
gst_structure_set_value (tmp2, "level", &va);
|
||||
g_value_unset (&va);
|
||||
if (!alternative)
|
||||
g_value_unset (&va);
|
||||
g_value_unset (&v);
|
||||
gst_caps_merge_structure (ret, tmp2);
|
||||
|
||||
if (alternative) {
|
||||
tmp2 = gst_structure_copy (tmp);
|
||||
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;
|
||||
}
|
||||
have_profile_level = TRUE;
|
||||
}
|
||||
|
||||
if (!have_profile_level) {
|
||||
|
|
Loading…
Reference in a new issue