From d1c51097eb1741a3f6d9e2d35b75abf2209ed123 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Mon, 2 Jul 2018 22:21:27 -0400 Subject: [PATCH] Upgrade FFmpeg to 4.0.1 across the board (including GCC2.) This was accomplished by adding some pretty nasty hacks to the FFmpeg recipe so that we can compile it for the GCC2 ABI using GCC7. This works because GCC's C ABI has not changed between GCC2 and GCC7. As a consequence of this, pretty much all the longstanding issues of the ancient-and-still-miscompiled FFmpeg 0.10 are now completely gone. Fixes #5080, #8461, #12696, #12436, #13981 #13410, #13337. Closes (possibly fixed earlier) #8605, #8511, #6984. Probably fixes (couldn't test) #13989, #11974. --- build/jam/repositories/HaikuPorts/x86_64 | 8 ++++---- build/jam/repositories/HaikuPorts/x86_gcc2 | 16 ++++++++-------- .../media/plugins/ffmpeg/AVCodecDecoder.cpp | 10 +++++----- .../media/plugins/ffmpeg/AVFormatWriter.cpp | 6 +++--- src/add-ons/media/plugins/ffmpeg/Jamfile | 8 +++----- 5 files changed, 23 insertions(+), 25 deletions(-) diff --git a/build/jam/repositories/HaikuPorts/x86_64 b/build/jam/repositories/HaikuPorts/x86_64 index 51b7f41b53..702d6778dc 100644 --- a/build/jam/repositories/HaikuPorts/x86_64 +++ b/build/jam/repositories/HaikuPorts/x86_64 @@ -33,8 +33,8 @@ RemotePackageRepository HaikuPorts diffutils-3.6-1 expat-2.2.5-1 expat_devel-2.2.5-1 - ffmpeg-3.4.2-3 - ffmpeg_devel-3.4.2-3 + ffmpeg-4.0.1-2 + ffmpeg_devel-4.0.1-2 findutils-4.6.0-1 flex-2.6.4-1 fluidlite-1.0.0-3 @@ -79,8 +79,8 @@ RemotePackageRepository HaikuPorts jpeg_devel-9c-2 keymapswitcher-1.2.7.11-4 less-531-1 - libedit-20170329_3.1-1 - libedit_devel-20170329_3.1-1 + libedit-20180525_3.1-1 + libedit_devel-20180525_3.1-1 libexecinfo-1.1-4 libffi-3.2.1-4 libgcrypt-1.8.2-2 diff --git a/build/jam/repositories/HaikuPorts/x86_gcc2 b/build/jam/repositories/HaikuPorts/x86_gcc2 index 1902a86f68..a0c3853f41 100644 --- a/build/jam/repositories/HaikuPorts/x86_gcc2 +++ b/build/jam/repositories/HaikuPorts/x86_gcc2 @@ -34,8 +34,8 @@ RemotePackageRepository HaikuPorts expat-2.2.1-2 expat_devel-2.2.1-2 findutils-4.6.0-1 - ffmpeg-0.10.16-1 - ffmpeg_devel-0.10.16-1 + ffmpeg-4.0.1-2 + ffmpeg_devel-4.0.1-2 flex-2.6.4-1 fluidlite_devel-1.0.0-3 fontconfig-2.12.6-2 @@ -74,8 +74,8 @@ RemotePackageRepository HaikuPorts jpeg_devel-9c-2 keymapswitcher-1.2.7.11-4 less-531-1 - libedit-20170329_3.1-1 - libedit_devel-20170329_3.1-1 + libedit-20180525_3.1-1 + libedit_devel-20180525_3.1-1 libffi-3.0.13-2 libiconv-1.15-4 libicns-0.8.1-6 @@ -168,8 +168,8 @@ RemotePackageRepository HaikuPorts curl_x86_devel-7.60.0-1 expat_x86-2.2.5-1 expat_x86_devel-2.2.5-1 - ffmpeg_x86-3.2.4-2 - ffmpeg_x86_devel-3.2.4-2 + ffmpeg_x86-4.0.1-2 + ffmpeg_x86_devel-4.0.1-2 fluidlite_x86_devel-1.0.0-3 fontconfig_x86-2.12.6-2 fontconfig_x86_devel-2.12.6-2 @@ -197,8 +197,8 @@ RemotePackageRepository HaikuPorts jasper_x86_devel-2.0.14-1 jpeg_x86-9c-2 jpeg_x86_devel-9c-2 - libedit_x86-2015_03_21_3.1-8 - libedit_x86_devel-2015_03_21_3.1-8 + libedit_x86-20180525_3.1-1 + libedit_x86_devel-20180525_3.1-1 libexecinfo_x86-1.1-4 libgcrypt_x86-1.8.2-2 libgpg_error_x86-1.31-1 diff --git a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp index d9b6f772ba..13ec9f3834 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVCodecDecoder.cpp @@ -468,11 +468,11 @@ AVCodecDecoder::_NegotiateVideoOutputFormat(media_format* inOutFormat) // properties accordingly regardless of the settings here. bool codecCanHandleIncompleteFrames - = (fCodec->capabilities & CODEC_CAP_TRUNCATED) != 0; + = (fCodec->capabilities & AV_CODEC_CAP_TRUNCATED) != 0; if (codecCanHandleIncompleteFrames) { // Expect and handle video frames to be splitted across consecutive // data chunks. - fContext->flags |= CODEC_FLAG_TRUNCATED; + fContext->flags |= AV_CODEC_FLAG_TRUNCATED; } // close any previous instance @@ -1444,7 +1444,7 @@ AVCodecDecoder::_LoadNextChunkIfNeededAndAssignStartTime() This is needed so that some decoders can read safely a predefined number of bytes at a time for performance optimization purposes. - The additional memory has a size of FF_INPUT_BUFFER_PADDING_SIZE as defined + The additional memory has a size of AV_INPUT_BUFFER_PADDING_SIZE as defined in avcodec.h. Ownership of fChunkBuffer memory is with the class so it needs to be freed @@ -1467,14 +1467,14 @@ AVCodecDecoder::_CopyChunkToChunkBufferAndAddPadding(const void* chunk, size_t chunkSize) { fChunkBuffer = static_cast(realloc(fChunkBuffer, - chunkSize + FF_INPUT_BUFFER_PADDING_SIZE)); + chunkSize + AV_INPUT_BUFFER_PADDING_SIZE)); if (fChunkBuffer == NULL) { fChunkBufferSize = 0; return B_NO_MEMORY; } memcpy(fChunkBuffer, chunk, chunkSize); - memset(fChunkBuffer + chunkSize, 0, FF_INPUT_BUFFER_PADDING_SIZE); + memset(fChunkBuffer + chunkSize, 0, AV_INPUT_BUFFER_PADDING_SIZE); // Establish safety net, by zero'ing the padding area. fChunkBufferSize = chunkSize; diff --git a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp index 8c04a87ee7..8a101b58fa 100644 --- a/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp +++ b/src/add-ons/media/plugins/ffmpeg/AVFormatWriter.cpp @@ -213,10 +213,10 @@ AVFormatWriter::StreamCookie::Init(media_format* format, // Now negociate the actual format with the encoder // First check if the requested format is acceptable AVCodec* codec = avcodec_find_encoder(fStream->codec->codec_id); - + if (codec == NULL) return B_MEDIA_BAD_FORMAT; - + const enum AVSampleFormat *p = codec->sample_fmts; for (; *p != -1; p++) { if (*p == fStream->codec->sample_fmt) @@ -293,7 +293,7 @@ AVFormatWriter::StreamCookie::Init(media_format* format, // Some formats want stream headers to be separate if ((fContext->oformat->flags & AVFMT_GLOBALHEADER) != 0) - fStream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; + fStream->codec->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; TRACE(" stream->time_base: (%d/%d), codec->time_base: (%d/%d))\n", fStream->time_base.num, fStream->time_base.den, diff --git a/src/add-ons/media/plugins/ffmpeg/Jamfile b/src/add-ons/media/plugins/ffmpeg/Jamfile index 9411065ac9..6003dcfed2 100644 --- a/src/add-ons/media/plugins/ffmpeg/Jamfile +++ b/src/add-ons/media/plugins/ffmpeg/Jamfile @@ -18,15 +18,15 @@ local sources = FFmpegPlugin.cpp MuxerTable.cpp CpuCapabilities.cpp - + gfx_conv_c.cpp gfx_conv_c_lookup.cpp gfx_util.cpp ; if $(TARGET_ARCH) != x86_64 { - sources += - gfx_conv_mmx.cpp + sources += + gfx_conv_mmx.cpp yuvrgb_sse.nasm yuvrgb_sse2.nasm yuvrgb_ssse3.nasm @@ -62,5 +62,3 @@ for architectureObject in [ MultiArchSubDirSetup ] { ; } } - -