]> git.sesse.net Git - vlc/blob - src/video_decoder/vdec_motion.c
Ajout des fichiers de la synchro un peu partout.
[vlc] / src / video_decoder / vdec_motion.c
1 /*****************************************************************************
2  * vdec_motion.c : motion compensation routines
3  * (c)1999 VideoLAN
4  *****************************************************************************/
5
6 /*****************************************************************************
7  * Preamble
8  *****************************************************************************/
9 #include <errno.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12 #include <unistd.h>
13 #include <string.h>
14 #include <sys/uio.h>
15 #include <X11/Xlib.h>
16 #include <X11/extensions/XShm.h>
17
18 #include "config.h"
19 #include "common.h"
20 #include "mtime.h"
21 #include "vlc_thread.h"
22
23 #include "intf_msg.h"
24 #include "debug.h"                    /* ?? temporaire, requis par netlist.h */
25
26 #include "input.h"
27 #include "input_netlist.h"
28 #include "decoder_fifo.h"
29 #include "video.h"
30 #include "video_output.h"
31
32 #include "vdec_idct.h"
33 #include "video_decoder.h"
34 #include "vdec_motion.h"
35
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"
41
42 /*
43  * Local prototypes
44  */
45
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 );
49
50 /*****************************************************************************
51  * vdec_DummyRecon : motion compensation for an intra macroblock
52  *****************************************************************************/
53 void vdec_DummyRecon( macroblock_t * p_mb )
54 {
55 }
56
57 /*****************************************************************************
58  * vdec_ForwardRecon : motion compensation for a forward predicted macroblock
59  *****************************************************************************/
60 void vdec_ForwardRecon( macroblock_t * p_mb )
61 {
62
63 }
64
65 /*****************************************************************************
66  * vdec_BackwardRecon : motion compensation for a backward predicted macroblock
67  *****************************************************************************/
68 void vdec_BackwardRecon( macroblock_t * p_mb )
69 {
70
71 }
72
73 /*****************************************************************************
74  * vdec_BidirectionalRecon : motion compensation for a bidirectionally
75  *                           predicted macroblock
76  *****************************************************************************/
77 void vdec_BidirectionalRecon( macroblock_t * p_mb )
78 {
79
80 }
81
82 /*****************************************************************************
83  * vdec_MotionMacroblock420 : motion compensation for a 4:2:0 macroblock
84  *****************************************************************************/
85 void vdec_MotionMacroblock420( macroblock_t * p_mb )
86 {
87     /* Luminance */
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] );
93
94 }
95
96 /*****************************************************************************
97  * MotionBlock : motion compensation for one 8x8 block
98  *****************************************************************************/
99 void __inline__ MotionBlock( coeff_t * p_src, pel_lookup_table_t * p_lookup,
100                              int i_width_line,
101                              coeff_t * p_dest, int i_dest_x, i_dest_y,
102                              int i_stride_line,
103                              i_mv1_x, i_mv1_y, i_mv2_x, i_mv2_y )
104 {
105     static f_motion_c_t     ComponentMode[4]
106                                 = { &ComponentNN, &ComponentNH, &ComponentHN,
107                                     &ComponentHH };
108
109     int i_mode;
110
111     i_mode = (i_mv_x & 1) | ((i_mv_y & 1) << 1);
112
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 );
117 }
118
119 /*****************************************************************************
120  * ComponentNN : motion compensation without half pel
121  *****************************************************************************/
122 void ComponentNN( coeff_t * p_src, pel_lookup_table_t * p_lookup,
123                   int i_width_line,
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 )
126 {
127     int             i_vpos;
128     register int    i_hpos, i_src_loc;
129     
130     i_src_loc = (i_dest_y + i_mv1_y)*i_width_line + i_dest_x + i_mv1_x;
131     
132     for( i_vpos = 0; i_vpos < 4; i_vpos++ )
133     {
134         for( i_hpos = 0; i_hpos < 8; i_hpos++ )
135         {
136             p_dest[i_hpos] += p_src[p_lookup->pi_pel[i_src_loc + i_hpos]];
137         }
138         
139         p_dest += 8;
140         i_src_loc += i_stride_line;
141     }
142
143     i_src_loc = (i_dest_y + i_mv2_y)*i_width_line + i_dest_x + i_mv2_x;
144
145     for( i_vpos = 4; i_vpos < 8; i_vpos++ )
146     {
147         for( i_hpos = 0; i_hpos < 8; i_hpos++ )
148         {
149             p_dest[i_hpos] += p_src[p_lookup->pi_pel[i_src_loc + i_hpos]];
150         }
151         
152         p_dest += 8;
153         i_src_loc += i_stride_line;
154     }
155 }