[vlc-commits] Fix building vlc with libfdk-aac v2

Antonio Larrosa git at videolan.org
Sat Feb 23 18:11:45 CET 2019


vlc | branch: master | Antonio Larrosa <antonio.larrosa at gmail.com> | Thu Feb 14 10:09:30 2019 +0100| [6ea9b13fe82fae2b25b7371c6c36d6296db28ccb] | committer: Jean-Baptiste Kempf

Fix building vlc with libfdk-aac v2

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.

This is based on:
https://git.libav.org/?p=libav.git;a=commitdiff_plain;h=141c960e21d2860e354f9b90df136184dd00a9a8;hp=c8bca9fe466f810fd484e2c6db7ef7bc83b5a943

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ea9b13fe82fae2b25b7371c6c36d6296db28ccb
---

 modules/codec/fdkaac.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/modules/codec/fdkaac.c b/modules/codec/fdkaac.c
index e0b3088c4a..3ac7b756a3 100644
--- a/modules/codec/fdkaac.c
+++ b/modules/codec/fdkaac.c
@@ -92,6 +92,11 @@ static void CloseEncoder(vlc_object_t *);
 #define SIGNALING_COMPATIBLE 1
 #define SIGNALING_HIERARCHICAL 2
 
+#define FDKENC_VER_AT_LEAST(vl0, vl1) \
+    (defined(AACENCODER_LIB_VL0) && \
+        ((AACENCODER_LIB_VL0 > vl0) || \
+         (AACENCODER_LIB_VL0 == vl0 && AACENCODER_LIB_VL1 >= vl1)))
+
 static const int pi_aot_values[] = { PROFILE_AAC_LC, PROFILE_AAC_HE, PROFILE_AAC_HE_v2, PROFILE_AAC_LD, PROFILE_AAC_ELD };
 static const char *const ppsz_aot_descriptions[] =
 { N_("AAC-LC"), N_("HE-AAC"), N_("HE-AAC-v2"), N_("AAC-LD"), N_("AAC-ELD") };
@@ -288,7 +293,11 @@ static int OpenEncoder(vlc_object_t *p_this)
     p_sys->i_maxoutputsize = 768*p_enc->fmt_in.audio.i_channels;
     p_enc->fmt_in.audio.i_bitspersample = 16;
     p_sys->i_frame_size = info.frameLength;
+#if FDKENC_VER_AT_LEAST(4, 0)
+    p_sys->i_encoderdelay = info.nDelay;
+#else
     p_sys->i_encoderdelay = info.encoderDelay;
+#endif
 
     p_enc->fmt_out.i_extra = info.confSize;
     if (p_enc->fmt_out.i_extra) {
@@ -351,21 +360,27 @@ static block_t *EncodeAudio(encoder_t *p_enc, block_t *p_aout_buf)
         int out_identifier = OUT_BITSTREAM_DATA;
         int out_size, out_elem_size;
         void *in_ptr, *out_ptr;
+        uint8_t dummy_buf[1];
 
         if (unlikely(i_samples == 0)) {
             // this forces the encoder to purge whatever is left in the internal buffer
+            /* 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_size       = 0;
+
             in_args.numInSamples = -1;
         } else {
             in_ptr = p_buffer + (i_samples - i_samples_left)*p_enc->fmt_in.audio.i_channels;
             in_size = 2*p_enc->fmt_in.audio.i_channels*i_samples_left;
-            in_elem_size = 2;
             in_args.numInSamples = p_enc->fmt_in.audio.i_channels*i_samples_left;
-            in_buf.numBufs = 1;
-            in_buf.bufs = &in_ptr;
-            in_buf.bufferIdentifiers = &in_identifier;
-            in_buf.bufSizes = &in_size;
-            in_buf.bufElSizes = &in_elem_size;
         }
+        in_elem_size = 2;
+        in_buf.numBufs = 1;
+        in_buf.bufs = &in_ptr;
+        in_buf.bufferIdentifiers = &in_identifier;
+        in_buf.bufSizes = &in_size;
+        in_buf.bufElSizes = &in_elem_size;
         block_t *p_block;
         p_block = block_Alloc(p_sys->i_maxoutputsize);
         p_block->i_buffer = p_sys->i_maxoutputsize;



More information about the vlc-commits mailing list