#include <stdio.h>
#define BITSTREAM_READER_LE
+#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"
int tmp;
if (value >= 60) {
- av_log(0, AV_LOG_ERROR, "value %d in qdm2_get_vlc too large\n", value);
+ av_log(NULL, AV_LOG_ERROR, "value %d in qdm2_get_vlc too large\n", value);
return 0;
}
int i, sb, ch, sb_used;
int tmp, tab;
- // This should never happen
- if (q->nb_channels <= 0)
- return;
-
for (ch = 0; ch < q->nb_channels; ch++)
for (sb = 0; sb < 30; sb++)
for (i = 0; i < 8; i++) {
int add1, add2, add3, add4;
int64_t multres;
- // This should never happen
- if (nb_channels <= 0)
- return;
-
if (!superblocktype_2_3) {
/* This case is untested, no samples available */
SAMPLES_NEEDED
for (j = 0; j < 16; j++)
sign_bits[j] = get_bits1 (gb);
+ if (q->coding_method[0][sb][0] <= 0) {
+ av_log(NULL, AV_LOG_ERROR, "coding method invalid\n");
+ return AVERROR_INVALIDDATA;
+ }
+
for (j = 0; j < 64; j++)
if (q->coding_method[1][sb][j] > q->coding_method[0][sb][j])
q->coding_method[0][sb][j] = q->coding_method[1][sb][j];
synthfilt_build_sb_samples(q, &gb, length, 8, QDM2_SB_USED(q->sub_sampling));
}
-/*
+/**
* Process new subpackets for synthesis filter
*
* @param q context
}
-/*
+/**
* Decode superblock, fill packet lists.
*
* @param q context
while ((n = qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) {
if (get_bits_left(gb)<0) {
if(local_int_4 < q->group_size)
- av_log(0, AV_LOG_ERROR, "overread in qdm2_fft_decode_tones()\n");
+ av_log(NULL, AV_LOG_ERROR, "overread in qdm2_fft_decode_tones()\n");
return;
}
offset = 1;
avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata);
extradata += 4;
- if (s->channels > MPA_MAX_CHANNELS) {
- av_log(avctx, AV_LOG_ERROR, "Too many channels\n");
+ if (s->channels <= 0 || s->channels > MPA_MAX_CHANNELS) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid number of channels\n");
return AVERROR_INVALIDDATA;
}
+ avctx->channel_layout = avctx->channels == 2 ? AV_CH_LAYOUT_STEREO :
+ AV_CH_LAYOUT_MONO;
avctx->sample_rate = AV_RB32(extradata);
extradata += 4;