diff dv.c @ 7538:06c291f42d5f libavcodec

Fixing the units in DV50 tables (both coordinates are supposed to be in units of 8 pixels) and simplifying the calculations of y_ptr and c_offset.
author romansh
date Mon, 11 Aug 2008 10:14:46 +0000
parents 910087e97750
children 1afa1171b7b2
line wrap: on
line diff
--- a/dv.c	Mon Aug 11 09:52:17 2008 +0000
+++ b/dv.c	Mon Aug 11 10:14:46 2008 +0000
@@ -470,16 +470,10 @@
         v = *mb_pos_ptr++;
         mb_x = v & 0xff;
         mb_y = v >> 8;
-        if (s->sys->pix_fmt == PIX_FMT_YUV422P) {
-            y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + (mb_x>>1))<<log2_blocksize);
-            c_offset = ((mb_y * s->picture.linesize[1] + (mb_x >> 2))<<log2_blocksize);
-        } else { /* 4:1:1 or 4:2:0 */
-            y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize);
-            if (s->sys->pix_fmt == PIX_FMT_YUV411P)
-                c_offset = ((mb_y * s->picture.linesize[1] + (mb_x >> 2))<<log2_blocksize);
-            else /* 4:2:0 */
-                c_offset = (((mb_y >> 1) * s->picture.linesize[1] + (mb_x >> 1))<<log2_blocksize);
-        }
+        y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<log2_blocksize);
+        c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
+                     (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<log2_blocksize);
+
         for(j = 0;j < 6; j++) {
             idct_put = s->idct_put[mb->dct_mode && log2_blocksize==3];
             if (s->sys->pix_fmt == PIX_FMT_YUV422P) { /* 4:2:2 */
@@ -838,16 +832,9 @@
         v = *mb_pos_ptr++;
         mb_x = v & 0xff;
         mb_y = v >> 8;
-        if (s->sys->pix_fmt == PIX_FMT_YUV422P) {
-            y_ptr = s->picture.data[0] + (mb_y * s->picture.linesize[0] * 8) + (mb_x * 4);
-        } else { /* 4:1:1 */
-            y_ptr = s->picture.data[0] + (mb_y * s->picture.linesize[0] * 8) + (mb_x * 8);
-        }
-        if (s->sys->pix_fmt == PIX_FMT_YUV420P) {
-            c_offset = (((mb_y >> 1) * s->picture.linesize[1] * 8) + ((mb_x >> 1) * 8));
-        } else { /* 4:2:2 or 4:1:1 */
-            c_offset = ((mb_y * s->picture.linesize[1] * 8) + ((mb_x >> 2) * 8));
-        }
+        y_ptr = s->picture.data[0] + ((mb_y * s->picture.linesize[0] + mb_x)<<3);
+        c_offset = (((mb_y>>(s->sys->pix_fmt == PIX_FMT_YUV420P)) * s->picture.linesize[1] +
+                     (mb_x>>((s->sys->pix_fmt == PIX_FMT_YUV411P)?2:1)))<<3);
         do_edge_wrap = 0;
         qnos[mb_index] = 15; /* No quantization */
         ptr = dif + mb_index*80 + 4;