1 /* $Id: declpcm.c,v 1.8 2005/11/04 14:44:01 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
9 struct hb_work_object_s
17 static int Work( hb_work_object_t * w, hb_buffer_t ** buf_in,
18 hb_buffer_t ** buf_out )
20 hb_buffer_t * in = *buf_in, * out;
30 if( in->data[5] != 0x80 )
32 hb_log( "no LPCM frame sync (%02x)", in->data[5] );
36 switch( ( in->data[4] >> 4 ) & 0x3 )
42 samplerate = 96000;//32000; /* FIXME vlc says it is 96000 */
52 count = ( in->size - 6 ) / 2;
53 out = hb_buffer_init( count * sizeof( float ) );
54 duration = count * 90000 / samplerate / 2;
55 out->start = in->start;
56 out->stop = out->start + duration;
58 samples_u8 = in->data + 6;
59 samples_fl32 = (float *) out->data;
61 /* Big endian int16 -> float conversion */
62 for( i = 0; i < count; i++ )
64 #ifdef WORDS_BIGENDIAN
65 samples_fl32[0] = *( (int16_t *) samples_u8 );
67 samples_fl32[0] = (int16_t) ( ( samples_u8[0] << 8 ) | samples_u8[1] );
78 static void Close( hb_work_object_t ** _w )
80 hb_work_object_t * w = *_w;
86 hb_work_object_t * hb_work_declpcm_init( hb_job_t * job, hb_audio_t * audio )
88 hb_work_object_t * w = calloc( sizeof( hb_work_object_t ), 1 );
89 w->name = strdup( "LPCM decoder" );