1 /*****************************************************************************
2 * vdec_motion.c : motion compensation routines
4 *****************************************************************************/
6 /*****************************************************************************
8 *****************************************************************************/
16 #include <X11/extensions/XShm.h>
21 #include "vlc_thread.h"
24 #include "debug.h" /* ?? temporaire, requis par netlist.h */
27 #include "input_netlist.h"
28 #include "decoder_fifo.h"
30 #include "video_output.h"
32 #include "vdec_idct.h"
33 #include "video_decoder.h"
34 #include "vdec_motion.h"
36 #include "vpar_blocks.h"
37 #include "vpar_headers.h"
38 #include "video_fifo.h"
39 #include "vpar_synchro.h"
40 #include "video_parser.h"
46 typedef void (*f_motion_c_t)( coeff_t *, pel_lookup_table_t *,
47 int, coeff_t *, int, int,
48 int, int, int, int, int );
50 /*****************************************************************************
51 * vdec_DummyRecon : motion compensation for an intra macroblock
52 *****************************************************************************/
53 void vdec_DummyRecon( macroblock_t * p_mb )
57 /*****************************************************************************
58 * vdec_ForwardRecon : motion compensation for a forward predicted macroblock
59 *****************************************************************************/
60 void vdec_ForwardRecon( macroblock_t * p_mb )
65 /*****************************************************************************
66 * vdec_BackwardRecon : motion compensation for a backward predicted macroblock
67 *****************************************************************************/
68 void vdec_BackwardRecon( macroblock_t * p_mb )
73 /*****************************************************************************
74 * vdec_BidirectionalRecon : motion compensation for a bidirectionally
75 * predicted macroblock
76 *****************************************************************************/
77 void vdec_BidirectionalRecon( macroblock_t * p_mb )
82 /*****************************************************************************
83 * vdec_MotionMacroblock420 : motion compensation for a 4:2:0 macroblock
84 *****************************************************************************/
85 void vdec_MotionMacroblock420( macroblock_t * p_mb )
88 MotionBlock( p_undec_p->p_forward->p_u, p_undec_p->p_forward->p_lookup_lum,
89 p_undec_p->p_picture->i_width, p_u, i_mb_x, i_mb_y,
90 p_undec_p->p_picture->i_width,
91 p_undec_p->ppp_motion_vectors[0][0][0],
92 p_undec_p->ppp_motion_vectors[0][0][1] );
96 /*****************************************************************************
97 * MotionBlock : motion compensation for one 8x8 block
98 *****************************************************************************/
99 void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup,
101 coeff_t * p_dest, int i_dest_x, i_dest_y,
103 i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y )
105 static f_motion_c_t ComponentMode[4]
106 = { &ComponentNN, &ComponentNH, &ComponentHN,
111 i_mode = (i_mv_x & 1) | ((i_mv_y & 1) << 1);
113 ComponentMode[i_mode]( p_src, p_lookup, i_width_line,
114 p_dest, i_dest_x, i_dest_y,
115 i_stride_line, i_mv1_x >> 1, i_mv1_y >> 1,
116 i_mv2_x >> 1, i_mv2_y >> 1 );
119 /*****************************************************************************
120 * ComponentNN : motion compensation without half pel
121 *****************************************************************************/
122 void ComponentNN( coeff_t * p_src, pel_lookup_table_t * p_lookup,
124 coeff_t * p_dest, int i_dest_x, i_dest_y,
125 int i_stride_line, i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y )
128 register int i_hpos, i_src_loc;
130 i_src_loc = (i_dest_y + i_mv1_y)*i_width_line + i_dest_x + i_mv1_x;
132 for( i_vpos = 0; i_vpos < 4; i_vpos++ )
134 for( i_hpos = 0; i_hpos < 8; i_hpos++ )
136 p_dest[i_hpos] += p_src[p_lookup->pi_pel[i_src_loc + i_hpos]];
140 i_src_loc += i_stride_line;
143 i_src_loc = (i_dest_y + i_mv2_y)*i_width_line + i_dest_x + i_mv2_x;
145 for( i_vpos = 4; i_vpos < 8; i_vpos++ )
147 for( i_hpos = 0; i_hpos < 8; i_hpos++ )
149 p_dest[i_hpos] += p_src[p_lookup->pi_pel[i_src_loc + i_hpos]];
153 i_src_loc += i_stride_line;