Hi Gabriele,
On 03.11.2015 18:43, Andreas Cadhalpun wrote:
> On 03.11.2015 00:51, Gabriele Giacone wrote:
>> Thanks for providing patches.
>> Could you please make your changes conditional upon
>> LIBAVCODEC_VERSION_{MAJOR,MINOR} / LIBAVUTIL_VERSION_INT / ... when
>> needed to keep supporting old ffmpeg/libav versions too?
>
> These changes are compatible with any version since FFmpeg 1.0/Libav 9.
>
> If you really need compatibility with more ancient versions, the simplest
> way would probably be to define the new names to the old names, e.g.:
>
> For VideoConverterFfmpeg.cpp:
> #if LIBAVUTIL_VERSION_MAJOR < 52
> #define AVPixelFormat PixelFormat
> #define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
> #define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
> #define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
> #define AV_PIX_FMT_YUV440P PIX_FMT_YUV440P
> #define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
> #define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P
> #define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
> #define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
> #define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
> #define AV_PIX_FMT_YUV411P PIX_FMT_YUV411P
> #define AV_PIX_FMT_YUV410P PIX_FMT_YUV410P
> #define AV_PIX_FMT_NV12 PIX_FMT_NV12
> #define AV_PIX_FMT_NV21 PIX_FMT_NV21
> #define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422
> #define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
> #define AV_PIX_FMT_UYYVYY411 PIX_FMT_UYYVYY411
> #define AV_PIX_FMT_NONE PIX_FMT_NONE
> #endif
>
> For VideoDecoderFfmpeg.cpp:
> #if LIBAVUTIL_VERSION_MAJOR < 52
> #define AVPixelFormat PixelFormat
> #define AV_PIX_FMT_RGBA PIX_FMT_RGBA
> #define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
> #define AV_PIX_FMT_NONE PIX_FMT_NONE
> #define AV_PIX_FMT_VAAPI_VLD PIX_FMT_VAAPI_VLD
> #endif
In case this wasn't explicit enough, attached is a patch
that should work also on older versions (untested).
The next version of FFmpeg is planned to be released this month
(and it might be called 3.0 instead of 2.9).
If this bug isn't fixed soon, it will become release critical and
thus the package will either get NMUed or removed from testing.
Best regards,
Andreas
diff --git a/debian/patches/ffmpeg_2.9.patch b/debian/patches/ffmpeg_2.9.patch
new file mode 100644
index 0000000..2e571b1
--- /dev/null
+++ b/debian/patches/ffmpeg_2.9.patch
@@ -0,0 +1,223 @@
+Description: Replace deprecated FFmpeg API
+Author: Andreas Cadhalpun <[email protected]>
+Last-Update: <2015-11-03>
+
+--- gnash-0.8.11~git20150419.orig/libmedia/ffmpeg/VideoConverterFfmpeg.cpp
++++ gnash-0.8.11~git20150419/libmedia/ffmpeg/VideoConverterFfmpeg.cpp
+@@ -26,6 +26,27 @@
+ #include "ffmpegHeaders.h"
+ #include "log.h"
+
++#if LIBAVUTIL_VERSION_MAJOR < 52
++#define AVPixelFormat PixelFormat
++#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
++#define AV_PIX_FMT_YUV444P PIX_FMT_YUV444P
++#define AV_PIX_FMT_YUVJ444P PIX_FMT_YUVJ444P
++#define AV_PIX_FMT_YUV440P PIX_FMT_YUV440P
++#define AV_PIX_FMT_YUVJ440P PIX_FMT_YUVJ440P
++#define AV_PIX_FMT_YUV422P PIX_FMT_YUV422P
++#define AV_PIX_FMT_YUVJ422P PIX_FMT_YUVJ422P
++#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P
++#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P
++#define AV_PIX_FMT_YUV411P PIX_FMT_YUV411P
++#define AV_PIX_FMT_YUV410P PIX_FMT_YUV410P
++#define AV_PIX_FMT_NV12 PIX_FMT_NV12
++#define AV_PIX_FMT_NV21 PIX_FMT_NV21
++#define AV_PIX_FMT_YUYV422 PIX_FMT_YUYV422
++#define AV_PIX_FMT_UYVY422 PIX_FMT_UYVY422
++#define AV_PIX_FMT_UYYVYY411 PIX_FMT_UYYVYY411
++#define AV_PIX_FMT_NONE PIX_FMT_NONE
++#endif
++
+ namespace gnash {
+ namespace media {
+ namespace ffmpeg {
+@@ -57,7 +78,7 @@ private:
+
+ // The lookup table in this function is adapted from chroma.c from the VLC
+ // codebase; its license permits distribution under GPLv3 and later.
+-PixelFormat
++AVPixelFormat
+ fourcc_to_ffmpeg(ImgBuf::Type4CC code)
+ {
+
+@@ -68,40 +89,40 @@ fourcc_to_ffmpeg(ImgBuf::Type4CC code)
+ static const struct
+ {
+ ImgBuf::Type4CC fourcc;
+- PixelFormat ffmpegcode;
++ AVPixelFormat ffmpegcode;
+ } pixfmt_table[] =
+ {
+ // Planar YUV formats
+- {GNASH_FOURCC('I','4','4','4'), PIX_FMT_YUV444P},
+- {GNASH_FOURCC('J','4','4','4'), PIX_FMT_YUVJ444P},
++ {GNASH_FOURCC('I','4','4','4'), AV_PIX_FMT_YUV444P},
++ {GNASH_FOURCC('J','4','4','4'), AV_PIX_FMT_YUVJ444P},
+
+ #if LIBAVUTIL_VERSION_INT >= ((49<<16)+(5<<8)+0)
+- {GNASH_FOURCC('I','4','4','0'), PIX_FMT_YUV440P},
+- {GNASH_FOURCC('J','4','4','0'), PIX_FMT_YUVJ440P},
++ {GNASH_FOURCC('I','4','4','0'), AV_PIX_FMT_YUV440P},
++ {GNASH_FOURCC('J','4','4','0'), AV_PIX_FMT_YUVJ440P},
+ #endif
+
+- {GNASH_FOURCC('I','4','2','2'), PIX_FMT_YUV422P},
+- {GNASH_FOURCC('J','4','2','2'), PIX_FMT_YUVJ422P},
++ {GNASH_FOURCC('I','4','2','2'), AV_PIX_FMT_YUV422P},
++ {GNASH_FOURCC('J','4','2','2'), AV_PIX_FMT_YUVJ422P},
+
+- {GNASH_FOURCC('I','4','2','0'), PIX_FMT_YUV420P},
+- {GNASH_FOURCC('Y','V','1','2'), PIX_FMT_YUV420P},
+- {GNASH_FOURCC('I','Y','U','V'), PIX_FMT_YUV420P},
+- {GNASH_FOURCC('J','4','2','0'), PIX_FMT_YUVJ420P},
+- {GNASH_FOURCC('I','4','1','1'), PIX_FMT_YUV411P},
+- {GNASH_FOURCC('I','4','1','0'), PIX_FMT_YUV410P},
+- {GNASH_FOURCC('Y','V','U','9'), PIX_FMT_YUV410P},
++ {GNASH_FOURCC('I','4','2','0'), AV_PIX_FMT_YUV420P},
++ {GNASH_FOURCC('Y','V','1','2'), AV_PIX_FMT_YUV420P},
++ {GNASH_FOURCC('I','Y','U','V'), AV_PIX_FMT_YUV420P},
++ {GNASH_FOURCC('J','4','2','0'), AV_PIX_FMT_YUVJ420P},
++ {GNASH_FOURCC('I','4','1','1'), AV_PIX_FMT_YUV411P},
++ {GNASH_FOURCC('I','4','1','0'), AV_PIX_FMT_YUV410P},
++ {GNASH_FOURCC('Y','V','U','9'), AV_PIX_FMT_YUV410P},
+
+ #if LIBAVUTIL_VERSION_INT >= ((49<<16)+(0<<8)+1)
+- {GNASH_FOURCC('N','V','1','2'), PIX_FMT_NV12},
+- {GNASH_FOURCC('N','V','2','1'), PIX_FMT_NV21},
++ {GNASH_FOURCC('N','V','1','2'), AV_PIX_FMT_NV12},
++ {GNASH_FOURCC('N','V','2','1'), AV_PIX_FMT_NV21},
+ #endif
+
+- {GNASH_FOURCC('Y','U','Y','2'), PIX_FMT_YUYV422},
+- {GNASH_FOURCC('Y','U','Y','V'), PIX_FMT_YUYV422},
+- {GNASH_FOURCC('U','Y','V','Y'), PIX_FMT_UYVY422},
+- {GNASH_FOURCC('Y','4','1','1'), PIX_FMT_UYYVYY411},
++ {GNASH_FOURCC('Y','U','Y','2'), AV_PIX_FMT_YUYV422},
++ {GNASH_FOURCC('Y','U','Y','V'), AV_PIX_FMT_YUYV422},
++ {GNASH_FOURCC('U','Y','V','Y'), AV_PIX_FMT_UYVY422},
++ {GNASH_FOURCC('Y','4','1','1'), AV_PIX_FMT_UYYVYY411},
+
+- { 0, PIX_FMT_NONE}
++ { 0, AV_PIX_FMT_NONE}
+ };
+ #undef GNASH_FOURCC
+
+@@ -112,13 +133,13 @@ fourcc_to_ffmpeg(ImgBuf::Type4CC code)
+ }
+ }
+
+- return PIX_FMT_NONE;
++ return AV_PIX_FMT_NONE;
+ }
+
+ VideoConverterFfmpeg::VideoConverterFfmpeg(ImgBuf::Type4CC srcFormat, ImgBuf::Type4CC dstFormat)
+ : VideoConverter(srcFormat, dstFormat)
+ {
+- if(fourcc_to_ffmpeg(_dst_fmt) == PIX_FMT_NONE) {
++ if(fourcc_to_ffmpeg(_dst_fmt) == AV_PIX_FMT_NONE) {
+ throw MediaException(_("VideoConverterFfmpeg cannot convert to the "
+ "requested format"));
+ }
+@@ -138,9 +159,9 @@ VideoConverterFfmpeg::convert(const ImgB
+ const int width = src.width;
+ const int height = src.height;
+
+- PixelFormat dst_pixFmt = fourcc_to_ffmpeg(_dst_fmt);
+- assert(dst_pixFmt != PIX_FMT_NONE);
+- PixelFormat src_pixFmt = PIX_FMT_RGB24;
++ AVPixelFormat dst_pixFmt = fourcc_to_ffmpeg(_dst_fmt);
++ assert(dst_pixFmt != AV_PIX_FMT_NONE);
++ AVPixelFormat src_pixFmt = AV_PIX_FMT_RGB24;
+
+ #ifdef HAVE_SWSCALE_H
+
+--- gnash-0.8.11~git20150419.orig/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
++++ gnash-0.8.11~git20150419/libmedia/ffmpeg/VideoDecoderFfmpeg.cpp
+@@ -39,6 +39,14 @@
+ # include "GnashVaapiImage.h"
+ #endif
+
++#if LIBAVUTIL_VERSION_MAJOR < 52
++#define AVPixelFormat PixelFormat
++#define AV_PIX_FMT_RGBA PIX_FMT_RGBA
++#define AV_PIX_FMT_RGB24 PIX_FMT_RGB24
++#define AV_PIX_FMT_NONE PIX_FMT_NONE
++#define AV_PIX_FMT_VAAPI_VLD PIX_FMT_VAAPI_VLD
++#endif
++
+ namespace gnash {
+ namespace media {
+ namespace ffmpeg {
+@@ -51,7 +59,7 @@ namespace {
+ void set_vaapi_context(AVCodecContext* avctx, VaapiContextFfmpeg* vactx);
+ void clear_vaapi_context(AVCodecContext* avctx);
+ void reset_context(AVCodecContext* avctx, VaapiContextFfmpeg* vactx = nullptr);
+- PixelFormat get_format(AVCodecContext* avctx, const PixelFormat* fmt);
++ AVPixelFormat get_format(AVCodecContext* avctx, const AVPixelFormat* fmt);
+ #if LIBAVCODEC_VERSION_MAJOR >= 55
+ int get_buffer(AVCodecContext* avctx, AVFrame* pic, int flags);
+ #else
+@@ -251,16 +259,16 @@ VideoDecoderFfmpeg::frameToImage(AVCodec
+ const AVFrame& srcFrameRef)
+ {
+ const AVFrame *srcFrame = &srcFrameRef;
+- PixelFormat srcPixFmt = srcCtx->pix_fmt;
++ AVPixelFormat srcPixFmt = srcCtx->pix_fmt;
+
+ const int width = srcCtx->width;
+ const int height = srcCtx->height;
+
+ #ifdef FFMPEG_VP6A
+- PixelFormat pixFmt = (srcCtx->codec->id == AV_CODEC_ID_VP6A) ?
+- PIX_FMT_RGBA : PIX_FMT_RGB24;
++ AVPixelFormat pixFmt = (srcCtx->codec->id == AV_CODEC_ID_VP6A) ?
++ AV_PIX_FMT_RGBA : AV_PIX_FMT_RGB24;
+ #else
+- PixelFormat pixFmt = PIX_FMT_RGB24;
++ AVPixelFormat pixFmt = AV_PIX_FMT_RGB24;
+ #endif
+
+ std::unique_ptr<image::GnashImage> im;
+@@ -306,10 +314,10 @@ VideoDecoderFfmpeg::frameToImage(AVCodec
+
+ switch (pixFmt)
+ {
+- case PIX_FMT_RGBA:
++ case AV_PIX_FMT_RGBA:
+ im.reset(new image::ImageRGBA(width, height));
+ break;
+- case PIX_FMT_RGB24:
++ case AV_PIX_FMT_RGB24:
+ im.reset(new image::ImageRGB(width, height));
+ break;
+ default:
+@@ -325,7 +333,7 @@ VideoDecoderFfmpeg::frameToImage(AVCodec
+ avpicture_fill(&picture, im->begin(), pixFmt, width, height);
+
+ #ifndef HAVE_SWSCALE_H
+- img_convert(&picture, PIX_FMT_RGB24, (AVPicture*)srcFrame,
++ img_convert(&picture, AV_PIX_FMT_RGB24, (AVPicture*)srcFrame,
+ srcPixFmt, width, height);
+ #else
+
+@@ -499,15 +507,15 @@ reset_context(AVCodecContext* avctx, Vaa
+ }
+
+ /// AVCodecContext.get_format() implementation
+-PixelFormat
+-get_format(AVCodecContext* avctx, const PixelFormat* fmt)
++AVPixelFormat
++get_format(AVCodecContext* avctx, const AVPixelFormat* fmt)
+ {
+ #ifdef HAVE_VA_VA_H
+ VaapiContextFfmpeg* const vactx = get_vaapi_context(avctx);
+
+ if (vactx) {
+- for (int i = 0; fmt[i] != PIX_FMT_NONE; i++) {
+- if (fmt[i] != PIX_FMT_VAAPI_VLD) continue;
++ for (int i = 0; fmt[i] != AV_PIX_FMT_NONE; i++) {
++ if (fmt[i] != AV_PIX_FMT_VAAPI_VLD) continue;
+
+ if (vactx->initDecoder(avctx->width, avctx->height)) {
+ return fmt[i];
diff --git a/debian/patches/series b/debian/patches/series
index 1eb8018..ad89ad3 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
00sensible
+ffmpeg_2.9.patch