[mythtv] [PATCH] DC10+ HWMJPEG max width issue

Mark J. Titorenko mythtv-dev at titorenko.net
Sun Aug 24 14:00:52 EDT 2003

Hello all,

Earlier this week I set about installing and configuring mythtv-0.11
to work with my DC10+ MJPEG card.  After getting it up and running
within a few minutes (great work with the release, and great work with
the Debian packages! :-)) I was happily watching live TV through

The first thing I noticed was that the right hand side of the picture
appeared to be cropped.  This was happening under all horizontal
decimations, although more of the picture was missing at decimation of
1 than at a decimation of 4.  There had been a post to mythtv-users
about a similar issue with a DC10+ card, so I thought I'd have a look
and see if I could figure out what was going on.

After a bit of a poke about in the source code (which, again, is great
work - very readable indeed!) I noticed that the NuppelVideoRecorder
class was using some values for the width of the image from the MJPEG
card which don't match the specs for the DC10+:

[in constructor]:

    hmjpg_maxw = 640;

[... in Initialize]:

       switch (hmjpg_hdecimation)
            case 2: w = 352; break;
            case 4: w = 176; break;
            default: w = hmjpg_maxw; break;

[... in StartRecording]:

    if ((vc.type & VID_TYPE_MJPEG_ENCODER) && hardware_encode)
        if (vc.maxwidth >= 768)
            hmjpg_maxw = 768;
        else if (vc.maxwidth >= 704)
            hmjpg_maxw = 704;
            hmjpg_maxw = 640;


The DC10+ has a max width of 768.  At decimation 2, the width should
be 384, and at decimation 4, the width should be 192.

This means that, at initialization time at least, bad values are being
used.  The hmjpg_maxw variable is then correctly updated in
StartRecording, and is used in DoMJPEG() correctly.  However the w
variable is still set with a bad value, and causing the RHS to end up
cropped.  AFAICS , the most likely cause is the AV codec getting
configured for images that are smaller than those being captured:

[in SetupAVCodec]:

            mpa_picture.linesize[0] = w;
            mpa_picture.linesize[1] = w / 2;
            mpa_picture.linesize[2] = w / 2;
    mpa_ctx->width = w;

To get it working with my DC10+, I changed the code as per the patch

I don't know what effect this patch will have on other HWMJPEG cards
with different (lower) max widths; I imagine it might cause the
recorded image to have a black bar on the RHS.

Perhaps the "max width" should be offered as a setting on the HWMJPEG
settings page?  Or could an ioctl be performed on the video device to
get the max width before setting the w variable in the Initialization

Overall, I am incredibly impressed with myth, and I hope to be able to
contribute to its development. One thing that comes to mind is that
I'd like a toggle in playback mode to switch from 4:3 to 16:9 so I can
watch widescreen channels in letterbox on my monitor.  Any pointers as
to how this might be achieved would be appreciated.


-------------- next part --------------
--- a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp	2003-08-07 21:53:20.000000000 +0100
+++ b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp	2003-08-24 12:21:12.000000000 +0100
@@ -132,7 +132,7 @@
     hmjpg_quality = 80;
     hmjpg_hdecimation = 2;
     hmjpg_vdecimation = 2;
-    hmjpg_maxw = 640;
+    hmjpg_maxw = 768;
     videoFilterList = "";
@@ -424,12 +424,7 @@
         codec = "mjpeg";
         hardware_encode = true;
-        switch (hmjpg_hdecimation)
-        {
-            case 2: w = 352; break;
-            case 4: w = 176; break;
-            default: w = hmjpg_maxw; break;
-        }
+        w = hmjpg_maxw / hmjpg_hdecimation;
         if (ntsc)

More information about the mythtv-dev mailing list