summaryrefslogtreecommitdiffstats
path: root/libhb/encavcodec.c
diff options
context:
space:
mode:
authorJohn Stebbins <[email protected]>2015-11-03 09:46:28 -0800
committerJohn Stebbins <[email protected]>2015-11-09 11:06:59 -0800
commita986f54a4109bb8c3b2fb57849b4b0ea01e3c522 (patch)
tree7add9d007dc8bdd72114637c8f3f7361621ad4a5 /libhb/encavcodec.c
parent63b340ebc33d57aeda22e340dab48b1df2106541 (diff)
libhb: make muxer, sync, and reader behave like other work objects
simplify job initialization sequence, clean up code, and document dependencies in the sequence better. Make hb_add set job->sequence_id. It is no longer necessary for the frontend to do this. If the frontend needs the sequence_id, it is returned by hb_add(). Clean up use of interjob. do_job() now uses sequence_id to detect when a new sequence of related jobs is running and automatically clears interjob.
Diffstat (limited to 'libhb/encavcodec.c')
-rw-r--r--libhb/encavcodec.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c
index 134dbcc6b..9cc4193b5 100644
--- a/libhb/encavcodec.c
+++ b/libhb/encavcodec.c
@@ -102,17 +102,8 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
// Set things in context that we will allow the user to
// override with advanced settings.
- if( job->pass_id == HB_PASS_ENCODE_2ND )
- {
- hb_interjob_t * interjob = hb_interjob_get( job->h );
- fps.den = interjob->vrate.den;
- fps.num = interjob->vrate.num;
- }
- else
- {
- fps.den = job->vrate.den;
- fps.num = job->vrate.num;
- }
+ fps.den = job->vrate.den;
+ fps.num = job->vrate.num;
// If the fps.num is the internal clock rate, there's a good chance
// this is a standard rate that we have in our hb_video_rates table.
@@ -163,7 +154,8 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
context->time_base.den = fps.num;
context->time_base.num = fps.den;
- context->gop_size = 10 * ((double)job->vrate.num / job->vrate.den + 0.5);
+ context->gop_size = ((double)job->orig_vrate.num / job->orig_vrate.den +
+ 0.5) * 10;
/* place job->encoder_options in an hb_dict_t for convenience */
hb_dict_t * lavc_opts = NULL;
@@ -234,6 +226,16 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job )
context->sample_aspect_ratio.num = job->par.num;
context->sample_aspect_ratio.den = job->par.den;
+ if (job->vcodec == HB_VCODEC_FFMPEG_MPEG4)
+ {
+ // MPEG-4 Part 2 stores the PAR num/den as unsigned 8-bit fields,
+ // and libavcodec's encoder fails to initialize if we don't
+ // reduce it to fit 8-bits.
+ hb_limit_rational(&context->sample_aspect_ratio.num,
+ &context->sample_aspect_ratio.den,
+ context->sample_aspect_ratio.num,
+ context->sample_aspect_ratio.den, 255);
+ }
hb_log( "encavcodec: encoding with stored aspect %d/%d",
job->par.num, job->par.den );