Re: Deinterlacing?

Bj|rn Englund <[email protected]> Tue, 27 Sep 2005 13:43:35 +0200
Newsgroups gmane.comp.video.ogle.devel
Message-ID <[email protected]>
Tue Sep 27 2005, Mikhail Ramendik wrote:

> I thought I would patch in a very simple deinterlacing system (repeat one 
> field, drop the other). But I just could not understand the code enough to do 
> this :( 
> 
> I understand that even adding a hook for that can be a real hassle. When a 
> hook is there one can try adapting code from mplayer or transcode, but the 
> hook migh take too much developer time. 

What information/parameters are needed for using code from mplayer or
transcode for better deinterlacing?


> 
> Yet what about a field-duplication solution, which should probably be enabled 
> from the command line at least?

Here is a short hack that drops the bottom field.
It only works with Xv and the zoom function doesn't work as it should with it.
It also leaks memory (xv_image).
Maybe you can use this as a start and make a better patch that works
without Xv and doesn't break the zoom and doesn't leak memory?

To enable the 'deinterlacing' press 'm', to disable it 'M'.

/Bj|rn

Index: video_output_x11.c
===================================================================
RCS file: /cvsroot/ogle/ogle/mpeg2_video/video_output_x11.c,v
retrieving revision 1.123
diff -u -r1.123 video_output_x11.c
--- video_output_x11.c  25 Sep 2005 08:51:04 -0000      1.123
+++ video_output_x11.c  27 Sep 2005 11:26:57 -0000
@@ -83,6 +83,10 @@
 #endif /* HAVE_XV */


+#define DEINTERLACE_TEST
+#ifdef DEINTERLACE_TEST
+static int deint;
+#endif
 //ugly hack
 extern data_q_t *cur_data_q;
 /*
@@ -1576,6 +1580,29 @@
        m_ev.input.input_base = base_keysym;
        m_ev.input.input_keycode = ev.xkey.keycode;

+#ifdef DEINTERLACE_TEST
+       if(use_xv) {
+         if(keysym == XK_m) {
+           if(deint != 1) {
+             fprintf(stderr, "displaying only top field\n");
+             deint = 1;
+             xv_image = XvShmCreateImage(mydisplay, xv_port, xv_id, NULL,
+                                         xv_image->width*2,
+                                         xv_image->height/2,
+                                         &shm_info);
+           }
+         } else if(keysym == XK_M) {
+           if(deint != 0) {
+             fprintf(stderr, "displaying both fields\n");
+             deint = 0;
+             xv_image = XvShmCreateImage(mydisplay, xv_port, xv_id, NULL,
+                                         xv_image->width/2,
+                                         xv_image->height*2,
+                                         &shm_info);
+           }
+         }
+       }
+#endif
        if(MsgSendEvent(msgq, input_client, &m_ev, IPC_NOWAIT) == -1) {
          switch(errno) {
          case EAGAIN:
@@ -2346,6 +2373,11 @@
   set_videoarea(&window, scale.image_width, scale.image_height);

   src_view_area = get_viewarea(draw_image);
+#ifdef DEINTERLACE_TEST
+  if(deint) {
+    src_view_area.height = src_view_area.height/2;
+  }
+#endif
   if(use_xshm) {
     XvShmPutImage(mydisplay, xv_port, dwin->win, mygc, xv_image,
                  src_view_area.x, src_view_area.y,