From 8358d67b734a7b62a769d5cc158c2bd6806ecc70 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 26 Oct 2003 11:30:18 +0000 Subject: [PATCH] Make it compile against latest CVS of FFMPEG: Original commit message from CVS: 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. --- ext/ffmpeg/gstffmpeg.c | 3 +-- ext/ffmpeg/gstffmpegcodecmap.c | 12 ++++++++++-- ext/ffmpeg/gstffmpegcolorspace.c | 2 +- ext/ffmpeg/gstffmpegdec.c | 26 ++++++++++++++++++++++++-- ext/ffmpeg/gstffmpegenc.c | 22 ---------------------- 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/ext/ffmpeg/gstffmpeg.c b/ext/ffmpeg/gstffmpeg.c index 9550347b7e..5463d38c6b 100644 --- a/ext/ffmpeg/gstffmpeg.c +++ b/ext/ffmpeg/gstffmpeg.c @@ -22,6 +22,7 @@ */ #include "config.h" +#include #ifdef HAVE_FFMPEG_UNINSTALLED #include #include @@ -30,8 +31,6 @@ #include #endif -#include - extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin); extern gboolean gst_ffmpegdec_register (GstPlugin *plugin); extern gboolean gst_ffmpegenc_register (GstPlugin *plugin); diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index a71fe874bb..c831dc65cf 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -20,13 +20,13 @@ */ #include "config.h" +#include #ifdef HAVE_FFMPEG_UNINSTALLED #include #else #include #endif #include -#include #include "gstffmpegcodecmap.h" @@ -758,9 +758,17 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps, 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) && diff --git a/ext/ffmpeg/gstffmpegcolorspace.c b/ext/ffmpeg/gstffmpegcolorspace.c index fc9610538b..98f84c6722 100644 --- a/ext/ffmpeg/gstffmpegcolorspace.c +++ b/ext/ffmpeg/gstffmpegcolorspace.c @@ -23,12 +23,12 @@ #include "config.h" #endif +#include #ifdef HAVE_FFMPEG_UNINSTALLED #include #else #include #endif -#include #include "gstffmpegcodecmap.h" diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c index 4fa7f1ae5a..433c076a38 100644 --- a/ext/ffmpeg/gstffmpegdec.c +++ b/ext/ffmpeg/gstffmpegdec.c @@ -96,11 +96,13 @@ static void gst_ffmpegdec_chain (GstPad *pad, 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 @@ gst_ffmpegdec_connect (GstPad *pad, /* 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 @@ gst_ffmpegdec_connect (GstPad *pad, return GST_PAD_LINK_OK; } +#if 0 static int gst_ffmpegdec_get_buffer (AVCodecContext *context, AVFrame *picture) @@ -268,6 +273,7 @@ gst_ffmpegdec_release_buffer (AVCodecContext *context, picture->linesize[i] = 0; } } +#endif static void gst_ffmpegdec_chain (GstPad *pad, @@ -306,8 +312,24 @@ gst_ffmpegdec_chain (GstPad *pad, &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); } diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c index d93d60b6c5..f882bfbe22 100644 --- a/ext/ffmpeg/gstffmpegenc.c +++ b/ext/ffmpeg/gstffmpegenc.c @@ -48,7 +48,6 @@ struct _GstFFMpegEnc { /* cache */ gulong bitrate; gint me_method; - gboolean hq; gint gop_size; gulong buffer_size; }; @@ -89,7 +88,6 @@ enum { ARG_0, ARG_BIT_RATE, ARG_GOP_SIZE, - ARG_HQ, ARG_ME_METHOD, ARG_BUFSIZE /* FILL ME */ @@ -170,10 +168,6 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass *klass) 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 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass *klass) 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 @@ gst_ffmpegenc_init(GstFFMpegEnc *ffmpegenc) 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 @@ gst_ffmpegenc_connect (GstPad *pad, 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 @@ gst_ffmpegenc_set_property (GObject *object, 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; @@ -452,9 +433,6 @@ gst_ffmpegenc_get_property (GObject *object, 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); break;