[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.7, Wed Jun 12 20:38:41 2002 UTC revision 1.11.2.6, Mon Dec 9 10:47:05 2002 UTC
# Line 42  Line 42 
42    *                                                                            *    *                                                                            *
43    *  Revision history:                                                         *    *  Revision history:                                                         *
44    *                                                                            *    *                                                                            *
45    *  29.03.2002 interlacing speedup - used transfer strides instead of    *  29.03.2002 interlacing speedup - used transfer strides instead of             *
46    *             manual field-to-frame conversion    *             manual field-to-frame conversion                                                           *
47    *  26.03.2002 interlacing support - moved transfers outside loops    *  26.03.2002 interlacing support - moved transfers outside loops                        *
48    *  22.12.2001 get_dc_scaler() moved to common.h    *  22.12.2001 get_dc_scaler() moved to common.h                                                          *
49    *  19.11.2001 introduced coefficient thresholding (Isibaar)                  *    *  19.11.2001 introduced coefficient thresholding (Isibaar)                  *
50    *  17.11.2001 initial version                                                *    *  17.11.2001 initial version                                                *
51    *                                                                            *    *                                                                            *
# Line 65  Line 65 
65  #include "../quant/quant_h263.h"  #include "../quant/quant_h263.h"
66  #include "../encoder.h"  #include "../encoder.h"
67    
68    #include "../image/reduced.h"
69    
70    MBFIELDTEST_PTR MBFieldTest;
71    
72  #define MIN(X, Y) ((X)<(Y)?(X):(Y))  #define MIN(X, Y) ((X)<(Y)?(X):(Y))
73  #define MAX(X, Y) ((X)>(Y)?(X):(Y))  #define MAX(X, Y) ((X)>(Y)?(X):(Y))
74    
75  #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 */
76    
 /* this isnt pretty, but its better than 20 ifdefs */  
   
77  void  void
78  MBTransQuantIntra(const MBParam * pParam,  MBTransQuantIntra(const MBParam * pParam,
79                                    FRAMEINFO * frame,                                    FRAMEINFO * frame,
# Line 84  Line 86 
86    
87          uint32_t stride = pParam->edged_width;          uint32_t stride = pParam->edged_width;
88          uint32_t stride2 = stride / 2;          uint32_t stride2 = stride / 2;
89          uint32_t next_block = stride * 8;          uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8);
90          uint32_t i;          uint32_t i;
91          uint32_t iQuant = frame->quant;          uint32_t iQuant = frame->quant;
92          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
93          IMAGE *pCurrent = &frame->image;          IMAGE *pCurrent = &frame->image;
94    
95            start_timer();
96            if ((frame->global_flags & XVID_REDUCED))
97            {
98                    pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);
99                    pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);
100                    pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4);
101    
102                    filter_18x18_to_8x8(&data[0 * 64], pY_Cur, stride);
103                    filter_18x18_to_8x8(&data[1 * 64], pY_Cur + 16, stride);
104                    filter_18x18_to_8x8(&data[2 * 64], pY_Cur + next_block, stride);
105                    filter_18x18_to_8x8(&data[3 * 64], pY_Cur + next_block + 16, stride);
106                    filter_18x18_to_8x8(&data[4 * 64], pU_Cur, stride2);
107                    filter_18x18_to_8x8(&data[5 * 64], pV_Cur, stride2);
108            }else{
109          pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);          pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
110          pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
111          pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
112    
         start_timer();  
113          transfer_8to16copy(&data[0 * 64], pY_Cur, stride);          transfer_8to16copy(&data[0 * 64], pY_Cur, stride);
114          transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride);          transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride);
115          transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride);          transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride);
116          transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride);          transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride);
117          transfer_8to16copy(&data[4 * 64], pU_Cur, stride2);          transfer_8to16copy(&data[4 * 64], pU_Cur, stride2);
118          transfer_8to16copy(&data[5 * 64], pV_Cur, stride2);          transfer_8to16copy(&data[5 * 64], pV_Cur, stride2);
119            }
120          stop_transfer_timer();          stop_transfer_timer();
121    
122            /* XXX: rrv+interlacing is buggy */
123          start_timer();          start_timer();
124          pMB->field_dct = 0;          pMB->field_dct = 0;
125          if ((frame->global_flags & XVID_INTERLACING)) {          if ((frame->global_flags & XVID_INTERLACING) &&
126                    (x_pos>0) && (x_pos<pParam->mb_width-1) &&
127                    (y_pos>0) && (y_pos<pParam->mb_height-1)) {
128                  pMB->field_dct = MBDecideFieldDCT(data);                  pMB->field_dct = MBDecideFieldDCT(data);
129          }          }
130          stop_interlacing_timer();          stop_interlacing_timer();
# Line 121  Line 140 
140                          start_timer();                          start_timer();
141                          quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);                          quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
142                          stop_quant_timer();                          stop_quant_timer();
   
                         start_timer();  
                         dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);  
                         stop_iquant_timer();  
143                  } else {                  } else {
144                          start_timer();                          start_timer();
145                          quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);                          quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
146                          stop_quant_timer();                          stop_quant_timer();
147                    }
148    
149                    /* speedup: dont decode when encoding only ivops */
150                    if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0)
151                    {
152                            if (pParam->m_quant_type == H263_QUANT) {
153                                    start_timer();
154                                    dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
155                                    stop_iquant_timer();
156                            } else {
157                          start_timer();                          start_timer();
158                          dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);                          dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
159                          stop_iquant_timer();                          stop_iquant_timer();
# Line 139  Line 163 
163                  idct(&data[i * 64]);                  idct(&data[i * 64]);
164                  stop_idct_timer();                  stop_idct_timer();
165          }          }
166            }
167    
168            /* speedup: dont decode when encoding only ivops */
169            if (pParam->iMaxKeyInterval != 1 || pParam->max_bframes > 0)
170            {
171    
172          if (pMB->field_dct) {          if (pMB->field_dct) {
173                  next_block = stride;                  next_block = stride;
# Line 146  Line 175 
175          }          }
176    
177          start_timer();          start_timer();
178                    if ((frame->global_flags & XVID_REDUCED))
179                    {
180                            copy_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
181                            copy_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
182                            copy_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
183                            copy_upsampled_8x8_16to8(pY_Cur + next_block + 16, &data[3 * 64], stride);
184                            copy_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
185                            copy_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
186    
187                    }else{
188          transfer_16to8copy(pY_Cur, &data[0 * 64], stride);          transfer_16to8copy(pY_Cur, &data[0 * 64], stride);
189          transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);          transfer_16to8copy(pY_Cur + 8, &data[1 * 64], stride);
190          transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride);          transfer_16to8copy(pY_Cur + next_block, &data[2 * 64], stride);
191          transfer_16to8copy(pY_Cur + next_block + 8, &data[3 * 64], stride);          transfer_16to8copy(pY_Cur + next_block + 8, &data[3 * 64], stride);
192          transfer_16to8copy(pU_Cur, &data[4 * 64], stride2);          transfer_16to8copy(pU_Cur, &data[4 * 64], stride2);
193          transfer_16to8copy(pV_Cur, &data[5 * 64], stride2);          transfer_16to8copy(pV_Cur, &data[5 * 64], stride2);
194                    }
195          stop_transfer_timer();          stop_transfer_timer();
196            }
197    
198  }  }
199    
# Line 169  Line 210 
210    
211          uint32_t stride = pParam->edged_width;          uint32_t stride = pParam->edged_width;
212          uint32_t stride2 = stride / 2;          uint32_t stride2 = stride / 2;
213          uint32_t next_block = stride * 8;          uint32_t next_block = stride * ((frame->global_flags & XVID_REDUCED)?16:8);
214          uint32_t i;          uint32_t i;
215          uint32_t iQuant = frame->quant;          uint32_t iQuant = frame->quant;
216          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
# Line 177  Line 218 
218          uint32_t sum;          uint32_t sum;
219          IMAGE *pCurrent = &frame->image;          IMAGE *pCurrent = &frame->image;
220    
221            if ((frame->global_flags & XVID_REDUCED))
222            {
223                    pY_Cur = pCurrent->y + (y_pos << 5) * stride + (x_pos << 5);
224                    pU_Cur = pCurrent->u + (y_pos << 4) * stride2 + (x_pos << 4);
225                    pV_Cur = pCurrent->v + (y_pos << 4) * stride2 + (x_pos << 4);
226            }else{
227          pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);          pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
228          pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
229          pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
230            }
231    
232          start_timer();          start_timer();
233          pMB->field_dct = 0;          pMB->field_dct = 0;
234          if ((frame->global_flags & XVID_INTERLACING)) {          if ((frame->global_flags & XVID_INTERLACING) &&
235                    (x_pos>0) && (x_pos<pParam->mb_width-1) &&
236                    (y_pos>0) && (y_pos<pParam->mb_height-1)) {
237                  pMB->field_dct = MBDecideFieldDCT(data);                  pMB->field_dct = MBDecideFieldDCT(data);
238          }          }
239          stop_interlacing_timer();          stop_interlacing_timer();
240    
241          for (i = 0; i < 6; i++) {          for (i = 0; i < 6; i++) {
242                    uint32_t increase_limit = (iQuant == 1) ? 1 : 0;
243    
244                  /*                  /*
245                   *  no need to transfer 8->16-bit                   *  no need to transfer 8->16-bit
246                   * (this is performed already in motion compensation)                   * (this is performed already in motion compensation)
# Line 207  Line 259 
259                          stop_quant_timer();                          stop_quant_timer();
260                  }                  }
261    
262                  if (sum >= TOOSMALL_LIMIT) {    // skip block ?                  if ((sum >= TOOSMALL_LIMIT + increase_limit) || (qcoeff[i*64] != 0) ||
263                            (qcoeff[i*64+1] != 0) || (qcoeff[i*64+8] != 0)) {
264    
265                          if (pParam->m_quant_type == H263_QUANT) {                          if (pParam->m_quant_type == H263_QUANT) {
266                                  start_timer();                                  start_timer();
# Line 233  Line 286 
286          }          }
287    
288          start_timer();          start_timer();
289            if ((frame->global_flags & XVID_REDUCED))
290            {
291                    if (cbp & 32)
292                            add_upsampled_8x8_16to8(pY_Cur, &data[0 * 64], stride);
293                    if (cbp & 16)
294                            add_upsampled_8x8_16to8(pY_Cur + 16, &data[1 * 64], stride);
295                    if (cbp & 8)
296                            add_upsampled_8x8_16to8(pY_Cur + next_block, &data[2 * 64], stride);
297                    if (cbp & 4)
298                            add_upsampled_8x8_16to8(pY_Cur + 16 + next_block, &data[3 * 64], stride);
299                    if (cbp & 2)
300                            add_upsampled_8x8_16to8(pU_Cur, &data[4 * 64], stride2);
301                    if (cbp & 1)
302                            add_upsampled_8x8_16to8(pV_Cur, &data[5 * 64], stride2);
303            }else{
304          if (cbp & 32)          if (cbp & 32)
305                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);                  transfer_16to8add(pY_Cur, &data[0 * 64], stride);
306          if (cbp & 16)          if (cbp & 16)
# Line 245  Line 313 
313                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);                  transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
314          if (cbp & 1)          if (cbp & 1)
315                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);                  transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
316            }
317          stop_transfer_timer();          stop_transfer_timer();
318    
319          return cbp;          return cbp;
320    
321  }  }
322    
323    void
324    MBTransQuantIntra2(const MBParam * pParam,
325                                      FRAMEINFO * frame,
326                                      MACROBLOCK * pMB,
327                                      const uint32_t x_pos,
328                                      const uint32_t y_pos,
329                                      int16_t data[6 * 64],
330                                      int16_t qcoeff[6 * 64])
331    {
332            MBTrans(pParam,frame,pMB,x_pos,y_pos,data);
333            MBfDCT(pParam,frame,pMB,data);
334            MBQuantIntra(pParam,frame,pMB,data,qcoeff);
335            MBDeQuantIntra(pParam,frame->quant,data,qcoeff);
336            MBiDCT(data,0x3F);
337            MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,0x3F);
338    }
339    
340    
341  /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */  uint8_t
342    MBTransQuantInter2(const MBParam * pParam,
343                                      FRAMEINFO * frame,
344                                      MACROBLOCK * pMB,
345                                      const uint32_t x_pos,
346                                      const uint32_t y_pos,
347                                      int16_t data[6 * 64],
348                                      int16_t qcoeff[6 * 64])
349    {
350            uint8_t cbp;
351    
352    /* there is no MBTrans for Inter block, that's done in motion compensation already */
353    
354            MBfDCT(pParam,frame,pMB,data);
355            cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);
356            MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp);
357            MBiDCT(data,cbp);
358            MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp);
359    
360            return cbp;
361    }
362    
363    uint8_t
364    MBTransQuantInterBVOP(const MBParam * pParam,
365                                      FRAMEINFO * frame,
366                                      MACROBLOCK * pMB,
367                                      int16_t data[6 * 64],
368                                      int16_t qcoeff[6 * 64])
369    {
370            uint8_t cbp;
371    
372    /* there is no MBTrans for Inter block, that's done in motion compensation already */
373    
374            MBfDCT(pParam,frame,pMB,data);
375            cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);
376    
377    /* we don't have to DeQuant, iDCT and Transfer back data for B-frames */
378    
379            return cbp;
380    }
381    
382    
383    void
384    MBfDCT(const MBParam * pParam,
385                                      FRAMEINFO * frame,
386                                      MACROBLOCK * pMB,
387                                      int16_t data[6 * 64])
388    {
389            int i;
390    
391            start_timer();
392            pMB->field_dct = 0;
393            if ((frame->global_flags & XVID_INTERLACING)) {
394                    pMB->field_dct = MBDecideFieldDCT(data);
395            }
396            stop_interlacing_timer();
397    
398            for (i = 0; i < 6; i++) {
399                    start_timer();
400                    fdct(&data[i * 64]);
401                    stop_dct_timer();
402            }
403    }
404    
405    void
406    MBQuantDeQuantIntra(const MBParam * pParam,
407                                            FRAMEINFO * frame,
408                                            MACROBLOCK * pMB,
409                                            int16_t qcoeff[6 * 64],
410                                            int16_t data[6*64])
411    {
412            int i;
413            int iQuant = frame->quant;
414    
415            start_timer();
416            pMB->field_dct = 0;
417            if ((frame->global_flags & XVID_INTERLACING)) {
418                    pMB->field_dct = MBDecideFieldDCT(data);
419            }
420            stop_interlacing_timer();
421    
422            for (i = 0; i < 6; i++) {
423                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
424    
425                    if (pParam->m_quant_type == H263_QUANT) {
426                            start_timer();
427                            quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
428                            stop_quant_timer();
429    
430                            start_timer();
431                            dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
432                            stop_iquant_timer();
433                    } else {
434                            start_timer();
435                            quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
436                            stop_quant_timer();
437    
438                            start_timer();
439                            dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
440                            stop_iquant_timer();
441                    }
442            }
443    }
444    
445    void
446    MBQuantIntra(const MBParam * pParam,
447                             FRAMEINFO * frame,
448                             MACROBLOCK *pMB,
449                         int16_t qcoeff[6 * 64],
450                             int16_t data[6*64])
451    {
452            int i;
453            int iQuant = frame->quant;
454    
455            start_timer();
456            pMB->field_dct = 0;
457            if ((frame->global_flags & XVID_INTERLACING)) {
458                    pMB->field_dct = MBDecideFieldDCT(data);
459            }
460            stop_interlacing_timer();
461    
462            for (i = 0; i < 6; i++) {
463                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
464    
465                    if (pParam->m_quant_type == H263_QUANT) {
466                            start_timer();
467                            quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
468                            stop_quant_timer();
469                    } else {
470                            start_timer();
471                            quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
472                            stop_quant_timer();
473                    }
474            }
475    }
476    
477    void
478    MBDeQuantIntra(const MBParam * pParam,
479                               const int iQuant,
480                                      int16_t qcoeff[6 * 64],
481                                      int16_t data[6*64])
482    {
483            int i;
484    
485            for (i = 0; i < 6; i++) {
486                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
487    
488                    if (pParam->m_quant_type == H263_QUANT) {
489                            start_timer();
490                            dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
491                            stop_iquant_timer();
492                    } else {
493                            start_timer();
494                            dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
495                            stop_iquant_timer();
496                    }
497            }
498    }
499    
500    uint8_t
501    MBQuantInter(const MBParam * pParam,
502                             const int iQuant,
503                                      int16_t data[6 * 64],
504                                      int16_t qcoeff[6 * 64])
505    {
506    
507            int i;
508            uint8_t cbp = 0;
509            int sum;
510    
511            for (i = 0; i < 6; i++) {
512    
513                    if (pParam->m_quant_type == 0) {
514                            start_timer();
515                            sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant);
516                            stop_quant_timer();
517                    } else {
518                            start_timer();
519                            sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], iQuant);
520                            stop_quant_timer();
521                    }
522    
523                    if (sum >= TOOSMALL_LIMIT) {    // skip block ?
524                            cbp |= 1 << (5 - i);
525                    }
526            }
527            return cbp;
528    }
529    
530    void
531    MBDeQuantInter( const MBParam * pParam,
532                                    const int iQuant,
533                                      int16_t data[6 * 64],
534                                      int16_t qcoeff[6 * 64],
535                                      const uint8_t cbp)
536    {
537            int i;
538    
539            for (i = 0; i < 6; i++) {
540                    if (cbp & (1 << (5 - i)))
541                    {
542                            if (pParam->m_quant_type == H263_QUANT) {
543                                    start_timer();
544                                    dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
545                                    stop_iquant_timer();
546                            } else {
547                                    start_timer();
548                                    dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
549                                    stop_iquant_timer();
550                            }
551                    }
552            }
553    }
554    
555    void
556    MBiDCT( int16_t data[6 * 64],
557                    const uint8_t cbp)
558    {
559            int i;
560    
561            for (i = 0; i < 6; i++) {
562                    if (cbp & (1 << (5 - i)))
563                    {
564                            start_timer();
565                            idct(&data[i * 64]);
566                            stop_idct_timer();
567    
568                    }
569            }
570    }
571    
572    
573    void
574    MBTrans(const MBParam * pParam,
575                                      FRAMEINFO * frame,
576                                      MACROBLOCK * pMB,
577                                      const uint32_t x_pos,
578                                      const uint32_t y_pos,
579                                      int16_t data[6 * 64])
580    {
581            uint32_t stride = pParam->edged_width;
582            uint32_t stride2 = stride / 2;
583            uint32_t next_block = stride * 8;
584            uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
585            IMAGE *pCurrent = &frame->image;
586    
587            pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
588            pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
589            pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
590    
591            start_timer();
592            transfer_8to16copy(&data[0 * 64], pY_Cur, stride);
593            transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride);
594            transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride);
595            transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride);
596            transfer_8to16copy(&data[4 * 64], pU_Cur, stride2);
597            transfer_8to16copy(&data[5 * 64], pV_Cur, stride2);
598            stop_transfer_timer();
599    }
600    
601    void
602    MBTransAdd(const MBParam * pParam,
603                                      FRAMEINFO * frame,
604                                      MACROBLOCK * pMB,
605                                      const uint32_t x_pos,
606                                      const uint32_t y_pos,
607                                      int16_t data[6 * 64],
608                                      const uint8_t cbp)
609    {
610            uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
611            uint32_t stride = pParam->edged_width;
612            uint32_t stride2 = stride / 2;
613            uint32_t next_block = stride * 8;
614            IMAGE *pCurrent = &frame->image;
615    
616            pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
617            pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
618            pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
619    
620            if (pMB->field_dct) {
621                    next_block = stride;
622                    stride *= 2;
623            }
624    
625            start_timer();
626            if (cbp & 32)
627                    transfer_16to8add(pY_Cur, &data[0 * 64], stride);
628            if (cbp & 16)
629                    transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);
630            if (cbp & 8)
631                    transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);
632            if (cbp & 4)
633                    transfer_16to8add(pY_Cur + next_block + 8, &data[3 * 64], stride);
634            if (cbp & 2)
635                    transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
636            if (cbp & 1)
637                    transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
638            stop_transfer_timer();
639    }
640    
641    
642    
643    /* permute block and return field dct choice */
644    
645    
646  uint32_t  uint32_t
647  MBDecideFieldDCT(int16_t data[6 * 64])  MBDecideFieldDCT(int16_t data[6 * 64])
648  {  {
649            uint32_t field = MBFieldTest(data);
650    
651            if (field) {
652                    MBFrameToField(data);
653            }
654    
655            return field;
656    }
657    
658    
659    /* if sum(diff between field lines) < sum(diff between frame lines), use field dct */
660    
661    uint32_t
662    MBFieldTest_c(int16_t data[6 * 64])
663    {
664          const uint8_t blocks[] =          const uint8_t blocks[] =
665                  { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 };                  { 0 * 64, 0 * 64, 0 * 64, 0 * 64, 2 * 64, 2 * 64, 2 * 64, 2 * 64 };
666          const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 };          const uint8_t lines[] = { 0, 16, 32, 48, 0, 16, 32, 48 };
# Line 292  Line 694 
694                  }                  }
695          }          }
696    
697          if (frame > field) {          return (frame >= (field + 350));
                 MBFrameToField(data);  
         }  
   
         return (frame > field);  
698  }  }
699    
700    

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.11.2.6

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