Home | History | Annotate | Download | only in arm
      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 <math.h>
     13 #include "vpx_mem/vpx_mem.h"
     14 
     15 #include "vp8/encoder/quantize.h"
     16 #include "vp8/common/entropy.h"
     17 
     18 DECLARE_ALIGNED(16, const short, vp8_rvsplus1_default_zig_zag1d[16]) =
     19 {
     20     1,  2,  6,  7,
     21     3,  5,  8,  13,
     22     4,  9,  12, 14,
     23     10, 11, 15, 16,
     24 };
     25 
     26 
     27 extern int vp8_fast_quantize_b_neon_func(short *coeff_ptr, short *zbin_ptr, short *qcoeff_ptr, short *dqcoeff_ptr, short *dequant_ptr, const short *scan_mask, short *round_ptr, short *quant_ptr);
     28 
     29 void vp8_fast_quantize_b_neon(BLOCK *b, BLOCKD *d)
     30 {
     31     d->eob = vp8_fast_quantize_b_neon_func(b->coeff, b->zbin, d->qcoeff, d->dqcoeff, d->dequant, vp8_rvsplus1_default_zig_zag1d, b->round, b->quant_fast);
     32 }
     33 
     34 /*
     35 //neon code is written according to the following rewritten c code
     36 void vp8_fast_quantize_b_neon(BLOCK *b,BLOCKD *d)
     37 {
     38     int i, rc, eob;
     39     int zbin;
     40     int x, x1, y, z, sz;
     41     short *coeff_ptr  = &b->Coeff[0];
     42     short *zbin_ptr   = &b->Zbin[0][0];
     43     short *round_ptr  = &b->Round[0][0];
     44     short *quant_ptr  = &b->Quant[0][0];
     45     short *qcoeff_ptr = d->qcoeff;
     46     short *dqcoeff_ptr= d->dqcoeff;
     47     short *dequant_ptr= &d->Dequant[0][0];
     48 
     49     eob = 0;
     50 
     51     for(i=0;i<16;i++)
     52     {
     53         z    = coeff_ptr[i];
     54         zbin = zbin_ptr[i] ;
     55         x  = abs(z);                                    // x = abs(z)
     56 
     57         if(x>=zbin)
     58         {
     59             sz = (z>>31);                               // sign of z
     60             y  = ((x+round_ptr[i])*quant_ptr[i])>>16;     // quantize (x)
     61             x1  = (y^sz) - sz;                          // get the sign back
     62 
     63             qcoeff_ptr[i] = x1;                          // write to destination
     64             dqcoeff_ptr[i] = x1 * dequant_ptr[i];         // dequantized value
     65 
     66             if(y)
     67             {
     68                 if(eob<vp8_rvsplus1_default_zig_zag1d[i])
     69                     eob=(int)vp8_rvsplus1_default_zig_zag1d[i];         // last nonzero coeffs
     70             }
     71         }else
     72         {
     73             qcoeff_ptr[i] = 0;                          // write to destination
     74             dqcoeff_ptr[i] = 0;         // dequantized value
     75         }
     76     }
     77         d->eob = eob;
     78 }
     79 */
     80