Merge "vp8_rd_pick_best_mbsegmentation code restructure"
[libvpx.git] / vp8 / common / predictdc.c
blobf315f50e03354264bf510e2fe0fb2d4829667566
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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 */
12 #include <stdlib.h>
13 #include "blockd.h"
16 void vp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons)
18 int diff;
19 int sign;
20 int last_dc = *lastdc;
21 int this_dc = *thisdc;
23 if (*cons > DCPREDCNTTHRESH)
25 this_dc += last_dc;
28 diff = abs(last_dc - this_dc);
29 sign = (last_dc >> 31) ^(this_dc >> 31);
30 sign |= (!last_dc | !this_dc);
32 if (sign)
34 *cons = 0;
36 else
38 if (diff <= DCPREDSIMTHRESH * quant)
39 (*cons)++ ;
42 *thisdc = this_dc;
43 *lastdc = this_dc;