changeset 11132:449c12b6c3a0 libavcodec

Implement CODEC_CAP_DRAW_HORIZ_BAND for VP3 decoder
author conrad
date Fri, 12 Feb 2010 22:01:35 +0000
parents 926f79d28a87
children cd2956d08cc1
files vp3.c
diffstat 1 files changed, 39 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vp3.c	Fri Feb 12 22:01:32 2010 +0000
+++ b/vp3.c	Fri Feb 12 22:01:35 2010 +0000
@@ -135,6 +135,7 @@
     int keyframe;
     DSPContext dsp;
     int flipped_image;
+    int last_slice_end;
 
     int qps[3];
     int nqps;
@@ -1450,6 +1451,37 @@
     }
 }
 
+/**
+ * called when all pixels up to row y are complete
+ */
+static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y)
+{
+    int h, cy;
+    int offset[4];
+
+    if(s->avctx->draw_horiz_band==NULL)
+        return;
+
+    h= y - s->last_slice_end;
+    y -= h;
+
+    if (!s->flipped_image) {
+        if (y == 0)
+            h -= s->height - s->avctx->height;  // account for non-mod16
+        y = s->height - y - h;
+    }
+
+    cy = y >> 1;
+    offset[0] = s->current_frame.linesize[0]*y;
+    offset[1] = s->current_frame.linesize[1]*cy;
+    offset[2] = s->current_frame.linesize[2]*cy;
+    offset[3] = 0;
+
+    emms_c();
+    s->avctx->draw_horiz_band(s->avctx, &s->current_frame, offset, y, 3, h);
+    s->last_slice_end= y + h;
+}
+
 /*
  * Perform the final rendering for a particular slice of data.
  * The slice number ranges from 0..(macroblock_height - 1).
@@ -1624,7 +1656,9 @@
       *     dispatch (slice - 1);
       */
 
-    emms_c();
+    // now that we've filtered the last rows, they're safe to display
+    if (slice)
+        vp3_draw_horiz_band(s, 16*slice);
 }
 
 /*
@@ -2008,6 +2042,7 @@
         return -1;
     }
 
+    s->last_slice_end = 0;
     for (i = 0; i < s->macroblock_height; i++)
         render_slice(s, i);
 
@@ -2016,6 +2051,7 @@
         int row = (s->height >> (3+!!i)) - 1;
         apply_loop_filter(s, i, row, row+1);
     }
+    vp3_draw_horiz_band(s, s->height);
 
     *data_size=sizeof(AVFrame);
     *(AVFrame*)data= s->current_frame;
@@ -2367,7 +2403,7 @@
     NULL,
     vp3_decode_end,
     vp3_decode_frame,
-    CODEC_CAP_DR1,
+    CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("Theora"),
 };
@@ -2382,7 +2418,7 @@
     NULL,
     vp3_decode_end,
     vp3_decode_frame,
-    CODEC_CAP_DR1,
+    CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND,
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"),
 };