h264parse: Remove the explicit PAR calculation based on VUI headers

The PAR calculation based on VUI headers is already doing by the
h264 codecparser and we does't need to duplicate those code.

https://bugzilla.gnome.org//show_bug.cgi?id=711009
This commit is contained in:
Sreerenj Balachandran 2013-10-28 15:04:16 +02:00 committed by Sebastian Dröge
parent fa12af3d01
commit ab3f7d6096
2 changed files with 21 additions and 110 deletions

View file

@ -184,11 +184,10 @@ gst_h264_parse_reset (GstH264Parse * h264parse)
h264parse->height = 0;
h264parse->fps_num = 0;
h264parse->fps_den = 0;
h264parse->aspect_ratio_idc = 0;
h264parse->sar_width = 0;
h264parse->sar_height = 0;
h264parse->upstream_par_n = -1;
h264parse->upstream_par_d = -1;
h264parse->parsed_par_n = 0;
h264parse->parsed_par_d = 0;
gst_buffer_replace (&h264parse->codec_data, NULL);
gst_buffer_replace (&h264parse->codec_data_in, NULL);
h264parse->nal_length_size = 4;
@ -1066,91 +1065,13 @@ gst_h264_parse_make_codec_data (GstH264Parse * h264parse)
static void
gst_h264_parse_get_par (GstH264Parse * h264parse, gint * num, gint * den)
{
gint par_n, par_d;
if (h264parse->upstream_par_n != -1 && h264parse->upstream_par_d != -1) {
*num = h264parse->upstream_par_n;
*den = h264parse->upstream_par_d;
return;
} else {
*num = h264parse->parsed_par_n;
*den = h264parse->parsed_par_d;
}
switch (h264parse->aspect_ratio_idc) {
case 1:
par_n = 1;
par_d = 1;
break;
case 2:
par_n = 12;
par_d = 11;
break;
case 3:
par_n = 10;
par_d = 11;
break;
case 4:
par_n = 16;
par_d = 11;
break;
case 5:
par_n = 40;
par_d = 33;
break;
case 6:
par_n = 24;
par_d = 11;
break;
case 7:
par_n = 20;
par_d = 11;
break;
case 8:
par_n = 32;
par_d = 11;
break;
case 9:
par_n = 80;
par_d = 33;
break;
case 10:
par_n = 18;
par_d = 11;
break;
case 11:
par_n = 15;
par_d = 11;
break;
case 12:
par_n = 64;
par_d = 33;
break;
case 13:
par_n = 160;
par_d = 99;
break;
case 14:
par_n = 4;
par_d = 3;
break;
case 15:
par_n = 3;
par_d = 2;
break;
case 16:
par_n = 2;
par_d = 1;
break;
case 255:
par_n = h264parse->sar_width;
par_d = h264parse->sar_height;
break;
default:
/* 0 and other values are undefined */
par_n = par_d = 0;
break;
}
*num = par_n;
*den = par_d;
}
static void
@ -1242,23 +1163,12 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps)
}
if (sps->vui_parameters.aspect_ratio_info_present_flag) {
if (G_UNLIKELY (h264parse->aspect_ratio_idc !=
sps->vui_parameters.aspect_ratio_idc)) {
h264parse->aspect_ratio_idc = sps->vui_parameters.aspect_ratio_idc;
GST_INFO_OBJECT (h264parse, "aspect ratio idc changed %d",
h264parse->aspect_ratio_idc);
modified = TRUE;
}
/* 255 means sar_width and sar_height present */
if (G_UNLIKELY (sps->vui_parameters.aspect_ratio_idc == 255 &&
(h264parse->sar_width != sps->vui_parameters.sar_width ||
h264parse->sar_height != sps->vui_parameters.sar_height))) {
h264parse->sar_width = sps->vui_parameters.sar_width;
h264parse->sar_height = sps->vui_parameters.sar_height;
GST_INFO_OBJECT (h264parse, "aspect ratio SAR changed %d/%d",
h264parse->sar_width, h264parse->sar_height);
modified = TRUE;
if (G_UNLIKELY ((h264parse->parsed_par_n != sps->vui_parameters.par_n)
|| (h264parse->parsed_par_d != sps->vui_parameters.par_d))) {
h264parse->parsed_par_n = sps->vui_parameters.par_n;
h264parse->parsed_par_d = sps->vui_parameters.par_d;
GST_INFO_OBJECT (h264parse, "pixel aspect ratio has been changed %d/%d",
h264parse->parsed_par_n, h264parse->parsed_par_d);
}
}
@ -1532,8 +1442,8 @@ gst_h264_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
/* sends a codec NAL downstream, decorating and transforming as needed.
* No ownership is taken of @nal */
static GstFlowReturn
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
GstClockTime ts)
gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse,
GstBuffer * nal, GstClockTime ts)
{
GstMapInfo map;
@ -1549,8 +1459,9 @@ gst_h264_parse_push_codec_buffer (GstH264Parse * h264parse, GstBuffer * nal,
}
static GstEvent *
check_pending_key_unit_event (GstEvent * pending_event, GstSegment * segment,
GstClockTime timestamp, guint flags, GstClockTime pending_key_unit_ts)
check_pending_key_unit_event (GstEvent * pending_event,
GstSegment * segment, GstClockTime timestamp, guint flags,
GstClockTime pending_key_unit_ts)
{
GstClockTime running_time, stream_time;
gboolean all_headers;
@ -2034,7 +1945,8 @@ gst_h264_parse_event (GstBaseParse * parse, GstEvent * event)
gst_video_event_parse_downstream_force_key_unit (event,
&timestamp, &stream_time, &running_time, &all_headers, &count);
GST_INFO_OBJECT (h264parse, "received downstream force key unit event, "
GST_INFO_OBJECT (h264parse,
"received downstream force key unit event, "
"seqnum %d running_time %" GST_TIME_FORMAT
" all_headers %d count %d", gst_event_get_seqnum (event),
GST_TIME_ARGS (running_time), all_headers, count);
@ -2137,8 +2049,8 @@ gst_h264_parse_set_property (GObject * object, guint prop_id,
}
static void
gst_h264_parse_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
gst_h264_parse_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstH264Parse *parse;

View file

@ -56,9 +56,8 @@ struct _GstH264Parse
/* stream */
gint width, height;
gint fps_num, fps_den;
gint aspect_ratio_idc;
gint sar_width, sar_height;
gint upstream_par_n, upstream_par_d;
gint parsed_par_n, parsed_par_d;
/* current codec_data in output caps, if any */
GstBuffer *codec_data;
/* input codec_data, if any */