mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 14:26:43 +00:00
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.
This commit is contained in:
parent
5b255e085e
commit
8358d67b73
5 changed files with 36 additions and 29 deletions
|
@ -22,6 +22,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <gst/gst.h>
|
||||||
#ifdef HAVE_FFMPEG_UNINSTALLED
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
||||||
#include <avcodec.h>
|
#include <avcodec.h>
|
||||||
#include <avformat.h>
|
#include <avformat.h>
|
||||||
|
@ -30,8 +31,6 @@
|
||||||
#include <ffmpeg/avformat.h>
|
#include <ffmpeg/avformat.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin);
|
extern gboolean gst_ffmpegdemux_register (GstPlugin *plugin);
|
||||||
extern gboolean gst_ffmpegdec_register (GstPlugin *plugin);
|
extern gboolean gst_ffmpegdec_register (GstPlugin *plugin);
|
||||||
extern gboolean gst_ffmpegenc_register (GstPlugin *plugin);
|
extern gboolean gst_ffmpegenc_register (GstPlugin *plugin);
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <gst/gst.h>
|
||||||
#ifdef HAVE_FFMPEG_UNINSTALLED
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
||||||
#include <avcodec.h>
|
#include <avcodec.h>
|
||||||
#else
|
#else
|
||||||
#include <ffmpeg/avcodec.h>
|
#include <ffmpeg/avcodec.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
#include "gstffmpegcodecmap.h"
|
#include "gstffmpegcodecmap.h"
|
||||||
|
|
||||||
|
@ -758,9 +758,17 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
|
||||||
case GST_MAKE_FOURCC ('I','4','2','0'):
|
case GST_MAKE_FOURCC ('I','4','2','0'):
|
||||||
context->pix_fmt = PIX_FMT_YUV420P;
|
context->pix_fmt = PIX_FMT_YUV420P;
|
||||||
break;
|
break;
|
||||||
case GST_MAKE_FOURCC ('Y','4','1','P'):
|
case GST_MAKE_FOURCC ('Y','4','1','B'):
|
||||||
context->pix_fmt = PIX_FMT_YUV411P;
|
context->pix_fmt = PIX_FMT_YUV411P;
|
||||||
break;
|
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',' '):
|
case GST_MAKE_FOURCC ('R','G','B',' '):
|
||||||
if (gst_caps_has_property_typed (caps, "depth",
|
if (gst_caps_has_property_typed (caps, "depth",
|
||||||
GST_PROPS_INT_TYPE) &&
|
GST_PROPS_INT_TYPE) &&
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
#ifdef HAVE_FFMPEG_UNINSTALLED
|
#ifdef HAVE_FFMPEG_UNINSTALLED
|
||||||
#include <avcodec.h>
|
#include <avcodec.h>
|
||||||
#else
|
#else
|
||||||
#include <ffmpeg/avcodec.h>
|
#include <ffmpeg/avcodec.h>
|
||||||
#endif
|
#endif
|
||||||
#include <gst/gst.h>
|
|
||||||
|
|
||||||
#include "gstffmpegcodecmap.h"
|
#include "gstffmpegcodecmap.h"
|
||||||
|
|
||||||
|
|
|
@ -96,11 +96,13 @@ static void gst_ffmpegdec_chain (GstPad *pad,
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_ffmpegdec_change_state (GstElement *element);
|
gst_ffmpegdec_change_state (GstElement *element);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* some sort of bufferpool handling, but different */
|
/* some sort of bufferpool handling, but different */
|
||||||
static int gst_ffmpegdec_get_buffer (AVCodecContext *context,
|
static int gst_ffmpegdec_get_buffer (AVCodecContext *context,
|
||||||
AVFrame *picture);
|
AVFrame *picture);
|
||||||
static void gst_ffmpegdec_release_buffer (AVCodecContext *context,
|
static void gst_ffmpegdec_release_buffer (AVCodecContext *context,
|
||||||
AVFrame *picture);
|
AVFrame *picture);
|
||||||
|
#endif
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
@ -185,9 +187,11 @@ gst_ffmpegdec_connect (GstPad *pad,
|
||||||
/* set defaults */
|
/* set defaults */
|
||||||
avcodec_get_context_defaults (ffmpegdec->context);
|
avcodec_get_context_defaults (ffmpegdec->context);
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* set buffer functions */
|
/* set buffer functions */
|
||||||
ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
|
ffmpegdec->context->get_buffer = gst_ffmpegdec_get_buffer;
|
||||||
ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
|
ffmpegdec->context->release_buffer = gst_ffmpegdec_release_buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* get size and so */
|
/* get size and so */
|
||||||
gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
|
gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
|
||||||
|
@ -216,6 +220,7 @@ gst_ffmpegdec_connect (GstPad *pad,
|
||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int
|
static int
|
||||||
gst_ffmpegdec_get_buffer (AVCodecContext *context,
|
gst_ffmpegdec_get_buffer (AVCodecContext *context,
|
||||||
AVFrame *picture)
|
AVFrame *picture)
|
||||||
|
@ -268,6 +273,7 @@ gst_ffmpegdec_release_buffer (AVCodecContext *context,
|
||||||
picture->linesize[i] = 0;
|
picture->linesize[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_ffmpegdec_chain (GstPad *pad,
|
gst_ffmpegdec_chain (GstPad *pad,
|
||||||
|
@ -306,8 +312,24 @@ gst_ffmpegdec_chain (GstPad *pad,
|
||||||
&have_data,
|
&have_data,
|
||||||
data, size);
|
data, size);
|
||||||
if (have_data) {
|
if (have_data) {
|
||||||
outbuf = GST_BUFFER (ffmpegdec->picture->base[0]);
|
/* libavcodec constantly crashes on stupid buffer allocation
|
||||||
GST_BUFFER_SIZE (outbuf) = GST_BUFFER_MAXSIZE (outbuf);
|
* 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 */
|
/* this isn't necessarily true, but it's better than nothing */
|
||||||
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
|
GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@ struct _GstFFMpegEnc {
|
||||||
/* cache */
|
/* cache */
|
||||||
gulong bitrate;
|
gulong bitrate;
|
||||||
gint me_method;
|
gint me_method;
|
||||||
gboolean hq;
|
|
||||||
gint gop_size;
|
gint gop_size;
|
||||||
gulong buffer_size;
|
gulong buffer_size;
|
||||||
};
|
};
|
||||||
|
@ -89,7 +88,6 @@ enum {
|
||||||
ARG_0,
|
ARG_0,
|
||||||
ARG_BIT_RATE,
|
ARG_BIT_RATE,
|
||||||
ARG_GOP_SIZE,
|
ARG_GOP_SIZE,
|
||||||
ARG_HQ,
|
|
||||||
ARG_ME_METHOD,
|
ARG_ME_METHOD,
|
||||||
ARG_BUFSIZE
|
ARG_BUFSIZE
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
|
@ -170,10 +168,6 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass *klass)
|
||||||
g_param_spec_int ("gop_size","GOP Size",
|
g_param_spec_int ("gop_size","GOP Size",
|
||||||
"Number of frames within one GOP",
|
"Number of frames within one GOP",
|
||||||
0, G_MAXINT, 15, G_PARAM_READWRITE));
|
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_object_class_install_property(G_OBJECT_CLASS (klass), ARG_ME_METHOD,
|
||||||
g_param_spec_enum ("me_method","ME Method",
|
g_param_spec_enum ("me_method","ME Method",
|
||||||
"Motion Estimation Method",
|
"Motion Estimation Method",
|
||||||
|
@ -188,10 +182,6 @@ gst_ffmpegenc_class_init (GstFFMpegEncClass *klass)
|
||||||
g_param_spec_ulong ("bitrate","Bit Rate",
|
g_param_spec_ulong ("bitrate","Bit Rate",
|
||||||
"Target Audio Bitrate",
|
"Target Audio Bitrate",
|
||||||
0, G_MAXULONG, 128000, G_PARAM_READWRITE));
|
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;
|
gobject_class->set_property = gst_ffmpegenc_set_property;
|
||||||
|
@ -225,7 +215,6 @@ gst_ffmpegenc_init(GstFFMpegEnc *ffmpegenc)
|
||||||
ffmpegenc->bitrate = 300000;
|
ffmpegenc->bitrate = 300000;
|
||||||
ffmpegenc->buffer_size = 512 * 1024;
|
ffmpegenc->buffer_size = 512 * 1024;
|
||||||
ffmpegenc->gop_size = 15;
|
ffmpegenc->gop_size = 15;
|
||||||
ffmpegenc->hq = FALSE;
|
|
||||||
} else if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
} else if (oclass->in_plugin->type == CODEC_TYPE_AUDIO) {
|
||||||
ffmpegenc->bitrate = 128000;
|
ffmpegenc->bitrate = 128000;
|
||||||
}
|
}
|
||||||
|
@ -272,11 +261,6 @@ gst_ffmpegenc_connect (GstPad *pad,
|
||||||
ffmpegenc->context->bit_rate = ffmpegenc->bitrate;
|
ffmpegenc->context->bit_rate = ffmpegenc->bitrate;
|
||||||
ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate;
|
ffmpegenc->context->bit_rate_tolerance = ffmpegenc->bitrate;
|
||||||
ffmpegenc->context->gop_size = ffmpegenc->gop_size;
|
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;
|
ffmpegenc->context->me_method = ffmpegenc->me_method;
|
||||||
|
|
||||||
/* general properties */
|
/* general properties */
|
||||||
|
@ -418,9 +402,6 @@ gst_ffmpegenc_set_property (GObject *object,
|
||||||
case ARG_GOP_SIZE:
|
case ARG_GOP_SIZE:
|
||||||
ffmpegenc->gop_size = g_value_get_int (value);
|
ffmpegenc->gop_size = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case ARG_HQ:
|
|
||||||
ffmpegenc->hq = g_value_get_boolean (value);
|
|
||||||
break;
|
|
||||||
case ARG_ME_METHOD:
|
case ARG_ME_METHOD:
|
||||||
ffmpegenc->me_method = g_value_get_enum (value);
|
ffmpegenc->me_method = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
|
@ -452,9 +433,6 @@ gst_ffmpegenc_get_property (GObject *object,
|
||||||
case ARG_GOP_SIZE:
|
case ARG_GOP_SIZE:
|
||||||
g_value_set_int (value, ffmpegenc->gop_size);
|
g_value_set_int (value, ffmpegenc->gop_size);
|
||||||
break;
|
break;
|
||||||
case ARG_HQ:
|
|
||||||
g_value_set_boolean (value, ffmpegenc->hq);
|
|
||||||
break;
|
|
||||||
case ARG_ME_METHOD:
|
case ARG_ME_METHOD:
|
||||||
g_value_set_enum (value, ffmpegenc->me_method);
|
g_value_set_enum (value, ffmpegenc->me_method);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue