Hi Sebastian, On Mon, 02 Nov 2015 23:28:58 +0200 Sebastian Dröge <sl...@coaxion.net> wrote: > Thanks for the patch, I've forwarded it upstream.
Thanks. > It would've been nice > to split it up into separate patches though: one for all the trivial > renames and deletion of the removed defines, one for the deinterlace > port which is non-trivial and a third for the video decoder edge stuff. > > If you have the time to do so, that would be great :) OK, split patches attached. Removing the 'edge stuff' is not really necessary for FFmpeg 2.9, it's just that it's not necessary and thus deprecated, see e.g. the APIchanges entry [1]: 2014-01-20 - eef74b2 / 93c553c - lavc 55.48.102 / 55.32.1 - avcodec.h Edges are not required anymore on video buffers allocated by get_buffer2() (i.e. as if the CODEC_FLAG_EMU_EDGE flag was always on). Deprecate CODEC_FLAG_EMU_EDGE and avcodec_get_edge_width(). Best regards, Andreas 1: https://anonscm.debian.org/cgit/pkg-multimedia/ffmpeg.git/tree/doc/APIchanges#n558
Description: Replace deprecated avpicture_deinterlace Author: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Last-Update: <2015-11-03> --- gst-libav1.0-1.6.1.orig/configure.ac +++ gst-libav1.0-1.6.1/configure.ac @@ -256,7 +256,7 @@ AC_ARG_WITH(system-libav, [AC_HELP_STRING([--with-system-libav], [use system Libav libraries])]) if test "x$with_system_libav" = "xyes"; then - PKG_CHECK_MODULES(LIBAV, libavformat libavcodec libavutil) + PKG_CHECK_MODULES(LIBAV, libavfilter libavformat libavcodec libavutil) PKG_CHECK_MODULES(SWSCALE, libswscale libavutil) saved_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LIBAV_CFLAGS" --- gst-libav1.0-1.6.1.orig/ext/libav/gstavdeinterlace.c +++ gst-libav1.0-1.6.1/ext/libav/gstavdeinterlace.c @@ -25,6 +25,9 @@ #endif #include <libavcodec/avcodec.h> +#include <libavfilter/avfilter.h> +#include <libavfilter/buffersrc.h> +#include <libavfilter/buffersink.h> #include <gst/gst.h> #include <gst/video/video.h> @@ -93,6 +96,14 @@ typedef struct _GstFFMpegDeinterlace enum AVPixelFormat pixfmt; AVPicture from_frame, to_frame; + + AVFilterContext *buffersink_ctx; + AVFilterContext *buffersrc_ctx; + AVFilterGraph *filter_graph; + AVFrame *filter_frame; + int last_width, last_height; + enum AVPixelFormat last_pixfmt; + } GstFFMpegDeinterlace; typedef struct _GstFFMpegDeinterlaceClass @@ -135,6 +146,8 @@ G_DEFINE_TYPE (GstFFMpegDeinterlace, gst static GstFlowReturn gst_ffmpegdeinterlace_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf); +static void gst_ffmpegdeinterlace_dispose (GObject *obj); + static void gst_ffmpegdeinterlace_class_init (GstFFMpegDeinterlaceClass * klass) { @@ -167,6 +180,8 @@ gst_ffmpegdeinterlace_class_init (GstFFM gst_element_class_set_static_metadata (element_class, "libav Deinterlace element", "Filter/Effect/Video/Deinterlace", "Deinterlace video", "Luca Ognibene <luo...@tin.it>"); + + gobject_class->dispose = gst_ffmpegdeinterlace_dispose; } static void @@ -277,8 +292,84 @@ gst_ffmpegdeinterlace_init (GstFFMpegDei deinterlace->reconfigure = FALSE; deinterlace->mode = DEFAULT_MODE; deinterlace->new_mode = -1; + deinterlace->last_width = -1; + deinterlace->last_height = -1; + deinterlace->last_pixfmt = AV_PIX_FMT_NONE; +} + +static void delete_filter_graph(GstFFMpegDeinterlace *deinterlace) { + if (deinterlace->filter_graph) { + av_frame_free(&deinterlace->filter_frame); + avfilter_graph_free(&deinterlace->filter_graph); + } +} + +static void gst_ffmpegdeinterlace_dispose (GObject *obj) { + GstFFMpegDeinterlace * deinterlace = GST_FFMPEGDEINTERLACE(obj); + delete_filter_graph(deinterlace); +} + +static int init_filter_graph(GstFFMpegDeinterlace *deinterlace, enum AVPixelFormat pixfmt, int width, int height) { + AVFilterInOut *inputs = NULL, *outputs = NULL; + char args[512]; + int res; + + delete_filter_graph(deinterlace); + deinterlace->filter_graph = avfilter_graph_alloc(); + snprintf(args, sizeof(args), + "buffer=video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=0/1[in];" + "[in]yadif[out];" + "[out]buffersink", + width, height, pixfmt); + res = avfilter_graph_parse2(deinterlace->filter_graph, args, &inputs, &outputs); + if (res < 0) + return res; + if(inputs || outputs) + return -1; + res = avfilter_graph_config(deinterlace->filter_graph, NULL); + if (res < 0) + return res; + + deinterlace->buffersrc_ctx = avfilter_graph_get_filter(deinterlace->filter_graph, "Parsed_buffer_0"); + deinterlace->buffersink_ctx = avfilter_graph_get_filter(deinterlace->filter_graph, "Parsed_buffersink_2"); + if (!deinterlace->buffersrc_ctx || !deinterlace->buffersink_ctx) + return -1; + deinterlace->filter_frame = av_frame_alloc(); + deinterlace->last_width = width; + deinterlace->last_height = height; + deinterlace->last_pixfmt = pixfmt; + + return 0; } +static int process_filter_graph(GstFFMpegDeinterlace *deinterlace, AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pixfmt, int width, int height) { + int res; + + if (!deinterlace->filter_graph || width != deinterlace->last_width || + height != deinterlace->last_height || pixfmt != deinterlace->last_pixfmt) { + res = init_filter_graph(deinterlace, pixfmt, width, height); + if (res < 0) + return res; + } + + memcpy(deinterlace->filter_frame->data, src->data, sizeof(src->data)); + memcpy(deinterlace->filter_frame->linesize, src->linesize, sizeof(src->linesize)); + deinterlace->filter_frame->width = width; + deinterlace->filter_frame->height = height; + deinterlace->filter_frame->format = pixfmt; + res = av_buffersrc_add_frame(deinterlace->buffersrc_ctx, deinterlace->filter_frame); + if (res < 0) + return res; + res = av_buffersink_get_frame(deinterlace->buffersink_ctx, deinterlace->filter_frame); + if (res < 0) + return res; + av_picture_copy(dst, (const AVPicture *) deinterlace->filter_frame, pixfmt, width, height); + av_frame_unref(deinterlace->filter_frame); + + return 0; + } + static GstFlowReturn gst_ffmpegdeinterlace_chain (GstPad * pad, GstObject * parent, GstBuffer * inbuf) @@ -320,7 +411,7 @@ gst_ffmpegdeinterlace_chain (GstPad * pa gst_ffmpeg_avpicture_fill (&deinterlace->to_frame, to_map.data, deinterlace->pixfmt, deinterlace->width, deinterlace->height); - avpicture_deinterlace (&deinterlace->to_frame, &deinterlace->from_frame, + process_filter_graph (deinterlace, &deinterlace->to_frame, &deinterlace->from_frame, deinterlace->pixfmt, deinterlace->width, deinterlace->height); gst_buffer_unmap (outbuf, &to_map); gst_buffer_unmap (inbuf, &from_map);
Description: Remove deprecated CODEC_FLAG_EMU_EDGE Author: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Last-Update: <2015-11-03> --- gst-libav1.0-1.6.1.orig/ext/libav/gstavviddec.c +++ gst-libav1.0-1.6.1/ext/libav/gstavviddec.c @@ -634,19 +634,10 @@ gst_ffmpegvideodec_prepare_dr_pool (GstF avcodec_align_dimensions2 (ffmpegdec->context, &width, &height, linesize_align); - if (ffmpegdec->context->flags & CODEC_FLAG_EMU_EDGE) - edge = 0; - else - edge = avcodec_get_edge_width (); - - /* increase the size for the padding */ - width += edge << 1; - height += edge << 1; - - align.padding_top = edge; - align.padding_left = edge; - align.padding_right = width - GST_VIDEO_INFO_WIDTH (info) - edge; - align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info) - edge; + align.padding_top = 0; + align.padding_left = 0; + align.padding_right = width - GST_VIDEO_INFO_WIDTH (info); + align.padding_bottom = height - GST_VIDEO_INFO_HEIGHT (info); /* add extra padding to match libav buffer allocation sizes */ align.padding_bottom++;
Description: Replace deprecated FFmpeg API Author: Andreas Cadhalpun <andreas.cadhal...@googlemail.com> Last-Update: <2015-11-03> --- gst-libav1.0-1.6.1.orig/ext/libav/gstavcfg.c +++ gst-libav1.0-1.6.1/ext/libav/gstavcfg.c @@ -173,13 +173,10 @@ gst_ffmpeg_idct_algo_get_type (void) {FF_IDCT_SIMPLEMMX, "Simple MMX", "simplemmx"}, {FF_IDCT_ARM, "ARM", "arm"}, {FF_IDCT_ALTIVEC, "Altivec", "altivec"}, - {FF_IDCT_SH4, "SH4", "sh4"}, {FF_IDCT_SIMPLEARM, "Simple ARM", "simplearm"}, - {FF_IDCT_IPP, "IPP", "ipp"}, {FF_IDCT_XVID, "XVID", "xvid"}, {FF_IDCT_SIMPLEARMV5TE, "Simple ARMV5TE", "simplearmv5te"}, {FF_IDCT_SIMPLEARMV6, "Simple ARMV6", "simplearmv6"}, - {FF_IDCT_SIMPLEVIS, "Simple Vis", "simplevis"}, {FF_IDCT_FAAN, "FAAN", "faan"}, {FF_IDCT_SIMPLENEON, "Simple NEON", "simpleneon"}, {0, NULL, NULL}, @@ -665,7 +662,7 @@ gst_ffmpeg_cfg_init (void) gst_ffmpeg_add_pspec (pspec, interlaced, FALSE, mpeg, NULL); pspec = g_param_spec_int ("max-bframes", "Max B-Frames", - "Maximum B-frames in a row", 0, FF_MAX_B_FRAMES, 0, + "Maximum B-frames in a row", 0, INT_MAX, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); gst_ffmpeg_add_pspec (pspec, config.max_b_frames, FALSE, mpeg, NULL); --- gst-libav1.0-1.6.1.orig/ext/libav/gstavcodecmap.c +++ gst-libav1.0-1.6.1/ext/libav/gstavcodecmap.c @@ -758,10 +758,6 @@ gst_ffmpeg_codecid_to_caps (enum AVCodec } break; - case AV_CODEC_ID_MPEG2VIDEO_XVMC: - /* this is a special ID - don't need it in GStreamer, I think */ - break; - case AV_CODEC_ID_H263: if (encode) { caps = @@ -2178,7 +2174,7 @@ gst_ffmpeg_codecid_to_caps (enum AVCodec */ static GstCaps * -gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt, AVCodecContext * context, +gst_ffmpeg_pixfmt_to_caps (enum AVPixelFormat pix_fmt, AVCodecContext * context, enum AVCodecID codec_id) { GstCaps *caps = NULL; @@ -2509,7 +2505,7 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps typedef struct { GstVideoFormat format; - enum PixelFormat pixfmt; + enum AVPixelFormat pixfmt; } PixToFmt; /* FIXME : FILLME */ @@ -2601,7 +2597,7 @@ static const PixToFmt pixtofmttable[] = }; GstVideoFormat -gst_ffmpeg_pixfmt_to_videoformat (enum PixelFormat pixfmt) +gst_ffmpeg_pixfmt_to_videoformat (enum AVPixelFormat pixfmt) { guint i; @@ -2613,7 +2609,7 @@ gst_ffmpeg_pixfmt_to_videoformat (enum P return GST_VIDEO_FORMAT_UNKNOWN; } -static enum PixelFormat +static enum AVPixelFormat gst_ffmpeg_videoformat_to_pixfmt_for_codec (GstVideoFormat format, const AVCodec * codec) { @@ -2637,7 +2633,7 @@ gst_ffmpeg_videoformat_to_pixfmt_for_cod return AV_PIX_FMT_NONE; } -enum PixelFormat +enum AVPixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format) { return gst_ffmpeg_videoformat_to_pixfmt_for_codec (format, NULL); --- gst-libav1.0-1.6.1.orig/ext/libav/gstavcodecmap.h +++ gst-libav1.0-1.6.1/ext/libav/gstavcodecmap.h @@ -132,8 +132,8 @@ void gst_ffmpeg_audioinfo_to_context (GstAudioInfo *info, AVCodecContext *context); -GstVideoFormat gst_ffmpeg_pixfmt_to_videoformat (enum PixelFormat pixfmt); -enum PixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format); +GstVideoFormat gst_ffmpeg_pixfmt_to_videoformat (enum AVPixelFormat pixfmt); +enum AVPixelFormat gst_ffmpeg_videoformat_to_pixfmt (GstVideoFormat format); GstAudioFormat gst_ffmpeg_smpfmt_to_audioformat (enum AVSampleFormat sample_fmt); --- gst-libav1.0-1.6.1.orig/ext/libav/gstavdeinterlace.c +++ gst-libav1.0-1.6.1/ext/libav/gstavdeinterlace.c @@ -91,7 +91,7 @@ typedef struct _GstFFMpegDeinterlace gboolean reconfigure; GstFFMpegDeinterlaceMode new_mode; - enum PixelFormat pixfmt; + enum AVPixelFormat pixfmt; AVPicture from_frame, to_frame; } GstFFMpegDeinterlace; --- gst-libav1.0-1.6.1.orig/ext/libav/gstavutils.c +++ gst-libav1.0-1.6.1/ext/libav/gstavutils.c @@ -279,7 +279,7 @@ gst_ffmpeg_avpicture_get_size (int pix_f int gst_ffmpeg_avpicture_fill (AVPicture * picture, - uint8_t * ptr, enum PixelFormat pix_fmt, int width, int height) + uint8_t * ptr, enum AVPixelFormat pix_fmt, int width, int height) { int size, w2, h2, size2; int stride, stride2; --- gst-libav1.0-1.6.1.orig/ext/libav/gstavutils.h +++ gst-libav1.0-1.6.1/ext/libav/gstavutils.h @@ -42,7 +42,7 @@ gst_ffmpeg_avpicture_get_size (int pix_f int gst_ffmpeg_avpicture_fill (AVPicture * picture, uint8_t * ptr, - enum PixelFormat pix_fmt, + enum AVPixelFormat pix_fmt, int width, int height); --- gst-libav1.0-1.6.1.orig/ext/libav/gstavviddec.c +++ gst-libav1.0-1.6.1/ext/libav/gstavviddec.c @@ -461,9 +461,6 @@ gst_ffmpegviddec_set_format (GstVideoDec /* set buffer functions */ ffmpegdec->context->get_buffer2 = gst_ffmpegviddec_get_buffer2; - ffmpegdec->context->get_buffer = NULL; - ffmpegdec->context->reget_buffer = NULL; - ffmpegdec->context->release_buffer = NULL; ffmpegdec->context->draw_horiz_band = NULL; /* reset coded_width/_height to prevent it being reused from last time when @@ -842,10 +839,6 @@ gst_ffmpegviddec_get_buffer2 (AVCodecCon picture->buf[0] = av_buffer_create (NULL, 0, dummy_free_buffer, dframe, 0); - /* tell ffmpeg we own this buffer, transfer the ref we have on the buffer to - * the opaque data. */ - picture->type = FF_BUFFER_TYPE_USER; - GST_LOG_OBJECT (ffmpegdec, "returned frame %p", dframe->buffer); return 0; @@ -1382,8 +1375,6 @@ gst_ffmpegviddec_video_frame (GstFFMpegV (guint64) ffmpegdec->picture->pts); GST_DEBUG_OBJECT (ffmpegdec, "picture: num %d", ffmpegdec->picture->coded_picture_number); - GST_DEBUG_OBJECT (ffmpegdec, "picture: ref %d", - ffmpegdec->picture->reference); GST_DEBUG_OBJECT (ffmpegdec, "picture: display %d", ffmpegdec->picture->display_picture_number); GST_DEBUG_OBJECT (ffmpegdec, "picture: opaque %p", --- gst-libav1.0-1.6.1.orig/ext/libav/gstavviddec.h +++ gst-libav1.0-1.6.1/ext/libav/gstavviddec.h @@ -41,7 +41,7 @@ struct _GstFFMpegVidDec gboolean opened; /* current output pictures */ - enum PixelFormat pic_pix_fmt; + enum AVPixelFormat pic_pix_fmt; gint pic_width; gint pic_height; gint pic_par_n; @@ -72,7 +72,7 @@ struct _GstFFMpegVidDec GstBufferPool *internal_pool; gint pool_width; gint pool_height; - enum PixelFormat pool_format; + enum AVPixelFormat pool_format; GstVideoInfo pool_info; }; --- gst-libav1.0-1.6.1.orig/ext/libav/gstavvidenc.c +++ gst-libav1.0-1.6.1/ext/libav/gstavvidenc.c @@ -290,7 +290,7 @@ gst_ffmpegvidenc_set_format (GstVideoEnc GstCaps *allowed_caps; GstCaps *icaps; GstVideoCodecState *output_format; - enum PixelFormat pix_fmt; + enum AVPixelFormat pix_fmt; GstFFMpegVidEnc *ffmpegenc = (GstFFMpegVidEnc *) encoder; GstFFMpegVidEncClass *oclass = (GstFFMpegVidEncClass *) G_OBJECT_GET_CLASS (ffmpegenc); --- gst-libav1.0-1.6.1.orig/ext/libswscale/gstffmpegscale.c +++ gst-libav1.0-1.6.1/ext/libswscale/gstffmpegscale.c @@ -45,7 +45,7 @@ typedef struct _GstFFMpegScale /* state */ GstVideoInfo in_info, out_info; - enum PixelFormat in_pixfmt, out_pixfmt; + enum AVPixelFormat in_pixfmt, out_pixfmt; struct SwsContext *ctx; /* property */ @@ -214,8 +214,8 @@ gst_ffmpegscale_init (GstFFMpegScale * s { scale->method = DEFAULT_PROP_METHOD; scale->ctx = NULL; - scale->in_pixfmt = PIX_FMT_NONE; - scale->out_pixfmt = PIX_FMT_NONE; + scale->in_pixfmt = AV_PIX_FMT_NONE; + scale->out_pixfmt = AV_PIX_FMT_NONE; } static void @@ -226,8 +226,8 @@ gst_ffmpegscale_reset (GstFFMpegScale * scale->ctx = NULL; } - scale->in_pixfmt = PIX_FMT_NONE; - scale->out_pixfmt = PIX_FMT_NONE; + scale->in_pixfmt = AV_PIX_FMT_NONE; + scale->out_pixfmt = AV_PIX_FMT_NONE; } static void @@ -442,11 +442,11 @@ gst_ffmpegscale_get_unit_size (GstBaseTr /* Convert a GstCaps (video/raw) to a FFMPEG PixFmt */ -static enum PixelFormat +static enum AVPixelFormat gst_ffmpeg_caps_to_pixfmt (const GstCaps * caps) { GstVideoInfo info; - enum PixelFormat pix_fmt; + enum AVPixelFormat pix_fmt; GST_DEBUG ("converting caps %" GST_PTR_FORMAT, caps); @@ -455,52 +455,52 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps switch (GST_VIDEO_INFO_FORMAT (&info)) { case GST_VIDEO_FORMAT_YUY2: - pix_fmt = PIX_FMT_YUYV422; + pix_fmt = AV_PIX_FMT_YUYV422; break; case GST_VIDEO_FORMAT_UYVY: - pix_fmt = PIX_FMT_UYVY422; + pix_fmt = AV_PIX_FMT_UYVY422; break; case GST_VIDEO_FORMAT_I420: - pix_fmt = PIX_FMT_YUV420P; + pix_fmt = AV_PIX_FMT_YUV420P; break; case GST_VIDEO_FORMAT_Y41B: - pix_fmt = PIX_FMT_YUV411P; + pix_fmt = AV_PIX_FMT_YUV411P; break; case GST_VIDEO_FORMAT_Y42B: - pix_fmt = PIX_FMT_YUV422P; + pix_fmt = AV_PIX_FMT_YUV422P; break; case GST_VIDEO_FORMAT_YUV9: - pix_fmt = PIX_FMT_YUV410P; + pix_fmt = AV_PIX_FMT_YUV410P; break; case GST_VIDEO_FORMAT_ARGB: - pix_fmt = PIX_FMT_ARGB; + pix_fmt = AV_PIX_FMT_ARGB; break; case GST_VIDEO_FORMAT_RGBA: - pix_fmt = PIX_FMT_RGBA; + pix_fmt = AV_PIX_FMT_RGBA; break; case GST_VIDEO_FORMAT_BGRA: - pix_fmt = PIX_FMT_BGRA; + pix_fmt = AV_PIX_FMT_BGRA; break; case GST_VIDEO_FORMAT_ABGR: - pix_fmt = PIX_FMT_ABGR; + pix_fmt = AV_PIX_FMT_ABGR; break; case GST_VIDEO_FORMAT_BGR: - pix_fmt = PIX_FMT_BGR24; + pix_fmt = AV_PIX_FMT_BGR24; break; case GST_VIDEO_FORMAT_RGB: - pix_fmt = PIX_FMT_RGB24; + pix_fmt = AV_PIX_FMT_RGB24; break; case GST_VIDEO_FORMAT_RGB16: - pix_fmt = PIX_FMT_RGB565; + pix_fmt = AV_PIX_FMT_RGB565; break; case GST_VIDEO_FORMAT_RGB15: - pix_fmt = PIX_FMT_RGB555; + pix_fmt = AV_PIX_FMT_RGB555; break; case GST_VIDEO_FORMAT_RGB8P: - pix_fmt = PIX_FMT_PAL8; + pix_fmt = AV_PIX_FMT_PAL8; break; default: - pix_fmt = PIX_FMT_NONE; + pix_fmt = AV_PIX_FMT_NONE; break; } return pix_fmt; @@ -508,7 +508,7 @@ gst_ffmpeg_caps_to_pixfmt (const GstCaps /* ERROR */ invalid_caps: { - return PIX_FMT_NONE; + return AV_PIX_FMT_NONE; } } @@ -537,8 +537,8 @@ gst_ffmpegscale_set_caps (GstBaseTransfo scale->in_pixfmt = gst_ffmpeg_caps_to_pixfmt (incaps); scale->out_pixfmt = gst_ffmpeg_caps_to_pixfmt (outcaps); - if (!ok || scale->in_pixfmt == PIX_FMT_NONE || - scale->out_pixfmt == PIX_FMT_NONE || + if (!ok || scale->in_pixfmt == AV_PIX_FMT_NONE || + scale->out_pixfmt == AV_PIX_FMT_NONE || GST_VIDEO_INFO_FORMAT (&scale->in_info) == GST_VIDEO_FORMAT_UNKNOWN || GST_VIDEO_INFO_FORMAT (&scale->out_info) == GST_VIDEO_FORMAT_UNKNOWN) goto refuse_caps;