[svn] / branches / dev-api-3 / xvidcore / src / motion / motion_comp.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/motion/motion_comp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 658, Tue Nov 19 13:04:35 2002 UTC revision 701, Mon Dec 9 10:47:05 2002 UTC
# Line 6  Line 6 
6  #include "../encoder.h"  #include "../encoder.h"
7  #include "../utils/mbfunctions.h"  #include "../utils/mbfunctions.h"
8  #include "../image/interpolate8x8.h"  #include "../image/interpolate8x8.h"
9    #include "../image/reduced.h"
10  #include "../utils/timer.h"  #include "../utils/timer.h"
11  #include "motion.h"  #include "motion.h"
12    
13  #define ABS(X) (((X)>0)?(X):-(X))  #define ABS(X) (((X)>0)?(X):-(X))
14  #define SIGN(X) (((X)>0)?1:-1)  #define SIGN(X) (((X)>0)?1:-1)
15    
16    
17    // decode an inter macroblock
18    
19    static void
20    rrv_mv_scaleup(VECTOR * mv)
21    {
22            if (mv->x > 0) {
23                    mv->x = 2*mv->x - 1;
24            } else if (mv->x < 0) {
25                    mv->x = 2*mv->x + 1;
26            }
27    
28            if (mv->y > 0) {
29                    mv->y = 2*mv->y - 1;
30            } else if (mv->y < 0) {
31                    mv->y = 2*mv->y + 1;
32            }
33    }
34    
35    
36  static __inline void  static __inline void
37  compensate16x16_interpolate(int16_t * const dct_codes,  compensate16x16_interpolate(int16_t * const dct_codes,
38                                                      uint8_t * const cur,                                                      uint8_t * const cur,
39                                                      const uint8_t * const ref,                                                      const uint8_t * const ref,
40                                                      const uint8_t * const refh,                                                      const uint8_t * const refh,
41                                                      const uint8_t * const refv,                                                      uint8_t * const refv,
42                                                      const uint8_t * const refhv,                                                      const uint8_t * const refhv,
43                                                      const uint32_t x,                                                      uint32_t x,
44                                                      const uint32_t y,                                                      uint32_t y,
45                                                      const int32_t dx,                                                      const int32_t dx,
46                                                      const int32_t dy,                                                      const int32_t dy,
47                                                      const uint32_t stride,                                                      const uint32_t stride,
48                                                      const uint32_t quarterpel,                                                      const uint32_t quarterpel,
49                                                            const int reduced_resolution,
50                                                      const uint32_t rounding)                                                      const uint32_t rounding)
51  {  {
52    
53            if (reduced_resolution)
54            {
55    
56                    /* XXX: todo */
57    
58                    VECTOR mv;
59                    int i,j;
60                    uint8_t tmp[18*18];
61    
62                    x*=2;
63                    y*=2;
64    
65                    mv.x = dx;
66                    mv.y = dy;
67                    rrv_mv_scaleup(&mv);
68    
69                    interpolate32x32_switch(
70                            refv, ref, x, y, mv.x, mv.y, stride, rounding);
71    
72                    for (j = 0; j < 32; j++)
73                    for (i = 0; i < 32; i++)
74                            cur[(y+j)*stride + x + i] -= refv[(y+j)*stride + x + i];
75    
76                    filter_18x18_to_8x8(dct_codes,     cur + y*stride + x, stride);
77                    filter_18x18_to_8x8(dct_codes+64,  cur + y*stride + x + 16, stride);
78                    filter_18x18_to_8x8(dct_codes+128, cur + (y+16)*stride + x, stride);
79                    filter_18x18_to_8x8(dct_codes+192, cur + (y+16)*stride + x + 16, stride);
80    
81                    /*
82                    for (j = 0; j < 16; j++)
83                    for (i = 0; i < 16; i++)
84                            tmp[(j+1)*18 + i+1] = refv[ (y+j)*stride + x+i];
85    
86                    for (i = 1; i < 17; i++)
87                    {
88                            tmp[ 0*18 + i] = tmp[ 1*18 + i];
89                            tmp[17*18 + i] = tmp[16*18 + i];
90                    }
91    
92                    for (i = 0; i < 18; i++)
93                    {
94                            tmp[ i*18 + 0] = tmp[i*18 + 1];
95                            tmp[ i*18 + 17] = tmp[i*18 + 16];
96                    }
97                    filter_18x18_to_8x8(dct_codes, tmp, 18);
98    
99    
100                    for (j = 0; j < 16; j++)
101                    for (i = 0; i < 16; i++)
102                            tmp[(j+1)*18 + i+1] = refv[ (y+j)*stride + x+i + 16];
103    
104                    for (i = 1; i < 17; i++)
105                    {
106                            tmp[ 0*18 + i] = tmp[ 1*18 + i];
107                            tmp[17*18 + i] = tmp[16*18 + i];
108                    }
109    
110                    for (i = 0; i < 18; i++)
111                    {
112                            tmp[ i*18 + 0] = tmp[i*18 + 1];
113                            tmp[ i*18 + 17] = tmp[i*18 + 16];
114                    }
115                    filter_18x18_to_8x8(dct_codes+64, tmp, 18);
116    
117                    for (j = 0; j < 16; j++)
118                    for (i = 0; i < 16; i++)
119                            tmp[(j+1)*18 + i+1] = refv[ (y+16+j)*stride + x+i];
120    
121                    for (i = 1; i < 17; i++)
122                    {
123                            tmp[ 0*18 + i] = tmp[ 1*18 + i];
124                            tmp[17*18 + i] = tmp[16*18 + i];
125                    }
126    
127                    for (i = 0; i < 18; i++)
128                    {
129                            tmp[ i*18 + 0] = tmp[i*18 + 1];
130                            tmp[ i*18 + 17] = tmp[i*18 + 16];
131                    }
132                    filter_18x18_to_8x8(dct_codes+128, tmp, 18);
133    
134                    for (j = 0; j < 16; j++)
135                    for (i = 0; i < 16; i++)
136                            tmp[(j+1)*18 + i+1] = refv[ (y+16+j)*stride + x+i + 16];
137    
138                    for (i = 1; i < 17; i++)
139                    {
140                            tmp[ 0*18 + i] = tmp[ 1*18 + i];
141                            tmp[17*18 + i] = tmp[16*18 + i];
142                    }
143    
144                    for (i = 0; i < 18; i++)
145                    {
146                            tmp[ i*18 + 0] = tmp[i*18 + 1];
147                            tmp[ i*18 + 17] = tmp[i*18 + 16];
148                    }
149                    filter_18x18_to_8x8(dct_codes+192, tmp, 18);
150                    */
151    
152    
153                    //memset(dct_codes, 0, sizeof(uint16_t) * 64 * 4);
154    
155            }else{
156          if(quarterpel) {          if(quarterpel) {
157                  interpolate16x16_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,                  interpolate16x16_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
158                          (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);                          (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
# Line 63  Line 189 
189                                                            reference + 8*stride + 8, stride);                                                            reference + 8*stride + 8, stride);
190          }          }
191  }  }
192    }
193    
194  static __inline void  static __inline void
195  compensate8x8_interpolate(int16_t * const dct_codes,  compensate8x8_interpolate(int16_t * const dct_codes,
# Line 77  Line 204 
204                                                    const int32_t dy,                                                    const int32_t dy,
205                                                    const uint32_t stride,                                                    const uint32_t stride,
206                                                    const uint32_t quarterpel,                                                    const uint32_t quarterpel,
207                                                      const int reduced_resolution,
208                                                    const uint32_t rounding)                                                    const uint32_t rounding)
209  {  {
210            if (reduced_resolution)
211            {
212                    // XXX: todo
213            } else {
214    
215          if(quarterpel) {          if(quarterpel) {
216                  interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,                  interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
217                          (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);                          (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
# Line 102  Line 235 
235                                                            reference, stride);                                                            reference, stride);
236          }          }
237  }  }
238    }
239    
240  void  void
241  MBMotionCompensation(MACROBLOCK * const mb,  MBMotionCompensation(MACROBLOCK * const mb,
# Line 117  Line 251 
251                                           const uint32_t height,                                           const uint32_t height,
252                                           const uint32_t edged_width,                                           const uint32_t edged_width,
253                                           const uint32_t quarterpel,                                           const uint32_t quarterpel,
254                                             const int reduced_resolution,
255                                           const uint32_t rounding)                                           const uint32_t rounding)
256  {  {
257    
258          if (mb->mode == MODE_NOT_CODED || mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {          if (mb->mode == MODE_NOT_CODED || mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) {
259    
260                  int32_t dx = (quarterpel ? mb->qmvs[0].x : mb->mvs[0].x);                  int32_t dx = (quarterpel ? mb->qmvs[0].x : mb->mvs[0].x);
261                  int32_t dy = (quarterpel ? mb->qmvs[0].y : mb->mvs[0].y);                  int32_t dy = (quarterpel ? mb->qmvs[0].y : mb->mvs[0].y);
262    
263                  if ( (mb->mode == MODE_NOT_CODED) && (dx==0) && (dy==0) ) {     /* quick copy */                  if ( (mb->mode == MODE_NOT_CODED) && (dx==0) && (dy==0) ) {     /* quick copy */
264                          transfer8x8_copy(cur->y + 16 * (i + j * edged_width),                          transfer16x16_copy(cur->y + 16 * (i + j * edged_width),
265                                                                  ref->y + 16 * (i + j * edged_width),                                                                  ref->y + 16 * (i + j * edged_width),
266                                                                  edged_width);                                                                  edged_width);
                         transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8,  
                                                                 ref->y + 16 * (i + j * edged_width) + 8,  
                                                                 edged_width);  
                         transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * edged_width,  
                                                                 ref->y + 16 * (i + j * edged_width) + 8 * edged_width,  
                                                                 edged_width);  
                         transfer8x8_copy(cur->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),  
                                                                 ref->y + 16 * (i + j * edged_width) + 8 * (edged_width+1),  
                                                                 edged_width);  
267    
268                          transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),                          transfer8x8_copy(cur->u + 8 * (i + j * edged_width/2),
269                                                                  ref->u + 8 * (i + j * edged_width/2),                                                                  ref->u + 8 * (i + j * edged_width/2),
# Line 149  Line 276 
276          /* quick MODE_NOT_CODED for GMC with MV!=(0,0) is still needed */          /* quick MODE_NOT_CODED for GMC with MV!=(0,0) is still needed */
277    
278                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
279                                                    refv->y, refhv->y, 16 * i, 16 * j, dx,                                                    refv->y, refhv->y, 16 * i, 16 * j, dx, dy,
280                                                    dy, edged_width, quarterpel, rounding);                                                    edged_width, quarterpel, reduced_resolution, rounding);
281    
282                  if (quarterpel)                  if (quarterpel)
283                  {                  {
# Line 162  Line 289 
289                  dy = (dy >> 1) + roundtab_79[dy & 0x3];                  dy = (dy >> 1) + roundtab_79[dy & 0x3];
290    
291                  /* uv-block-based compensation */                  /* uv-block-based compensation */
292                    if (reduced_resolution)
293                    {
294                            // XXX: todo
295                    }else{
296                  transfer_8to16sub(&dct_codes[4 * 64],                  transfer_8to16sub(&dct_codes[4 * 64],
297                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
298                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
# Line 173  Line 304 
304                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,                                                          interpolate8x8_switch2(refv->u, ref->v, 8 * i, 8 * j,
305                                                                                                          dx, dy, edged_width / 2, rounding),                                                                                                          dx, dy, edged_width / 2, rounding),
306                                                          edged_width / 2);                                                          edged_width / 2);
307                    }
308    
309          } else {                                        // mode == MODE_INTER4V          } else {                                        // mode == MODE_INTER4V
310                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
# Line 183  Line 315 
315                  else                  else
316                          mvs = mb->mvs;                          mvs = mb->mvs;
317    
318                    if (reduced_resolution)
319                    {
320                            ///XXX: todo
321                    }else{
322    
323                  compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
324                                                            refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,                                                            refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,
325                                                            mvs[0].y, edged_width, quarterpel, rounding);                                                            mvs[0].y, edged_width, quarterpel, reduced_resolution, rounding);
326                  compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
327                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,
328                                                            mvs[1].x, mvs[1].y, edged_width, quarterpel, rounding);                                                                    mvs[1].x, mvs[1].y, edged_width, quarterpel, reduced_resolution, rounding);
329                  compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
330                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,
331                                                            mvs[2].x, mvs[2].y, edged_width, quarterpel, rounding);                                                                    mvs[2].x, mvs[2].y, edged_width, quarterpel, reduced_resolution, rounding);
332                  compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
333                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
334                                                            mvs[3].x, mvs[3].y, edged_width, quarterpel, rounding);                                                                    mvs[3].x, mvs[3].y, edged_width, quarterpel, reduced_resolution, rounding);
335                    }
336    
337                  if(quarterpel)                  if(quarterpel)
338                          sum = (mvs[0].x / 2) + (mvs[1].x / 2) + (mvs[2].x / 2) + (mvs[3].x / 2);                          sum = (mvs[0].x / 2) + (mvs[1].x / 2) + (mvs[2].x / 2) + (mvs[3].x / 2);
# Line 211  Line 349 
349                  dy = (sum >> 3) + roundtab_76[sum & 0xf];                  dy = (sum >> 3) + roundtab_76[sum & 0xf];
350    
351                  /* uv-block-based compensation */                  /* uv-block-based compensation */
352                    if (reduced_resolution)
353                    {
354                            //XXX: todo
355                    }else{
356                  transfer_8to16sub(&dct_codes[4 * 64],                  transfer_8to16sub(&dct_codes[4 * 64],
357                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,                                                          cur->u + 8 * j * edged_width / 2 + 8 * i,
358                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,                                                          interpolate8x8_switch2(refv->u, ref->u, 8 * i, 8 * j,
# Line 224  Line 366 
366                                                          edged_width / 2);                                                          edged_width / 2);
367          }          }
368  }  }
369    }
370    
371    
372  void  void
# Line 266  Line 409 
409    
410                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, f_ref->y, f_refh->y,                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, f_ref->y, f_refh->y,
411                                                    f_refv->y, f_refhv->y, 16 * i, 16 * j, dx,                                                    f_refv->y, f_refhv->y, 16 * i, 16 * j, dx,
412                                                    dy, edged_width, quarterpel, 0);                                                    dy, edged_width, quarterpel, 0 /*reduced_resolution*/, 0);
413    
414                  if (quarterpel) {                  if (quarterpel) {
415                          dx /= 2;                          dx /= 2;
# Line 304  Line 447 
447    
448                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, b_ref->y, b_refh->y,                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, b_ref->y, b_refh->y,
449                                                    b_refv->y, b_refhv->y, 16 * i, 16 * j, b_dx,                                                    b_refv->y, b_refhv->y, 16 * i, 16 * j, b_dx,
450                                                    b_dy, edged_width, quarterpel, 0);                                                    b_dy, edged_width, quarterpel, 0 /*reduced_resolution*/, 0);
451    
452                  if (quarterpel) {                  if (quarterpel) {
453                          b_dx /= 2;                          b_dx /= 2;

Legend:
Removed from v.658  
changed lines
  Added in v.701

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4