[cvs] / xvidcore / src / utils / mbtransquant.c Repository:
ViewVC logotype

Diff of /xvidcore/src/utils/mbtransquant.c

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

revision 1.21.2.2, Mon Mar 10 00:38:49 2003 UTC revision 1.22.2.1, Sun May 4 15:15:59 2003 UTC
# Line 71  Line 71 
71    
72  #define TOOSMALL_LIMIT  1       /* skip blocks having a coefficient sum below this value */  #define TOOSMALL_LIMIT  1       /* skip blocks having a coefficient sum below this value */
73    
74    static __inline void
75    MBfDCT(int16_t data[6 * 64])
76    {
77            start_timer();
78            fdct(&data[0 * 64]);
79            fdct(&data[1 * 64]);
80            fdct(&data[2 * 64]);
81            fdct(&data[3 * 64]);
82            fdct(&data[4 * 64]);
83            fdct(&data[5 * 64]);
84            stop_dct_timer();
85    }
86    
87    
88    static __inline uint32_t
89    QuantizeInterBlock(     int16_t qcoeff[64],
90                                            const int16_t data[64],
91                                            const uint32_t iQuant,
92                                            const uint32_t quant_type)
93    {
94            uint32_t sum;
95    
96            start_timer();
97            if (quant_type == H263_QUANT)
98                    sum = quant_inter(qcoeff, data, iQuant);
99            else
100                    sum = quant4_inter(qcoeff, data, iQuant);
101    
102            stop_quant_timer();
103            return sum;
104    }
105    
106  void  void
107  MBTransQuantIntra(const MBParam * pParam,  MBTransQuantIntra(const MBParam * const pParam,
108                                    FRAMEINFO * frame,                                  FRAMEINFO * const frame,
109                                    MACROBLOCK * pMB,                                  MACROBLOCK * const pMB,
110                                    const uint32_t x_pos,                                    const uint32_t x_pos,
111                                    const uint32_t y_pos,                                    const uint32_t y_pos,
112                                    int16_t data[6 * 64],                                    int16_t data[6 * 64],
# Line 82  Line 114 
114  {  {
115    
116          uint32_t stride = pParam->edged_width;          uint32_t stride = pParam->edged_width;
117          uint32_t stride2 = stride / 2;          const uint32_t stride2 = stride / 2;
118          uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8);          uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8);
119          uint32_t i;          int i;
120          uint32_t iQuant = frame->quant;          const uint32_t iQuant = pMB->quant;
121          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
122          IMAGE *pCurrent = &frame->image;          const IMAGE * const pCurrent = &frame->image;
123    
124          start_timer();          start_timer();
125          if ((frame->vop_flags & XVID_REDUCED))          if ((frame->global_flags & XVID_REDUCED))
126          {          {
127                  pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);                  pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);
128                  pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);                  pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);
# Line 119  Line 151 
151          /* XXX: rrv+interlacing is buggy */          /* XXX: rrv+interlacing is buggy */
152          start_timer();          start_timer();
153          pMB->field_dct = 0;          pMB->field_dct = 0;
154          if ((frame->vol_flags & XVID_INTERLACING) &&          if ((frame->global_flags & XVID_INTERLACING) &&
155                  (x_pos>0) && (x_pos<pParam->mb_width-1) &&                  (x_pos>0) && (x_pos<pParam->mb_width-1) &&
156                  (y_pos>0) && (y_pos<pParam->mb_height-1)) {                  (y_pos>0) && (y_pos<pParam->mb_height-1)) {
157                  pMB->field_dct = MBDecideFieldDCT(data);                  pMB->field_dct = MBDecideFieldDCT(data);
158          }          }
159          stop_interlacing_timer();          stop_interlacing_timer();
160    
161          for (i = 0; i < 6; i++) {          MBfDCT(data);
                 uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);  
162    
163                  start_timer();          for (i = 0; i < 6; i++) {
164                  fdct(&data[i * 64]);                  const uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
                 stop_dct_timer();  
165    
                 if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
166                          start_timer();                          start_timer();
167                    if (pParam->m_quant_type == H263_QUANT)
168                          quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);                          quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
169                          stop_quant_timer();                  else
                 } else {  
                         start_timer();  
170                          quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);                          quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
171                          stop_quant_timer();                          stop_quant_timer();
                 }  
172    
173                  /* speedup: dont decode when encoding only ivops */                  /* speedup: dont decode when encoding only ivops */
174                  if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0)                  if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0)
175                  {                  {
                         if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
176                                  start_timer();                                  start_timer();
177                            if (pParam->m_quant_type == H263_QUANT)
178                                  dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);                                  dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
179                                  stop_iquant_timer();                          else
                         } else {  
                                 start_timer();  
180                                  dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);                                  dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
181                                  stop_iquant_timer();                                  stop_iquant_timer();
                         }  
182    
183                          start_timer();                          start_timer();
184                          idct(&data[i * 64]);                          idct(&data[i * 64]);
# Line 172  Line 196 
196                  }                  }
197    
198                  start_timer();                  start_timer();
199                  if ((frame->vop_flags & XVID_REDUCED))                  if ((frame->global_flags & XVID_REDUCED)) {
                 {  
200                          copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);                          copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
201                          copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);                          copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
202                          copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);                          copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
203                          copy_upsampled_8x8_16to8(pY_Cur + next_block + 16, &data[3 * 64], stride);                          copy_upsampled_8x8_16to8(pY_Cur + next_block + 16, &data[3 * 64], stride);
204                          copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);                          copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
205                          copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);                          copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
   
206                  }else{                  }else{
207                          transfer_16to8copy(pY_Cur, &data[0 * 64], stride);                          transfer_16to8copy(pY_Cur, &data[0 * 64], stride);
208                          transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);                          transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);
# Line 194  Line 216 
216    
217  }  }
218    
   
219  uint8_t  uint8_t
220  MBTransQuantInter(const MBParam * pParam,  MBTransQuantInter(const MBParam * const pParam,
221                                    FRAMEINFO * frame,                                  FRAMEINFO * const frame,
222                                    MACROBLOCK * pMB,                                  MACROBLOCK * const pMB,
223                                    const uint32_t x_pos,                                    const uint32_t x_pos,
224                                    const uint32_t y_pos,                                    const uint32_t y_pos,
225                                    int16_t data[6 * 64],                                    int16_t data[6 * 64],
226                                    int16_t qcoeff[6 * 64])                                    int16_t qcoeff[6 * 64])
227  {  {
   
228          uint32_t stride = pParam->edged_width;          uint32_t stride = pParam->edged_width;
229          uint32_t stride2 = stride / 2;          const uint32_t stride2 = stride / 2;
230          uint32_t next_block = stride * ((frame->vop_flags & XVID_REDUCED)?16:8);          uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8);
231          uint32_t i;          int i;
232          uint32_t iQuant = frame->quant;          const uint32_t iQuant = pMB->quant;
233          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
234          uint8_t cbp = 0;          int cbp = 0;
235          uint32_t sum;          uint32_t sum;
236          IMAGE *pCurrent = &frame->image;          const IMAGE * const pCurrent = &frame->image;
237    
238          if ((frame->vop_flags & XVID_REDUCED))          if ((frame->global_flags & XVID_REDUCED)) {
         {  
239                  pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);                  pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);
240                  pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);                  pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);
241                  pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4);                  pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4);
# Line 228  Line 247 
247    
248          start_timer();          start_timer();
249          pMB->field_dct = 0;          pMB->field_dct = 0;
250          if ((frame->vol_flags & XVID_INTERLACING) &&          if ((frame->global_flags & XVID_INTERLACING) &&
251                  (x_pos>0) && (x_pos<pParam->mb_width-1) &&                  (x_pos>0) && (x_pos<pParam->mb_width-1) &&
252                  (y_pos>0) && (y_pos<pParam->mb_height-1)) {                  (y_pos>0) && (y_pos<pParam->mb_height-1)) {
253                  pMB->field_dct = MBDecideFieldDCT(data);                  pMB->field_dct = MBDecideFieldDCT(data);
254          }          }
255          stop_interlacing_timer();          stop_interlacing_timer();
256    
257          for (i = 0; i < 6; i++) {          MBfDCT(data);
                 uint32_t increase_limit = (iQuant == 1) ? 1 : 0;  
258    
259            for (i = 0; i < 6; i++) {
260                    const uint32_t limit = TOOSMALL_LIMIT + ((iQuant == 1) ? 1 : 0);
261                  /*                  /*
262                   *  no need to transfer 8->16-bit                   *  no need to transfer 8->16-bit
263                   * (this is performed already in motion compensation)                   * (this is performed already in motion compensation)
264                   */                   */
                 start_timer();  
                 fdct(&data[i * 64]);  
                 stop_dct_timer();  
265    
266                  if (!(pParam->vol_flags & XVID_MPEGQUANT)) {                  sum = QuantizeInterBlock(&qcoeff[i * 64], &data[i * 64], iQuant, pParam->m_quant_type);
267                          start_timer();  
268                          sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant);                  if(frame->global_flags & XVID_CARTOON_MODE) {
269                          stop_quant_timer();                          limit *= 3;
                 } else {  
                         start_timer();  
                         sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], iQuant);  
                         stop_quant_timer();  
270                  }                  }
271    
272                  if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) ||                  if (sum >= limit) {
                         (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) {  
273    
                         if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
274                                  start_timer();                                  start_timer();
275                            if (pParam->m_quant_type == H263_QUANT)
276                                  dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant);                                  dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
277                                  stop_iquant_timer();                          else
                         } else {  
                                 start_timer();  
278                                  dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant);                                  dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
279                                  stop_iquant_timer();                                  stop_iquant_timer();
                         }  
280    
281                          cbp |= 1 << (5 - i);                          cbp |= 1 << (5 - i);
282    
# Line 283  Line 292 
292          }          }
293    
294          start_timer();          start_timer();
295          if ((frame->vop_flags & XVID_REDUCED))          if ((frame->global_flags & XVID_REDUCED)) {
         {  
296                  if (cbp & 32)                  if (cbp & 32)
297                          add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);                          add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
298                  if (cbp & 16)                  if (cbp & 16)
# Line 313  Line 321 
321          }          }
322          stop_transfer_timer();          stop_transfer_timer();
323    
324          return cbp;          return (uint8_t) cbp;
   
 }  
   
 void  
 MBTransQuantIntra2(const MBParam * pParam,  
                                   FRAMEINFO * frame,  
                                   MACROBLOCK * pMB,  
                                   const uint32_t x_pos,  
                                   const uint32_t y_pos,  
                                   int16_t data[6 * 64],  
                                   int16_t qcoeff[6 * 64])  
 {  
         MBTrans(pParam,frame,pMB,x_pos,y_pos,data);  
         MBfDCT(pParam,frame,pMB,data);  
         MBQuantIntra(pParam,frame,pMB,data,qcoeff);  
         MBDeQuantIntra(pParam,frame->quant,data,qcoeff);  
         MBiDCT(data,0x3F);  
         MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,0x3F);  
 }  
   
   
 uint8_t  
 MBTransQuantInter2(const MBParam * pParam,  
                                   FRAMEINFO * frame,  
                                   MACROBLOCK * pMB,  
                                   const uint32_t x_pos,  
                                   const uint32_t y_pos,  
                                   int16_t data[6 * 64],  
                                   int16_t qcoeff[6 * 64])  
 {  
         uint8_t cbp;  
   
 /* there is no MBTrans for Inter block, that's done in motion compensation already */  
   
         MBfDCT(pParam,frame,pMB,data);  
         cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);  
         MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp);  
         MBiDCT(data,cbp);  
         MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp);  
   
         return cbp;  
325  }  }
326    
327  uint8_t  uint8_t
328  MBTransQuantInterBVOP(const MBParam * pParam,  MBTransQuantInterBVOP(const MBParam * pParam,
329                                    FRAMEINFO * frame,                                    FRAMEINFO * frame,
330                                    MACROBLOCK * pMB,                                    MACROBLOCK * pMB,
                                   const uint32_t x_pos,  
                                   const uint32_t y_pos,  
331                                    int16_t data[6 * 64],                                    int16_t data[6 * 64],
332                                    int16_t qcoeff[6 * 64])                                    int16_t qcoeff[6 * 64])
333  {  {
334          uint8_t cbp;          int cbp = 0;
   
 /* there is no MBTrans for Inter block, that's done in motion compensation already */  
   
         MBfDCT(pParam,frame,pMB,data);  
         cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);  
   
         /*  
          * History comment:  
          * we don't have to DeQuant, iDCT and Transfer back data for B-frames  
          */  
   
         /*  
          * As an exception to the previous rule, if we are willing to have extra  
          * stats then we have to DeQuant, iDCT and Transfer back the data :-)  
          */  
         if(frame->vop_flags & XVID_EXTRASTATS) {  
                 MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp);  
                 MBiDCT(data,cbp);  
                 MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp);  
         }  
   
         return cbp;  
 }  
   
   
 void  
 MBfDCT(const MBParam * pParam,  
                                   FRAMEINFO * frame,  
                                   MACROBLOCK * pMB,  
                                   int16_t data[6 * 64])  
 {  
         int i;  
   
         start_timer();  
         pMB->field_dct = 0;  
         if ((frame->vol_flags & XVID_INTERLACING)) {  
                 pMB->field_dct = MBDecideFieldDCT(data);  
         }  
         stop_interlacing_timer();  
   
         for (i = 0; i < 6; i++) {  
                 start_timer();  
                 fdct(&data[i * 64]);  
                 stop_dct_timer();  
         }  
 }  
   
 void  
 MBQuantDeQuantIntra(const MBParam * pParam,  
                                         FRAMEINFO * frame,  
                                         MACROBLOCK * pMB,  
                                         int16_t qcoeff[6 * 64],  
                                         int16_t data[6*64])  
 {  
335          int i;          int i;
         int iQuant = frame->quant;  
   
         start_timer();  
         pMB->field_dct = 0;  
         if ((frame->vol_flags & XVID_INTERLACING)) {  
                 pMB->field_dct = MBDecideFieldDCT(data);  
         }  
         stop_interlacing_timer();  
   
         for (i = 0; i < 6; i++) {  
                 uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);  
   
                 if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
                         start_timer();  
                         quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);  
                         stop_quant_timer();  
   
                         start_timer();  
                         dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);  
                         stop_iquant_timer();  
                 } else {  
                         start_timer();  
                         quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);  
                         stop_quant_timer();  
336    
337                          start_timer();  /* there is no MBTrans for Inter block, that's done in motion compensation already */
                         dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);  
                         stop_iquant_timer();  
                 }  
         }  
 }  
   
 void  
 MBQuantIntra(const MBParam * pParam,  
                          FRAMEINFO * frame,  
                          MACROBLOCK *pMB,  
                      int16_t qcoeff[6 * 64],  
                          int16_t data[6*64])  
 {  
         int i;  
         int iQuant = frame->quant;  
338    
339          start_timer();          start_timer();
340          pMB->field_dct = 0;          pMB->field_dct = 0;
341          if ((frame->vol_flags & XVID_INTERLACING)) {          if ((frame->global_flags & XVID_INTERLACING)) {
342                  pMB->field_dct = MBDecideFieldDCT(data);                  pMB->field_dct = MBDecideFieldDCT(data);
343          }          }
344          stop_interlacing_timer();          stop_interlacing_timer();
345    
346          for (i = 0; i < 6; i++) {          MBfDCT(data);
                 uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);  
   
                 if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
                         start_timer();  
                         quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);  
                         stop_quant_timer();  
                 } else {  
                         start_timer();  
                         quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);  
                         stop_quant_timer();  
                 }  
         }  
 }  
   
 void  
 MBDeQuantIntra(const MBParam * pParam,  
                            const int iQuant,  
                                   int16_t qcoeff[6 * 64],  
                                   int16_t data[6*64])  
 {  
         int i;  
347    
348          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
349                  uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);                  int codedecision = 0;
   
                 if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
                         start_timer();  
                         dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);  
                         stop_iquant_timer();  
                 } else {  
                         start_timer();  
                         dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);  
                         stop_iquant_timer();  
                 }  
         }  
 }  
   
 uint8_t  
 MBQuantInter(const MBParam * pParam,  
                          const int iQuant,  
                                   int16_t data[6 * 64],  
                                   int16_t qcoeff[6 * 64])  
 {  
350    
351          int i;                  int sum = QuantizeInterBlock(&qcoeff[i * 64], &data[i * 64], pMB->quant, pParam->m_quant_type);
         uint8_t cbp = 0;  
         int sum;  
352    
353          for (i = 0; i < 6; i++) {                  if(frame->global_flags & XVID_CARTOON_MODE) {
354                            limit *= 2;
                 if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
                         start_timer();  
                         sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant);  
                         stop_quant_timer();  
                 } else {  
                         start_timer();  
                         sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], iQuant);  
                         stop_quant_timer();  
355                  }                  }
356    
357                  if (sum >= TOOSMALL_LIMIT) {    // skip block ?                  if ((sum > 2) || (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0) ) codedecision = 1;
358                          cbp |= 1 << (5 - i);                  else {
359                  }                          if (pMB->mode == MODE_DIRECT || pMB->mode == MODE_DIRECT_NO4V) {
360          }                                  // dark blocks prevention for direct mode
361          return cbp;                                  if ( (qcoeff[i*64] < -1) || (qcoeff[i*64] > 0) ) codedecision = 1;
362                            } else
363                                    if (qcoeff[i*64] != 0) codedecision = 1; // not direct mode
364  }  }
365    
366  void                  if (codedecision) cbp |= 1 << (5 - i);
 MBDeQuantInter( const MBParam * pParam,  
                                 const int iQuant,  
                                   int16_t data[6 * 64],  
                                   int16_t qcoeff[6 * 64],  
                                   const uint8_t cbp)  
 {  
         int i;  
   
         for (i = 0; i < 6; i++) {  
                 if (cbp & (1 << (5 - i)))  
                 {  
                         if (!(pParam->vol_flags & XVID_MPEGQUANT)) {  
                                 start_timer();  
                                 dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant);  
                                 stop_iquant_timer();  
                         } else {  
                                 start_timer();  
                                 dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant);  
                                 stop_iquant_timer();  
                         }  
                 }  
         }  
367  }  }
368    
369  void  /* we don't have to DeQuant, iDCT and Transfer back data for B-frames if we don't reconstruct this frame */
370  MBiDCT( int16_t data[6 * 64],  /* warning: reconstruction not supported yet */
371                  const uint8_t cbp)          return (uint8_t) cbp;
 {  
         int i;  
   
         for (i = 0; i < 6; i++) {  
                 if (cbp & (1 << (5 - i)))  
                 {  
                         start_timer();  
                         idct(&data[i * 64]);  
                         stop_idct_timer();  
   
                 }  
         }  
 }  
   
   
 void  
 MBTrans(const MBParam * pParam,  
                                   FRAMEINFO * frame,  
                                   MACROBLOCK * pMB,  
                                   const uint32_t x_pos,  
                                   const uint32_t y_pos,  
                                   int16_t data[6 * 64])  
 {  
         uint32_t stride = pParam->edged_width;  
         uint32_t stride2 = stride / 2;  
         uint32_t next_block = stride * 8;  
         uint8_t *pY_Cur, *pU_Cur, *pV_Cur;  
         IMAGE *pCurrent = &frame->image;  
   
         pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);  
         pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);  
         pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);  
   
         start_timer();  
         transfer_8to16copy(&data[0 * 64], pY_Cur, stride);  
         transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride);  
         transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride);  
         transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride);  
         transfer_8to16copy(&data[4 * 64], pU_Cur, stride2);  
         transfer_8to16copy(&data[5 * 64], pV_Cur, stride2);  
         stop_transfer_timer();  
372  }  }
373    
 void  
 MBTransAdd(const MBParam * pParam,  
                                   FRAMEINFO * frame,  
                                   MACROBLOCK * pMB,  
                                   const uint32_t x_pos,  
                                   const uint32_t y_pos,  
                                   int16_t data[6 * 64],  
                                   const uint8_t cbp)  
 {  
         uint8_t *pY_Cur, *pU_Cur, *pV_Cur;  
         uint32_t stride = pParam->edged_width;  
         uint32_t stride2 = stride / 2;  
         uint32_t next_block = stride * 8;  
         IMAGE *pCurrent = &frame->image;  
   
         pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);  
         pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);  
         pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);  
   
         if (pMB->field_dct) {  
                 next_block = stride;  
                 stride *= 2;  
         }  
   
         start_timer();  
         if (cbp & 32)  
                 transfer_16to8add(pY_Cur, &data[0 * 64], stride);  
         if (cbp & 16)  
                 transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);  
         if (cbp & 8)  
                 transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);  
         if (cbp & 4)  
                 transfer_16to8add(pY_Cur + next_block + 8, &data[3 * 64], stride);  
         if (cbp & 2)  
                 transfer_16to8add(pU_Cur, &data[4 * 64], stride2);  
         if (cbp & 1)  
                 transfer_16to8add(pV_Cur, &data[5 * 64], stride2);  
         stop_transfer_timer();  
 }  
   
   
   
374  /* permute block and return field dct choice */  /* permute block and return field dct choice */
375    
376    static uint32_t
 uint32_t  
377  MBDecideFieldDCT(int16_t data[6 * 64])  MBDecideFieldDCT(int16_t data[6 * 64])
378  {  {
379          uint32_t field = MBFieldTest(data);          const uint32_t field = MBFieldTest(data);
380            if (field) MBFrameToField(data);
         if (field) {  
                 MBFrameToField(data);  
         }  
381    
382          return field;          return field;
383  }  }
384    
   
385  /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */  /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */
386    
387  uint32_t  uint32_t

Legend:
Removed from v.1.21.2.2  
changed lines
  Added in v.1.22.2.1

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