cog/ThirdParty/ffmpeg/patches/0003-avcodec-libfdk_aac-sup...

66 lines
2.1 KiB
Diff

diff --git a/configure b/configure
index 0de9b2abcb..7e9eb8f3b2 100755
--- a/configure
+++ b/configure
@@ -3328,7 +3328,7 @@ libdav1d_decoder_deps="libdav1d"
libdav1d_decoder_select="atsc_a53"
libdavs2_decoder_deps="libdavs2"
libdavs2_decoder_select="avs2_parser"
-libfdk_aac_decoder_deps="libfdk_aac"
+libfdk_aac_decoder_deps="libfdk_aac fmtconvert"
libfdk_aac_encoder_deps="libfdk_aac"
libfdk_aac_encoder_select="audio_frame_queue"
libgme_demuxer_deps="libgme"
diff --git a/libavcodec/libfdk-aacdec.c b/libavcodec/libfdk-aacdec.c
index 11eee51a98..9e199eb56f 100644
--- a/libavcodec/libfdk-aacdec.c
+++ b/libavcodec/libfdk-aacdec.c
@@ -25,6 +25,7 @@
#include "avcodec.h"
#include "codec_internal.h"
#include "internal.h"
+#include "fmtconvert.h"
#ifdef AACDECODER_LIB_VL0
#define FDKDEC_VER_AT_LEAST(vl0, vl1) \
@@ -65,6 +66,7 @@ typedef struct FDKAACDecContext {
int delay_samples;
#endif
AVChannelLayout downmix_layout;
+ FmtConvertContext fmt_conv;
} FDKAACDecContext;
@@ -367,13 +369,15 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
#endif
- avctx->sample_fmt = AV_SAMPLE_FMT_S16;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
s->decoder_buffer_size = DECODER_BUFFSIZE * DECODER_MAX_CHANNELS;
s->decoder_buffer = av_malloc(s->decoder_buffer_size);
if (!s->decoder_buffer)
return AVERROR(ENOMEM);
+ ff_fmt_convert_init(&s->fmt_conv, avctx);
+
return 0;
}
@@ -452,9 +456,11 @@ static int fdk_aac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
goto end;
- memcpy(frame->extended_data[0], s->decoder_buffer + input_offset,
- avctx->ch_layout.nb_channels * frame->nb_samples *
- av_get_bytes_per_sample(avctx->sample_fmt));
+ const int count = avctx->ch_layout.nb_channels * frame->nb_samples;
+ const float scale = 1.0f / (float)0x800000;
+ s->fmt_conv.int32_to_float_fmul_scalar((float *) frame->extended_data[0],
+ (INT_PCM *)s->decoder_buffer + input_offset,
+ scale, count);
*got_frame_ptr = 1;
ret = avpkt->size - valid;