[Ffmpeg-devel] Snow slicing support

Oded Shimon ods15
Mon Apr 3 20:47:58 CEST 2006


Just thought this patch might be of general interest to anyone. What I 
find interesting about it, is that it's not the sliced output that helps 
at all, but the rearranging of how the data is handled, of unpacking 
coeffs seperately from decoding image. It is actually a surprisngly huge 
difference on my cpu, almost 20% faster in some cases. This code trades 
off code switches against data switches, and even in my high res video 
(944x544), code switches prooved to be far more expensive...

I don't really expect this patch to go in CVS, but I am interested in any 
comments if anyone has any...

- ods15
-------------- next part --------------
Index: snow.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/snow.c,v
retrieving revision 1.87
diff -u -r1.87 libavcodec/snow.c
--- libavcodec/snow.c	30 Jan 2006 23:33:18 -0000	1.87
+++ libavcodec/snow.c	10 Mar 2006 16:26:57 -0000
@@ -4328,6 +4239,16 @@
     }
     STOP_TIMER("unpack coeffs");
 }
+#if 1
+}
+
+    for(plane_index=3; plane_index--; ){
+        Plane *p= &s->plane[plane_index];
+        int w= p->width;
+        int h= p->height;
+        int x;
+        int decode_state[MAX_DECOMPOSITIONS][4][1]; /* Stored state info for unpack_coeffs. 1 variable per instance. */
+#endif
 
 {START_TIMER
     const int mb_h= s->b_height << s->block_max_depth;
@@ -4405,6 +4326,18 @@
 
         y = FFMIN(p->height, slice_starty);
         end_y = FFMIN(p->height, slice_h);
+
+        if (avctx->draw_horiz_band && plane_index == 0) {
+             int start = y;// << s->chroma_v_shift;
+             int end = end_y;// << s->chroma_v_shift;
+             int offset[4];
+             offset[0] = s->current_picture.linesize[0] * start;
+             offset[1] = s->current_picture.linesize[1] * (start >> s->chroma_v_shift);
+             offset[2] = s->current_picture.linesize[2] * (start >> s->chroma_v_shift);
+             offset[3] = 0;
+             avctx->draw_horiz_band(avctx, &s->current_picture, offset, start, 3, end - start);
+        }
+
         while(y < end_y)
             slice_buffer_release(&s->sb, y++);
     }
@@ -4452,7 +4385,7 @@
     NULL,
     decode_end,
     decode_frame,
-    0 /*CODEC_CAP_DR1*/ /*| CODEC_CAP_DRAW_HORIZ_BAND*/,
+    CODEC_CAP_DRAW_HORIZ_BAND /*| CODEC_CAP_DR1*/,
     NULL
 };
 



More information about the ffmpeg-devel mailing list