Commit 25866680 authored by Adriano Pallavicino's avatar Adriano Pallavicino Committed by Josh de Kock

lavc/qdm2: increase code clarity

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
Signed-off-by: 's avatarJosh de Kock <josh@itanimul.li>
parent 7e9e1b70
...@@ -537,7 +537,7 @@ static void fill_coding_method_array(sb_int8_array tone_level_idx, ...@@ -537,7 +537,7 @@ static void fill_coding_method_array(sb_int8_array tone_level_idx,
/* This case is untested, no samples available */ /* This case is untested, no samples available */
avpriv_request_sample(NULL, "!superblocktype_2_3"); avpriv_request_sample(NULL, "!superblocktype_2_3");
return; return;
for (ch = 0; ch < nb_channels; ch++) for (ch = 0; ch < nb_channels; ch++) {
for (sb = 0; sb < 30; sb++) { for (sb = 0; sb < 30; sb++) {
for (j = 1; j < 63; j++) { // The loop only iterates to 63 so the code doesn't overflow the buffer 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; add1 = tone_level_idx[ch][sb][j] - 10;
...@@ -566,67 +566,68 @@ static void fill_coding_method_array(sb_int8_array tone_level_idx, ...@@ -566,67 +566,68 @@ static void fill_coding_method_array(sb_int8_array tone_level_idx,
} }
tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1]; tone_level_idx_temp[ch][sb][0] = tone_level_idx_temp[ch][sb][1];
} }
acc = 0; }
for (ch = 0; ch < nb_channels; ch++) acc = 0;
for (sb = 0; sb < 30; sb++) for (ch = 0; ch < nb_channels; ch++)
for (j = 0; j < 64; j++) for (sb = 0; sb < 30; sb++)
acc += tone_level_idx_temp[ch][sb][j]; for (j = 0; j < 64; j++)
acc += tone_level_idx_temp[ch][sb][j];
multres = 0x66666667LL * (acc * 10);
esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31); multres = 0x66666667LL * (acc * 10);
for (ch = 0; ch < nb_channels; ch++) esp_40 = (multres >> 32) / 8 + ((multres & 0xffffffff) >> 31);
for (sb = 0; sb < 30; sb++) for (ch = 0; ch < nb_channels; ch++)
for (j = 0; j < 64; j++) { for (sb = 0; sb < 30; sb++)
comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10; for (j = 0; j < 64; j++) {
if (comp < 0) comp = tone_level_idx_temp[ch][sb][j]* esp_40 * 10;
comp += 0xff; if (comp < 0)
comp /= 256; // signed shift comp += 0xff;
switch(sb) { comp /= 256; // signed shift
case 0: switch(sb) {
if (comp < 30) case 0:
comp = 30; if (comp < 30)
comp += 15; comp = 30;
break; comp += 15;
case 1: break;
if (comp < 24) case 1:
comp = 24; if (comp < 24)
comp += 10; comp = 24;
break; comp += 10;
case 2: break;
case 3: case 2:
case 4: case 3:
if (comp < 16) case 4:
comp = 16; if (comp < 16)
} comp = 16;
if (comp <= 5)
tmp = 0;
else if (comp <= 10)
tmp = 10;
else if (comp <= 16)
tmp = 16;
else if (comp <= 24)
tmp = -1;
else
tmp = 0;
coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
} }
if (comp <= 5)
tmp = 0;
else if (comp <= 10)
tmp = 10;
else if (comp <= 16)
tmp = 16;
else if (comp <= 24)
tmp = -1;
else
tmp = 0;
coding_method[ch][sb][j] = ((tmp & 0xfffa) + 30 )& 0xff;
}
for (sb = 0; sb < 30; sb++)
fix_coding_method_array(sb, nb_channels, coding_method);
for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) for (sb = 0; sb < 30; sb++)
fix_coding_method_array(sb, nb_channels, coding_method); for (j = 0; j < 64; j++)
for (ch = 0; ch < nb_channels; ch++) if (sb >= 10) {
for (sb = 0; sb < 30; sb++) if (coding_method[ch][sb][j] < 10)
for (j = 0; j < 64; j++) coding_method[ch][sb][j] = 10;
if (sb >= 10) { } else {
if (coding_method[ch][sb][j] < 10) if (sb >= 2) {
coding_method[ch][sb][j] = 10; if (coding_method[ch][sb][j] < 16)
coding_method[ch][sb][j] = 16;
} else { } else {
if (sb >= 2) { if (coding_method[ch][sb][j] < 30)
if (coding_method[ch][sb][j] < 16) coding_method[ch][sb][j] = 30;
coding_method[ch][sb][j] = 16;
} else {
if (coding_method[ch][sb][j] < 30)
coding_method[ch][sb][j] = 30;
}
} }
}
} else { // superblocktype_2_3 != 0 } else { // superblocktype_2_3 != 0
for (ch = 0; ch < nb_channels; ch++) for (ch = 0; ch < nb_channels; ch++)
for (sb = 0; sb < 30; sb++) for (sb = 0; sb < 30; sb++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment