From: Antonio Larrosa Subject: Fix building vlc with fdk-aac v2 Based on the patch at https://git.libav.org/?p=libav.git;a=commitdiff_plain;h=141c960e21d2860e354f9b90df136184dd00a9a8;hp=c8bca9fe466f810fd484e2c6db7ef7bc83b5a943 Index: vlc-3.0.6/modules/codec/fdkaac.c =================================================================== --- vlc-3.0.6.orig/modules/codec/fdkaac.c +++ vlc-3.0.6/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_t 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) { @@ -353,21 +362,27 @@ static block_t *EncodeAudio(encoder_t *p 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;