From: Ronald B. <rb...@us...> - 2003-10-26 11:35:32
|
CVS Root: /cvsroot/gstreamer Module: gst-plugins Changes by: rbultje Date: Sun Oct 26 2003 03:30:30 PST Log message: Make it compile against latest CVS of FFMPEG: * Put gst/gst.h above avcodec.h because it needs some types defined in glib.h * Remove HQ (removed from lavc) property Also add some functions to make SVQ1 decoding work: * Add YUV9 colorspace * Let lavc do its own buffer allocation and copy from there instead of using our own buffer allocation functions. Somehow, that breaks. I don't know why. Modified files: ext/ffmpeg : gstffmpeg.c gstffmpegcodecmap.c gstffmpegcolorspace.c gstffmpegdec.c gstffmpegenc.c Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpeg.c.diff?r1=1.11&r2=1.12 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegcodecmap.c.diff?r1=1.16&r2=1.17 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegcolorspace.c.diff?r1=1.1&r2=1.2 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegdec.c.diff?r1=1.26&r2=1.27 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegenc.c.diff?r1=1.25&r2=1.26 ====Begin Diffs==== Index: gstffmpeg.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpeg.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- gstffmpeg.c 25 Oct 2003 16:29:13 -0000 1.11 +++ gstffmpeg.c 26 Oct 2003 11:30:18 -0000 1.12 @@ -22,6 +22,7 @@ */ #include "config.h" +#include <gst/gst.h> #ifdef HAVE_FFMPEG_UNINSTALLED #include <avcodec.h> #include <avformat.h> @@ -29,8 +30,6 @@ #include <ffmpeg/avcodec.h> #include <ffmpeg/avformat.h> #endif - -#include <gst/gst.h> extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin); extern gboolean gst_ffmpegdec_register (GstPlugin *plugin); Index: gstffmpegcodecmap.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegcodecmap.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- gstffmpegcodecmap.c 22 Oct 2003 10:17:15 -0000 1.16 +++ gstffmpegcodecmap.c 26 Oct 2003 11:30:18 -0000 1.17 @@ -20,13 +20,13 @@ */ #include "config.h" +#include <gst/gst.h> #ifdef HAVE_FFMPEG_UNINSTALLED #include <avcodec.h> #else #include <ffmpeg/avcodec.h> #endif #include <string.h> -#include <gst/gst.h> #include "gstffmpegcodecmap.h" @@ -758,9 +758,17 @@ case GST_MAKE_FOURCC ('I','4','2','0'): context->pix_fmt = PIX_FMT_YUV420P; break; - case GST_MAKE_FOURCC ('Y','4','1','P'): + case GST_MAKE_FOURCC ('Y','4','1','B'): context->pix_fmt = PIX_FMT_YUV411P; break; + case GST_MAKE_FOURCC ('Y','U','V','9'): + context->pix_fmt = PIX_FMT_YUV410P; + break; +#if 0 + case FIXME: + context->pix_fmt = PIX_FMT_YUV444P; + break; +#endif case GST_MAKE_FOURCC ('R','G','B',' '): if (gst_caps_has_property_typed (caps, "depth", GST_PROPS_INT_TYPE) && Index: gstffmpegcolorspace.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegcolorspace.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstffmpegcolorspace.c 25 Oct 2003 16:29:13 -0000 1.1 +++ gstffmpegcolorspace.c 26 Oct 2003 11:30:18 -0000 1.2 @@ -23,12 +23,12 @@ #include "config.h" #endif +#include <gst/gst.h> #ifdef HAVE_FFMPEG_UNINSTALLED #include <avcodec.h> #else #include <ffmpeg/avcodec.h> #endif -#include <gst/gst.h> #include "gstffmpegcodecmap.h" Index: gstffmpegdec.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegdec.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- gstffmpegdec.c 9 Oct 2003 02:23:00 -0000 1.26 +++ gstffmpegdec.c 26 Oct 2003 11:30:18 -0000 1.27 @@ -96,11 +96,13 @@ static GstElementStateReturn gst_ffmpegdec_change_state (GstElement *element); +#if 0 /* some sort of bufferpool handling, but different */ static int gst_ffmpegdec_get_buffer (AVCodecContext *context, AVFrame *picture); static void gst_ffmpegdec_release_buffer (AVCodecContext *context, AVFrame *picture); +#endif static GstElementClass *parent_class = NULL; @@ -185,9 +187,11 @@ /* set defaults */ avcodec_get_context_defaults (ffmpegdec->context); +#if 0 /* set buffer functions */ ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer; ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer; +#endif /* get size and so */ gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type, @@ -216,6 +220,7 @@ return GST_PAD_LINK_OK; } +#if 0 static int gst_ffmpegdec_get_buffer (AVCodecContext *context, AVFrame *picture) @@ -268,6 +273,7 @@ picture->linesize[i] = 0; } } +#endif static void gst_ffmpegdec_chain (GstPad *pad, @@ -306,8 +312,24 @@ &have_data, data, size); if (have_data) { - outbuf = GST_BUFFER (ffmpegdec->picture->base[0]); - GST_BUFFER_SIZE (outbuf) = GST_BUFFER_MAXSIZE (outbuf); + /* libavcodec constantly crashes on stupid buffer allocation + * errors inside. This drives me crazy, so we let it allocate + * it's own buffers and copy to our own buffer afterwards... */ + AVPicture pic; + gint size = avpicture_get_size (ffmpegdec->context->pix_fmt, + ffmpegdec->context->width, + ffmpegdec->context->height); + outbuf = gst_buffer_new_and_alloc (size); + avpicture_fill (&pic, GST_BUFFER_DATA (outbuf), + ffmpegdec->context->pix_fmt, + ffmpegdec->context->width, + ffmpegdec->context->height); + img_convert (&pic, ffmpegdec->context->pix_fmt, + (AVPicture *) ffmpegdec->picture, + ffmpegdec->context->pix_fmt, + ffmpegdec->context->width, + ffmpegdec->context->height); + /* this isn't necessarily true, but it's better than nothing */ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf); } Index: gstffmpegenc.c =================================================================== RCS file: /cvsroot/gstreamer/gst-plugins/ext/ffmpeg/gstffmpegenc.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- gstffmpegenc.c 20 Oct 2003 08:24:39 -0000 1.25 +++ gstffmpegenc.c 26 Oct 2003 11:30:18 -0000 1.26 @@ -48,7 +48,6 @@ /* cache */ gulong bitrate; gint me_method; - gboolean hq; gint gop_size; gulong buffer_size; }; @@ -89,7 +88,6 @@ ARG_0, ARG_BIT_RATE, ARG_GOP_SIZE, - ARG_HQ, ARG_ME_METHOD, ARG_BUFSIZE /* FILL ME */ @@ -170,10 +168,6 @@ g_param_spec_int ("gop_size","GOP Size", "Number of frames within one GOP", 0, G_MAXINT, 15, G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_HQ, - g_param_spec_boolean ("hq","HQ", - "Brute Force (slow) MB-type decision mode", - FALSE, G_PARAM_READWRITE)); g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_ME_METHOD, g_param_spec_enum ("me_method","ME Method", "Motion Estimation Method", @@ -188,10 +182,6 @@ g_param_spec_ulong ("bitrate","Bit Rate", "Target Audio Bitrate", 0, G_MAXULONG, 128000, G_PARAM_READWRITE)); - g_object_class_install_property(G_OBJECT_CLASS (klass), ARG_HQ, - g_param_spec_boolean ("hq","HQ", - "Brute Force (slow) MB-type decision mode", - FALSE, G_PARAM_READWRITE)); } gobject_class->set_property = gst_ffmpegenc_set_property; @@ -225,7 +215,6 @@ ffmpegenc->bitrate = 300000; ffmpegenc->buffer_size = 512 * 1024; ffmpegenc->gop_size = 15; - ffmpegenc->hq = FALSE; } else if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) { ffmpegenc->bitrate = 128000; } @@ -272,11 +261,6 @@ ffmpegenc->context->bit_rate = ffmpegenc->bitrate; ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate; ffmpegenc->context->gop_size = ffmpegenc->gop_size; - if (ffmpegenc->hq) { - ffmpegenc->context->flags |= CODEC_FLAG_HQ; - } else { - ffmpegenc->context->flags &= ~CODEC_FLAG_HQ; - } ffmpegenc->context->me_method = ffmpegenc->me_method; /* general properties */ @@ -418,9 +402,6 @@ case ARG_GOP_SIZE: ffmpegenc->gop_size = g_value_get_int (value); break; - case ARG_HQ: - ffmpegenc->hq = g_value_get_boolean (value); - break; case ARG_ME_METHOD: ffmpegenc->me_method = g_value_get_enum (value); break; @@ -451,9 +432,6 @@ break; case ARG_GOP_SIZE: g_value_set_int (value, ffmpegenc->gop_size); - break; - case ARG_HQ: - g_value_set_boolean (value, ffmpegenc->hq); break; case ARG_ME_METHOD: g_value_set_enum (value, ffmpegenc->me_method); |