Fix compatibility with ffmpeg 7.x

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit f6e20b92a9)
r14.1.x
Michele Calgaro 3 months ago
parent 88d21b1b28
commit a4d07cf64b
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -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

Loading…
Cancel
Save