[mythtv] Resizing video recording 'on the fly'

Kristof Pelckmans kristof.pelckmans at antwerpen.be
Sun Jun 27 15:03:11 EDT 2004


Hello,

I made an automatic aspect ratio detection filter for mythtv that will predict
the first non black horizontal line in an incoming stream.

Now I am looking into effectively changing the size of the stream that is
written, but I'm not quite sure how to deal with this. My idea was to add extra
attributes (zoomx, zoomy, zoomw and zoomh) to each frame that permit to specify
a rectangle within the frame. Only the specified rectangle would be encoded and
written out.

I tried two things :
1) let avcodec do the right stuff using AVPanScan
2) alter width and the memory locations of the y u and v pointers be

But neither of them seem to work very well :-(

Could anyone help me out ?

Thanks !

Kristof

--- mythtv/libs/libmythtv/NuppelVideoRecorder.cpp       2004-06-12
11:15:49.000000000 +0200
+++ mythtv-dev/libs/libmythtv/NuppelVideoRecorder.cpp   2004-06-27
20:52:43.813642800 +0200
@@ -3092,6 +3092,11 @@
                 frame.size = videobuffer[act_video_encode]->bufferlen;
                 frame.frameNumber = videobuffer[act_video_encode]->sample;
                 frame.timecode = videobuffer[act_video_encode]->timecode;
+
+                               frame.zoomx = 0;
+                               frame.zoomy = 0;
+                               frame.zoomh = frame.height;
+                               frame.zoomw = frame.width;

                 WriteVideo(&frame);

@@ -3164,12 +3169,6 @@

     memset(&frameheader, 0, sizeof(frameheader));

-    planes[0] = buf;
-    planes[1] = planes[0] + frame->width * frame->height;
-    if (picture_format == PIX_FMT_YUV422P)
-        planes[2] = planes[1] + (frame->width * frame->height) / 2;
-    else
-        planes[2] = planes[1] + (frame->width * frame->height) / 4;
     compressthis = compression;

     if (lf == 0)
@@ -3236,9 +3235,42 @@

     if (videoFilters)
         videoFilters->ProcessFrame(frame);
+/*
+    planes[0] = buf;
+    planes[1] = planes[0] + frame->width * frame->height;
+    if (picture_format == PIX_FMT_YUV422P)
+        planes[2] = planes[1] + (frame->width * frame->height) / 2;
+    else
+        planes[2] = planes[1] + (frame->width * frame->height) / 4;
+*/
+
+    planes[0] = buf + (frame->zoomy * frame->width);
+    planes[1] = planes[0] + frame->width * frame->height + (frame->zoomy *
(frame->width / 2));
+    if (picture_format == PIX_FMT_YUV422P)
+        planes[2] = planes[1] + (frame->width * frame->height) / 2 +
(frame->zoomy * (frame->width / 2));
+    else
+        planes[2] = planes[1] + (frame->width * frame->height) / 4 +
(frame->zoomy * (frame->width / 2));
+
+       frame->height = frame->zoomh;
+       mpa_ctx->height = frame->zoomh;

     if (useavcodec)
     {
+               mpa_pan_scan.id = 0;
+
+               mpa_pan_scan.position[0][0] = frame->zoomx;
+               mpa_pan_scan.position[1][0] = frame->zoomx / 2;
+               mpa_pan_scan.position[2][0] = frame->zoomx / 2;
+
+               mpa_pan_scan.position[0][1] = frame->zoomy;
+               mpa_pan_scan.position[1][1] = frame->zoomy / 2;
+               mpa_pan_scan.position[2][1] = frame->zoomy / 2;
+
+               mpa_pan_scan.width = frame->zoomw;
+               mpa_pan_scan.height = frame->zoomh;
+
+               mpa_picture.pan_scan = &mpa_pan_scan;
+
         mpa_picture.data[0] = planes[0];
         mpa_picture.data[1] = planes[1];
         mpa_picture.data[2] = planes[2];



More information about the mythtv-dev mailing list