summaryrefslogtreecommitdiff
path: root/sys/androidmedia/gstamcvideodec.c
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-03 10:06:02 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-10-15 16:28:42 +0200
commit86176bd2a216cbc5ae2565e899bbd1bc97c50fec (patch)
treec68fe4aacaca45b9c55a1ce4547c9c14e7bf79b0 /sys/androidmedia/gstamcvideodec.c
parentfc5a18c091303302a5ac5f32589611bed9df1ae8 (diff)
downloadgstreamer-plugins-bad-86176bd2a216cbc5ae2565e899bbd1bc97c50fec.tar.gz
List profiles in reverse to minimize caps
Diffstat (limited to 'sys/androidmedia/gstamcvideodec.c')
-rw-r--r--sys/androidmedia/gstamcvideodec.c193
1 files changed, 100 insertions, 93 deletions
diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c
index b0cfd7237..7eace20fc 100644
--- a/sys/androidmedia/gstamcvideodec.c
+++ b/sys/androidmedia/gstamcvideodec.c
@@ -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, };
-
- 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)
+ 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);
+
+ 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;
- 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;
+ 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;
+ }
}
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);
-
- if (profile == -1) {
- GST_ERROR ("Unable to map h263 profile 0x%08x",
- type->profile_levels[j].profile);
- continue;
- }
+ profile =
+ gst_amc_h263_profile_to_gst_id (type->profile_levels[j].profile);
- 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) {