static QDM2SubPNode *qdm2_search_subpacket_type_in_list(QDM2SubPNode *list,
int type)
{
- while (list != NULL && list->packet != NULL) {
+ while (list && list->packet) {
if (list->packet->type == type)
return list;
list = list->next;
* @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;
}
/**
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;
}
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;
}
* @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;
QDM2SubPNode *nodes[4];
nodes[0] = qdm2_search_subpacket_type_in_list(list, 9);
- if (nodes[0] != NULL)
+ if (nodes[0])
process_subpacket_9(q, nodes[0]);
nodes[1] = qdm2_search_subpacket_type_in_list(list, 10);
- if (nodes[1] != NULL)
+ if (nodes[1])
process_subpacket_10(q, nodes[1]);
else
process_subpacket_10(q, NULL);
nodes[2] = qdm2_search_subpacket_type_in_list(list, 11);
- if (nodes[0] != NULL && nodes[1] != NULL && nodes[2] != NULL)
+ if (nodes[0] && nodes[1] && nodes[2])
process_subpacket_11(q, nodes[2]);
else
process_subpacket_11(q, NULL);
nodes[3] = qdm2_search_subpacket_type_in_list(list, 12);
- if (nodes[0] != NULL && nodes[1] != NULL && nodes[3] != NULL)
+ if (nodes[0] && nodes[1] && nodes[3])
process_subpacket_12(q, nodes[3]);
else
process_subpacket_12(q, NULL);
}
} // Packet bytes loop
- if (q->sub_packet_list_D[0].packet != NULL) {
+ if (q->sub_packet_list_D[0].packet) {
process_synthesis_subpackets(q, q->sub_packet_list_D);
q->do_synth_filter = 1;
} else if (q->do_synth_filter) {
int i, j, min, max, value, type, unknown_flag;
GetBitContext gb;
- if (q->sub_packet_list_B[0].packet == NULL)
+ if (!q->sub_packet_list_B[0].packet)
return;
/* reset minimum indexes for FFT coefficients */
for (ch = 0; ch < q->channels; ch++) {
qdm2_calculate_fft(q, ch, q->sub_packet);
- if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
+ if (!q->has_errors && q->sub_packet_list_C[0].packet) {
SAMPLES_NEEDED_2("has errors, and C list is not empty")
return -1;
}
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"),
};