mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
h264parser: Parse the cropping-rectangle separately.
Assign the un-cropped width/height to sps->width/sps->height during sps header parsing. Added new fields to SPS header structure to provide the crop-rectangle dimensions. https://bugzilla.gnome.org/show_bug.cgi?id=694068
This commit is contained in:
parent
1472dd3d58
commit
529ece338f
2 changed files with 23 additions and 10 deletions
|
@ -1437,7 +1437,6 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
|
|||
{
|
||||
NalReader nr;
|
||||
gint width, height;
|
||||
guint8 frame_cropping_flag;
|
||||
guint subwc[] = { 1, 2, 2, 1 };
|
||||
guint subhc[] = { 1, 2, 1, 1 };
|
||||
GstH264VUIParams *vui = NULL;
|
||||
|
@ -1530,8 +1529,8 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
|
|||
READ_UINT8 (&nr, sps->mb_adaptive_frame_field_flag, 1);
|
||||
|
||||
READ_UINT8 (&nr, sps->direct_8x8_inference_flag, 1);
|
||||
READ_UINT8 (&nr, frame_cropping_flag, 1);
|
||||
if (frame_cropping_flag) {
|
||||
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);
|
||||
|
@ -1557,19 +1556,31 @@ gst_h264_parse_sps (GstH264NalUnit * nalu, GstH264SPS * sps,
|
|||
height = (sps->pic_height_in_map_units_minus1 + 1);
|
||||
height *= 16 * (2 - sps->frame_mbs_only_flag);
|
||||
GST_LOG ("initial width=%d, height=%d", width, height);
|
||||
|
||||
width -= (sps->frame_crop_left_offset + sps->frame_crop_right_offset)
|
||||
* subwc[sps->chroma_format_idc];
|
||||
height -= (sps->frame_crop_top_offset + sps->frame_crop_bottom_offset
|
||||
* subhc[sps->chroma_format_idc] * (2 - sps->frame_mbs_only_flag));
|
||||
if (width < 0 || height < 0) {
|
||||
GST_WARNING ("invalid width/height in SPS");
|
||||
goto error;
|
||||
}
|
||||
GST_LOG ("final width=%u, height=%u", width, height);
|
||||
|
||||
sps->width = width;
|
||||
sps->height = height;
|
||||
|
||||
if (sps->frame_cropping_flag) {
|
||||
width -= (sps->frame_crop_left_offset + sps->frame_crop_right_offset)
|
||||
* subwc[sps->chroma_format_idc];
|
||||
height -= (sps->frame_crop_top_offset + sps->frame_crop_bottom_offset
|
||||
* subhc[sps->chroma_format_idc] * (2 - sps->frame_mbs_only_flag));
|
||||
|
||||
sps->crop_rect_width = width;
|
||||
sps->crop_rect_height = height;
|
||||
sps->crop_rect_x =
|
||||
sps->frame_crop_left_offset * subwc[sps->chroma_format_idc];
|
||||
sps->crop_rect_y =
|
||||
sps->frame_crop_top_offset * subhc[sps->chroma_format_idc] * (2 -
|
||||
sps->frame_mbs_only_flag);
|
||||
|
||||
GST_LOG ("crop_rectangle x=%u y=%u width=%u, height=%u", sps->crop_rect_x,
|
||||
sps->crop_rect_y, width, height);
|
||||
}
|
||||
sps->fps_num = 0;
|
||||
sps->fps_den = 1;
|
||||
|
||||
|
|
|
@ -467,12 +467,14 @@ struct _GstH264SPS
|
|||
|
||||
guint8 vui_parameters_present_flag;
|
||||
/* if vui_parameters_present_flag */
|
||||
GstH264VUIParams vui_parameters;
|
||||
GstH264VUIParams vui_parameters;
|
||||
|
||||
/* calculated values */
|
||||
guint8 chroma_array_type;
|
||||
guint32 max_frame_num;
|
||||
gint width, height;
|
||||
gint crop_rect_width, crop_rect_height;
|
||||
gint crop_rect_x, crop_rect_y;
|
||||
gint fps_num, fps_den;
|
||||
gboolean valid;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue