]> git.sesse.net Git - vlc/blobdiff - plugins/motion/vdec_motion_common.c
___ _ _ _ _____ _____ ____ _ _ ____ _____
[vlc] / plugins / motion / vdec_motion_common.c
index df73182f81e073b04e6dac7d6c6f641eb7f47c6b..86aa61a3a1994ee5525756dea52d415bcd384b38 100644 (file)
@@ -2,7 +2,7 @@
  * vdec_motion_common.c : common motion compensation routines common
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: vdec_motion_common.c,v 1.4 2001/02/19 19:08:59 massiot Exp $
+ * $Id: vdec_motion_common.c,v 1.11 2001/12/09 17:01:36 sam Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Jean-Marc Dressler <polux@via.ecp.fr>
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+/* MODULE_NAME defined in Makefile together with -DBUILTIN */
+#ifdef BUILTIN
+#   include "modules_inner.h"
+#else
+#   define _M( foo ) foo
+#endif
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "defs.h"
 
-#include "config.h"
 #include "common.h"
 #include "threads.h"
 #include "mtime.h"
-#include "modules.h"
 
 #include "intf_msg.h"
 
 #include "video.h"
 
-#include "vdec_motion.h"
-#include "vpar_blocks.h"
+#include "vdec_ext-plugins.h"
+
+#include "modules.h"
+#include "modules_export.h"
 
-extern int motion_Probe( probedata_t *p_data );
+extern int _M( motion_Probe )( probedata_t *p_data );
 
 static void vdec_MotionFieldField420  ( macroblock_t * p_mb );
 static void vdec_MotionFieldField422  ( macroblock_t * p_mb );
@@ -66,9 +73,9 @@ static void vdec_MotionFrameDMV444    ( macroblock_t * p_mb );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void motion_getfunctions( function_list_t * p_function_list )
+void _M( motion_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = motion_Probe;
+    p_function_list->pf_probe = _M( motion_Probe );
 
 #define list p_function_list->functions.motion
 #define motion_functions( yuv ) \
@@ -88,14 +95,14 @@ void motion_getfunctions( function_list_t * p_function_list )
 }
 
 #define __MotionComponents(width,height)                \
-void MotionComponent_x_y_copy_##width##_##height ();    \
-void MotionComponent_X_y_copy_##width##_##height ();    \
-void MotionComponent_x_Y_copy_##width##_##height ();    \
-void MotionComponent_X_Y_copy_##width##_##height ();    \
-void MotionComponent_x_y_avg_##width##_##height ();     \
-void MotionComponent_X_y_avg_##width##_##height ();     \
-void MotionComponent_x_Y_avg_##width##_##height ();     \
-void MotionComponent_X_Y_avg_##width##_##height ();
+void _M( MotionComponent_x_y_copy_##width##_##height )();    \
+void _M( MotionComponent_X_y_copy_##width##_##height )();    \
+void _M( MotionComponent_x_Y_copy_##width##_##height )();    \
+void _M( MotionComponent_X_Y_copy_##width##_##height )();    \
+void _M( MotionComponent_x_y_avg_##width##_##height )();     \
+void _M( MotionComponent_X_y_avg_##width##_##height )();     \
+void _M( MotionComponent_x_Y_avg_##width##_##height )();     \
+void _M( MotionComponent_X_Y_avg_##width##_##height )();
 
 __MotionComponents (16,16)       /* 444, 422, 420 */
 __MotionComponents (16,8)        /* 444, 422, 420 */
@@ -113,20 +120,20 @@ __MotionComponents (8,16)        /* 422 */
             switch (i_select)                                                \
             {                                                                \
             case 0:                                                          \
-                MotionComponent_x_y_copy_##width##_##height (p_src, p_dest,  \
-                                                             i_stride);      \
+                _M( MotionComponent_x_y_copy_##width##_##height )(p_src,     \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 1:                                                          \
-                MotionComponent_X_y_copy_##width##_##height (p_src, p_dest,  \
-                                                             i_stride);      \
+                _M( MotionComponent_X_y_copy_##width##_##height )(p_src,     \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 2:                                                          \
-                MotionComponent_x_Y_copy_##width##_##height (p_src, p_dest,  \
-                                                             i_stride);      \
+                _M( MotionComponent_x_Y_copy_##width##_##height )(p_src,     \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 3:                                                          \
-                MotionComponent_X_Y_copy_##width##_##height (p_src, p_dest,  \
-                                                             i_stride);      \
+                _M( MotionComponent_X_Y_copy_##width##_##height )(p_src,     \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             }                                                                \
         }                                                                    \
@@ -135,20 +142,20 @@ __MotionComponents (8,16)        /* 422 */
             switch (i_select)                                                \
             {                                                                \
             case 0:                                                          \
-                MotionComponent_x_y_avg_##width##_##height (p_src, p_dest,   \
-                                                            i_stride);       \
+                _M( MotionComponent_x_y_avg_##width##_##height )(p_src,      \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 1:                                                          \
-                MotionComponent_X_y_avg_##width##_##height (p_src, p_dest,   \
-                                                            i_stride);       \
+                _M( MotionComponent_X_y_avg_##width##_##height )(p_src,      \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 2:                                                          \
-                MotionComponent_x_Y_avg_##width##_##height (p_src, p_dest,   \
-                                                            i_stride);       \
+                _M( MotionComponent_x_Y_avg_##width##_##height )(p_src,      \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             case 3:                                                          \
-                MotionComponent_X_Y_avg_##width##_##height (p_src, p_dest,   \
-                                                            i_stride);       \
+                _M( MotionComponent_X_Y_avg_##width##_##height )(p_src,      \
+                                                          p_dest, i_stride); \
                 break;                                                       \
             }                                                                \
         }                                                                    \
@@ -158,8 +165,8 @@ __MotionComponents (8,16)        /* 422 */
  * vdec_MotionComponent : last stage of motion compensation
  *****************************************************************************/
 static __inline__ void MotionComponent(
-                    yuv_data_t * p_src,     /* source block */
-                    yuv_data_t * p_dest,    /* dest block */
+                    pixel_data_t * p_src,   /* source block */
+                    pixel_data_t * p_dest,  /* dest block */
                     int i_width,            /* (explicit) width of block */
                     int i_height,           /* (explicit) height of block */
                     int i_stride,           /* number of coeffs to jump
@@ -207,7 +214,8 @@ static __inline__ void Motion420(
                          + b_source_field)
                        * p_mb->p_picture->i_width
                        + (i_mv_y >> 1) * i_l_stride;
-    if( i_source_offset >= p_source->i_width * p_source->i_height )
+
+    if( i_source_offset >= p_source->i_size )
     {
         intf_WarnMsg( 2, "Bad motion vector (lum)" );
         return;
@@ -215,9 +223,10 @@ static __inline__ void Motion420(
 
     /* Luminance */
     MotionComponent( /* source */
-                     p_source->p_y + i_source_offset,
+                     p_source->planes[ Y_PLANE ].p_data
+                       + i_source_offset,
                      /* destination */
-                     p_mb->p_picture->p_y
+                     p_mb->p_picture->planes[ Y_PLANE ].p_data
                        + (p_mb->i_l_x)
                        + (p_mb->i_motion_l_y + b_dest_field + i_offset)
                          * p_mb->p_picture->i_width,
@@ -234,7 +243,8 @@ static __inline__ void Motion420(
                            + b_source_field)
                           * p_mb->p_picture->i_chroma_width
                         + ((i_mv_y/2) >> 1) * i_c_stride;
-    if( i_source_offset >= (p_source->i_width * p_source->i_height) / 4 )
+
+    if( i_source_offset >= p_source->i_chroma_size )
     {
         intf_WarnMsg( 2, "Bad motion vector (chroma)" );
         return;
@@ -248,17 +258,17 @@ static __inline__ void Motion420(
     i_c_select = (((i_mv_y/2) & 1) << 1) | ((i_mv_x/2) & 1);
 
     /* Chrominance Cr */
-    MotionComponent( p_source->p_u
+    MotionComponent( p_source->planes[ U_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_u
+                     p_mb->p_picture->planes[ U_PLANE ].p_data
                        + i_dest_offset,
                      8, i_c_height, i_c_stride,
                      i_c_select, b_average );
 
     /* Chrominance Cb */
-    MotionComponent( p_source->p_v
+    MotionComponent( p_source->planes[ V_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_v
+                     p_mb->p_picture->planes[ V_PLANE ].p_data
                        + i_dest_offset,
                      8, i_c_height, i_c_stride,
                      i_c_select, b_average );
@@ -291,14 +301,14 @@ static __inline__ void Motion422(
 
     /* Luminance */
     MotionComponent( /* source */
-                     p_source->p_y
+                     p_source->planes[ Y_PLANE ].p_data
                        + (p_mb->i_l_x + (i_mv_x >> 1))
                        + (p_mb->i_motion_l_y + i_offset
                           + b_source_field)
                        * p_mb->p_picture->i_width
                        + (i_mv_y >> 1) * p_mb->i_l_stride,
                      /* destination */
-                     p_mb->p_picture->p_y
+                     p_mb->p_picture->planes[ Y_PLANE ].p_data
                        + (p_mb->i_l_x)
                        + (p_mb->i_motion_l_y + b_dest_field)
                          * p_mb->p_picture->i_width,
@@ -321,17 +331,17 @@ static __inline__ void Motion422(
     i_c_select = ((i_mv_y & 1) << 1) | ((i_mv_x/2) & 1);
 
     /* Chrominance Cr */
-    MotionComponent( p_source->p_u
+    MotionComponent( p_source->planes[ U_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_u
+                     p_mb->p_picture->planes[ U_PLANE ].p_data
                        + i_dest_offset,
                      8, i_height, i_c_stride,
                      i_c_select, b_average );
 
     /* Chrominance Cb */
-    MotionComponent( p_source->p_v
+    MotionComponent( p_source->planes[ V_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_u
+                     p_mb->p_picture->planes[ U_PLANE ].p_data
                        + i_dest_offset,
                      8, i_height, i_c_stride,
                      i_c_select, b_average );
@@ -375,25 +385,25 @@ static __inline__ void Motion444(
 
 
     /* Luminance */
-    MotionComponent( p_source->p_y
+    MotionComponent( p_source->planes[ Y_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_y
+                     p_mb->p_picture->planes[ Y_PLANE ].p_data
                        + i_dest_offset,
                      16, i_height, i_l_stride,
                      i_select, b_average );
 
     /* Chrominance Cr */
-    MotionComponent( p_source->p_u
+    MotionComponent( p_source->planes[ U_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_u
+                     p_mb->p_picture->planes[ U_PLANE ].p_data
                        + i_dest_offset,
                      16, i_height, i_l_stride,
                      i_select, b_average );
 
     /* Chrominance Cb */
-    MotionComponent( p_source->p_v
+    MotionComponent( p_source->planes[ V_PLANE ].p_data
                        + i_source_offset,
-                     p_mb->p_picture->p_v
+                     p_mb->p_picture->planes[ V_PLANE ].p_data
                        + i_dest_offset,
                      16, i_height, i_l_stride,
                      i_select, b_average );