• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdlib.h>
13 #include "blockd.h"
14 
15 
vp8_predict_dc(short * lastdc,short * thisdc,short quant,short * cons)16 void vp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons)
17 {
18     int diff;
19     int sign;
20     int last_dc = *lastdc;
21     int this_dc = *thisdc;
22 
23     if (*cons  > DCPREDCNTTHRESH)
24     {
25         this_dc += last_dc;
26     }
27 
28     diff = abs(last_dc - this_dc);
29     sign  = (last_dc >> 31) ^(this_dc >> 31);
30     sign |= (!last_dc | !this_dc);
31 
32     if (sign)
33     {
34         *cons = 0;
35     }
36     else
37     {
38         if (diff <= DCPREDSIMTHRESH * quant)
39             (*cons)++ ;
40     }
41 
42     *thisdc = this_dc;
43     *lastdc = this_dc;
44 }
45