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

Diff of /xvidcore/src/decoder.c

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

revision 1.5, Tue Mar 26 11:16:08 2002 UTC revision 1.8, Fri Mar 29 00:37:57 2002 UTC
# Line 32  Line 32 
32   *   *
33   *      History:   *      History:
34   *   *
35     *  29.03.2002  interlacing fix - compensated block wasn't being used when
36     *              reconstructing blocks, thus artifacts
37     *              interlacing speedup - used transfers to re-interlace
38     *              interlaced decoding should be as fast as progressive now
39   *  26.03.2002  interlacing support - moved transfers outside decode loop   *  26.03.2002  interlacing support - moved transfers outside decode loop
40   *      26.12.2001      decoder_mbinter: dequant/idct moved within if(coded) block   *      26.12.2001      decoder_mbinter: dequant/idct moved within if(coded) block
41   *      22.12.2001      block based interpolation   *      22.12.2001      block based interpolation
# Line 55  Line 59 
59  #include "dct/fdct.h"  #include "dct/fdct.h"
60  #include "utils/mem_transfer.h"  #include "utils/mem_transfer.h"
61  #include "image/interpolate8x8.h"  #include "image/interpolate8x8.h"
 #include "utils/mbfunctions.h"  
62    
63  #include "bitstream/mbcoding.h"  #include "bitstream/mbcoding.h"
64  #include "prediction/mbprediction.h"  #include "prediction/mbprediction.h"
# Line 147  Line 150 
150                                           const uint32_t quant,                                           const uint32_t quant,
151                                           const uint32_t intra_dc_threshold)                                           const uint32_t intra_dc_threshold)
152  {  {
         CACHE_ALIGN int16_t block[6][64];  
         CACHE_ALIGN int16_t data[6][64];  
153    
154          const uint32_t stride = dec->edged_width;          DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE);
155            DECLARE_ALIGNED_MATRIX(data,  6, 64, int16_t, CACHE_LINE);
156    
157            uint32_t stride = dec->edged_width;
158            uint32_t stride2 = stride / 2;
159            uint32_t next_block = stride * 8;
160          uint32_t i;          uint32_t i;
161          uint32_t iQuant = pMB->quant;          uint32_t iQuant = pMB->quant;
162          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
163    
164      pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);      pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
165      pU_Cur = dec->cur.u + (y_pos << 3) * (stride >> 1) + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
166      pV_Cur = dec->cur.v + (y_pos << 3) * (stride >> 1) + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
167    
168          memset(block, 0, sizeof(block));                // clear          memset(block, 0, 6*64*sizeof(int16_t));         // clear
169    
170          for (i = 0; i < 6; i++)          for (i = 0; i < 6; i++)
171          {          {
# Line 168  Line 174 
174                  int start_coeff;                  int start_coeff;
175    
176                  start_timer();                  start_timer();
177                  predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, block[i], iQuant, iDcScaler, predictors);                  predict_acdc(dec->mbs, x_pos, y_pos, dec->mb_width, i, &block[i*64], iQuant, iDcScaler, predictors);
178                  if (!acpred_flag)                  if (!acpred_flag)
179                  {                  {
180                          pMB->acpred_directions[i] = 0;                          pMB->acpred_directions[i] = 0;
# Line 188  Line 194 
194                                  BitstreamSkip(bs, 1);           // marker                                  BitstreamSkip(bs, 1);           // marker
195                          }                          }
196    
197                          block[i][0] = dc_dif;                          block[i*64 + 0] = dc_dif;
198                          start_coeff = 1;                          start_coeff = 1;
199                  }                  }
200                  else                  else
# Line 199  Line 205 
205                  start_timer();                  start_timer();
206                  if (cbp & (1 << (5-i)))                 // coded                  if (cbp & (1 << (5-i)))                 // coded
207                  {                  {
208                          get_intra_block(bs, block[i], pMB->acpred_directions[i], start_coeff);                          get_intra_block(bs, &block[i*64], pMB->acpred_directions[i], start_coeff);
209                  }                  }
210                  stop_coding_timer();                  stop_coding_timer();
211    
212                  start_timer();                  start_timer();
213                  add_acdc(pMB, i, block[i], iDcScaler, predictors);                  add_acdc(pMB, i, &block[i*64], iDcScaler, predictors);
214                  stop_prediction_timer();                  stop_prediction_timer();
215    
216                  start_timer();                  start_timer();
217                  if (dec->quant_type == 0)                  if (dec->quant_type == 0)
218                  {                  {
219                          dequant_intra(data[i], block[i], iQuant, iDcScaler);                          dequant_intra(&data[i*64], &block[i*64], iQuant, iDcScaler);
220                  }                  }
221                  else                  else
222                  {                  {
223                          dequant4_intra(data[i], block[i], iQuant, iDcScaler);                          dequant4_intra(&data[i*64], &block[i*64], iQuant, iDcScaler);
224                  }                  }
225                  stop_iquant_timer();                  stop_iquant_timer();
226    
227                  start_timer();                  start_timer();
228                  idct(data[i]);                  idct(&data[i*64]);
229                  stop_idct_timer();                  stop_idct_timer();
230          }          }
231    
232          start_timer();          if (pMB->field_dct)
         if (dec->interlacing && pMB->field_dct)  
233          {          {
234                  MBFieldToFrame(data);                  next_block = stride;
235                    stride *= 2;
236          }          }
         stop_interlacing_timer();  
237    
238          start_timer();          start_timer();
239          transfer_16to8copy(pY_Cur, data[0], stride);          transfer_16to8copy(pY_Cur,                  &data[0*64], stride);
240          transfer_16to8copy(pY_Cur + 8, data[1], stride);          transfer_16to8copy(pY_Cur + 8,              &data[1*64], stride);
241          transfer_16to8copy(pY_Cur + 8 * stride, data[2], stride);          transfer_16to8copy(pY_Cur + next_block,     &data[2*64], stride);
242          transfer_16to8copy(pY_Cur + 8 + 8 * stride, data[3], stride);          transfer_16to8copy(pY_Cur + 8 + next_block, &data[3*64], stride);
243          transfer_16to8copy(pU_Cur, data[4], stride / 2);          transfer_16to8copy(pU_Cur,                  &data[4*64], stride2);
244          transfer_16to8copy(pV_Cur, data[5], stride / 2);          transfer_16to8copy(pV_Cur,                  &data[5*64], stride2);
245          stop_transfer_timer();          stop_transfer_timer();
246  }  }
247    
# Line 262  Line 267 
267                                           const uint32_t quant,                                           const uint32_t quant,
268                                           const uint32_t rounding)                                           const uint32_t rounding)
269  {  {
         CACHE_ALIGN int16_t block[6][64];  
         CACHE_ALIGN int16_t data[6][64];  
270    
271          const uint32_t stride = dec->edged_width;          DECLARE_ALIGNED_MATRIX(block,6, 64, int16_t, CACHE_LINE);
272          const uint32_t stride2 = dec->edged_width / 2;          DECLARE_ALIGNED_MATRIX(data, 6, 64, int16_t, CACHE_LINE);
273    
274            uint32_t stride = dec->edged_width;
275            uint32_t stride2 = stride / 2;
276            uint32_t next_block = stride * 8;
277      uint32_t i;      uint32_t i;
278      uint32_t iQuant = pMB->quant;      uint32_t iQuant = pMB->quant;
279          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;          uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
280          int uv_dx, uv_dy;          int uv_dx, uv_dy;
281    
282      pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);      pY_Cur = dec->cur.y + (y_pos << 4) * stride + (x_pos << 4);
283      pU_Cur = dec->cur.u + (y_pos << 3) * (stride >> 1) + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
284      pV_Cur = dec->cur.v + (y_pos << 3) * (stride >> 1) + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
285    
286          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)          if (pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)
287          {          {
# Line 307  Line 314 
314          {          {
315                  if (cbp & (1 << (5-i)))                 // coded                  if (cbp & (1 << (5-i)))                 // coded
316                  {                  {
317                          memset(block[i], 0, 64 * sizeof(int16_t));              // clear                          memset(&block[i*64], 0, 64 * sizeof(int16_t));          // clear
318    
319                          start_timer();                          start_timer();
320                          get_inter_block(bs, block[i]);                          get_inter_block(bs, &block[i*64]);
321                          stop_coding_timer();                          stop_coding_timer();
322    
323                          start_timer();                          start_timer();
324                          if (dec->quant_type == 0)                          if (dec->quant_type == 0)
325                          {                          {
326                                  dequant_inter(data[i], block[i], iQuant);                                  dequant_inter(&data[i*64], &block[i*64], iQuant);
327                          }                          }
328                          else                          else
329                          {                          {
330                                  dequant4_inter(data[i], block[i], iQuant);                                  dequant4_inter(&data[i*64], &block[i*64], iQuant);
331                          }                          }
332                          stop_iquant_timer();                          stop_iquant_timer();
333    
334                          start_timer();                          start_timer();
335                          idct(data[i]);                          idct(&data[i*64]);
336                          stop_idct_timer();                          stop_idct_timer();
337                  }                  }
338          }          }
339    
         start_timer();  
340          if (pMB->field_dct)          if (pMB->field_dct)
341          {          {
342                  MBFieldToFrame(data);                  next_block = stride;
343                    stride *= 2;
344          }          }
         stop_interlacing_timer();  
345    
346          start_timer();          start_timer();
347          if (cbp & 32)          if (cbp & 32)
348                  transfer_16to8add(pY_Cur, data[0], stride);                  transfer_16to8add(pY_Cur,                  &data[0*64], stride);
349          if (cbp & 16)          if (cbp & 16)
350                  transfer_16to8add(pY_Cur + 8, data[1], stride);                  transfer_16to8add(pY_Cur + 8,              &data[1*64], stride);
351          if (cbp & 8)          if (cbp & 8)
352                  transfer_16to8add(pY_Cur + 8 * stride, data[2], stride);                  transfer_16to8add(pY_Cur + next_block,     &data[2*64], stride);
353          if (cbp & 4)          if (cbp & 4)
354                  transfer_16to8add(pY_Cur + 8 + 8 * stride, data[3], stride);                  transfer_16to8add(pY_Cur + 8 + next_block, &data[3*64], stride);
355          if (cbp & 2)          if (cbp & 2)
356                  transfer_16to8add(pU_Cur, data[4], stride / 2);                  transfer_16to8add(pU_Cur,                  &data[4*64], stride2);
357          if (cbp & 1)          if (cbp & 1)
358                  transfer_16to8add(pV_Cur, data[5], stride / 2);                  transfer_16to8add(pV_Cur,                  &data[5*64], stride2);
359          stop_transfer_timer();          stop_transfer_timer();
360  }  }
361    
362    
363  void decoder_iframe(DECODER * dec, Bitstream * bs, int quant, int intra_dc_threshold)  void decoder_iframe(DECODER * dec, Bitstream * bs, int quant, int intra_dc_threshold)
364  {  {
365    
366          uint32_t x, y;          uint32_t x, y;
367    
368          for (y = 0; y < dec->mb_height; y++)          for (y = 0; y < dec->mb_height; y++)
# Line 408  Line 415 
415                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold);                          decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, intra_dc_threshold);
416                  }                  }
417          }          }
418    
419  }  }
420    
421    
422  void get_motion_vector(DECODER *dec, Bitstream *bs, int x, int y, int k, VECTOR * mv, int fcode)  void get_motion_vector(DECODER *dec, Bitstream *bs, int x, int y, int k, VECTOR * mv, int fcode)
423  {  {
424    
425          int scale_fac = 1 << (fcode - 1);          int scale_fac = 1 << (fcode - 1);
426          int high = (32 * scale_fac) - 1;          int high = (32 * scale_fac) - 1;
427          int low = ((-32) * scale_fac);          int low = ((-32) * scale_fac);
# Line 462  Line 471 
471    
472  void decoder_pframe(DECODER * dec, Bitstream * bs, int rounding, int quant, int fcode, int intra_dc_threshold)  void decoder_pframe(DECODER * dec, Bitstream * bs, int rounding, int quant, int fcode, int intra_dc_threshold)
473  {  {
474    
475          uint32_t x, y;          uint32_t x, y;
476    
477          image_swap(&dec->cur, &dec->refn);          image_swap(&dec->cur, &dec->refn);
# Line 614  Line 624 
624    
625  int decoder_decode(DECODER * dec, XVID_DEC_FRAME * frame)  int decoder_decode(DECODER * dec, XVID_DEC_FRAME * frame)
626  {  {
627    
628          Bitstream bs;          Bitstream bs;
629          uint32_t rounding;          uint32_t rounding;
630          uint32_t quant;          uint32_t quant;
# Line 657  Line 668 
668          stop_global_timer();          stop_global_timer();
669    
670          return XVID_ERR_OK;          return XVID_ERR_OK;
671    
672  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

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