summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-09-29 23:31:57 +0000
committerjstebbins <[email protected]>2009-09-29 23:31:57 +0000
commit61bef2b28ed7caa4c5869c0bc5b042136bc82c1d (patch)
tree75ba9e44cfba919ff14c8f2db52241dee2bedec6 /libhb
parent6326b82b065467cdd85b0989f151d3e09d10b309 (diff)
flush lame encoder
The last mp3 frame was not complete. Most players ignore the broken frame, but a user ran across some software that handled it badly and crashed. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2852 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/enclame.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/libhb/enclame.c b/libhb/enclame.c
index 8f4defcc5..027aa3add 100644
--- a/libhb/enclame.c
+++ b/libhb/enclame.c
@@ -28,6 +28,7 @@ struct hb_work_private_s
/* LAME handle */
lame_global_flags * lame;
+ int done;
unsigned long input_samples;
unsigned long output_bytes;
uint8_t * buf;
@@ -138,14 +139,33 @@ int enclameWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
hb_buffer_t ** buf_out )
{
hb_work_private_t * pv = w->private_data;
+ hb_buffer_t * in = *buf_in;
hb_buffer_t * buf;
if ( (*buf_in)->size <= 0 )
{
/* EOF on input - send it downstream & say we're done */
- *buf_out = *buf_in;
- *buf_in = NULL;
- return HB_WORK_DONE;
+ if ( pv->done )
+ {
+ *buf_out = *buf_in;
+ *buf_in = NULL;
+ return HB_WORK_DONE;
+ }
+ else
+ {
+ pv->done = 1;
+ hb_fifo_push( w->fifo_in, in);
+ *buf_in = NULL;
+
+ buf = hb_buffer_init( pv->output_bytes );
+ buf->size = lame_encode_flush( pv->lame, buf->data, LAME_MAXMP3BUFFER );
+ if( buf->size <= 0 )
+ {
+ hb_buffer_close( &buf );
+ }
+ *buf_out = buf;
+ return HB_WORK_OK;
+ }
}
hb_list_add( pv->list, *buf_in );