hb_work_object_t hb_encavcodec =
{
- WORK_DECSUB,
+ WORK_ENCAVCODEC,
"MPEG-4 encoder (libavcodec)",
encavcodecInit,
encavcodecWork,
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" );
}
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;
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;
}
/***********************************************************************
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;
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 );