]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/blobdiff - libavcodec/roqvideo.c
frsh: Export information about the last RTP contract and VRES
[frescor/ffmpeg.git] / libavcodec / roqvideo.c
index f6b0184360959a3833e23caec6e668734eadf0de..d97c4361ce47578574f9a9b3537e80496d8d7594 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2003 the ffmpeg project
+ * Copyright (C) 2003 Mike Melanson
+ * Copyright (C) 2003 Dr. Tim Ferguson
  *
  * This file is part of FFmpeg.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
  */
 
 /**
- * @file roqvideo.c
- * Id RoQ Video common functions based on work by Dr. Tim Ferguson
+ * @file libavcodec/roqvideo.c
+ * id RoQ Video common functions based on work by Dr. Tim Ferguson
  */
 
 #include "avcodec.h"
@@ -43,8 +43,8 @@ void ff_apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell)
     unsigned char *bptr;
     int boffs,stride;
 
-    stride = ri->y_stride;
-    boffs = (y * stride) + x;
+    stride = ri->current_frame->linesize[0];
+    boffs = y*stride + x;
 
     bptr = ri->current_frame->data[0] + boffs;
     bptr[0       ] = cell->y[0];
@@ -52,6 +52,9 @@ void ff_apply_vector_2x2(RoqContext *ri, int x, int y, roq_cell *cell)
     bptr[stride  ] = cell->y[2];
     bptr[stride+1] = cell->y[3];
 
+    stride = ri->current_frame->linesize[1];
+    boffs = y*stride + x;
+
     bptr = ri->current_frame->data[1] + boffs;
     bptr[0       ] =
     bptr[1       ] =
@@ -70,14 +73,17 @@ void ff_apply_vector_4x4(RoqContext *ri, int x, int y, roq_cell *cell)
     unsigned char *bptr;
     int boffs,stride;
 
-    stride = ri->y_stride;
-    boffs = (y * stride) + x;
+    stride = ri->current_frame->linesize[0];
+    boffs = y*stride + x;
 
     bptr = ri->current_frame->data[0] + boffs;
     bptr[         0] = bptr[         1] = bptr[stride    ] = bptr[stride  +1] = cell->y[0];
     bptr[         2] = bptr[         3] = bptr[stride  +2] = bptr[stride  +3] = cell->y[1];
     bptr[stride*2  ] = bptr[stride*2+1] = bptr[stride*3  ] = bptr[stride*3+1] = cell->y[2];
-    bptr[stride*2+2] = bptr[stride*2+3] = bptr[stride*3+2] = bptr[stride*3+3] = cell->y[2];
+    bptr[stride*2+2] = bptr[stride*2+3] = bptr[stride*3+2] = bptr[stride*3+3] = cell->y[3];
+
+    stride = ri->current_frame->linesize[1];
+    boffs = y*stride + x;
 
     bptr = ri->current_frame->data[1] + boffs;
     bptr[         0] = bptr[         1] = bptr[stride    ] = bptr[stride  +1] =
@@ -102,17 +108,20 @@ static inline void apply_motion_generic(RoqContext *ri, int x, int y, int deltax
     my = y + deltay;
 
     /* check MV against frame boundaries */
-    if ((mx < 0) || (mx > ri->avctx->width - sz) ||
-        (my < 0) || (my > ri->avctx->height - sz)) {
+    if ((mx < 0) || (mx > ri->width - sz) ||
+        (my < 0) || (my > ri->height - sz)) {
         av_log(ri->avctx, AV_LOG_ERROR, "motion vector out of bounds: MV = (%d, %d), boundaries = (0, 0, %d, %d)\n",
-            mx, my, ri->avctx->width, ri->avctx->height);
+            mx, my, ri->width, ri->height);
         return;
     }
 
-    for(cp = 0; cp < 3; cp++)
-        block_copy(ri->current_frame->data[cp] + (y * ri->y_stride) + x,
-                   ri->last_frame->data[cp] + (my * ri->y_stride) + mx,
-                   ri->y_stride, ri->y_stride, sz);
+    for(cp = 0; cp < 3; cp++) {
+        int outstride = ri->current_frame->linesize[cp];
+        int instride  = ri->last_frame   ->linesize[cp];
+        block_copy(ri->current_frame->data[cp] + y*outstride + x,
+                   ri->last_frame->data[cp] + my*instride + mx,
+                   outstride, instride, sz);
+    }
 }