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

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

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

revision 367, Fri Aug 9 10:45:05 2002 UTC revision 368, Fri Aug 9 19:58:42 2002 UTC
# Line 251  Line 251 
251    
252  }  }
253    
254    void
255    MBTransQuantIntra2(const MBParam * pParam,
256                                      FRAMEINFO * frame,
257                                      MACROBLOCK * pMB,
258                                      const uint32_t x_pos,
259                                      const uint32_t y_pos,
260                                      int16_t data[6 * 64],
261                                      int16_t qcoeff[6 * 64])
262    {
263            MBTrans(pParam,frame,pMB,x_pos,y_pos,data);
264            MBfDCT(pParam,frame,pMB,data);
265            MBQuantIntra(pParam,frame,pMB,data,qcoeff);
266            MBDeQuantIntra(pParam,frame->quant,data,qcoeff);
267            MBiDCT(data,0x3F);
268            MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,0x3F);
269    }
270    
271    
272    uint8_t
273    MBTransQuantInter2(const MBParam * pParam,
274                                      FRAMEINFO * frame,
275                                      MACROBLOCK * pMB,
276                                      const uint32_t x_pos,
277                                      const uint32_t y_pos,
278                                      int16_t data[6 * 64],
279                                      int16_t qcoeff[6 * 64])
280    {
281            uint8_t cbp;
282    
283    /* there is no MBTrans for Inter block, that's done in motion compensation already */
284    
285            MBfDCT(pParam,frame,pMB,data);
286            cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);
287            MBDeQuantInter(pParam,frame->quant,data,qcoeff,cbp);
288            MBiDCT(data,cbp);
289            MBTransAdd(pParam,frame,pMB,x_pos,y_pos,data,cbp);
290    
291            return cbp;
292    }
293    
294    uint8_t
295    MBTransQuantInterBVOP(const MBParam * pParam,
296                                      FRAMEINFO * frame,
297                                      MACROBLOCK * pMB,
298                                      const uint32_t x_pos,
299                                      const uint32_t y_pos,
300                                      int16_t data[6 * 64],
301                                      int16_t qcoeff[6 * 64])
302    {
303            uint8_t cbp;
304    
305    /* there is no MBTrans for Inter block, that's done in motion compensation already */
306    
307            MBfDCT(pParam,frame,pMB,data);
308            cbp = MBQuantInter(pParam,frame->quant,data,qcoeff);
309    
310    /* we don't have to DeQuant, iDCT and Transfer back data for B-frames */
311    
312            return cbp;
313    }
314    
315    
316    void
317    MBfDCT(const MBParam * pParam,
318                                      FRAMEINFO * frame,
319                                      MACROBLOCK * pMB,
320                                      int16_t data[6 * 64])
321    {
322            int i;
323    
324            start_timer();
325            pMB->field_dct = 0;
326            if ((frame->global_flags & XVID_INTERLACING)) {
327                    pMB->field_dct = MBDecideFieldDCT(data);
328            }
329            stop_interlacing_timer();
330    
331            for (i = 0; i < 6; i++) {
332                    start_timer();
333                    fdct(&data[i * 64]);
334                    stop_dct_timer();
335            }
336    }
337    
338    void
339    MBQuantDeQuantIntra(const MBParam * pParam,
340                                            FRAMEINFO * frame,
341                                            MACROBLOCK * pMB,
342                                            int16_t qcoeff[6 * 64],
343                                            int16_t data[6*64])
344    {
345            int i;
346            int iQuant = frame->quant;
347    
348            start_timer();
349            pMB->field_dct = 0;
350            if ((frame->global_flags & XVID_INTERLACING)) {
351                    pMB->field_dct = MBDecideFieldDCT(data);
352            }
353            stop_interlacing_timer();
354    
355            for (i = 0; i < 6; i++) {
356                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
357    
358                    if (pParam->m_quant_type == H263_QUANT) {
359                            start_timer();
360                            quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
361                            stop_quant_timer();
362    
363                            start_timer();
364                            dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
365                            stop_iquant_timer();
366                    } else {
367                            start_timer();
368                            quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
369                            stop_quant_timer();
370    
371                            start_timer();
372                            dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
373                            stop_iquant_timer();
374                    }
375            }
376    }
377    
378    void
379    MBQuantIntra(const MBParam * pParam,
380                             FRAMEINFO * frame,
381                             MACROBLOCK *pMB,
382                         int16_t qcoeff[6 * 64],
383                             int16_t data[6*64])
384    {
385            int i;
386            int iQuant = frame->quant;
387    
388            start_timer();
389            pMB->field_dct = 0;
390            if ((frame->global_flags & XVID_INTERLACING)) {
391                    pMB->field_dct = MBDecideFieldDCT(data);
392            }
393            stop_interlacing_timer();
394    
395            for (i = 0; i < 6; i++) {
396                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
397    
398                    if (pParam->m_quant_type == H263_QUANT) {
399                            start_timer();
400                            quant_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
401                            stop_quant_timer();
402                    } else {
403                            start_timer();
404                            quant4_intra(&qcoeff[i * 64], &data[i * 64], iQuant, iDcScaler);
405                            stop_quant_timer();
406                    }
407            }
408    }
409    
410    void
411    MBDeQuantIntra(const MBParam * pParam,
412                               const int iQuant,
413                                      int16_t qcoeff[6 * 64],
414                                      int16_t data[6*64])
415    {
416            int i;
417    
418            for (i = 0; i < 6; i++) {
419                    uint32_t iDcScaler = get_dc_scaler(iQuant, i < 4);
420    
421                    if (pParam->m_quant_type == H263_QUANT) {
422                            start_timer();
423                            dequant_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
424                            stop_iquant_timer();
425                    } else {
426                            start_timer();
427                            dequant4_intra(&data[i * 64], &qcoeff[i * 64], iQuant, iDcScaler);
428                            stop_iquant_timer();
429                    }
430            }
431    }
432    
433    uint8_t
434    MBQuantInter(const MBParam * pParam,
435                             const int iQuant,
436                                      int16_t data[6 * 64],
437                                      int16_t qcoeff[6 * 64])
438    {
439    
440            int i;
441            uint8_t cbp = 0;
442            int sum;
443    
444            for (i = 0; i < 6; i++) {
445    
446                    if (pParam->m_quant_type == 0) {
447                            start_timer();
448                            sum = quant_inter(&qcoeff[i * 64], &data[i * 64], iQuant);
449                            stop_quant_timer();
450                    } else {
451                            start_timer();
452                            sum = quant4_inter(&qcoeff[i * 64], &data[i * 64], iQuant);
453                            stop_quant_timer();
454                    }
455    
456                    if (sum >= TOOSMALL_LIMIT) {    // skip block ?
457                            cbp |= 1 << (5 - i);
458                    }
459            }
460            return cbp;
461    }
462    
463    void
464    MBDeQuantInter( const MBParam * pParam,
465                                    const int iQuant,
466                                      int16_t data[6 * 64],
467                                      int16_t qcoeff[6 * 64],
468                                      const uint8_t cbp)
469    {
470            int i;
471    
472            for (i = 0; i < 6; i++) {
473                    if (cbp & (1 << (5 - i)))
474                    {
475                            if (pParam->m_quant_type == H263_QUANT) {
476                                    start_timer();
477                                    dequant_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
478                                    stop_iquant_timer();
479                            } else {
480                                    start_timer();
481                                    dequant4_inter(&data[i * 64], &qcoeff[i * 64], iQuant);
482                                    stop_iquant_timer();
483                            }
484                    }
485            }
486    }
487    
488    void
489    MBiDCT( int16_t data[6 * 64],
490                    const uint8_t cbp)
491    {
492            int i;
493    
494            for (i = 0; i < 6; i++) {
495                    if (cbp & (1 << (5 - i)))
496                    {
497                            start_timer();
498                            idct(&data[i * 64]);
499                            stop_idct_timer();
500    
501                    }
502            }
503    }
504    
505    
506    void
507    MBTrans(const MBParam * pParam,
508                                      FRAMEINFO * frame,
509                                      MACROBLOCK * pMB,
510                                      const uint32_t x_pos,
511                                      const uint32_t y_pos,
512                                      int16_t data[6 * 64])
513    {
514            uint32_t stride = pParam->edged_width;
515            uint32_t stride2 = stride / 2;
516            uint32_t next_block = stride * 8;
517            uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
518            IMAGE *pCurrent = &frame->image;
519    
520            pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
521            pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
522            pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
523    
524            start_timer();
525            transfer_8to16copy(&data[0 * 64], pY_Cur, stride);
526            transfer_8to16copy(&data[1 * 64], pY_Cur + 8, stride);
527            transfer_8to16copy(&data[2 * 64], pY_Cur + next_block, stride);
528            transfer_8to16copy(&data[3 * 64], pY_Cur + next_block + 8, stride);
529            transfer_8to16copy(&data[4 * 64], pU_Cur, stride2);
530            transfer_8to16copy(&data[5 * 64], pV_Cur, stride2);
531            stop_transfer_timer();
532    }
533    
534    void
535    MBTransAdd(const MBParam * pParam,
536                                      FRAMEINFO * frame,
537                                      MACROBLOCK * pMB,
538                                      const uint32_t x_pos,
539                                      const uint32_t y_pos,
540                                      int16_t data[6 * 64],
541                                      const uint8_t cbp)
542    {
543            uint8_t *pY_Cur, *pU_Cur, *pV_Cur;
544            uint32_t stride = pParam->edged_width;
545            uint32_t stride2 = stride / 2;
546            uint32_t next_block = stride * 8;
547            IMAGE *pCurrent = &frame->image;
548    
549            pY_Cur = pCurrent->y + (y_pos << 4) * stride + (x_pos << 4);
550            pU_Cur = pCurrent->u + (y_pos << 3) * stride2 + (x_pos << 3);
551            pV_Cur = pCurrent->v + (y_pos << 3) * stride2 + (x_pos << 3);
552    
553            if (pMB->field_dct) {
554                    next_block = stride;
555                    stride *= 2;
556            }
557    
558            start_timer();
559            if (cbp & 32)
560                    transfer_16to8add(pY_Cur, &data[0 * 64], stride);
561            if (cbp & 16)
562                    transfer_16to8add(pY_Cur + 8, &data[1 * 64], stride);
563            if (cbp & 8)
564                    transfer_16to8add(pY_Cur + next_block, &data[2 * 64], stride);
565            if (cbp & 4)
566                    transfer_16to8add(pY_Cur + next_block + 8, &data[3 * 64], stride);
567            if (cbp & 2)
568                    transfer_16to8add(pU_Cur, &data[4 * 64], stride2);
569            if (cbp & 1)
570                    transfer_16to8add(pV_Cur, &data[5 * 64], stride2);
571            stop_transfer_timer();
572    }
573    
574    
575    
576  /* 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 */
577    

Legend:
Removed from v.367  
changed lines
  Added in v.368

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