Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2022-10-31 23:24:47 +0300
committerJames Almer <jamrial@gmail.com>2022-11-04 15:14:51 +0300
commitb4a4a3149911b0dd24b6268a04849673e16ef99f (patch)
tree546bd9763d4ef3ebde293114466ba3fca149c79a
parentfe2d8f1872ac40d3046c6d104d73c5244e251703 (diff)
avcodec/atrac3plus: reorder channels to match the output layout
The order in which the channels are coded in the bitstream do not always follow the native, bitmask-based order of channels both signaled by the WAV container and forced by this same decoder. This is the case with layouts containing an LFE channel, as it's always coded last. Fixes ticket #9964. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 3819719099df601c470e961b9d49b9100c65641b)
-rw-r--r--libavcodec/atrac3plusdec.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/libavcodec/atrac3plusdec.c b/libavcodec/atrac3plusdec.c
index f87ffb8938..aef4e36df8 100644
--- a/libavcodec/atrac3plusdec.c
+++ b/libavcodec/atrac3plusdec.c
@@ -48,6 +48,17 @@
#include "atrac.h"
#include "atrac3plus.h"
+static const uint8_t channel_map[8][8] = {
+ { 0, },
+ { 0, 1, },
+ { 0, 1, 2, },
+ { 0, 1, 2, 3, },
+ { 0, },
+ { 0, 1, 2, 4, 5, 3, },
+ { 0, 1, 2, 4, 5, 6, 3, },
+ { 0, 1, 2, 4, 5, 6, 7, 3, },
+};
+
typedef struct ATRAC3PContext {
GetBitContext gb;
AVFloatDSPContext *fdsp;
@@ -65,6 +76,7 @@ typedef struct ATRAC3PContext {
int num_channel_blocks; ///< number of channel blocks
uint8_t channel_blocks[5]; ///< channel configuration descriptor
+ const uint8_t *channel_map; ///< channel layout map
} ATRAC3PContext;
static av_cold int atrac3p_decode_close(AVCodecContext *avctx)
@@ -143,6 +155,8 @@ static av_cold int set_channel_params(ATRAC3PContext *ctx,
return AVERROR_INVALIDDATA;
}
+ ctx->channel_map = channel_map[channels - 1];
+
return 0;
}
@@ -378,7 +392,7 @@ static int atrac3p_decode_frame(AVCodecContext *avctx, AVFrame *frame,
channels_to_process, avctx);
for (i = 0; i < channels_to_process; i++)
- memcpy(samples_p[out_ch_index + i], ctx->outp_buf[i],
+ memcpy(samples_p[ctx->channel_map[out_ch_index + i]], ctx->outp_buf[i],
ATRAC3P_FRAME_SAMPLES * sizeof(**samples_p));
ch_block++;