X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fencavcodec.c;h=85aa6085fdfd4cbf9864bfd143f9537229bc278c;hb=516553c65ad905dad51054dffb76fee8f217a1c9;hp=45c79fddcdc383b5f7d1c1ff31ce4a24cef3d517;hpb=68e3a3c68e1af09f9547b2deca6bc4716e7ee10d;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index 45c79fdd..85aa6085 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -21,7 +21,7 @@ void encavcodecClose( hb_work_object_t * ); hb_work_object_t hb_encavcodec = { - WORK_DECSUB, + WORK_ENCAVCODEC, "MPEG-4 encoder (libavcodec)", encavcodecInit, encavcodecWork, @@ -65,16 +65,29 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) context->gop_size = 10 * job->vrate / job->vrate_base; context->pix_fmt = PIX_FMT_YUV420P; - if( job->mux & HB_MUX_MP4 ) + if( job->pixel_ratio ) + { + context->sample_aspect_ratio.num = job->pixel_aspect_width; + context->sample_aspect_ratio.den = job->pixel_aspect_height; + + hb_log( "encavcodec: encoding with stored aspect %d/%d", + job->pixel_aspect_width, job->pixel_aspect_height ); + } + + if( job->mux & ( HB_MUX_MP4 | HB_MUX_PSP ) ) { context->flags |= CODEC_FLAG_GLOBAL_HEADER; } + if( job->mux & HB_MUX_PSP ) + { + context->flags |= CODEC_FLAG_BITEXACT; + } if( job->grayscale ) { context->flags |= CODEC_FLAG_GRAY; } - if( job->pass ) + if( job->pass != 0 && job->pass != -1 ) { char filename[1024]; memset( filename, 0, 1024 ); hb_get_tempory_filename( job->h, filename, "ffmpeg.log" ); @@ -110,11 +123,17 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) } pv->context = context; - if( ( job->mux & HB_MUX_MP4 ) && job->pass != 1 ) + if( ( job->mux & ( HB_MUX_MP4 | HB_MUX_PSP ) ) && job->pass != 1 ) { +#if 0 /* Hem hem */ w->config->mpeg4.length = 15; memcpy( w->config->mpeg4.bytes, context->extradata + 15, 15 ); +#else + w->config->mpeg4.length = context->extradata_size; + memcpy( w->config->mpeg4.bytes, context->extradata, + context->extradata_size ); +#endif } return 0; @@ -132,12 +151,15 @@ void encavcodecClose( hb_work_object_t * w ) if( pv->context ) { hb_log( "encavcodec: closing libavcodec" ); + avcodec_flush_buffers( pv->context ); avcodec_close( pv->context ); } if( pv->file ) { fclose( pv->file ); } + free( pv ); + w->private_data = NULL; } /*********************************************************************** @@ -153,6 +175,12 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, AVFrame * frame; hb_buffer_t * in = *buf_in, * buf; + if(!in->data) + { + *buf_out = NULL; + return HB_WORK_DONE; + } + frame = avcodec_alloc_frame(); frame->data[0] = in->data; frame->data[1] = frame->data[0] + job->width * job->height; @@ -167,7 +195,7 @@ int encavcodecWork( hb_work_object_t * w, hb_buffer_t ** buf_in, frame ); buf->start = in->start; buf->stop = in->stop; - buf->key = pv->context->coded_frame->key_frame; + buf->frametype = pv->context->coded_frame->key_frame ? HB_FRAME_KEY : HB_FRAME_REF; av_free( frame );