summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2012-10-01 09:37:21 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-03-24 19:38:13 +0100
commite61ae7ffa2560d4954dee63a64993369ca16c705 (patch)
tree54e9544868588fdf9f980bf2e60b7c6f824319f6 /gst-libs
parentbd4dceeff46d1874c6106ec0a04bfbe71cb1a11b (diff)
codecparsers: h264: add gst_h264_parse_sps_data() helper.
Split seq_parameter_set_data() parsing off gst_h264_parse_sps() so that it could be re-used later on. https://bugzilla.gnome.org/show_bug.cgi?id=685215 Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/codecparsers/gsth264parser.c123
1 files changed, 69 insertions, 54 deletions
diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c
index 19521282c..a89db0d3a 100644
--- a/gst-libs/gst/codecparsers/gsth264parser.c
+++ b/gst-libs/gst/codecparsers/gsth264parser.c
@@ -1182,30 +1182,16 @@ gst_h264_parser_parse_sps (GstH264NalParser * nalparser, GstH264NalUnit * nalu,
return res;
}
-/**
- * gst_h264_parse_sps:
- * @nalu: The #GST_H264_NAL_SPS #GstH264NalUnit to parse
- * @sps: The #GstH264SPS to fill.
- * @parse_vui_params: Whether to parse the vui_params or not
- *
- * Parses @data, and fills the @sps structure.
- *
- * Returns: a #GstH264ParserResult
- */
-GstH264ParserResult
-gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
+/* Parse seq_parameter_set_data() */
+static gboolean
+gst_h264_parse_sps_data (NalReader * nr, GstH264SPS * sps,
gboolean parse_vui_params)
{
- NalReader nr;
gint width, height;
guint subwc[] = { 1, 2, 2, 1 };
guint subhc[] = { 1, 2, 1, 1 };
GstH264VUIParams *vui = NULL;
- INITIALIZE_DEBUG_CATEGORY;
- GST_DEBUG ("parsing SPS");
- nal_reader_init (&nr, nalu->data + nalu->offset + 1, nalu->size - 1);
-
/* set default values for fields that might not be present in the bitstream
and have valid defaults */
sps->chroma_format_idc = 1;
@@ -1222,38 +1208,38 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
sps->frame_crop_bottom_offset = 0;
sps->delta_pic_order_always_zero_flag = 0;
- READ_UINT8 (&nr, sps->profile_idc, 8);
- READ_UINT8 (&nr, sps->constraint_set0_flag, 1);
- READ_UINT8 (&nr, sps->constraint_set1_flag, 1);
- READ_UINT8 (&nr, sps->constraint_set2_flag, 1);
- READ_UINT8 (&nr, sps->constraint_set3_flag, 1);
+ READ_UINT8 (nr, sps->profile_idc, 8);
+ READ_UINT8 (nr, sps->constraint_set0_flag, 1);
+ READ_UINT8 (nr, sps->constraint_set1_flag, 1);
+ READ_UINT8 (nr, sps->constraint_set2_flag, 1);
+ READ_UINT8 (nr, sps->constraint_set3_flag, 1);
/* skip reserved_zero_4bits */
- if (!nal_reader_skip (&nr, 4))
+ if (!nal_reader_skip (nr, 4))
goto error;
- READ_UINT8 (&nr, sps->level_idc, 8);
+ READ_UINT8 (nr, sps->level_idc, 8);
- READ_UE_ALLOWED (&nr, sps->id, 0, GST_H264_MAX_SPS_COUNT - 1);
+ READ_UE_ALLOWED (nr, sps->id, 0, GST_H264_MAX_SPS_COUNT - 1);
if (sps->profile_idc == 100 || sps->profile_idc == 110 ||
sps->profile_idc == 122 || sps->profile_idc == 244 ||
sps->profile_idc == 44 || sps->profile_idc == 83 ||
sps->profile_idc == 86) {
- READ_UE_ALLOWED (&nr, sps->chroma_format_idc, 0, 3);
+ READ_UE_ALLOWED (nr, sps->chroma_format_idc, 0, 3);
if (sps->chroma_format_idc == 3)
- READ_UINT8 (&nr, sps->separate_colour_plane_flag, 1);
+ READ_UINT8 (nr, sps->separate_colour_plane_flag, 1);
- READ_UE_ALLOWED (&nr, sps->bit_depth_luma_minus8, 0, 6);
- READ_UE_ALLOWED (&nr, sps->bit_depth_chroma_minus8, 0, 6);
- READ_UINT8 (&nr, sps->qpprime_y_zero_transform_bypass_flag, 1);
+ READ_UE_ALLOWED (nr, sps->bit_depth_luma_minus8, 0, 6);
+ READ_UE_ALLOWED (nr, sps->bit_depth_chroma_minus8, 0, 6);
+ READ_UINT8 (nr, sps->qpprime_y_zero_transform_bypass_flag, 1);
- READ_UINT8 (&nr, sps->scaling_matrix_present_flag, 1);
+ READ_UINT8 (nr, sps->scaling_matrix_present_flag, 1);
if (sps->scaling_matrix_present_flag) {
guint8 n_lists;
n_lists = (sps->chroma_format_idc != 3) ? 8 : 12;
- if (!gst_h264_parser_parse_scaling_list (&nr,
+ if (!gst_h264_parser_parse_scaling_list (nr,
sps->scaling_lists_4x4, sps->scaling_lists_8x8,
default_4x4_inter, default_4x4_intra,
default_8x8_inter, default_8x8_intra, n_lists))
@@ -1261,46 +1247,46 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
}
}
- READ_UE_ALLOWED (&nr, sps->log2_max_frame_num_minus4, 0, 12);
+ READ_UE_ALLOWED (nr, sps->log2_max_frame_num_minus4, 0, 12);
sps->max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4);
- READ_UE_ALLOWED (&nr, sps->pic_order_cnt_type, 0, 2);
+ READ_UE_ALLOWED (nr, sps->pic_order_cnt_type, 0, 2);
if (sps->pic_order_cnt_type == 0) {
- READ_UE_ALLOWED (&nr, sps->log2_max_pic_order_cnt_lsb_minus4, 0, 12);
+ READ_UE_ALLOWED (nr, sps->log2_max_pic_order_cnt_lsb_minus4, 0, 12);
} else if (sps->pic_order_cnt_type == 1) {
guint i;
- READ_UINT8 (&nr, sps->delta_pic_order_always_zero_flag, 1);
- READ_SE (&nr, sps->offset_for_non_ref_pic);
- READ_SE (&nr, sps->offset_for_top_to_bottom_field);
- READ_UE_ALLOWED (&nr, sps->num_ref_frames_in_pic_order_cnt_cycle, 0, 255);
+ READ_UINT8 (nr, sps->delta_pic_order_always_zero_flag, 1);
+ READ_SE (nr, sps->offset_for_non_ref_pic);
+ READ_SE (nr, sps->offset_for_top_to_bottom_field);
+ READ_UE_ALLOWED (nr, sps->num_ref_frames_in_pic_order_cnt_cycle, 0, 255);
for (i = 0; i < sps->num_ref_frames_in_pic_order_cnt_cycle; i++)
- READ_SE (&nr, sps->offset_for_ref_frame[i]);
+ READ_SE (nr, sps->offset_for_ref_frame[i]);
}
- READ_UE (&nr, sps->num_ref_frames);
- READ_UINT8 (&nr, sps->gaps_in_frame_num_value_allowed_flag, 1);
- READ_UE (&nr, sps->pic_width_in_mbs_minus1);
- READ_UE (&nr, sps->pic_height_in_map_units_minus1);
- READ_UINT8 (&nr, sps->frame_mbs_only_flag, 1);
+ READ_UE (nr, sps->num_ref_frames);
+ READ_UINT8 (nr, sps->gaps_in_frame_num_value_allowed_flag, 1);
+ READ_UE (nr, sps->pic_width_in_mbs_minus1);
+ READ_UE (nr, sps->pic_height_in_map_units_minus1);
+ READ_UINT8 (nr, sps->frame_mbs_only_flag, 1);
if (!sps->frame_mbs_only_flag)
- READ_UINT8 (&nr, sps->mb_adaptive_frame_field_flag, 1);
+ READ_UINT8 (nr, sps->mb_adaptive_frame_field_flag, 1);
- READ_UINT8 (&nr, sps->direct_8x8_inference_flag, 1);
- READ_UINT8 (&nr, sps->frame_cropping_flag, 1);
+ READ_UINT8 (nr, sps->direct_8x8_inference_flag, 1);
+ READ_UINT8 (nr, sps->frame_cropping_flag, 1);
if (sps->frame_cropping_flag) {
- READ_UE (&nr, sps->frame_crop_left_offset);
- READ_UE (&nr, sps->frame_crop_right_offset);
- READ_UE (&nr, sps->frame_crop_top_offset);
- READ_UE (&nr, sps->frame_crop_bottom_offset);
+ READ_UE (nr, sps->frame_crop_left_offset);
+ READ_UE (nr, sps->frame_crop_right_offset);
+ READ_UE (nr, sps->frame_crop_top_offset);
+ READ_UE (nr, sps->frame_crop_bottom_offset);
}
- READ_UINT8 (&nr, sps->vui_parameters_present_flag, 1);
+ READ_UINT8 (nr, sps->vui_parameters_present_flag, 1);
if (sps->vui_parameters_present_flag && parse_vui_params) {
- if (!gst_h264_parse_vui_parameters (sps, &nr))
+ if (!gst_h264_parse_vui_parameters (sps, nr))
goto error;
vui = &sps->vui_parameters;
}
@@ -1364,6 +1350,35 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
} else {
GST_LOG ("No VUI, unknown framerate");
}
+ return TRUE;
+
+error:
+ return FALSE;
+}
+
+/**
+ * gst_h264_parse_sps:
+ * @nalu: The #GST_H264_NAL_SPS #GstH264NalUnit to parse
+ * @sps: The #GstH264SPS to fill.
+ * @parse_vui_params: Whether to parse the vui_params or not
+ *
+ * Parses @data, and fills the @sps structure.
+ *
+ * Returns: a #GstH264ParserResult
+ */
+GstH264ParserResult
+gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
+ gboolean parse_vui_params)
+{
+ NalReader nr;
+
+ INITIALIZE_DEBUG_CATEGORY;
+ GST_DEBUG ("parsing SPS");
+
+ nal_reader_init (&nr, nalu->data + nalu->offset + 1, nalu->size - 1);
+
+ if (!gst_h264_parse_sps_data (&nr, sps, parse_vui_params))
+ goto error;
sps->valid = TRUE;