mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
fixed, strengthened, rewrote, and renamed a variety of the ADPCM decoders
(including MS, DK4 and DK3 ADPCM) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4855 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
3605aa4ec8
commit
ba4694f4bb
251
adpcm.c
251
adpcm.c
@ -12,6 +12,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "bswap.h"
|
#include "bswap.h"
|
||||||
#include "adpcm.h"
|
#include "adpcm.h"
|
||||||
|
#include "mp_msg.h"
|
||||||
|
|
||||||
#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
|
#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
|
||||||
#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
|
#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
|
||||||
@ -196,11 +197,19 @@ int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
|||||||
int predictor;
|
int predictor;
|
||||||
|
|
||||||
// fetch the header information, in stereo if both channels are present
|
// fetch the header information, in stereo if both channels are present
|
||||||
|
if (input[stream_ptr] > 6)
|
||||||
|
mp_msg(MSGT_DECAUDIO, MSGL_WARN,
|
||||||
|
"MS ADPCM: coefficient (%d) out of range (should be [0..6])\n",
|
||||||
|
input[stream_ptr]);
|
||||||
coeff1[0] = ms_adapt_coeff1[input[stream_ptr]];
|
coeff1[0] = ms_adapt_coeff1[input[stream_ptr]];
|
||||||
coeff2[0] = ms_adapt_coeff2[input[stream_ptr]];
|
coeff2[0] = ms_adapt_coeff2[input[stream_ptr]];
|
||||||
stream_ptr++;
|
stream_ptr++;
|
||||||
if (channels == 2)
|
if (channels == 2)
|
||||||
{
|
{
|
||||||
|
if (input[stream_ptr] > 6)
|
||||||
|
mp_msg(MSGT_DECAUDIO, MSGL_WARN,
|
||||||
|
"MS ADPCM: coefficient (%d) out of range (should be [0..6])\n",
|
||||||
|
input[stream_ptr]);
|
||||||
coeff1[1] = ms_adapt_coeff1[input[stream_ptr]];
|
coeff1[1] = ms_adapt_coeff1[input[stream_ptr]];
|
||||||
coeff2[1] = ms_adapt_coeff2[input[stream_ptr]];
|
coeff2[1] = ms_adapt_coeff2[input[stream_ptr]];
|
||||||
stream_ptr++;
|
stream_ptr++;
|
||||||
@ -267,49 +276,71 @@ int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
|||||||
return (block_size - (MS_ADPCM_PREAMBLE_SIZE * channels)) * 2;
|
return (block_size - (MS_ADPCM_PREAMBLE_SIZE * channels)) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// note: This decoder assumes the format 0x61 data always comes in
|
int dk4_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
||||||
// mono flavor
|
int channels, int block_size)
|
||||||
int fox61_adpcm_decode_block(unsigned short *output, unsigned char *input)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int predictor;
|
int output_ptr;
|
||||||
int index;
|
int predictor_l = 0;
|
||||||
|
int predictor_r = 0;
|
||||||
|
int index_l = 0;
|
||||||
|
int index_r = 0;
|
||||||
|
|
||||||
// the first predictor value goes straight to the output
|
// the first predictor value goes straight to the output
|
||||||
predictor = output[0] = LE_16(&input[0]);
|
predictor_l = output[0] = LE_16(&input[0]);
|
||||||
SE_16BIT(predictor);
|
SE_16BIT(predictor_l);
|
||||||
index = input[2];
|
index_l = input[2];
|
||||||
|
if (channels == 2)
|
||||||
// unpack the nibbles
|
|
||||||
for (i = 4; i < FOX61_ADPCM_BLOCK_SIZE; i++)
|
|
||||||
{
|
{
|
||||||
output[1 + (i - 4) * 2 + 0] = (input[i] >> 4) & 0x0F;
|
predictor_r = output[1] = LE_16(&input[4]);
|
||||||
output[1 + (i - 4) * 2 + 1] = input[i] & 0x0F;
|
SE_16BIT(predictor_r);
|
||||||
|
index_r = input[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
decode_nibbles(&output[1], FOX61_ADPCM_SAMPLES_PER_BLOCK - 1, 1,
|
output_ptr = channels;
|
||||||
predictor, index,
|
for (i = DK4_ADPCM_PREAMBLE_SIZE * channels; i < block_size; i++)
|
||||||
0, 0);
|
{
|
||||||
|
output[output_ptr++] = input[i] >> 4;
|
||||||
|
output[output_ptr++] = input[i] & 0x0F;
|
||||||
|
}
|
||||||
|
|
||||||
return FOX61_ADPCM_SAMPLES_PER_BLOCK;
|
decode_nibbles(&output[channels],
|
||||||
|
(block_size - DK4_ADPCM_PREAMBLE_SIZE * channels) * 2 - channels,
|
||||||
|
channels,
|
||||||
|
predictor_l, index_l,
|
||||||
|
predictor_r, index_r);
|
||||||
|
|
||||||
|
return (block_size - DK4_ADPCM_PREAMBLE_SIZE * channels) * 2 - channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DK3_GET_NEXT_NIBBLE() \
|
||||||
|
if (decode_top_nibble_next) \
|
||||||
|
{ \
|
||||||
|
nibble = (last_byte >> 4) & 0x0F; \
|
||||||
|
decode_top_nibble_next = 0; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
last_byte = input[in_ptr++]; \
|
||||||
|
nibble = last_byte & 0x0F; \
|
||||||
|
decode_top_nibble_next = 1; \
|
||||||
|
}
|
||||||
|
|
||||||
// note: This decoder assumes the format 0x62 data always comes in
|
// note: This decoder assumes the format 0x62 data always comes in
|
||||||
// stereo flavor
|
// stereo flavor
|
||||||
int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input)
|
int dk3_adpcm_decode_block(unsigned short *output, unsigned char *input)
|
||||||
{
|
{
|
||||||
int pred1;
|
int sum_pred;
|
||||||
int pred2;
|
int diff_pred;
|
||||||
int index1;
|
int sum_index;
|
||||||
int index2;
|
int diff_index;
|
||||||
|
int diff_channel;
|
||||||
int in_ptr = 0x10;
|
int in_ptr = 0x10;
|
||||||
int out_ptr = 0;
|
int out_ptr = 0;
|
||||||
|
|
||||||
int flag1 = 0;
|
|
||||||
int flag2 = 1;
|
|
||||||
int sum;
|
|
||||||
unsigned char last_byte = 0;
|
unsigned char last_byte = 0;
|
||||||
unsigned char nibble;
|
unsigned char nibble;
|
||||||
|
int decode_top_nibble_next = 0;
|
||||||
|
|
||||||
// ADPCM work variables
|
// ADPCM work variables
|
||||||
int sign;
|
int sign;
|
||||||
@ -317,137 +348,93 @@ int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input)
|
|||||||
int step;
|
int step;
|
||||||
int diff;
|
int diff;
|
||||||
|
|
||||||
pred1 = LE_16(&input[10]);
|
sum_pred = LE_16(&input[10]);
|
||||||
pred2 = LE_16(&input[12]);
|
diff_pred = LE_16(&input[12]);
|
||||||
SE_16BIT(pred1);
|
SE_16BIT(sum_pred);
|
||||||
SE_16BIT(pred2);
|
SE_16BIT(diff_pred);
|
||||||
sum = pred2;
|
diff_channel = diff_pred;
|
||||||
index1 = input[14];
|
sum_index = input[14];
|
||||||
index2 = input[15];
|
diff_index = input[15];
|
||||||
|
|
||||||
while (in_ptr < 2048)
|
while (in_ptr < 2048)
|
||||||
{
|
{
|
||||||
if (flag2)
|
// process the first predictor of the sum channel
|
||||||
{
|
DK3_GET_NEXT_NIBBLE();
|
||||||
last_byte = input[in_ptr++];
|
|
||||||
nibble = last_byte & 0x0F;
|
|
||||||
|
|
||||||
step = adpcm_step[index1];
|
step = adpcm_step[sum_index];
|
||||||
|
|
||||||
sign = nibble & 8;
|
sign = nibble & 8;
|
||||||
delta = nibble & 7;
|
delta = nibble & 7;
|
||||||
|
|
||||||
diff = step >> 3;
|
diff = step >> 3;
|
||||||
if (delta & 4) diff += step;
|
if (delta & 4) diff += step;
|
||||||
if (delta & 2) diff += step >> 1;
|
if (delta & 2) diff += step >> 1;
|
||||||
if (delta & 1) diff += step >> 2;
|
if (delta & 1) diff += step >> 2;
|
||||||
|
|
||||||
if (sign)
|
if (sign)
|
||||||
pred1 -= diff;
|
sum_pred -= diff;
|
||||||
else
|
|
||||||
pred1 += diff;
|
|
||||||
|
|
||||||
CLAMP_S16(pred1);
|
|
||||||
|
|
||||||
index1 += adpcm_index[nibble];
|
|
||||||
CLAMP_0_TO_88(index1);
|
|
||||||
|
|
||||||
if (flag1)
|
|
||||||
flag2 = 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nibble = (last_byte >> 4) & 0x0F;
|
|
||||||
|
|
||||||
step = adpcm_step[index2];
|
|
||||||
|
|
||||||
sign = nibble & 8;
|
|
||||||
delta = nibble & 7;
|
|
||||||
|
|
||||||
diff = step >> 3;
|
|
||||||
if (delta & 4) diff += step;
|
|
||||||
if (delta & 2) diff += step >> 1;
|
|
||||||
if (delta & 1) diff += step >> 2;
|
|
||||||
|
|
||||||
if (sign)
|
|
||||||
pred2 -= diff;
|
|
||||||
else
|
|
||||||
pred2 += diff;
|
|
||||||
|
|
||||||
CLAMP_S16(pred2);
|
|
||||||
|
|
||||||
index2 += adpcm_index[nibble];
|
|
||||||
CLAMP_0_TO_88(index2);
|
|
||||||
|
|
||||||
sum = (sum + pred2) / 2;
|
|
||||||
}
|
|
||||||
output[out_ptr++] = pred1 + sum;
|
|
||||||
output[out_ptr++] = pred1 - sum;
|
|
||||||
|
|
||||||
flag1 ^= 1;
|
|
||||||
if (in_ptr >= 2048)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
sum_pred += diff;
|
||||||
nibble = (last_byte >> 4) & 0x0F;
|
|
||||||
|
|
||||||
step = adpcm_step[index1];
|
CLAMP_S16(sum_pred);
|
||||||
|
|
||||||
sign = nibble & 8;
|
sum_index += adpcm_index[nibble];
|
||||||
delta = nibble & 7;
|
CLAMP_0_TO_88(sum_index);
|
||||||
|
|
||||||
|
// process the diff channel predictor
|
||||||
|
DK3_GET_NEXT_NIBBLE();
|
||||||
|
|
||||||
diff = step >> 3;
|
step = adpcm_step[diff_index];
|
||||||
if (delta & 4) diff += step;
|
|
||||||
if (delta & 2) diff += step >> 1;
|
|
||||||
if (delta & 1) diff += step >> 2;
|
|
||||||
|
|
||||||
if (sign)
|
sign = nibble & 8;
|
||||||
pred1 -= diff;
|
delta = nibble & 7;
|
||||||
else
|
|
||||||
pred1 += diff;
|
|
||||||
|
|
||||||
CLAMP_S16(pred1);
|
diff = step >> 3;
|
||||||
|
if (delta & 4) diff += step;
|
||||||
|
if (delta & 2) diff += step >> 1;
|
||||||
|
if (delta & 1) diff += step >> 2;
|
||||||
|
|
||||||
index1 += adpcm_index[nibble];
|
if (sign)
|
||||||
CLAMP_0_TO_88(index1);
|
diff_pred -= diff;
|
||||||
|
else
|
||||||
|
diff_pred += diff;
|
||||||
|
|
||||||
if (flag1)
|
CLAMP_S16(diff_pred);
|
||||||
flag2 = 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
last_byte = input[in_ptr++];
|
|
||||||
nibble = last_byte & 0x0F;
|
|
||||||
|
|
||||||
step = adpcm_step[index2];
|
diff_index += adpcm_index[nibble];
|
||||||
|
CLAMP_0_TO_88(diff_index);
|
||||||
|
|
||||||
sign = nibble & 8;
|
// output the first pair of stereo PCM samples
|
||||||
delta = nibble & 7;
|
diff_channel = (diff_channel + diff_pred) / 2;
|
||||||
|
output[out_ptr++] = sum_pred + diff_channel;
|
||||||
|
output[out_ptr++] = sum_pred - diff_channel;
|
||||||
|
|
||||||
diff = step >> 3;
|
// process the second predictor of the sum channel
|
||||||
if (delta & 4) diff += step;
|
DK3_GET_NEXT_NIBBLE();
|
||||||
if (delta & 2) diff += step >> 1;
|
|
||||||
if (delta & 1) diff += step >> 2;
|
|
||||||
|
|
||||||
if (sign)
|
step = adpcm_step[sum_index];
|
||||||
pred2 -= diff;
|
|
||||||
else
|
|
||||||
pred2 += diff;
|
|
||||||
|
|
||||||
CLAMP_S16(pred2);
|
sign = nibble & 8;
|
||||||
|
delta = nibble & 7;
|
||||||
|
|
||||||
index2 += adpcm_index[nibble];
|
diff = step >> 3;
|
||||||
CLAMP_0_TO_88(index2);
|
if (delta & 4) diff += step;
|
||||||
|
if (delta & 2) diff += step >> 1;
|
||||||
|
if (delta & 1) diff += step >> 2;
|
||||||
|
|
||||||
sum = (sum + pred2) / 2;
|
if (sign)
|
||||||
}
|
sum_pred -= diff;
|
||||||
|
else
|
||||||
|
sum_pred += diff;
|
||||||
|
|
||||||
output[out_ptr++] = pred1 + sum;
|
CLAMP_S16(sum_pred);
|
||||||
output[out_ptr++] = pred1 - sum;
|
|
||||||
|
|
||||||
flag1 ^= 1;
|
sum_index += adpcm_index[nibble];
|
||||||
if (in_ptr >= 2048)
|
CLAMP_0_TO_88(sum_index);
|
||||||
break;
|
|
||||||
}
|
// output the second pair of stereo PCM samples
|
||||||
|
output[out_ptr++] = sum_pred + diff_channel;
|
||||||
|
output[out_ptr++] = sum_pred - diff_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out_ptr;
|
return out_ptr;
|
||||||
|
19
adpcm.h
19
adpcm.h
@ -10,21 +10,22 @@
|
|||||||
#define MS_ADPCM_SAMPLES_PER_BLOCK \
|
#define MS_ADPCM_SAMPLES_PER_BLOCK \
|
||||||
((sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2)
|
((sh_audio->wf->nBlockAlign - MS_ADPCM_PREAMBLE_SIZE) * 2)
|
||||||
|
|
||||||
#define FOX61_ADPCM_PREAMBLE_SIZE 4
|
#define DK4_ADPCM_PREAMBLE_SIZE 4
|
||||||
#define FOX61_ADPCM_BLOCK_SIZE 0x200
|
#define DK4_ADPCM_SAMPLES_PER_BLOCK \
|
||||||
#define FOX61_ADPCM_SAMPLES_PER_BLOCK \
|
(((sh_audio->wf->nBlockAlign - DK4_ADPCM_PREAMBLE_SIZE) * 2) + 1)
|
||||||
(((FOX61_ADPCM_BLOCK_SIZE - FOX61_ADPCM_PREAMBLE_SIZE) * 2) + 1)
|
|
||||||
|
|
||||||
// pretend there's such a thing as mono for this format
|
// pretend there's such a thing as mono for this format
|
||||||
#define FOX62_ADPCM_PREAMBLE_SIZE 8
|
#define DK3_ADPCM_PREAMBLE_SIZE 8
|
||||||
#define FOX62_ADPCM_BLOCK_SIZE 0x400
|
#define DK3_ADPCM_BLOCK_SIZE 0x400
|
||||||
// this isn't exact
|
// this isn't exact
|
||||||
#define FOX62_ADPCM_SAMPLES_PER_BLOCK 6000
|
#define DK3_ADPCM_SAMPLES_PER_BLOCK 6000
|
||||||
|
|
||||||
int ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
int ima_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
||||||
int channels);
|
int channels);
|
||||||
int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
int ms_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
||||||
int channels, int block_size);
|
int channels, int block_size);
|
||||||
int fox61_adpcm_decode_block(unsigned short *output, unsigned char *input);
|
int dk4_adpcm_decode_block(unsigned short *output, unsigned char *input,
|
||||||
int fox62_adpcm_decode_block(unsigned short *output, unsigned char *input);
|
int channels, int block_size);
|
||||||
|
int dk3_adpcm_decode_block(unsigned short *output, unsigned char *input);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -224,8 +224,8 @@ static short get_driver(char *s,int audioflag)
|
|||||||
"liba52",
|
"liba52",
|
||||||
"g72x",
|
"g72x",
|
||||||
"imaadpcm",
|
"imaadpcm",
|
||||||
"fox61adpcm",
|
"dk4adpcm",
|
||||||
"fox62adpcm",
|
"dk3adpcm",
|
||||||
"roqaudio",
|
"roqaudio",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
#define AFM_A52 14
|
#define AFM_A52 14
|
||||||
#define AFM_G72X 15
|
#define AFM_G72X 15
|
||||||
#define AFM_IMAADPCM 16
|
#define AFM_IMAADPCM 16
|
||||||
#define AFM_FOX61ADPCM 17
|
#define AFM_DK4ADPCM 17
|
||||||
#define AFM_FOX62ADPCM 18
|
#define AFM_DK3ADPCM 18
|
||||||
#define AFM_ROQAUDIO 19
|
#define AFM_ROQAUDIO 19
|
||||||
|
|
||||||
#define VFM_MPEG 1
|
#define VFM_MPEG 1
|
||||||
|
55
dec_audio.c
55
dec_audio.c
@ -425,21 +425,21 @@ case AFM_MSADPCM:
|
|||||||
sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK;
|
sh_audio->ds->ss_div = MS_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
|
sh_audio->ds->ss_mul = sh_audio->wf->nBlockAlign;
|
||||||
break;
|
break;
|
||||||
case AFM_FOX61ADPCM:
|
case AFM_DK4ADPCM:
|
||||||
sh_audio->audio_out_minsize=FOX61_ADPCM_SAMPLES_PER_BLOCK * 4;
|
sh_audio->audio_out_minsize=DK4_ADPCM_SAMPLES_PER_BLOCK * 4;
|
||||||
sh_audio->ds->ss_div=FOX61_ADPCM_SAMPLES_PER_BLOCK;
|
sh_audio->ds->ss_div=DK4_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
sh_audio->ds->ss_mul=FOX61_ADPCM_BLOCK_SIZE;
|
sh_audio->ds->ss_mul=sh_audio->wf->nBlockAlign;
|
||||||
break;
|
break;
|
||||||
case AFM_FOX62ADPCM:
|
case AFM_DK3ADPCM:
|
||||||
sh_audio->audio_out_minsize=FOX62_ADPCM_SAMPLES_PER_BLOCK * 4;
|
sh_audio->audio_out_minsize=DK3_ADPCM_SAMPLES_PER_BLOCK * 4;
|
||||||
sh_audio->ds->ss_div=FOX62_ADPCM_SAMPLES_PER_BLOCK;
|
sh_audio->ds->ss_div=DK3_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
sh_audio->ds->ss_mul=FOX62_ADPCM_BLOCK_SIZE;
|
sh_audio->ds->ss_mul=DK3_ADPCM_BLOCK_SIZE;
|
||||||
break;
|
break;
|
||||||
case AFM_ROQAUDIO:
|
case AFM_ROQAUDIO:
|
||||||
// minsize was stored in wf->nBlockAlign by the RoQ demuxer
|
// minsize was stored in wf->nBlockAlign by the RoQ demuxer
|
||||||
sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign;
|
sh_audio->audio_out_minsize=sh_audio->wf->nBlockAlign;
|
||||||
sh_audio->ds->ss_div=FOX62_ADPCM_SAMPLES_PER_BLOCK;
|
sh_audio->ds->ss_div=DK3_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
sh_audio->ds->ss_mul=FOX62_ADPCM_BLOCK_SIZE;
|
sh_audio->ds->ss_mul=DK3_ADPCM_BLOCK_SIZE;
|
||||||
sh_audio->context = roq_decode_audio_init();
|
sh_audio->context = roq_decode_audio_init();
|
||||||
break;
|
break;
|
||||||
case AFM_MPEG:
|
case AFM_MPEG:
|
||||||
@ -724,17 +724,17 @@ case AFM_MSADPCM:
|
|||||||
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
|
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
|
||||||
(sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK;
|
(sh_audio->channels*sh_audio->samplerate) / MS_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
break;
|
break;
|
||||||
case AFM_FOX61ADPCM:
|
case AFM_DK4ADPCM:
|
||||||
sh_audio->channels=sh_audio->wf->nChannels;
|
sh_audio->channels=sh_audio->wf->nChannels;
|
||||||
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
|
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
|
||||||
sh_audio->i_bps=FOX61_ADPCM_BLOCK_SIZE*
|
sh_audio->i_bps = sh_audio->wf->nBlockAlign *
|
||||||
(sh_audio->channels*sh_audio->samplerate) / FOX61_ADPCM_SAMPLES_PER_BLOCK;
|
(sh_audio->channels*sh_audio->samplerate) / DK4_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
break;
|
break;
|
||||||
case AFM_FOX62ADPCM:
|
case AFM_DK3ADPCM:
|
||||||
sh_audio->channels=sh_audio->wf->nChannels;
|
sh_audio->channels=sh_audio->wf->nChannels;
|
||||||
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
|
sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
|
||||||
sh_audio->i_bps=FOX62_ADPCM_BLOCK_SIZE*
|
sh_audio->i_bps=DK3_ADPCM_BLOCK_SIZE*
|
||||||
(sh_audio->channels*sh_audio->samplerate) / FOX62_ADPCM_SAMPLES_PER_BLOCK;
|
(sh_audio->channels*sh_audio->samplerate) / DK3_ADPCM_SAMPLES_PER_BLOCK;
|
||||||
break;
|
break;
|
||||||
case AFM_ROQAUDIO:
|
case AFM_ROQAUDIO:
|
||||||
sh_audio->channels=sh_audio->wf->nChannels;
|
sh_audio->channels=sh_audio->wf->nChannels;
|
||||||
@ -1163,21 +1163,24 @@ int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen){
|
|||||||
sh_audio->wf->nBlockAlign);
|
sh_audio->wf->nBlockAlign);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AFM_FOX61ADPCM:
|
case AFM_DK4ADPCM:
|
||||||
{ unsigned char ibuf[FOX61_ADPCM_BLOCK_SIZE]; // bytes / stereo frame
|
{ static unsigned char *ibuf = NULL;
|
||||||
if (demux_read_data(sh_audio->ds, ibuf, FOX61_ADPCM_BLOCK_SIZE) !=
|
if (!ibuf)
|
||||||
FOX61_ADPCM_BLOCK_SIZE)
|
ibuf = (unsigned char *)malloc(sh_audio->wf->nBlockAlign);
|
||||||
|
if (demux_read_data(sh_audio->ds, ibuf, sh_audio->wf->nBlockAlign) !=
|
||||||
|
sh_audio->wf->nBlockAlign)
|
||||||
break; // EOF
|
break; // EOF
|
||||||
len=2*fox61_adpcm_decode_block((unsigned short*)buf,ibuf);
|
len=2*dk4_adpcm_decode_block((unsigned short*)buf,ibuf,
|
||||||
|
sh_audio->wf->nChannels, sh_audio->wf->nBlockAlign);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AFM_FOX62ADPCM:
|
case AFM_DK3ADPCM:
|
||||||
{ unsigned char ibuf[FOX62_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame
|
{ unsigned char ibuf[DK3_ADPCM_BLOCK_SIZE * 2]; // bytes / stereo frame
|
||||||
if (demux_read_data(sh_audio->ds, ibuf,
|
if (demux_read_data(sh_audio->ds, ibuf,
|
||||||
FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) !=
|
DK3_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels) !=
|
||||||
FOX62_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels)
|
DK3_ADPCM_BLOCK_SIZE * sh_audio->wf->nChannels)
|
||||||
break; // EOF
|
break; // EOF
|
||||||
len = 2 * fox62_adpcm_decode_block(
|
len = 2 * dk3_adpcm_decode_block(
|
||||||
(unsigned short*)buf,ibuf);
|
(unsigned short*)buf,ibuf);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -384,19 +384,19 @@ audiocodec msadpcm
|
|||||||
format 0x2
|
format 0x2
|
||||||
driver msadpcm
|
driver msadpcm
|
||||||
|
|
||||||
audiocodec fox61adpcm
|
audiocodec dk4adpcm
|
||||||
info "Duck DK4 ADPCM (rogue format number)"
|
info "Duck DK4 ADPCM (rogue format number)"
|
||||||
status working
|
status working
|
||||||
comment "This format number was used by Duck Corp. but not officially registered with Microsoft"
|
comment "This format number was used by Duck Corp. but not officially registered with Microsoft"
|
||||||
format 0x61
|
format 0x61
|
||||||
driver fox61adpcm
|
driver dk4adpcm
|
||||||
|
|
||||||
audiocodec fox62adpcm
|
audiocodec dk3adpcm
|
||||||
info "Duck DK3 ADPCM (rogue format number)"
|
info "Duck DK3 ADPCM (rogue format number)"
|
||||||
status working
|
status working
|
||||||
comment "This format number was used by Duck Corp. but not officially registered with Microsoft"
|
comment "This format number was used by Duck Corp. but not officially registered with Microsoft"
|
||||||
format 0x62
|
format 0x62
|
||||||
driver fox62adpcm
|
driver dk3adpcm
|
||||||
|
|
||||||
audiocodec roqaudio
|
audiocodec roqaudio
|
||||||
info "Id RoQ File Audio Decoder"
|
info "Id RoQ File Audio Decoder"
|
||||||
|
Loading…
Reference in New Issue
Block a user