Commit 8358d67b authored by Ronald S. Bultje's avatar Ronald S. Bultje

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.
parent 5b255e08
......@@ -22,6 +22,7 @@
*/
#include "config.h"
#include <gst/gst.h>
#ifdef HAVE_FFMPEG_UNINSTALLED
#include <avcodec.h>
#include <avformat.h>
......@@ -30,8 +31,6 @@
#include <ffmpeg/avformat.h>
#endif
#include <gst/gst.h>
extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin);
extern gboolean gst_ffmpegdec_register (GstPlugin *plugin);
extern gboolean gst_ffmpegenc_register (GstPlugin *plugin);
......
......@@ -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 @@ 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) &&
......
......@@ -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"
......
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment