[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 530, Mon Sep 23 20:36:02 2002 UTC revision 588, Thu Oct 10 12:16:00 2002 UTC
# Line 1  Line 1 
1    // 04.10.2002   added qpel support to MBMotionCompensation
2  // 01.05.2002   updated MBMotionCompensationBVOP  // 01.05.2002   updated MBMotionCompensationBVOP
3  // 14.04.2002   bframe compensation  // 14.04.2002   bframe compensation
4    
# Line 12  Line 13 
13    
14    
15  static __inline void  static __inline void
16  compensate8x8_halfpel(int16_t * const dct_codes,  compensate16x16_interpolate(int16_t * const dct_codes,
17                                            uint8_t * const cur,                                            uint8_t * const cur,
18                                            const uint8_t * const ref,                                            const uint8_t * const ref,
19                                            const uint8_t * const refh,                                            const uint8_t * const refh,
# Line 21  Line 22 
22                                            const uint32_t x,                                            const uint32_t x,
23                                            const uint32_t y,                                            const uint32_t y,
24                                            const int32_t dx,                                            const int32_t dx,
25                                            const int dy,                                                      const int32_t dy,
26                                            const uint32_t stride)                                                      const uint32_t stride,
27                                                        const uint32_t quarterpel,
28                                                        const uint32_t rounding)
29    {
30            if(quarterpel) {
31                    interpolate16x16_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
32                            (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
33    
34                    transfer_8to16sub(dct_codes, cur + y*stride + x,
35                                                      refv + y*stride + x, stride);
36                    transfer_8to16sub(dct_codes+64, cur + y*stride + x + 8,
37                                                      refv + y*stride + x + 8, stride);
38                    transfer_8to16sub(dct_codes+128, cur + y*stride + x + 8*stride,
39                                                      refv + y*stride + x + 8*stride, stride);
40                    transfer_8to16sub(dct_codes+192, cur + y*stride + x + 8*stride + 8,
41                                                      refv + y*stride + x + 8*stride+8, stride);
42    
43            }
44            else
45            {
46                    const uint8_t * reference;
47    
48                    switch (((dx & 1) << 1) + (dy & 1))     // ((dx%2)?2:0)+((dy%2)?1:0)
49                    {
50                    case 0: reference = ref + ((y + dy / 2) * stride + x + dx / 2); break;
51                    case 1: reference = refv + ((y + (dy-1) / 2) * stride + x + dx / 2); break;
52                    case 2: reference = refh + ((y + dy / 2) * stride + x + (dx-1) / 2); break;
53                    default:                                        // case 3:
54                            reference = refhv + ((y + (dy-1) / 2) * stride + x + (dx-1) / 2); break;
55                    }
56                    transfer_8to16sub(dct_codes, cur + y * stride + x,
57                                                              reference, stride);
58                    transfer_8to16sub(dct_codes+64, cur + y * stride + x + 8,
59                                                              reference + 8, stride);
60                    transfer_8to16sub(dct_codes+128, cur + y * stride + x + 8*stride,
61                                                              reference + 8*stride, stride);
62                    transfer_8to16sub(dct_codes+192, cur + y * stride + x + 8*stride+8,
63                                                              reference + 8*stride + 8, stride);
64            }
65    }
66    
67    static __inline void
68    compensate8x8_interpolate(int16_t * const dct_codes,
69                                                      uint8_t * const cur,
70                                                      const uint8_t * const ref,
71                                                      const uint8_t * const refh,
72                                                      const uint8_t * const refv,
73                                                      const uint8_t * const refhv,
74                                                      const uint32_t x,
75                                                      const uint32_t y,
76                                                      const int32_t dx,
77                                                      const int32_t dy,
78                                                      const uint32_t stride,
79                                                      const uint32_t quarterpel,
80                                                      const uint32_t rounding)
81    {
82            if(quarterpel) {
83                    interpolate8x8_quarterpel((uint8_t *) refv, (uint8_t *) ref, (uint8_t *) refh,
84                            (uint8_t *) refh + 64, (uint8_t *) refhv, x, y, dx, dy, stride, rounding);
85    
86                    transfer_8to16sub(dct_codes, cur + y*stride + x,
87                                                      refv + y*stride + x, stride);
88            }
89            else
90  {  {
91          const uint8_t * reference;          const uint8_t * reference;
92    
# Line 37  Line 101 
101          transfer_8to16sub(dct_codes, cur + y * stride + x,          transfer_8to16sub(dct_codes, cur + y * stride + x,
102                                                    reference, stride);                                                    reference, stride);
103  }  }
104    }
105    
106  void  void
107  MBMotionCompensation(MACROBLOCK * const mb,  MBMotionCompensation(MACROBLOCK * const mb,
# Line 51  Line 116 
116                                           const uint32_t width,                                           const uint32_t width,
117                                           const uint32_t height,                                           const uint32_t height,
118                                           const uint32_t edged_width,                                           const uint32_t edged_width,
119                                             const uint32_t quarterpel,
120                                           const uint32_t rounding)                                           const uint32_t rounding)
121  {  {
         static const uint32_t roundtab[16] =  
                 { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };  
   
122          if (mb->mode == MODE_NOT_CODED) {          if (mb->mode == MODE_NOT_CODED) {
123                  transfer8x8_copy(cur->y + 16 * (i + j * edged_width),                  transfer8x8_copy(cur->y + 16 * (i + j * edged_width),
124                                                          ref->y + 16 * (i + j * edged_width),                                                          ref->y + 16 * (i + j * edged_width),
# Line 83  Line 146 
146                  int32_t dx = mb->mvs[0].x;                  int32_t dx = mb->mvs[0].x;
147                  int32_t dy = mb->mvs[0].y;                  int32_t dy = mb->mvs[0].y;
148    
149                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  if(quarterpel) {
150                                                            refv->y, refhv->y, 16 * i, 16 * j, dx, dy,                          dx = mb->qmvs[0].x;
151                                                            edged_width);                          dy = mb->qmvs[0].y;
152                  compensate8x8_halfpel(&dct_codes[1 * 64], cur->y, ref->y, refh->y,                  }
153                                                            refv->y, refhv->y, 16 * i + 8, 16 * j, dx, dy,  
154                                                            edged_width);                  compensate16x16_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
155                  compensate8x8_halfpel(&dct_codes[2 * 64], cur->y, ref->y, refh->y,                                                            refv->y, refhv->y, 16 * i, 16 * j, dx,
156                                                            refv->y, refhv->y, 16 * i, 16 * j + 8, dx, dy,                                                            dy, edged_width, quarterpel, rounding);
157                                                            edged_width);  
158                  compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,                  if (quarterpel)
159                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8, dx,                  {
160                                                            dy, edged_width);                          dx = (dx >> 1) | (dx & 1);
161                            dy = (dy >> 1) | (dy & 1);
162                    }
163    
164                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;                  dx = (dx & 3) ? (dx >> 1) | 1 : dx / 2;
165                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;                  dy = (dy & 3) ? (dy >> 1) | 1 : dy / 2;
# Line 114  Line 179 
179    
180          } else {                                        // mode == MODE_INTER4V          } else {                                        // mode == MODE_INTER4V
181                  int32_t sum, dx, dy;                  int32_t sum, dx, dy;
182                    VECTOR *mvs;
183    
184                  compensate8x8_halfpel(&dct_codes[0 * 64], cur->y, ref->y, refh->y,                  if(quarterpel)
185                                                            refv->y, refhv->y, 16 * i, 16 * j, mb->mvs[0].x,                          mvs = mb->qmvs;
186                                                            mb->mvs[0].y, edged_width);                  else
187                  compensate8x8_halfpel(&dct_codes[1 * 64], cur->y, ref->y, refh->y,                          mvs = mb->mvs;
188    
189                    compensate8x8_interpolate(&dct_codes[0 * 64], cur->y, ref->y, refh->y,
190                                                              refv->y, refhv->y, 16 * i, 16 * j, mvs[0].x,
191                                                              mvs[0].y, edged_width, quarterpel, rounding);
192                    compensate8x8_interpolate(&dct_codes[1 * 64], cur->y, ref->y, refh->y,
193                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j,
194                                                            mb->mvs[1].x, mb->mvs[1].y, edged_width);                                                            mvs[1].x, mvs[1].y, edged_width, quarterpel, rounding);
195                  compensate8x8_halfpel(&dct_codes[2 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[2 * 64], cur->y, ref->y, refh->y,
196                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i, 16 * j + 8,
197                                                            mb->mvs[2].x, mb->mvs[2].y, edged_width);                                                            mvs[2].x, mvs[2].y, edged_width, quarterpel, rounding);
198                  compensate8x8_halfpel(&dct_codes[3 * 64], cur->y, ref->y, refh->y,                  compensate8x8_interpolate(&dct_codes[3 * 64], cur->y, ref->y, refh->y,
199                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,                                                            refv->y, refhv->y, 16 * i + 8, 16 * j + 8,
200                                                            mb->mvs[3].x, mb->mvs[3].y, edged_width);                                                            mvs[3].x, mvs[3].y, edged_width, quarterpel, rounding);
201    
202                    sum = mvs[0].x + mvs[1].x + mvs[2].x + mvs[3].x;
203    
204                    if(quarterpel)
205                            sum /= 2;
206    
                 sum = mb->mvs[0].x + mb->mvs[1].x + mb->mvs[2].x + mb->mvs[3].x;  
207                  dx = (sum ? SIGN(sum) *                  dx = (sum ? SIGN(sum) *
208                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
209    
210                  sum = mb->mvs[0].y + mb->mvs[1].y + mb->mvs[2].y + mb->mvs[3].y;                  sum = mvs[0].y + mvs[1].y + mvs[2].y + mvs[3].y;
211    
212                    if(quarterpel)
213                            sum /= 2;
214    
215                  dy = (sum ? SIGN(sum) *                  dy = (sum ? SIGN(sum) *
216                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);                            (roundtab[ABS(sum) % 16] + (ABS(sum) / 16) * 2) : 0);
217    

Legend:
Removed from v.530  
changed lines
  Added in v.588

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