[mythtv] Proposed change for transcode scalebitrate to use sqrt()

Brad Templeton brad+mydev at templetons.com
Tue Feb 24 02:26:19 UTC 2009


Currently, the nvp transcoder used by mythtranscode has the scalebitrate option which
scales the bitrate linearly with the number of pixels, multiplying the selected
bitrate by the number of pixels in the image normalized to 640x480.

By and large, this turns out to never be useful.  If you have one bitrate for
640x480, you will be using far too high a bitrate on 720p, which has 3 times
the pixels.

There is not a science to just how you should scale bitrates, but many believe
that doing it based on linear dimension (or the square root of the number of
pixels) is much closer to the right number.   One can go a bit higher, such as
a slightly smaller root (ie. say pixels ^ 0.66 instead of pixels ^ 0.5 ) if
this is not enough.

This is the line to patch:


--- NuppelVideoRecorder.cpp     (revision 19741)
+++ NuppelVideoRecorder.cpp     (working copy)
@@ -517,7 +517,7 @@
     int usebitrate = targetbitrate * 1000;
     if (scalebitrate)
     {
-        float diff = (w_out * h_out) / (640.0 * 480.0);
+        float diff = sqrt( (w_out * h_out) / (640.0 * 480.0));
         usebitrate = (int)(diff * usebitrate);
     }




However, there is a danger here.  Some people will have tuned their transcode profiles
based on a linear ratio.    As noted, I doubt anybody would do this over a wide
swath, using a transcode profile tuned for SDTV for HDTV with "scale up" but many
people might have set a bitrate on the profile for their SD recordings at say 352x480,
with that checkbox set.   For them, if they set the rate at 3000 kbps, they would be
getting 1650 kbps under the linear rule, and 2200 kbps under the sqrt rule, which would
make their files larger than expected.   If they checked it for HD files, it would
make their files smaller than expected.

The only backwards compatible way to do this would be to add another option, a
second box saying "Scale bitrate by sqrt of new size / 640x480" of which only
one should be checked.    Or a box with an exponent, so the user can set it as 
1.0 (the current setting) or 0.5 (square root) or anything else they want.

Bug #2

On the subject of mythtranscode codec profiles, there are two options in the UI
for interlaced dct and motion estimation.  These options are connected to nothing.
Mythtranscode ignores them, and does not pass them to NVP, as far as I can tell.
Is this just an error, or do they present problems requiring they be disabled?
In any event, it might make sense to remove them from the UI or to pass them
on.    I presume they do nothing on progressive video anyway so they can be
set on a profile used with both 1080p and 1080i recordings.

(In fact, with the above change to the bitrate scaler, it becomes possible to
define transcode profiles that can be used on all the main classes of
recordings -- 480i, 720p, 1080i, 1080p etc.)



More information about the mythtv-dev mailing list