History

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

bnnm committed 9 years ago

Commit cab0f3a1 parent 9a619be1 file · +8 −9Browse files

Unified · Split

libavcodec/atrac3.c+8−9
@@ -49,7 +49,7 @@ · 48 unmodified lines
4949 #include "atrac3data.h"
5050
5151 #define JOINT_STEREO 0x12
52−#define STEREO 0x2
52+#define SINGLE 0x2
5353
5454 #define SAMPLES_PER_FRAME 1024
5555 #define MDCT_SIZE 512
@@ -567,7 +567,7 @@ static void channel_weighting(float *su1, float *su2, int *p3) · 511 unmodified lines
567567 * @param snd the channel unit to be used
568568 * @param output the decoded samples before IQMF in float representation
569569 * @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)
571571 */
572572 static int decode_channel_sound_unit(ATRAC3Context *q, GetBitContext *gb,
573573 ChannelUnit *snd, float *output,
@@ -702,7 +702,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *databuf, · 128 unmodified lines
702702
703703 channel_weighting(out_samples[0], out_samples[1], q->weighting_delay);
704704 } else {
705− /* normal stereo mode or mono */
705+ /* single channels */
706706 /* Decode the channel sound units. */
707707 for (i = 0; i < avctx->channels; i++) {
708708 /* 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
797797 const uint8_t *edata_ptr = avctx->extradata;
798798 ATRAC3Context *q = avctx->priv_data;
799799
800− if (avctx->channels <= 0 || avctx->channels > 2) {
800+ if (avctx->channels <= 0 || avctx->channels > 6) {
801801 av_log(avctx, AV_LOG_ERROR, "Channel configuration error!\n");
802802 return AVERROR(EINVAL);
803803 }
@@ -823,7 +823,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 19 unmodified lines
823823 samples_per_frame = SAMPLES_PER_FRAME * avctx->channels;
824824 version = 4;
825825 delay = 0x88E;
826− q->coding_mode = q->coding_mode ? JOINT_STEREO : STEREO;
826+ q->coding_mode = q->coding_mode ? JOINT_STEREO : SINGLE;
827827 q->scrambled_stream = 0;
828828
829829 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
855855 return AVERROR_INVALIDDATA;
856856 }
857857
858− if (samples_per_frame != SAMPLES_PER_FRAME &&
859− samples_per_frame != SAMPLES_PER_FRAME * 2) {
858+ if (samples_per_frame != SAMPLES_PER_FRAME * avctx->channels) {
860859 av_log(avctx, AV_LOG_ERROR, "Unknown amount of samples per frame %d.\n",
861860 samples_per_frame);
862861 return AVERROR_INVALIDDATA;
@@ -868,8 +867,8 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) · 5 unmodified lines
868867 return AVERROR_INVALIDDATA;
869868 }
870869
871− if (q->coding_mode == STEREO)
872− av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n");
870+ if (q->coding_mode == SINGLE)
871+ av_log(avctx, AV_LOG_DEBUG, "Single channels detected.\n");
873872 else if (q->coding_mode == JOINT_STEREO) {
874873 if (avctx->channels != 2) {
875874 av_log(avctx, AV_LOG_ERROR, "Invalid coding mode\n");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t