Raises max channels to 6 (for non joint-stereo only), there is no difference decoding 1 or N discrete channels. Fixes trac issue #5840
Unified · Split
| @@ -49,7 +49,7 @@ · 48 unmodified lines | |||
| 49 | #include "atrac3data.h" | 49 | #include "atrac3data.h" |
| 50 | 50 | ||
| 51 | #define JOINT_STEREO 0x12 | 51 | #define JOINT_STEREO 0x12 |
| 52 | #define STEREO 0x2 | 52 | #define SINGLE 0x2 |
| 53 | 53 | ||
| 54 | #define SAMPLES_PER_FRAME 1024 | 54 | #define SAMPLES_PER_FRAME 1024 |
| 55 | #define MDCT_SIZE 512 | 55 | #define MDCT_SIZE 512 |
| @@ -567,7 +567,7 @@ static void channel_weighting(float *su1, float *su2, int *p3) · 511 unmodified lines | |||
| 567 | * @param snd the channel unit to be used | 567 | * @param snd the channel unit to be used |
| 568 | * @param output the decoded samples before IQMF in float representation | 568 | * @param output the decoded samples before IQMF in float representation |
| 569 | * @param channel_num channel number | 569 | * @param channel_num channel number |
| 570 | * @param coding_mode the coding mode (JOINT_STEREO or regular stereo/mono) | 570 | * @param coding_mode the coding mode (JOINT_STEREO or single channels) |
| 571 | */ | 571 | */ |
| 572 | static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, | 572 | static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb, |
| 573 | ChannelUnit *snd, float *output, | 573 | ChannelUnit *snd, float *output, |
| @@ -702,7 +702,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, · 128 unmodified lines | |||
| 702 | 702 | ||
| 703 | channel_weighting(out_samples[0], out_samples[1], q->weighting_delay); | 703 | channel_weighting(out_samples[0], out_samples[1], q->weighting_delay); |
| 704 | } else { | 704 | } else { |
| 705 | /* normal stereo mode or mono */ | 705 | /* single channels */ |
| 706 | /* Decode the channel sound units. */ | 706 | /* Decode the channel sound units. */ |
| 707 | for (i = 0; i < avctx->channels; i++) { | 707 | for (i = 0; i < avctx->channels; i++) { |
| 708 | /* Set the bitstream reader at the start of a channel sound unit. */ | 708 | /* 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) · 88 unmodified lines | |||
| 797 | const uint8_t *edata_ptr = avctx->extradata; | 797 | const uint8_t *edata_ptr = avctx->extradata; |
| 798 | ATRAC3Context *q = avctx->priv_data; | 798 | ATRAC3Context *q = avctx->priv_data; |
| 799 | 799 | ||
| 800 | if (avctx->channels <= 0 || avctx->channels > 2) { | 800 | if (avctx->channels <= 0 || avctx->channels > 6) { |
| 801 | av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); | 801 | av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n"); |
| 802 | return AVERROR(EINVAL); | 802 | return AVERROR(EINVAL); |
| 803 | } | 803 | } |
| @@ -823,7 +823,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 19 unmodified lines | |||
| 823 | samples_per_frame = SAMPLES_PER_FRAME * avctx->channels; | 823 | samples_per_frame = SAMPLES_PER_FRAME * avctx->channels; |
| 824 | version = 4; | 824 | version = 4; |
| 825 | delay = 0x88E; | 825 | delay = 0x88E; |
| 826 | q->coding_mode = q->coding_mode ? JOINT_STEREO : STEREO; | 826 | q->coding_mode = q->coding_mode ? JOINT_STEREO : SINGLE; |
| 827 | q->scrambled_stream = 0; | 827 | q->scrambled_stream = 0; |
| 828 | 828 | ||
| 829 | if (avctx->block_align != 96 * avctx->channels * frame_factor && | 829 | if (avctx->block_align != 96 * avctx->channels * frame_factor && |
| @@ -855,8 +855,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 25 unmodified lines | |||
| 855 | return AVERROR_INVALIDDATA; | 855 | return AVERROR_INVALIDDATA; |
| 856 | } | 856 | } |
| 857 | 857 | ||
| 858 | if (samples_per_frame != SAMPLES_PER_FRAME && | 858 | if (samples_per_frame != SAMPLES_PER_FRAME * avctx->channels) { |
| 859 | samples_per_frame != SAMPLES_PER_FRAME * 2) { | ||
| 860 | av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n", | 859 | av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n", |
| 861 | samples_per_frame); | 860 | samples_per_frame); |
| 862 | return AVERROR_INVALIDDATA; | 861 | return AVERROR_INVALIDDATA; |
| @@ -868,8 +867,8 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 5 unmodified lines | |||
| 868 | return AVERROR_INVALIDDATA; | 867 | return AVERROR_INVALIDDATA; |
| 869 | } | 868 | } |
| 870 | 869 | ||
| 871 | if (q->coding_mode == STEREO) | 870 | if (q->coding_mode == SINGLE) |
| 872 | av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n"); | 871 | av_log(avctx, AV_LOG_DEBUG, "Single channels detected.\n"); |
| 873 | else if (q->coding_mode == JOINT_STEREO) { | 872 | else if (q->coding_mode == JOINT_STEREO) { |
| 874 | if (avctx->channels != 2) { | 873 | if (avctx->channels != 2) { |
| 875 | av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n"); | 874 | av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n"); |