| /* |
| * Copyright (c) 2010 The VP8 project authors. All Rights Reserved. |
| * |
| * Use of this source code is governed by a BSD-style license and patent |
| * grant that can be found in the LICENSE file in the root of the source |
| * tree. All contributing project authors may be found in the AUTHORS |
| * file in the root of the source tree. |
| */ |
| |
| |
| #include <stdlib.h> |
| #include "blockd.h" |
| |
| |
| void vp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons) |
| { |
| int diff; |
| int sign; |
| int last_dc = *lastdc; |
| int this_dc = *thisdc; |
| |
| if (*cons > DCPREDCNTTHRESH) |
| { |
| this_dc += last_dc; |
| } |
| |
| diff = abs(last_dc - this_dc); |
| sign = (last_dc >> 31) ^(this_dc >> 31); |
| sign |= (!last_dc | !this_dc); |
| |
| if (sign) |
| { |
| *cons = 0; |
| } |
| else |
| { |
| if (diff <= DCPREDSIMTHRESH * quant) |
| (*cons)++ ; |
| } |
| |
| *thisdc = this_dc; |
| *lastdc = this_dc; |
| } |