diff options
author | Michele Calgaro <[email protected]> | 2024-08-14 10:00:09 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2024-08-15 17:15:34 +0900 |
commit | a4d07cf64ba4728ca78e2e7c69d9cc98cb449208 (patch) | |
tree | e6a3159d8ca3ecf8126d497959a372d6e00f8ada | |
parent | 88d21b1b284629b6f1b0a80dd743e99751ac0b65 (diff) | |
download | akode-a4d07cf64ba4728ca78e2e7c69d9cc98cb449208.tar.gz akode-a4d07cf64ba4728ca78e2e7c69d9cc98cb449208.zip |
Fix compatibility with ffmpeg 7.x
Signed-off-by: Michele Calgaro <[email protected]>
(cherry picked from commit f6e20b92a94717a4519bf79ddd416c7c7b3caab5)
-rw-r--r-- | akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp b/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp index dd772ce..6db8834 100644 --- a/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp +++ b/akode/plugins/ffmpeg_decoder/ffmpeg_decoder.cpp @@ -45,12 +45,16 @@ extern "C" { // FFMPEG callbacks extern "C" { - static int akode_read(void* opaque, unsigned char *buf, int size) + static int akode_read(void* opaque, uint8_t *buf, int size) { aKode::File *file = (aKode::File*)opaque; return file->read((char*)buf, size); } - static int akode_write(void* opaque, unsigned char *buf, int size) +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(60, 16, 100) + static int akode_write(void* opaque, uint8_t *buf, int size) +#else + static int akode_write(void* opaque, const uint8_t *buf, int size) +#endif { aKode::File *file = (aKode::File*)opaque; return file->write((char*)buf, size); @@ -129,7 +133,11 @@ FFMPEGDecoder::~FFMPEGDecoder() { static bool setAudioConfiguration(AudioConfiguration *config, AVCodecContext *codec_context) { config->sample_rate = codec_context->sample_rate; +# if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100) config->channels = codec_context->channels; +# else + config->channels = codec_context->ch_layout.nb_channels; +# endif // I do not know FFMPEGs surround channel ordering if (config->channels > 2) return false; config->channel_config = MonoStereo; @@ -411,7 +419,11 @@ retry: d->buffer = decodeFrame->data; #if !defined(FFMPEG_AVFRAME_HAVE_CHANNELS) +# if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100) d->buffer_size = decodeFrame->nb_samples * d->ic->streams[d->audioStream]->CODECPAR->channels * av_get_bytes_per_sample(d->ic->streams[d->audioStream]->codec->sample_fmt); +# else + d->buffer_size = decodeFrame->nb_samples * d->ic->streams[d->audioStream]->CODECPAR->ch_layout.nb_channels * av_get_bytes_per_sample((AVSampleFormat)d->ic->streams[d->audioStream]->codecpar->format); +# endif #else d->buffer_size = decodeFrame->nb_samples * decodeFrame->channels * av_get_bytes_per_sample(d->audioStream_ctx->sample_fmt); #endif |