[FFmpeg-devel] [PATCH 1/3] vc1dec: the second field is written wrong to the picture

Sebastian Sandberg sebastiand.sandberg at gmail.com
Thu Jan 31 18:04:20 CET 2013


this happens for I/BI field pictures
---
 libavcodec/vc1dec.c |   33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index e056ffb..f4c31a8 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -82,6 +82,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v)
     int topleft_mb_pos, top_mb_pos;
     int stride_y, fieldtx;
     int v_dist;
+    uint8_t *destY, *destU, *destV;
 
     /* The put pixels loop is always one MB row behind the decoding loop,
      * because we can only put pixels when overlap filtering is done, and
@@ -91,28 +92,36 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v)
      * decoding loop. The reason for this is again, because for filtering
      * of the right MB edge, we need the next MB present. */
     if (!s->first_slice_line) {
+        destY = s->dest[0];
+        destU = s->dest[1];
+        destV = s->dest[2];
+        if (v->field_mode && v->second_field) {
+            destY += s->current_picture_ptr->f.linesize[0];
+            destU += s->current_picture_ptr->f.linesize[1];
+            destV += s->current_picture_ptr->f.linesize[2];
+        }
         if (s->mb_x) {
             topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1;
             fieldtx        = v->fieldtx_plane[topleft_mb_pos];
             stride_y       = s->linesize << fieldtx;
             v_dist         = (16 - fieldtx) >> (fieldtx == 0);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0],
-                                             s->dest[0] - 16 * s->linesize - 16,
+                                             destY - 16 * s->linesize - 16,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1],
-                                             s->dest[0] - 16 * s->linesize - 8,
+                                             destY - 16 * s->linesize - 8,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2],
-                                             s->dest[0] - v_dist * s->linesize - 16,
+                                             destY - v_dist * s->linesize - 16,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3],
-                                             s->dest[0] - v_dist * s->linesize - 8,
+                                             destY - v_dist * s->linesize - 8,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4],
-                                             s->dest[1] - 8 * s->uvlinesize - 8,
+                                             destU - 8 * s->uvlinesize - 8,
                                              s->uvlinesize);
             s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][5],
-                                             s->dest[2] - 8 * s->uvlinesize - 8,
+                                             destV - 8 * s->uvlinesize - 8,
                                              s->uvlinesize);
         }
         if (s->mb_x == s->mb_width - 1) {
@@ -121,22 +130,22 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v)
             stride_y   = s->linesize << fieldtx;
             v_dist     = fieldtx ? 15 : 8;
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0],
-                                             s->dest[0] - 16 * s->linesize,
+                                             destY - 16 * s->linesize,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1],
-                                             s->dest[0] - 16 * s->linesize + 8,
+                                             destY - 16 * s->linesize + 8,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2],
-                                             s->dest[0] - v_dist * s->linesize,
+                                             destY - v_dist * s->linesize,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3],
-                                             s->dest[0] - v_dist * s->linesize + 8,
+                                             destY - v_dist * s->linesize + 8,
                                              stride_y);
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4],
-                                             s->dest[1] - 8 * s->uvlinesize,
+                                             destU - 8 * s->uvlinesize,
                                              s->uvlinesize);
             s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][5],
-                                             s->dest[2] - 8 * s->uvlinesize,
+                                             destV - 8 * s->uvlinesize,
                                              s->uvlinesize);
         }
     }
-- 
1.7.10.4



More information about the ffmpeg-devel mailing list