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 "predictdc.h"
     15 #include "idct.h"
     16 #include "vpx_mem/vpx_mem.h"
     17 
     18 extern void vp8_short_idct4x4llm_c(short *input, short *output, int pitch) ;
     19 extern void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch);
     20 
     21 
     22 void vp8_dequantize_b_c(BLOCKD *d)
     23 {
     24     int i;
     25     short *DQ  = d->dqcoeff;
     26     short *Q   = d->qcoeff;
     27     short *DQC = d->dequant;
     28 
     29     for (i = 0; i < 16; i++)
     30     {
     31         DQ[i] = Q[i] * DQC[i];
     32     }
     33 }
     34 
     35 void vp8_dequant_idct_add_c(short *input, short *dq, unsigned char *pred,
     36                             unsigned char *dest, int pitch, int stride)
     37 {
     38     short output[16];
     39     short *diff_ptr = output;
     40     int r, c;
     41     int i;
     42 
     43     for (i = 0; i < 16; i++)
     44     {
     45         input[i] = dq[i] * input[i];
     46     }
     47 
     48     /* the idct halves ( >> 1) the pitch */
     49     vp8_short_idct4x4llm_c(input, output, 4 << 1);
     50 
     51     vpx_memset(input, 0, 32);
     52 
     53     for (r = 0; r < 4; r++)
     54     {
     55         for (c = 0; c < 4; c++)
     56         {
     57             int a = diff_ptr[c] + pred[c];
     58 
     59             if (a < 0)
     60                 a = 0;
     61 
     62             if (a > 255)
     63                 a = 255;
     64 
     65             dest[c] = (unsigned char) a;
     66         }
     67 
     68         dest += stride;
     69         diff_ptr += 4;
     70         pred += pitch;
     71     }
     72 }
     73 
     74 void vp8_dequant_dc_idct_add_c(short *input, short *dq, unsigned char *pred,
     75                                unsigned char *dest, int pitch, int stride,
     76                                int Dc)
     77 {
     78     int i;
     79     short output[16];
     80     short *diff_ptr = output;
     81     int r, c;
     82 
     83     input[0] = (short)Dc;
     84 
     85     for (i = 1; i < 16; i++)
     86     {
     87         input[i] = dq[i] * input[i];
     88     }
     89 
     90     /* the idct halves ( >> 1) the pitch */
     91     vp8_short_idct4x4llm_c(input, output, 4 << 1);
     92 
     93     vpx_memset(input, 0, 32);
     94 
     95     for (r = 0; r < 4; r++)
     96     {
     97         for (c = 0; c < 4; c++)
     98         {
     99             int a = diff_ptr[c] + pred[c];
    100 
    101             if (a < 0)
    102                 a = 0;
    103 
    104             if (a > 255)
    105                 a = 255;
    106 
    107             dest[c] = (unsigned char) a;
    108         }
    109 
    110         dest += stride;
    111         diff_ptr += 4;
    112         pred += pitch;
    113     }
    114 }
    115