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

Mark J. Titorenko mythtv-dev at titorenko.net
Mon Aug 25 18:00:30 EDT 2003


On Sun, Aug 24, 2003 at 01:00:52PM +0100, Mark J. Titorenko wrote:
[snip]
> To get it working with my DC10+, I changed the code as per the patch
> attached.
> 
> 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
> method?

Attached is a patch that supercedes my previous effort and which
instead adds an initialization method for HWMJPEG cards.  The max
width is read via an ioctl at initialization time which should result
in the width being set up for correct behaviour for all HWMJPEG cards.

Cheers,

Mark.
-------------- next part --------------
diff -u ./NuppelVideoRecorder.cpp new/NuppelVideoRecorder.cpp
--- ./NuppelVideoRecorder.cpp	2003-08-25 16:51:53.000000000 +0100
+++ new/NuppelVideoRecorder.cpp	2003-08-25 16:50:59.000000000 +0100
@@ -423,13 +423,12 @@
     {
         codec = "mjpeg";
         hardware_encode = true;
+	if (MJPEGInit() != 0 )
+	{
+	  cerr << "Could not detect max width for hardware MJPEG card, falling back to default: " << hmjpg_maxw << endl;
+	}
 
-        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)
         {
@@ -566,6 +565,45 @@
     return 0; 
 }
 
+int NuppelVideoRecorder::MJPEGInit(void)
+{
+    fd = open(videodevice.ascii(), O_RDWR);
+    if (fd <= 0)
+    {
+        cerr << "Can't open video device: " << videodevice << endl;
+        perror("open video:");
+        return 1;
+    }
+
+    struct video_capability vc;
+
+    memset(&vc, 0, sizeof(vc));
+
+    if (ioctl(fd, VIDIOCGCAP, &vc) < 0)
+    {
+        perror("VIDIOCGCAP:");
+        close(fd);
+        return 1;
+    }
+    close(fd);
+
+    if (vc.type & VID_TYPE_MJPEG_ENCODER)
+    {
+        if (vc.maxwidth >= 768)
+            hmjpg_maxw = 768;
+        else if (vc.maxwidth >= 704)
+            hmjpg_maxw = 704;
+        else
+            hmjpg_maxw = 640;
+    }
+    else
+    {
+       cerr << "Video device " << videodevice << " does not appear to have hardware MJPEG capture capabilities." << endl;
+       return 1;
+    }
+    return 0; 
+}
+
 void NuppelVideoRecorder::InitFilters(void)
 {
     if (videoFilters.size() > 0)
@@ -765,13 +803,6 @@
 
     if ((vc.type & VID_TYPE_MJPEG_ENCODER) && hardware_encode)
     {
-        if (vc.maxwidth >= 768)
-            hmjpg_maxw = 768;
-        else if (vc.maxwidth >= 704)
-            hmjpg_maxw = 704;
-        else
-            hmjpg_maxw = 640;
-
         DoMJPEG();
         return;
     }
diff -u ./NuppelVideoRecorder.h new/NuppelVideoRecorder.h
--- ./NuppelVideoRecorder.h	2003-08-25 16:51:54.000000000 +0100
+++ new/NuppelVideoRecorder.h	2003-08-25 16:50:59.000000000 +0100
@@ -92,6 +92,7 @@
     void doVbiThread(void);
     
  private:
+    int MJPEGInit(void);   
     void InitBuffers(void);
     void InitFilters(void);   
  


More information about the mythtv-dev mailing list