Home | History | Annotate | Download | only in decoder
      1 /*
      2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 
     12 #include "vpx_ports/config.h"
     13 #include "dequantize.h"
     14 #include "vp8/common/idct.h"
     15 #include "vpx_mem/vpx_mem.h"
     16 
     17 extern void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) ;
     18 extern void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch);
     19 
     20 
     21 void vp8_dequantize_b_c(BLOCKD *d)
     22 {
     23     int i;
     24     short *DQ  = d->dqcoeff;
     25     short *Q   = d->qcoeff;
     26     short *DQC = d->dequant;
     27 
     28     for (i = 0; i < 16; i++)
     29     {
     30         DQ[i] = Q[i] * DQC[i];
     31     }
     32 }
     33 
     34 void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred,
     35                             unsigned char *dest, int pitch, int stride)
     36 {
     37     short output[16];
     38     short *diff_ptr = output;
     39     int r, c;
     40     int i;
     41 
     42     for (i = 0; i < 16; i++)
     43     {
     44         input[i] = dq[i] * input[i];
     45     }
     46 
     47     /* the idct halves ( >> 1) the pitch */
     48     vp8_short_idct4x4llm_c(input, output, 4 << 1);
     49 
     50     vpx_memset(input, 0, 32);
     51 
     52     for (r = 0; r < 4; r++)
     53     {
     54         for (c = 0; c < 4; c++)
     55         {
     56             int a = diff_ptr[c] + pred[c];
     57 
     58             if (a < 0)
     59                 a = 0;
     60 
     61             if (a > 255)
     62                 a = 255;
     63 
     64             dest[c] = (unsigned char) a;
     65         }
     66 
     67         dest += stride;
     68         diff_ptr += 4;
     69         pred += pitch;
     70     }
     71 }
     72 
     73 void vp8_dequant_dc_idct_add_c(short *input, short *dq, unsigned char *pred,
     74                                unsigned char *dest, int pitch, int stride,
     75                                int Dc)
     76 {
     77     int i;
     78     short output[16];
     79     short *diff_ptr = output;
     80     int r, c;
     81 
     82     input[0] = (short)Dc;
     83 
     84     for (i = 1; i < 16; i++)
     85     {
     86         input[i] = dq[i] * input[i];
     87     }
     88 
     89     /* the idct halves ( >> 1) the pitch */
     90     vp8_short_idct4x4llm_c(input, output, 4 << 1);
     91 
     92     vpx_memset(input, 0, 32);
     93 
     94     for (r = 0; r < 4; r++)
     95     {
     96         for (c = 0; c < 4; c++)
     97         {
     98             int a = diff_ptr[c] + pred[c];
     99 
    100             if (a < 0)
    101                 a = 0;
    102 
    103             if (a > 255)
    104                 a = 255;
    105 
    106             dest[c] = (unsigned char) a;
    107         }
    108 
    109         dest += stride;
    110         diff_ptr += 4;
    111         pred += pitch;
    112     }
    113 }
    114