1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

avcodec/atrac3: allow 6 channels (non-joint stereo)

Raises max channels to 6 (for non joint-stereo only),
there is no difference decoding 1 or N discrete channels.
Fixes trac issue #5840

Signed-off-by: bnnm <bananaman255@gmail.com>
This commit is contained in:
bnnm 2017-01-19 20:53:12 +01:00 committed by Paul B Mahol
parent 9a619bef54
commit cab0f3abc5

View File

@ -49,7 +49,7 @@
#include "atrac3data.h"
#define JOINT_STEREO 0x12
#define STEREO 0x2
#define SINGLE 0x2
#define SAMPLES_PER_FRAME 1024
#define MDCT_SIZE 512
@ -567,7 +567,7 @@ static void channel_weighting(float *su1, float *su2, int *p3)
* @param snd the channel unit to be used
* @param output the decoded samples before IQMF in float representation
* @param channel_num channel number
* @param coding_mode the coding mode (JOINT_STEREO or regular stereo/mono)
* @param coding_mode the coding mode (JOINT_STEREO or single channels)
*/
static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
ChannelUnit *snd, float *output,
@ -702,7 +702,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf,
channel_weighting(out_samples[0], out_samples[1], q->weighting_delay);
} else {
/* normal stereo mode or mono */
/* single channels */
/* Decode the channel sound units. */
for (i = 0; i < avctx->channels; i++) {
/* Set the bitstream reader at the start of a channel sound unit. */
@ -797,7 +797,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
const uint8_t *edata_ptr = avctx->extradata;
ATRAC3Context *q = avctx->priv_data;
if (avctx->channels <= 0 || avctx->channels > 2) {
if (avctx->channels <= 0 || avctx->channels > 6) {
av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
return AVERROR(EINVAL);
}
@ -823,7 +823,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
samples_per_frame = SAMPLES_PER_FRAME * avctx->channels;
version = 4;
delay = 0x88E;
q->coding_mode = q->coding_mode ? JOINT_STEREO : STEREO;
q->coding_mode = q->coding_mode ? JOINT_STEREO : SINGLE;
q->scrambled_stream = 0;
if (avctx->block_align != 96 * avctx->channels * frame_factor &&
@ -855,8 +855,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
if (samples_per_frame != SAMPLES_PER_FRAME &&
samples_per_frame != SAMPLES_PER_FRAME * 2) {
if (samples_per_frame != SAMPLES_PER_FRAME * avctx->channels) {
av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
samples_per_frame);
return AVERROR_INVALIDDATA;
@ -868,8 +867,8 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
if (q->coding_mode == STEREO)
av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
if (q->coding_mode == SINGLE)
av_log(avctx, AV_LOG_DEBUG, "Single channels detected.\n");
else if (q->coding_mode == JOINT_STEREO) {
if (avctx->channels != 2) {
av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");