Commit 7373cdfb authored by Michel Lespinasse's avatar Michel Lespinasse

Decoupage de vdec_motion en deux parties :

vdec_motion_inner contient le code plus ou moins bourin qui calcule les pixels
(je pense que c'est la que la majorite du temps est ecoulee, et qu'il y aurait
eventuellement un avantage a rechercher des optimisations particulieres pour
ce fichier, genre debouclage de boucles ou quelque chose du genre)

Le code dans vdec_motion contient quand a lui des tests sur le type exact
de prediction a effectuer, des calculs de pointeurs en fonction des motion
vectors, et les appels a vdec_motion_inner.

La fonction MotionComponent de vdec_motion a ete modifiee pour appeler
directement la bonne fonction de vdec_motion_inner en fonction des parametres.
La encore en raison de la gestion d'inlines faite a la compilation, pour chaque
appel les parametres i_width, i_height et b_average sont deja connus et
donc l'appel de MotionComponent devrait s'etendre a un simple switch (i_select)
et un appel de la fonction correspondante dans vdec_motion_inner.

Le code dans vdec_motion presente toujours une apparence contestable mais
je n'ai pas modifie son fonctionnement (seulement la fonction MotionComponent).
parent 5f0e921c
......@@ -241,6 +241,7 @@ video_parser_obj = video_parser/video_parser.o \
video_decoder_obj = video_decoder/video_decoder.o \
video_decoder/vdec_motion.o \
video_decoder/vdec_motion_inner.o \
video_decoder/vdec_idct.o
endif
......
......@@ -37,6 +37,76 @@
#include "video_parser.h"
#include "video_fifo.h"
#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 ();
__MotionComponents (16,16) /* 444, 422, 420 */
__MotionComponents (16,8) /* 444, 422, 420 */
__MotionComponents (8,8) /* 422, 420 */
__MotionComponents (8,4) /* 420 */
#if 0
__MotionComponents (8,16) /* 422 */
#endif
#define ___callTheRightOne(width,height) \
if ((i_width == width) && (i_height == height)) \
{ \
if (!b_average) \
{ \
switch (i_select) \
{ \
case 0: \
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); \
break; \
case 2: \
MotionComponent_x_Y_copy_##width##_##height (p_src, p_dest, \
i_stride, \
i_step); \
break; \
case 3: \
MotionComponent_X_Y_copy_##width##_##height (p_src, p_dest, \
i_stride, \
i_step); \
break; \
} \
} \
else \
{ \
switch (i_select) \
{ \
case 0: \
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); \
break; \
case 2: \
MotionComponent_x_Y_avg_##width##_##height (p_src, p_dest, \
i_stride, \
i_step); \
break; \
case 3: \
MotionComponent_X_Y_avg_##width##_##height (p_src, p_dest, \
i_stride, \
i_step); \
break; \
} \
} \
}
/*****************************************************************************
* vdec_MotionComponent : last stage of motion compensation
*****************************************************************************/
......@@ -54,175 +124,13 @@ static __inline__ void MotionComponent(
boolean_t b_average /* (explicit) averaging of several
* predictions */ )
{
int i_x, i_y, i_x1;
unsigned int i_dummy;
if( !b_average )
{
/* Please note that b_average will be expanded at compile time */
switch( i_select )
{
case 0:
/* !xh, !yh, !average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
p_dest[i_x+i_x1] = p_src[i_x+i_x1];
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 1:
/* xh, !yh, !average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
p_dest[i_x+i_x1] = (unsigned int)(p_src[i_x+i_x1]
+ p_src[i_x+i_x1 + 1] + 1)
>> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 2:
/* !xh, yh, !average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
p_dest[i_x+i_x1] = (unsigned int)(p_src[i_x+i_x1] + 1
+ p_src[i_x+i_x1 + i_step])
>> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 3:
/* xh, yh, !average (3) */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
p_dest[i_x+i_x1]
= ((unsigned int)(
p_src[i_x+i_x1]
+ p_src[i_x+i_x1 + 1]
+ p_src[i_x+i_x1 + i_step]
+ p_src[i_x+i_x1 + i_step + 1]
+ 2) >> 2);
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
}
}
else
{
/* b_average */
switch( i_select )
{
case 0:
/* !xh, !yh, average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
i_dummy = p_dest[i_x + i_x1] + p_src[i_x + i_x1];
p_dest[i_x + i_x1] = (i_dummy + 1) >> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 1:
/* xh, !yh, average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
i_dummy = p_dest[i_x+i_x1]
+ ((unsigned int)(p_src[i_x+i_x1]
+ p_src[i_x+i_x1 + 1] + 1) >> 1);
p_dest[i_x + i_x1] = (i_dummy + 1) >> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 2:
/* !xh, yh, average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
i_dummy = p_dest[i_x+i_x1]
+ ((unsigned int)(p_src[i_x+i_x1] + 1
+ p_src[i_x+i_x1 + i_step]) >> 1);
p_dest[i_x + i_x1] = (i_dummy + 1) >> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
case 3:
/* xh, yh, average */
for( i_y = 0; i_y < i_height; i_y ++ )
{
for( i_x = 0; i_x < i_width; i_x += 8 )
{
for( i_x1 = 0; i_x1 < 8; i_x1++ )
{
i_dummy = p_dest[i_x+i_x1]
+ ((unsigned int)(
p_src[i_x+i_x1]
+ p_src[i_x+i_x1 + 1]
+ p_src[i_x+i_x1 + i_step]
+ p_src[i_x+i_x1 + i_step + 1]
+ 2) >> 2);
p_dest[i_x + i_x1] = (i_dummy + 1) >> 1;
}
}
p_dest += i_stride;
p_src += i_stride;
}
break;
}
}
___callTheRightOne (16,16)
___callTheRightOne (16,8)
___callTheRightOne (8,8)
___callTheRightOne (8,4)
#if 0
___callTheRightOne (8,16)
#endif
}
/*****************************************************************************
......
/*****************************************************************************
* vdec_motion.c : motion compensation routines
* (c)1999 VideoLAN
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/uio.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "intf_msg.h"
#include "debug.h" /* XXX?? temporaire, requis par netlist.h */
#include "input.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "video.h"
#include "video_output.h"
#include "vdec_idct.h"
#include "video_decoder.h"
#include "vdec_motion.h"
#include "vpar_blocks.h"
#include "vpar_headers.h"
#include "vpar_synchro.h"
#include "video_parser.h"
#include "video_fifo.h"
#define __MotionComponent_x_y_copy(width,height) \
void MotionComponent_x_y_copy_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride) \
{ \
int i_x, i_y; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
p_dest[i_x] = p_src[i_x]; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_X_y_copy(width,height) \
void MotionComponent_X_y_copy_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride) \
{ \
int i_x, i_y; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
p_dest[i_x] = (unsigned int)(p_src[i_x] \
+ p_src[i_x + 1] \
+ 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_x_Y_copy(width,height) \
void MotionComponent_x_Y_copy_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride, \
int i_step) \
{ \
int i_x, i_y; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
p_dest[i_x] = (unsigned int)(p_src[i_x] \
+ p_src[i_x + i_step] \
+ 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_X_Y_copy(width,height) \
void MotionComponent_X_Y_copy_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride, \
int i_step) \
{ \
int i_x, i_y; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
p_dest[i_x] = (unsigned int)(p_src[i_x] \
+ p_src[i_x + 1] \
+ p_src[i_x + i_step] \
+ p_src[i_x + i_step + 1] \
+ 2) >> 2; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_x_y_avg(width,height) \
void MotionComponent_x_y_avg_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride) \
{ \
int i_x, i_y; \
unsigned int i_dummy; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
i_dummy = p_dest[i_x] + p_src[i_x]; \
p_dest[i_x] = (i_dummy + 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_X_y_avg(width,height) \
void MotionComponent_X_y_avg_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride) \
{ \
int i_x, i_y; \
unsigned int i_dummy; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x] \
+ p_src[i_x + 1] \
+ 1) >> 1); \
p_dest[i_x] = (i_dummy + 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_x_Y_avg(width,height) \
void MotionComponent_x_Y_avg_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride, \
int i_step) \
{ \
int i_x, i_y; \
unsigned int i_dummy; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
i_dummy = \
p_dest[i_x] + ((unsigned int)(p_src[i_x] \
+ p_src[i_x + i_step] \
+ 1) >> 1); \
p_dest[i_x] = (i_dummy + 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponent_X_Y_avg(width,height) \
void MotionComponent_X_Y_avg_##width##_##height(yuv_data_t * p_src, \
yuv_data_t * p_dest, \
int i_stride, \
int i_step) \
{ \
int i_x, i_y; \
unsigned int i_dummy; \
\
for( i_y = 0; i_y < height; i_y ++ ) \
{ \
for( i_x = 0; i_x < width; i_x++ ) \
{ \
i_dummy = \
p_dest[i_x] + ((unsigned int)(p_src[i_x] \
+ p_src[i_x + 1] \
+ p_src[i_x + i_step] \
+ p_src[i_x + i_step + 1] \
+ 2) >> 2); \
p_dest[i_x] = (i_dummy + 1) >> 1; \
} \
p_dest += i_stride; \
p_src += i_stride; \
} \
}
#define __MotionComponents(width,height) \
__MotionComponent_x_y_copy(width,height) \
__MotionComponent_X_y_copy(width,height) \
__MotionComponent_x_Y_copy(width,height) \
__MotionComponent_X_Y_copy(width,height) \
__MotionComponent_x_y_avg(width,height) \
__MotionComponent_X_y_avg(width,height) \
__MotionComponent_x_Y_avg(width,height) \
__MotionComponent_X_Y_avg(width,height)
__MotionComponents (16,16) /* 444, 422, 420 */
__MotionComponents (16,8) /* 444, 422, 420 */
__MotionComponents (8,8) /* 422, 420 */
__MotionComponents (8,4) /* 420 */
#if 0
__MotionComponents (8,16) /* 422 */
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment