/* for floating point to fixed point conversion */
-static float f2i_scale = (float) (1 << (FRAC_BITS - 15));
+static const float f2i_scale = (float) (1 << (FRAC_BITS - 15));
static int qdm2_get_vlc (GetBitContext *gb, VLC *vlc, int flag, int depth)
SAMPLES_NEEDED
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) {
- for (j = 1; j < 64; j++) {
+ for (j = 1; j < 63; j++) { // The loop only iterates to 63 so the code doesn't overflow the buffer
add1 = tone_level_idx[ch][sb][j] - 10;
if (add1 < 0)
add1 = 0;
/* process subpackets ordered by type, largest type first */
for (i = 0, max = 256; i < q->sub_packets_B; i++) {
- QDM2SubPacket *packet;
+ QDM2SubPacket *packet= NULL;
/* find subpacket with largest type less than max */
- for (j = 0, min = 0, packet = NULL; j < q->sub_packets_B; j++) {
+ for (j = 0, min = 0; j < q->sub_packets_B; j++) {
value = q->sub_packet_list_B[j].packet->type;
if (value > min && value < max) {
min = value;
max = min;
/* check for errors (?) */
+ if (!packet)
+ return;
+
if (i == 0 && (packet->type < 16 || packet->type >= 48 || fft_subpackets[packet->type - 16]))
return;
qdm2_init(s);
+ avctx->sample_fmt = SAMPLE_FMT_S16;
+
// dump_context(s);
return 0;
}
.init = qdm2_decode_init,
.close = qdm2_decode_close,
.decode = qdm2_decode_frame,
- .long_name = "QDesign Music Codec 2",
+ .long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),
};