summaryrefslogtreecommitdiffstats
path: root/libhb/encac3.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-04-08 16:49:24 +0000
committerjstebbins <[email protected]>2011-04-08 16:49:24 +0000
commitf20621c2d30ad805dfefcab335506f660a133ffe (patch)
tree5d1a3e9e844b94584790b7f002c3fdec39081326 /libhb/encac3.c
parentde122b044e99b0ad1abff0ba51e1a4d9e7d8b020 (diff)
Change internal audio representation range
...from float [-32768...32767] to float [-1.0...1.0] Using the range [-1.0..1.0] requires fewer translations of the range for our various encoders and decoders. This also gets rid of a hacky translation from float to int to float in decavcodec audio decoding. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3908 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/encac3.c')
-rw-r--r--libhb/encac3.c17
1 files changed, 1 insertions, 16 deletions
diff --git a/libhb/encac3.c b/libhb/encac3.c
index 179086607..693e8b02e 100644
--- a/libhb/encac3.c
+++ b/libhb/encac3.c
@@ -18,7 +18,6 @@ struct hb_work_private_s
unsigned long output_bytes;
hb_list_t * list;
uint8_t * buf;
- float * samples;
};
int encac3Init( hb_work_object_t *, hb_job_t * );
@@ -53,7 +52,6 @@ int encac3Init( hb_work_object_t * w, hb_job_t * job )
pv->output_bytes = AC3_MAX_CODED_FRAME_SIZE;
pv->buf = malloc( pv->input_samples * sizeof( float ) );
- pv->samples = malloc( pv->input_samples * sizeof( float ) );
codec = avcodec_find_encoder( CODEC_ID_AC3 );
if( !codec )
@@ -127,12 +125,6 @@ void encac3Close( hb_work_object_t * w )
pv->buf = NULL;
}
- if ( pv->samples )
- {
- free( pv->samples );
- pv->samples = NULL;
- }
-
if ( pv->list )
hb_list_empty( &pv->list );
@@ -147,7 +139,6 @@ static hb_buffer_t * Encode( hb_work_object_t * w )
uint64_t pts, pos;
hb_audio_t * audio = w->audio;
hb_buffer_t * buf;
- int ii;
if( hb_list_bytes( pv->list ) < pv->input_samples * sizeof( float ) )
{
@@ -188,15 +179,9 @@ static hb_buffer_t * Encode( hb_work_object_t * w )
(float*)pv->buf, AC3_SAMPLES_PER_FRAME);
}
- for (ii = 0; ii < pv->input_samples; ii++)
- {
- // ffmpeg float samples are -1.0 to 1.0
- pv->samples[ii] = ((float*)pv->buf)[ii] / 32768.0;
- }
-
buf = hb_buffer_init( pv->output_bytes );
buf->size = avcodec_encode_audio( pv->context, buf->data, buf->alloc,
- (short*)pv->samples );
+ (short*)pv->buf );
buf->start = pts + 90000 * pos / pv->out_discrete_channels / sizeof( float ) / audio->config.out.samplerate;
buf->stop = buf->start + 90000 * AC3_SAMPLES_PER_FRAME / audio->config.out.samplerate;