]> granicus.if.org Git - handbrake/commitdiff
libhb: only sanitize PAR for the MPEG-4 encoder.
authorRodeo <tdskywalker@gmail.com>
Fri, 9 Jan 2015 23:33:48 +0000 (23:33 +0000)
committerRodeo <tdskywalker@gmail.com>
Fri, 9 Jan 2015 23:33:48 +0000 (23:33 +0000)
The MPEG-2 and VP8 encoders will initialize
fine regardless, and the PAR will be stored
at the container, not the bitstream level.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6713 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/work.c

index 39f0dd3ac8bcfbb22475db247187ea7c1f08e4f5..20f8f8906e8755d272b6b7ae0a906ea28caf1156 100644 (file)
@@ -911,24 +911,14 @@ static void do_job(hb_job_t *job)
         job->cfr = 0;
     }
 
-    /* While x264 is smart enough to reduce fractions on its own, libavcodec
-     * needs some help with the math, so lose superfluous factors. */
-    hb_reduce(&job->par.num, &job->par.den,
-               job->par.num,  job->par.den);
-    if (job->vcodec & HB_VCODEC_FFMPEG_MASK)
+    /*
+     * 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 handle it.
+     */
+    if (job->vcodec == HB_VCODEC_FFMPEG_MPEG4)
     {
-        /* Just to make working with ffmpeg even more fun,
-         * lavc's MPEG-4 encoder can't handle PAR values >= 255,
-         * even though AVRational does. Adjusting downwards
-         * distorts the display aspect slightly, but such is life. */
-        while ((job->par.num & ~0xFF) ||
-               (job->par.den & ~0xFF))
-        {
-            job->par.num >>= 1;
-            job->par.den >>= 1;
-            hb_reduce(&job->par.num, &job->par.den,
-                       job->par.num,  job->par.den);
-        }
+        hb_limit_rational(&job->par.num, &job->par.den,
+                           job->par.num,  job->par.den, 255);
     }
 
 #ifdef USE_QSV