[FFmpeg-soc] [soc]: r5603 - in indeo5: indeo5.c ivi_common.c ivi_common.h

kostya subversion at mplayerhq.hu
Wed Jan 27 17:17:58 CET 2010


Author: kostya
Date: Wed Jan 27 17:17:58 2010
New Revision: 5603

Log:
Use single inline function for motion vector scaling

Modified:
   indeo5/indeo5.c
   indeo5/ivi_common.c
   indeo5/ivi_common.h

Modified: indeo5/indeo5.c
==============================================================================
--- indeo5/indeo5.c	Wed Jan 27 17:12:56 2010	(r5602)
+++ indeo5/indeo5.c	Wed Jan 27 17:17:58 2010	(r5603)
@@ -528,19 +528,12 @@ static int decode_mb_info(IVI5DecContext
                 mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
                 if (band->inherit_mv){
                     /* motion vector inheritance */
-                    switch (mv_scale) {
-                    case 0:
+                    if (mv_scale) {
+                        mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+                        mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+                    } else {
                         mb->mv_x = ref_mb->mv_x;
                         mb->mv_y = ref_mb->mv_y;
-                        break;
-                    case 1:
-                        mb->mv_x = IVI_MV_DIV2(ref_mb->mv_x);
-                        mb->mv_y = IVI_MV_DIV2(ref_mb->mv_y);
-                        break;
-                    case 2:
-                        mb->mv_x = IVI_MV_DIV4(ref_mb->mv_x);
-                        mb->mv_y = IVI_MV_DIV4(ref_mb->mv_y);
-                        break;
                     }
                 }
             } else {
@@ -574,19 +567,12 @@ static int decode_mb_info(IVI5DecContext
                 } else {
                     if (band->inherit_mv){
                         /* motion vector inheritance */
-                        switch (mv_scale) {
-                        case 0:
+                        if (mv_scale) {
+                            mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+                            mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+                        } else {
                             mb->mv_x = ref_mb->mv_x;
                             mb->mv_y = ref_mb->mv_y;
-                            break;
-                        case 1:
-                            mb->mv_x = IVI_MV_DIV2(ref_mb->mv_x);
-                            mb->mv_y = IVI_MV_DIV2(ref_mb->mv_y);
-                            break;
-                        case 2:
-                            mb->mv_x = IVI_MV_DIV4(ref_mb->mv_x);
-                            mb->mv_y = IVI_MV_DIV4(ref_mb->mv_y);
-                            break;
                         }
                     } else {
                         /* decode motion vector deltas */

Modified: indeo5/ivi_common.c
==============================================================================
--- indeo5/ivi_common.c	Wed Jan 27 17:12:56 2010	(r5602)
+++ indeo5/ivi_common.c	Wed Jan 27 17:17:58 2010	(r5603)
@@ -443,19 +443,12 @@ void ff_ivi_process_empty_tile(AVCodecCo
 
             if (band->inherit_mv) {
                 /* motion vector inheritance */
-                switch (mv_scale) {
-                case 0:
+                if (mv_scale) {
+                    mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
+                    mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
+                } else {
                     mb->mv_x = ref_mb->mv_x;
                     mb->mv_y = ref_mb->mv_y;
-                    break;
-                case 1:
-                    mb->mv_x = IVI_MV_DIV2(ref_mb->mv_x);
-                    mb->mv_y = IVI_MV_DIV2(ref_mb->mv_y);
-                    break;
-                case 2:
-                    mb->mv_x = IVI_MV_DIV4(ref_mb->mv_x);
-                    mb->mv_y = IVI_MV_DIV4(ref_mb->mv_y);
-                    break;
                 }
                 need_mc |= mb->mv_x || mb->mv_y; /* tracking non-zero motion vectors */
             }

Modified: indeo5/ivi_common.h
==============================================================================
--- indeo5/ivi_common.h	Wed Jan 27 17:12:56 2010	(r5602)
+++ indeo5/ivi_common.h	Wed Jan 27 17:17:58 2010	(r5603)
@@ -185,11 +185,11 @@ static inline int ivi_pic_config_cmp(IVI
 /* TODO: find a way to calculate this without the conditional using bit magic */
 #define IVI_TOSIGNED(val) (((val) & 1) ? ((val) + 1) >> 1 : -(((val) + 1) >> 1))
 
-/** divide the motion vector mv by 4 */
-#define IVI_MV_DIV4(mv) (((mv) + 1 + ((mv) > 0))>>2)
-
-/** divide the motion vector mv by 2 */
-#define IVI_MV_DIV2(mv) (((mv) + ((mv) > 0))>>1)
+/** scales motion vector */
+static inline int ivi_scale_mv(int mv, int mv_scale)
+{
+    return (mv + (mv > 0) + (mv_scale - 1)) >> mv_scale;
+}
 
 /**
  *  Generates a huffman codebook from the given descriptor


More information about the FFmpeg-soc mailing list