From: awk Date: Sat, 19 May 2007 01:55:32 +0000 (+0000) Subject: git-svn-id: svn://localhost/HandBrake/trunk@590 b64f7644-9d1e-0410-96f1-a4d463321fa5 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ddc4bf7708a6106b849e92c74ac7570f400e0a7f;p=handbrake-jp%2Fhandbrake-jp-git.git git-svn-id: svn://localhost/HandBrake/trunk@590 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/AUTHORS b/AUTHORS index b6e0909a..85c60995 100644 --- a/AUTHORS +++ b/AUTHORS @@ -70,4 +70,9 @@ Unknown (mirkwood) + Windows CLI port Unknown (Nyx) - + Frame re-ordering and flushing in mp4 \ No newline at end of file + + Frame re-ordering and flushing in mp4 + + Andrew Kimpton (awk) + + MPEG Audio fixes + + MPEG Stream Support + \ No newline at end of file diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 4d74fc68..4301f43d 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -27,6 +27,7 @@ struct hb_work_private_s AVCodecContext * context; int64_t pts_last; + AVCodecParserContext *parser; }; @@ -38,12 +39,15 @@ struct hb_work_private_s int decavcodecInit( hb_work_object_t * w, hb_job_t * job ) { AVCodec * codec; + hb_work_private_t * pv = calloc( 1, sizeof( hb_work_private_t ) ); w->private_data = pv; pv->job = job; - + codec = avcodec_find_decoder( CODEC_ID_MP2 ); + pv->parser = av_parser_init(CODEC_ID_MP2); + pv->context = avcodec_alloc_context(); avcodec_open( pv->context, codec ); pv->pts_last = -1; @@ -59,6 +63,7 @@ int decavcodecInit( hb_work_object_t * w, hb_job_t * job ) void decavcodecClose( hb_work_object_t * w ) { hb_work_private_t * pv = w->private_data; + av_parser_close(pv->parser); avcodec_close( pv->context ); } @@ -72,10 +77,12 @@ int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, { hb_work_private_t * pv = w->private_data; hb_buffer_t * in = *buf_in, * buf, * last = NULL; - int pos, len, out_size, i; + int pos, len, out_size, i, uncompressed_len; short buffer[AVCODEC_MAX_AUDIO_FRAME_SIZE]; uint64_t cur; - + unsigned char *parser_output_buffer; + int parser_output_buffer_len; + *buf_out = NULL; if( in->start < 0 || @@ -93,8 +100,13 @@ int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, pos = 0; while( pos < in->size ) { - len = avcodec_decode_audio( pv->context, buffer, &out_size, - in->data + pos, in->size - pos ); + len = av_parser_parse(pv->parser, pv->context,&parser_output_buffer,&parser_output_buffer_len,in->data + pos,in->size - pos,cur,cur); + + out_size = 0; + uncompressed_len = 0; + if (parser_output_buffer_len) + uncompressed_len = avcodec_decode_audio( pv->context, buffer, &out_size, + parser_output_buffer, parser_output_buffer_len ); if( out_size ) { short * s16; @@ -102,8 +114,21 @@ int decavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, buf = hb_buffer_init( 2 * out_size ); + int sample_size_in_bytes = 2; // Default to 2 bytes + switch (pv->context->sample_fmt) + { + case SAMPLE_FMT_S16: + sample_size_in_bytes = 2; + break; + /* We should handle other formats here - but that needs additional format conversion work below */ + /* For now we'll just report the error and try to carry on */ + default: + hb_log("decavcodecWork - Unknown Sample Format from avcodec_decode_audio (%d) !", pv->context->sample_fmt); + break; + } + buf->start = cur; - buf->stop = cur + 90000 * ( out_size / 4 ) / + buf->stop = cur + 90000 * ( out_size / (sample_size_in_bytes * pv->context->channels) ) / pv->context->sample_rate; cur = buf->stop; diff --git a/libhb/hb.c b/libhb/hb.c index 4aa89fb0..467ba92a 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -114,7 +114,8 @@ hb_handle_t * hb_init_real( int verbose, int update_check ) register_avcodec( &mpeg4_encoder ); register_avcodec( &mp2_decoder ); register_avcodec( &ac3_encoder ); - + av_register_codec_parser( &mpegaudio_parser); + /* Start library thread */ hb_log( "hb_init: starting libhb thread" ); h->die = 0;