Commit e2dedee8 authored by Laurent Aimar's avatar Laurent Aimar

* adpcm: added DUCK 4 variant support. (thx M. Melanson who provided me

somes samples.)
parent 25c8c4c9
......@@ -2,7 +2,7 @@
* adpcm.c : adpcm variant audio decoder
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: adpcm.c,v 1.6 2003/01/13 17:39:05 fenrir Exp $
* $Id: adpcm.c,v 1.7 2003/02/16 09:50:22 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -41,6 +41,8 @@
#define ADPCM_IMA_QT 1
#define ADPCM_IMA_WAV 2
#define ADPCM_MS 3
#define ADPCM_DK3 4
#define ADPCM_DK4 4
typedef struct adec_thread_s
{
......@@ -78,6 +80,7 @@ static void EndThread ( adec_thread_t * );
static void DecodeAdpcmMs( adec_thread_t *, aout_buffer_t * );
static void DecodeAdpcmImaWav( adec_thread_t *, aout_buffer_t * );
static void DecodeAdpcmDk4( adec_thread_t *, aout_buffer_t * );
/*****************************************************************************
* Module descriptor
......@@ -153,7 +156,7 @@ static int OpenDecoder( vlc_object_t *p_this )
// case VLC_FOURCC('i','m','a', '4'): /* IMA ADPCM */
case VLC_FOURCC('m','s',0x00,0x02): /* MS ADPCM */
case VLC_FOURCC('m','s',0x00,0x11): /* IMA ADPCM */
// case VLC_FOURCC('m','s',0x00,0x61): /* Duck DK4 ADPCM */
case VLC_FOURCC('m','s',0x00,0x61): /* Duck DK4 ADPCM */
// case VLC_FOURCC('m','s',0x00,0x62): /* Duck DK3 ADPCM */
p_fifo->pf_run = RunDecoder;
......@@ -242,8 +245,10 @@ static int InitThread( adec_thread_t * p_adec )
p_adec->i_codec = ADPCM_MS;
break;
case VLC_FOURCC('m','s',0x00,0x61): /* Duck DK4 ADPCM */
p_adec->i_codec = ADPCM_DK4;
break;
case VLC_FOURCC('m','s',0x00,0x62): /* Duck DK3 ADPCM */
p_adec->i_codec = 0;
p_adec->i_codec = ADPCM_DK3;
break;
}
......@@ -285,6 +290,11 @@ static int InitThread( adec_thread_t * p_adec )
2 * ( p_adec->i_block - 7 * p_adec->p_wf->nChannels ) /
p_adec->p_wf->nChannels + 2;
break;
case ADPCM_DK4:
p_adec->i_samplesperblock =
2 * ( p_adec->i_block - 4 * p_adec->p_wf->nChannels ) /
p_adec->p_wf->nChannels + 1;
break;
default:
p_adec->i_samplesperblock = 0;
}
......@@ -442,6 +452,8 @@ static void DecodeThread( adec_thread_t *p_adec )
case ADPCM_MS:
DecodeAdpcmMs( p_adec, p_aout_buffer );
break;
case ADPCM_DK4:
DecodeAdpcmDk4( p_adec, p_aout_buffer );
default:
break;
}
......@@ -480,6 +492,9 @@ static void EndThread (adec_thread_t *p_adec)
(v) |= ( *p_buffer ) << 8; p_buffer++; \
if( (v)&0x8000 ) (v) -= 0x010000;
/*
* MS
*/
typedef struct adpcm_ms_channel_s
{
int i_idelta;
......@@ -588,6 +603,9 @@ static void DecodeAdpcmMs( adec_thread_t *p_adec,
}
/*
* IMA-WAV
*/
typedef struct adpcm_ima_wav_channel_s
{
int i_predictor;
......@@ -689,6 +707,53 @@ static void DecodeAdpcmImaWav( adec_thread_t *p_adec,
}
}
/*
* Dk4
*/
static void DecodeAdpcmDk4( adec_thread_t *p_adec,
aout_buffer_t *p_aout_buffer)
{
uint8_t *p_buffer;
adpcm_ima_wav_channel_t channel[2];
int i_nibbles;
uint16_t *p_sample;
int b_stereo;
p_buffer = p_adec->p_block;
b_stereo = p_adec->p_wf->nChannels == 2 ? 1 : 0;
GetWord( channel[0].i_predictor );
GetByte( channel[0].i_step_index );
CLAMP( channel[0].i_step_index, 0, 88 );
p_buffer++;
if( b_stereo )
{
GetWord( channel[1].i_predictor );
GetByte( channel[1].i_step_index );
CLAMP( channel[1].i_step_index, 0, 88 );
p_buffer++;
}
p_sample = (int16_t*)p_aout_buffer->p_buffer;
/* first output predictor */
*p_sample++ = channel[0].i_predictor;
if( b_stereo )
{
*p_sample++ = channel[1].i_predictor;
}
for( i_nibbles = 0;
i_nibbles < p_adec->i_block - 4 * (b_stereo ? 2:1 );
i_nibbles++ )
{
*p_sample++ = AdpcmImaWavExpandNibble( &channel[0],
(*p_buffer) >> 4);
*p_sample++ = AdpcmImaWavExpandNibble( &channel[b_stereo ? 1 : 0],
(*p_buffer)&0x0f);
p_buffer++;
}
}
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