Skip to contentSkip to conversation

package/ffmpeg: Fix building with libfdk-aac v2

PATCH New Bernd Kuhls 2 participants 2 messages Jan 28, 2019 – Feb 4, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ffmpeg: Fix building with libfdk-aac v2

Add upstream patches to fix
http://autobuild.buildroot.net/results/909/9097a2b190f4032ff51eda531f4379a99da5181a/

after fdk-aac was bumped to 2.0.0:
https://git.buildroot.net/buildroot/commit/package/fdk-aac?id=31ff32824a4f3d09351367c3418b5605f9c40521

---
 ...cenc-Fix-building-with-libfdk-aac-v2.patch | 100 ++++++++++++++++++
 ...stently-use-a-proper-version-check-m.patch |  99 +++++++++++++++++
 ...dk-aac-Don-t-use-defined-in-a-define.patch |  72 +++++++++++++
 3 files changed, 271 insertions(+)
 create mode 100644 package/ffmpeg/0002-libfdk-aacenc-Fix-building-with-libfdk-aac-v2.patch
 create mode 100644 package/ffmpeg/0003-libfdk-aac-Consistently-use-a-proper-version-check-m.patch
 create mode 100644 package/ffmpeg/0004-libfdk-aac-Don-t-use-defined-in-a-define.patch
package/ffmpeg/0002-libfdk-aacenc-Fix-building-with-libfdk-aac-v2.patch new file +100 -0
new file mode 100644
index 0000000000..3f452242fa
@@ -0,0 +1,100 @@
+From c60fb550302878aba7e86037451f7996e8069289 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <[email protected]>
+Date: Fri, 31 Aug 2018 14:25:30 +0300
+Subject: [PATCH] libfdk-aacenc: Fix building with libfdk-aac v2
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When flushing the encoder, we now need to provide non-null buffer
+parameters for everything, even if they are unused.
+
+The encoderDelay parameter has been replaced by two, nDelay and
+nDelayCore.
+
+Downloaded from
+http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=141c960e21d2860e354f9b90df136184dd00a9a8
+
+Signed-off-by: Martin Storsj?? <[email protected]>
+[Bernd: rebased for ffmpeg 3.4.5]
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ libavcodec/libfdk-aacenc.c | 34 +++++++++++++++++++++++++---------
+ 1 file changed, 25 insertions(+), 9 deletions(-)
+
+diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
+index 0e2051b468..f5adb407ed 100644
+--- a/libavcodec/libfdk-aacenc.c
++++ b/libavcodec/libfdk-aacenc.c
+@@ -26,6 +26,11 @@
+ #include "audio_frame_queue.h"
+ #include "internal.h"
+ 
++#define FDKENC_VER_AT_LEAST(vl0, vl1) \
++    (defined(AACENCODER_LIB_VL0) && \
++        ((AACENCODER_LIB_VL0 > vl0) || \
++         (AACENCODER_LIB_VL0 == vl0 && AACENCODER_LIB_VL1 >= vl1)))
++
+ typedef struct AACContext {
+     const AVClass *class;
+     HANDLE_AACENCODER handle;
+@@ -286,7 +291,11 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
+     }
+ 
+     avctx->frame_size = info.frameLength;
++#if FDKENC_VER_AT_LEAST(4, 0)
++    avctx->initial_padding = info.nDelay;
++#else
+     avctx->initial_padding = info.encoderDelay;
++#endif
+     ff_af_queue_init(avctx, &s->afq);
+ 
+     if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
+@@ -319,28 +328,35 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+     int out_buffer_size, out_buffer_element_size;
+     void *in_ptr, *out_ptr;
+     int ret;
++    uint8_t dummy_buf[1];
+     AACENC_ERROR err;
+ 
+     /* handle end-of-stream small frame and flushing */
+     if (!frame) {
++        /* Must be a non-null pointer, even if it's a dummy. We could use
++         * the address of anything else on the stack as well. */
++        in_ptr               = dummy_buf;
++        in_buffer_size       = 0;
++
+         in_args.numInSamples = -1;
+     } else {
+-        in_ptr                   = frame->data[0];
+-        in_buffer_size           = 2 * avctx->channels * frame->nb_samples;
+-        in_buffer_element_size   = 2;
++        in_ptr               = frame->data[0];
++        in_buffer_size       = 2 * avctx->channels * frame->nb_samples;
+ 
+-        in_args.numInSamples     = avctx->channels * frame->nb_samples;
+-        in_buf.numBufs           = 1;
+-        in_buf.bufs              = &in_ptr;
+-        in_buf.bufferIdentifiers = &in_buffer_identifier;
+-        in_buf.bufSizes          = &in_buffer_size;
+-        in_buf.bufElSizes        = &in_buffer_element_size;
++        in_args.numInSamples = avctx->channels * frame->nb_samples;
+ 
+         /* add current frame to the queue */
+         if ((ret = ff_af_queue_add(&s->afq, frame)) < 0)
+             return ret;
+     }
+ 
++    in_buffer_element_size   = 2;
++    in_buf.numBufs           = 1;
++    in_buf.bufs              = &in_ptr;
++    in_buf.bufferIdentifiers = &in_buffer_identifier;
++    in_buf.bufSizes          = &in_buffer_size;
++    in_buf.bufElSizes        = &in_buffer_element_size;
++
+     /* The maximum packet size is 6144 bits aka 768 bytes per channel. */
+     if ((ret = ff_alloc_packet2(avctx, avpkt, FFMAX(8192, 768 * avctx->channels), 0)) < 0)
+         return ret;
+-- 
+2.20.1
+
package/ffmpeg/0003-libfdk-aac-Consistently-use-a-proper-version-check-m.patch new file +99 -0

99 lines not on this page · raw message

package/ffmpeg/0004-libfdk-aac-Don-t-use-defined-in-a-define.patch new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 package/ffmpeg: Fix building with libfdk-aac v2

Quoted 7 lines · On Mon, 28 Jan 2019 21:55:19 +0100 Bernd Kuhls <[email protected]> wrote:

Add upstream patches to fix
http://autobuild.buildroot.net/results/909/9097a2b190f4032ff51eda531f4379a99da5181a/

after fdk-aac was bumped to 2.0.0:
https://git.buildroot.net/buildroot/commit/package/fdk-aac?id=31ff32824a4f3d09351367c3418b5605f9c40521

Quoted 8 lines
---
 ...cenc-Fix-building-with-libfdk-aac-v2.patch | 100 ++++++++++++++++++
 ...stently-use-a-proper-version-check-m.patch |  99 +++++++++++++++++
 ...dk-aac-Don-t-use-defined-in-a-define.patch |  72 +++++++++++++
 3 files changed, 271 insertions(+)
 create mode 100644 package/ffmpeg/0002-libfdk-aacenc-Fix-building-with-libfdk-aac-v2.patch
 create mode 100644 package/ffmpeg/0003-libfdk-aac-Consistently-use-a-proper-version-check-m.patch
 create mode 100644 package/ffmpeg/0004-libfdk-aac-Don-t-use-defined-in-a-define.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com