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 int declpcmInit( hb_work_object_t *, hb_job_t * );
10 int declpcmWork( hb_work_object_t *, hb_buffer_t **, hb_buffer_t ** );
11 void declpcmClose( hb_work_object_t * );
13 hb_work_object_t hb_declpcm =
22 int declpcmInit( hb_work_object_t * w, hb_job_t * job )
27 int declpcmWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
28 hb_buffer_t ** buf_out )
30 hb_buffer_t * in = *buf_in, * out;
40 if( in->data[5] != 0x80 )
42 hb_log( "no LPCM frame sync (%02x)", in->data[5] );
46 switch( ( in->data[4] >> 4 ) & 0x3 )
52 samplerate = 96000;//32000; /* FIXME vlc says it is 96000 */
62 count = ( in->size - 6 ) / 2;
63 out = hb_buffer_init( count * sizeof( float ) );
64 duration = count * 90000 / samplerate / 2;
65 out->start = in->start;
66 out->stop = out->start + duration;
68 samples_u8 = in->data + 6;
69 samples_fl32 = (float *) out->data;
71 /* Big endian int16 -> float conversion */
72 for( i = 0; i < count; i++ )
74 #ifdef WORDS_BIGENDIAN
75 samples_fl32[0] = *( (int16_t *) samples_u8 );
77 samples_fl32[0] = (int16_t) ( ( samples_u8[0] << 8 ) | samples_u8[1] );
88 void declpcmClose( hb_work_object_t * w )