* @param channels number of channels
* @param coding_method q->coding_method[0][0][0]
*/
-static void fix_coding_method_array(int sb, int channels,
- sb_int8_array coding_method)
+static int fix_coding_method_array(int sb, int channels,
+ sb_int8_array coding_method)
{
int j, k;
int ch;
for (ch = 0; ch < channels; ch++) {
for (j = 0; j < 64; ) {
+ if (coding_method[ch][sb][j] < 8)
+ return -1;
if ((coding_method[ch][sb][j] - 8) > 22) {
run = 1;
case_val = 8;
j += run;
}
}
+ return 0;
}
/**
int length, int sb_min, int sb_max)
{
int sb, j, k, n, ch, run, channels;
- int joined_stereo, zero_encoding, chs;
+ int joined_stereo, zero_encoding;
int type34_first;
float type34_div = 0;
float type34_predictor;
if (length == 0) {
// If no data use noise
for (sb=sb_min; sb < sb_max; sb++)
- build_sb_samples_from_noise (q, sb);
+ build_sb_samples_from_noise(q, sb);
return;
}
for (sb = sb_min; sb < sb_max; sb++) {
- FIX_NOISE_IDX(q->noise_idx);
-
channels = q->nb_channels;
if (q->nb_channels <= 1 || sb < 12)
else if (sb >= 24)
joined_stereo = 1;
else
- joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1 (gb) : 0;
+ joined_stereo = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0;
if (joined_stereo) {
if (get_bits_left(gb) >= 16)
for (j = 0; j < 16; j++)
- sign_bits[j] = get_bits1 (gb);
+ sign_bits[j] = get_bits1(gb);
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];
- fix_coding_method_array(sb, q->nb_channels, q->coding_method);
+ if (fix_coding_method_array(sb, q->nb_channels,
+ q->coding_method)) {
+ build_sb_samples_from_noise(q, sb);
+ continue;
+ }
channels = 1;
}
for (ch = 0; ch < channels; ch++) {
+ FIX_NOISE_IDX(q->noise_idx);
zero_encoding = (get_bits_left(gb) >= 1) ? get_bits1(gb) : 0;
type34_predictor = 0.0;
type34_first = 1;
}
if (joined_stereo) {
- float tmp[10][MPA_MAX_CHANNELS];
-
- for (k = 0; k < run; k++) {
- tmp[k][0] = samples[k];
- tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k];
+ for (k = 0; k < run && j + k < 128; k++) {
+ q->sb_samples[0][j + k][sb] =
+ q->tone_level[0][sb][(j + k) / 2] * samples[k];
+ if (q->nb_channels == 2) {
+ if (sign_bits[(j + k) / 8])
+ q->sb_samples[1][j + k][sb] =
+ q->tone_level[1][sb][(j + k) / 2] * -samples[k];
+ else
+ q->sb_samples[1][j + k][sb] =
+ q->tone_level[1][sb][(j + k) / 2] * samples[k];
+ }
}
- for (chs = 0; chs < q->nb_channels; chs++)
- for (k = 0; k < run; k++)
- if ((j + k) < 128)
- q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs];
} else {
for (k = 0; k < run; k++)
if ((j + k) < 128)
* @param q context
* @param gb bitreader context
*/
-static void init_tone_level_dequantization (QDM2Context *q, GetBitContext *gb)
+static void init_tone_level_dequantization(QDM2Context *q, GetBitContext *gb)
{
int sb, j, k, n, ch;
AVCodec ff_qdm2_decoder = {
.name = "qdm2",
+ .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
.type = AVMEDIA_TYPE_AUDIO,
.id = AV_CODEC_ID_QDM2,
.priv_data_size = sizeof(QDM2Context),
.close = qdm2_decode_close,
.decode = qdm2_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
};