From: <th...@fr...> - 2005-11-22 23:13:13
|
CVS Root: /cvs/gstreamer Module: gst-ffmpeg Changes by: thaytan Date: Tue Nov 22 2005 15:13:03 PST Log message: * HACKING: * ext/ffmpeg/gstffmpegcolorspace.c: Remove mentions of ffmpegcolorspace now that it's in gst-plugins-base * ext/ffmpeg/Makefile.am: Link to gstreamer libraries * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_to_pixfmt): * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init), (gst_ffmpegdec_close), (gst_ffmpegdec_setcaps), (gst_ffmpegdec_negotiate), (gst_ffmpegdec_frame): Convert to fractional framerate Modified files: . : ChangeLog HACKING ext/ffmpeg : Makefile.am gstffmpegcodecmap.c gstffmpegdec.c Removed files: ext/ffmpeg : gstffmpegcolorspace.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ChangeLog.diff?r1=1.220&r2=1.221 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/HACKING.diff?r1=1.7&r2=1.8 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/Makefile.am.diff?r1=1.22&r2=1.23 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.c.diff?r1=1.96&r2=1.97 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcolorspace.c http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegdec.c.diff?r1=1.126&r2=1.127 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-ffmpeg/ChangeLog,v retrieving revision 1.220 retrieving revision 1.221 diff -u -d -r1.220 -r1.221 --- ChangeLog 22 Nov 2005 12:01:00 -0000 1.220 +++ ChangeLog 22 Nov 2005 23:12:51 -0000 1.221 @@ -1,3 +1,18 @@ +2005-11-23 Jan Schmidt <th...@ma...> + + * HACKING: + * ext/ffmpeg/gstffmpegcolorspace.c: + Remove mentions of ffmpegcolorspace now that it's in + gst-plugins-base + * ext/ffmpeg/Makefile.am: + Link to gstreamer libraries + * ext/ffmpeg/gstffmpegcodecmap.c: (gst_ffmpeg_caps_to_pixfmt): + * ext/ffmpeg/gstffmpegdec.c: (gst_ffmpegdec_init), + (gst_ffmpegdec_close), (gst_ffmpegdec_setcaps), + (gst_ffmpegdec_negotiate), (gst_ffmpegdec_frame): + Convert to fractional framerate 2005-11-22 Andy Wingo <wi...@po...> * ext/ffmpeg/gstffmpegdec.c (gst_ffmpegdec_sink_event): Run Index: HACKING RCS file: /cvs/gstreamer/gst-ffmpeg/HACKING,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- HACKING 14 Apr 2004 15:21:51 -0000 1.7 +++ HACKING 22 Nov 2005 23:12:51 -0000 1.8 @@ -195,19 +195,10 @@ * gstffmpeg{dec,enc,demux,mux}.c are wrappers for specific element types from their ffmpeg counterpart. If you want to wrap a new type of element in wrapper file. - -* gstffmpegcolorspace.c is a wrapper for one specific function in ffmpeg: - colorspace conversion. This works different from the previously mentioned - ones, and we'll come to that in the next item. If you want to wrap one - specific function, then that, too, belongs in a new wrapper file. -* the important difference between all those is that the colorspace element - contains one element, so there is a 1<->1 mapping. This makes for a fairly - basic element implementation. gstffmpegcolorspace.c, therefore, doesn't - differ much from other colorspace elements. The ffmpeg element types, - however, define a whole *list* of elements (in GStreamer, each decoder etc. - needs to be its own element). We use a set of tricks for that to keep - coding simple: codec mapping and dynamic type creation. + The ffmpeg element types, define a whole *list* of elements (in + GStreamer, each decoder etc. needs to be its own element). + We use a set of tricks for that to keep coding simple: codec + mapping and dynamic type creation. * ffmpeg uses CODEC_ID_* enumerations for their codecs. GStreamer uses caps, which consists of a mimetype and a defined set of properties. In ffmpeg, Index: Makefile.am RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/Makefile.am,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Makefile.am 23 Oct 2005 16:07:46 -0000 1.22 +++ Makefile.am 22 Nov 2005 23:12:51 -0000 1.23 @@ -7,17 +7,16 @@ # gstffmpegdemux.c \ # gstffmpegmux.c \ # gstffmpegprotocol.c \ -# gstffmpegcolorspace.c \ # gstffmpegscale.c \ # gstffmpegdeinterlace.c -libgstffmpeg_la_CFLAGS = $(GST_CFLAGS) \ +libgstffmpeg_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) \ -I $(top_srcdir)/gst-libs/ext/ffmpeg/libavformat \ -I $(top_srcdir)/gst-libs/ext/ffmpeg/libavutil \ -I $(top_srcdir)/gst-libs/ext/ffmpeg/libavcodec libgstffmpeg_la_LIBADD = \ - $(top_builddir)/gst-libs/ext/ffmpeg/libavformat/libavformat.la + $(top_builddir)/gst-libs/ext/ffmpeg/libavformat/libavformat.la \ + $(GST_LIBS) libgstffmpeg_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = \ Index: gstffmpegcodecmap.c RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegcodecmap.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- gstffmpegcodecmap.c 23 Oct 2005 16:07:46 -0000 1.96 +++ gstffmpegcodecmap.c 22 Nov 2005 23:12:51 -0000 1.97 @@ -86,17 +86,14 @@ gst_caps_new_simple (mimetype, \ "width", G_TYPE_INT, context->width, \ "height", G_TYPE_INT, context->height, \ - "framerate", G_TYPE_DOUBLE, (double) 1. * \ - context->time_base.den / \ - context->time_base.num, \ - __VA_ARGS__, NULL) \ + "framerate", GST_TYPE_FRACTION, context->time_base.den, \ + context->time_base.num, __VA_ARGS__, NULL) \ : \ "width", GST_TYPE_INT_RANGE, 16, 4096, \ "height", GST_TYPE_INT_RANGE, 16, 4096, \ - "framerate", GST_TYPE_DOUBLE_RANGE, (double) 1., \ - G_MAXDOUBLE, \ - __VA_ARGS__, NULL) + "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, \ + G_MAXINT, 1, __VA_ARGS__, NULL) /* same for audio - now with channels/sample rate */ @@ -1102,7 +1099,7 @@ AVCodecContext * context, gboolean raw) { GstStructure *structure; - gdouble fps; + const GValue *fps; g_return_if_fail (gst_caps_get_size (caps) == 1); structure = gst_caps_get_structure (caps, 0); @@ -1111,23 +1108,16 @@ gst_structure_get_int (structure, "height", &context->height); gst_structure_get_int (structure, "bpp", &context->bits_per_sample); - if (gst_structure_get_double (structure, "framerate", &fps)) { - GValue dfps = { 0 }; - GValue framerate = { 0 }; - /* convert double to fraction for the framerate */ - g_value_init (&dfps, G_TYPE_DOUBLE); - g_value_init (&framerate, GST_TYPE_FRACTION); - g_value_set_double (&dfps, fps); - g_value_transform (&dfps, &framerate); + fps = gst_structure_get_value (structure, "framerate"); + g_return_if_fail (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)); - /* somehow these seem mixed up.. */ - context->time_base.den = gst_value_get_fraction_numerator (&framerate); - context->time_base.num = gst_value_get_fraction_denominator (&framerate); + /* somehow these seem mixed up.. */ + context->time_base.den = gst_value_get_fraction_numerator (fps); + context->time_base.num = gst_value_get_fraction_denominator (fps); - GST_DEBUG ("setting framerate %d/%d = %lf", - context->time_base.den, context->time_base.num, fps); - } + GST_DEBUG ("setting framerate %d/%d = %lf", + context->time_base.den, context->time_base.num, + 1. * context->time_base.den / context->time_base.num); if (!raw) return; --- gstffmpegcolorspace.c DELETED --- Index: gstffmpegdec.c RCS file: /cvs/gstreamer/gst-ffmpeg/ext/ffmpeg/gstffmpegdec.c,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- gstffmpegdec.c 22 Nov 2005 12:01:00 -0000 1.126 +++ gstffmpegdec.c 22 Nov 2005 23:12:51 -0000 1.127 @@ -56,7 +56,9 @@ struct { gint width, height; - gdouble fps, old_fps; + gint fps_n, fps_d; + gint old_fps_n, old_fps_d; enum PixelFormat pix_fmt; } video; @@ -289,8 +291,8 @@ ffmpegdec->last_buffer = NULL; - ffmpegdec->format.video.fps = -1.0; - ffmpegdec->format.video.old_fps = -1.0; + ffmpegdec->format.video.fps_n = -1; + ffmpegdec->format.video.old_fps_n = -1; } static void @@ -402,8 +404,8 @@ ffmpegdec->pctx = NULL; } static gboolean @@ -466,6 +468,7 @@ (GstFFMpegDecClass *) (G_OBJECT_GET_CLASS (ffmpegdec)); const GValue *par; GST_DEBUG ("setcaps called"); @@ -498,13 +501,12 @@ gst_value_init_and_copy (ffmpegdec->par, par); - if (gst_structure_has_field (structure, "framerate")) { - ffmpegdec->format.video.old_fps = ffmpegdec->format.video.fps; - gst_structure_get_double (structure, "framerate", - &ffmpegdec->format.video.fps); + if (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps)) { + ffmpegdec->format.video.fps_n = gst_value_get_fraction_numerator (fps); + ffmpegdec->format.video.fps_d = gst_value_get_fraction_denominator (fps); } else { - ffmpegdec->format.video.fps = -1.0; + ffmpegdec->format.video.fps_n = -1; /* do *not* draw edges */ @@ -635,16 +637,19 @@ case CODEC_TYPE_VIDEO: if (ffmpegdec->format.video.width == ffmpegdec->context->width && ffmpegdec->format.video.height == ffmpegdec->context->height && - ffmpegdec->format.video.fps == ffmpegdec->format.video.old_fps && + ffmpegdec->format.video.fps_n == ffmpegdec->format.video.old_fps_n && + ffmpegdec->format.video.fps_d == ffmpegdec->format.video.old_fps_d && ffmpegdec->format.video.pix_fmt == ffmpegdec->context->pix_fmt) return TRUE; - GST_DEBUG ("Renegotiating video from %dx%d@%0.2ffps to %dx%d@%0.2ffps", + GST_DEBUG ("Renegotiating video from %dx%d@ %d/%d fps to %dx%d@ %d/%d fps", ffmpegdec->format.video.width, ffmpegdec->format.video.height, - ffmpegdec->format.video.old_fps, ffmpegdec->context->width, - ffmpegdec->context->height, ffmpegdec->format.video.old_fps); + ffmpegdec->format.video.old_fps_n, ffmpegdec->format.video.old_fps_n, + ffmpegdec->context->width, ffmpegdec->context->height, + ffmpegdec->format.video.fps_n, ffmpegdec->format.video.fps_d); ffmpegdec->format.video.width = ffmpegdec->context->width; ffmpegdec->format.video.height = ffmpegdec->context->height; - ffmpegdec->format.video.old_fps = ffmpegdec->format.video.fps; + ffmpegdec->format.video.old_fps_n = ffmpegdec->format.video.fps_n; + ffmpegdec->format.video.old_fps_d = ffmpegdec->format.video.fps_d; ffmpegdec->format.video.pix_fmt = ffmpegdec->context->pix_fmt; break; case CODEC_TYPE_AUDIO: @@ -667,9 +672,10 @@ if (caps) { /* If a demuxer provided a framerate then use it (#313970) */ - if (ffmpegdec->format.video.fps != -1.0) { + if (ffmpegdec->format.video.fps_n != -1) { gst_structure_set (gst_caps_get_structure (caps, 0), "framerate", - G_TYPE_DOUBLE, ffmpegdec->format.video.fps, NULL); + GST_TYPE_FRACTION, ffmpegdec->format.video.fps_n, + ffmpegdec->format.video.fps_d, NULL); } /* Add pixel-aspect-ratio if we have it. Prefer @@ -835,15 +841,16 @@ /* If we have used the framerate from the demuxer then * also use the demuxer's timestamp information (#317596) */ - if (ffmpegdec->format.video.fps != -1.0 && inbuf != NULL) { + if (ffmpegdec->format.video.fps_n != -1 && inbuf != NULL) { gst_buffer_stamp (outbuf, inbuf); } else { GST_BUFFER_TIMESTAMP (outbuf) = ffmpegdec->next_ts; if (ffmpegdec->context->time_base.num != 0 && ffmpegdec->context->time_base.den != 0) { - GST_BUFFER_DURATION (outbuf) = GST_SECOND * - ffmpegdec->context->time_base.num / - ffmpegdec->context->time_base.den; + GST_BUFFER_DURATION (outbuf) = + gst_util_clock_time_scale (GST_SECOND, + ffmpegdec->context->time_base.num, + ffmpegdec->context->time_base.den); /* Take repeat_pict into account */ GST_BUFFER_DURATION (outbuf) += GST_BUFFER_DURATION (outbuf) |