1474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org/* 2474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 3474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * 4474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * Use of this source code is governed by a BSD-style license 5474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * that can be found in the LICENSE file in the root of the source 6474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * tree. An additional intellectual property rights grant can be found 7474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * in the file PATENTS. All contributing project authors may 8474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org * be found in the AUTHORS file in the root of the source tree. 9474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org */ 10474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org 11474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org 12474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org#include "treewriter.h" 13474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org 14474eb7536515fb785e925cc9375d22817c416851hclam@chromium.orgstatic void cost( 15474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org int *const C, 16474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org vp8_tree T, 17474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org const vp8_prob *const P, 18474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org int i, 19474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org int c 20474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org) 21474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org{ 22474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org const vp8_prob p = P [i>>1]; 23474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org 24474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org do 25474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org { 26474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org const vp8_tree_index j = T[i]; 27474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org const int d = c + vp8_cost_bit(p, i & 1); 28474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org 29474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org if (j <= 0) 30474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org C[-j] = d; 31474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org else 32474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org cost(C, T, P, j, d); 33474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org } 34474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org while (++i & 1); 35474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org} 36474eb7536515fb785e925cc9375d22817c416851hclam@chromium.orgvoid vp8_cost_tokens(int *c, const vp8_prob *p, vp8_tree t) 37474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org{ 38474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org cost(c, t, p, 0, 0); 39474eb7536515fb785e925cc9375d22817c416851hclam@chromium.org} 405c1d3b27608a3f3f6028c069b9bf066a4de474b6hclam@chromium.orgvoid vp8_cost_tokens2(int *c, const vp8_prob *p, vp8_tree t,int start) 415c1d3b27608a3f3f6028c069b9bf066a4de474b6hclam@chromium.org{ 425c1d3b27608a3f3f6028c069b9bf066a4de474b6hclam@chromium.org cost(c, t, p, start, 0); 435c1d3b27608a3f3f6028c069b9bf066a4de474b6hclam@chromium.org} 44