ext/mpeg2dec/gstmpeg2dec.*: Use fractional framerates

Original commit message from CVS:
* ext/mpeg2dec/gstmpeg2dec.c: (src_templ),
(gst_mpeg2dec_negotiate_format), (handle_sequence),
(gst_mpeg2dec_sink_event):
* ext/mpeg2dec/gstmpeg2dec.h:
Use fractional framerates
This commit is contained in:
Jan Schmidt 2005-11-23 00:12:24 +00:00
parent 93933f17fa
commit 23b68823d6
3 changed files with 25 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2005-11-23 Jan Schmidt <thaytan@mad.scientist.com>
* ext/mpeg2dec/gstmpeg2dec.c: (src_templ),
(gst_mpeg2dec_negotiate_format), (handle_sequence),
(gst_mpeg2dec_sink_event):
* ext/mpeg2dec/gstmpeg2dec.h:
Use fractional framerates
2005-11-22 Wim Taymans <wim@fluendo.com> 2005-11-22 Wim Taymans <wim@fluendo.com>
* gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_set_clock): * gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_set_clock):

View file

@ -43,9 +43,10 @@ GST_DEBUG_CATEGORY_STATIC (mpeg2dec_debug);
#define GST_CAT_DEFAULT (mpeg2dec_debug) #define GST_CAT_DEFAULT (mpeg2dec_debug)
/* table with framerates expressed as fractions */ /* table with framerates expressed as fractions */
static gdouble fpss[] = { 24.0 / 1.001, 24.0, 25.0, static gint fpss[][2] = { {24000, 1001},
30.0 / 1.001, 30.0, 50.0, {24, 1}, {25, 1}, {30000, 1001},
60.0 / 1.001, 60.0, 0 {30, 1}, {50, 1}, {60000, 1001},
{60, 1}, {0, 1}
}; };
/* frame periods */ /* frame periods */
@ -77,6 +78,8 @@ enum
/* /*
* We can't use fractions in static pad templates, so * We can't use fractions in static pad templates, so
* we do something manual... * we do something manual...
* FIXME: This is no longer true. We could use a normal pad template
* now
*/ */
static GstPadTemplate * static GstPadTemplate *
src_templ (void) src_templ (void)
@ -103,9 +106,9 @@ src_templ (void)
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
g_value_init (&list, GST_TYPE_LIST); g_value_init (&list, GST_TYPE_LIST);
g_value_init (&fps, G_TYPE_DOUBLE); g_value_init (&fps, GST_TYPE_FRACTION);
for (n = 0; fpss[n] != 0; n++) { for (n = 0; fpss[n][0] != 0; n++) {
g_value_set_double (&fps, fpss[n]); gst_value_set_fraction (&fps, fpss[n][0], fpss[n][1]);
gst_value_list_append_value (&list, &fps); gst_value_list_append_value (&list, &fps);
} }
gst_structure_set_value (structure, "framerate", &list); gst_structure_set_value (structure, "framerate", &list);
@ -510,7 +513,7 @@ gst_mpeg2dec_negotiate_format (GstMpeg2dec * mpeg2dec)
"height", G_TYPE_INT, mpeg2dec->height, "height", G_TYPE_INT, mpeg2dec->height,
"pixel-aspect-ratio", GST_TYPE_FRACTION, mpeg2dec->pixel_width, "pixel-aspect-ratio", GST_TYPE_FRACTION, mpeg2dec->pixel_width,
mpeg2dec->pixel_height, mpeg2dec->pixel_height,
"framerate", G_TYPE_DOUBLE, mpeg2dec->frame_rate, NULL); "framerate", GST_TYPE_FRACTION, mpeg2dec->fps_n, mpeg2dec->fps_d, NULL);
gst_pad_set_caps (mpeg2dec->srcpad, caps); gst_pad_set_caps (mpeg2dec->srcpad, caps);
gst_caps_unref (caps); gst_caps_unref (caps);
@ -536,15 +539,17 @@ handle_sequence (GstMpeg2dec * mpeg2dec, const mpeg2_info_t * info)
/* find framerate */ /* find framerate */
for (i = 0; i < 9; i++) { for (i = 0; i < 9; i++) {
if (info->sequence->frame_period == frame_periods[i]) { if (info->sequence->frame_period == frame_periods[i]) {
mpeg2dec->frame_rate = fpss[i]; mpeg2dec->fps_n = fpss[i][0];
mpeg2dec->fps_d = fpss[i][1];
} }
} }
mpeg2dec->frame_period = info->sequence->frame_period * GST_USECOND / 27; mpeg2dec->frame_period = info->sequence->frame_period * GST_USECOND / 27;
GST_DEBUG_OBJECT (mpeg2dec, GST_DEBUG_OBJECT (mpeg2dec,
"sequence flags: %d, frame period: %d (%g), frame rate: %g", "sequence flags: %d, frame period: %d (%g), frame rate: %d/%d",
info->sequence->flags, info->sequence->frame_period, info->sequence->flags, info->sequence->frame_period,
(double) (mpeg2dec->frame_period) / GST_SECOND, mpeg2dec->frame_rate); (double) (mpeg2dec->frame_period) / GST_SECOND, mpeg2dec->fps_n,
mpeg2dec->fps_d);
GST_DEBUG_OBJECT (mpeg2dec, "profile: %02x, colour_primaries: %d", GST_DEBUG_OBJECT (mpeg2dec, "profile: %02x, colour_primaries: %d",
info->sequence->profile_level_id, info->sequence->colour_primaries); info->sequence->profile_level_id, info->sequence->colour_primaries);
GST_DEBUG_OBJECT (mpeg2dec, "transfer chars: %d, matrix coef: %d", GST_DEBUG_OBJECT (mpeg2dec, "transfer chars: %d, matrix coef: %d",
@ -911,7 +916,6 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
} }
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;
default: default:
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;

View file

@ -97,7 +97,8 @@ struct _GstMpeg2dec {
gint64 frame_period; gint64 frame_period;
guint64 offset; guint64 offset;
gdouble frame_rate; gint fps_n;
gint fps_d;
gboolean need_sequence; gboolean need_sequence;
GstEvent *pending_event; GstEvent *pending_event;