From 3f78077ba80ca4a13e0b8280aa6ffc3df97a8ea2 Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Mon, 2 Sep 2024 20:48:03 +0200 Subject: [PATCH] Add a new channel layout API ffmpeg 7.0;pleas check line 1176:av_channel_layout_default Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/03dd326d7663a5fb6487e4e83ce162ad862ea126 Author: Jacek Jendrzej Date: 2024-09-02 (Mon, 02 Sep 2024) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/container/container_ffmpeg.c | 29 ++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/libeplayer3/container/container_ffmpeg.c b/libeplayer3/container/container_ffmpeg.c index 01d9e67..ccdeb9d 100644 --- a/libeplayer3/container/container_ffmpeg.c +++ b/libeplayer3/container/container_ffmpeg.c @@ -1022,7 +1022,11 @@ static void FFMPEGThread(Context_t *context) } pcmPrivateData_t pcmExtradata; +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0) + pcmExtradata.channels = get_codecpar(audioTrack->stream)->ch_layout.nb_channels; +#else pcmExtradata.channels = get_codecpar(audioTrack->stream)->channels; +#endif pcmExtradata.bits_per_coded_sample = get_codecpar(audioTrack->stream)->bits_per_coded_sample; pcmExtradata.sample_rate = get_codecpar(audioTrack->stream)->sample_rate; pcmExtradata.bit_rate = get_codecpar(audioTrack->stream)->bit_rate; @@ -1164,6 +1168,16 @@ static void FFMPEGThread(Context_t *context) } swr = swr_alloc(); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0) + out_channels = c->ch_layout.nb_channels; + + if (c->ch_layout.u.mask == 0) + { + av_channel_layout_default(&c->ch_layout, c->ch_layout.nb_channels); + } + + out_channel_layout = c->ch_layout.u.mask; +#else out_channels = c->channels; if (c->channel_layout == 0) @@ -1172,7 +1186,7 @@ static void FFMPEGThread(Context_t *context) } out_channel_layout = c->channel_layout; - +#endif uint8_t downmix = stereo_software_decoder && out_channels > 2 ? 1 : 0; #ifdef __sh__ // player2 won't play mono @@ -1186,8 +1200,11 @@ static void FFMPEGThread(Context_t *context) out_channel_layout = AV_CH_LAYOUT_STEREO_DOWNMIX; out_channels = 2; } - +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0) + av_opt_set_int(swr, "in_channel_layout", c->ch_layout.u.mask, 0); +#else av_opt_set_int(swr, "in_channel_layout", c->channel_layout, 0); +#endif av_opt_set_int(swr, "out_channel_layout", out_channel_layout, 0); av_opt_set_int(swr, "in_sample_rate", c->sample_rate, 0); av_opt_set_int(swr, "out_sample_rate", out_sample_rate, 0); @@ -1225,7 +1242,11 @@ static void FFMPEGThread(Context_t *context) ////////////////////////////////////////////////////////////////////// // Update pcmExtradata according to decode parameters +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0) + pcmExtradata.channels = c->ch_layout.nb_channels; +#else pcmExtradata.channels = av_get_channel_layout_nb_channels(out_channel_layout); +#endif pcmExtradata.bits_per_coded_sample = 16; pcmExtradata.sample_rate = out_sample_rate; // The data described by the sample format is always in native-endian order @@ -2456,7 +2477,11 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 int32_t object_type = 2; // LC int32_t sample_index = aac_get_sample_rate_index(get_codecpar(stream)->sample_rate); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(61, 0, 0) + int32_t chan_config = get_chan_config(get_codecpar(stream)->ch_layout.nb_channels); +#else int32_t chan_config = get_chan_config(get_codecpar(stream)->channels); +#endif ffmpeg_printf(1, "aac object_type %d\n", object_type); ffmpeg_printf(1, "aac sample_index %d\n", sample_index); ffmpeg_printf(1, "aac chan_config %d\n", chan_config);