1693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com/*
2693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *
4693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  Use of this source code is governed by a BSD-style license
5693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  that can be found in the LICENSE file in the root of the source
6693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  tree. An additional intellectual property rights grant can be found
7693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  in the file PATENTS.  All contributing project authors may
8693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com *  be found in the AUTHORS file in the root of the source tree.
9693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com */
10693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com
11693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com#ifndef VP9_ENCODER_VP9_CONTEXT_TREE_H_
12693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com#define VP9_ENCODER_VP9_CONTEXT_TREE_H_
13693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com
1488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org#include "vp9/common/vp9_onyxc_int.h"
15693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com
1688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgstruct VP9_COMP;
1788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
1888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org// Structure to hold snapshot of coding context during the mode picking process
1988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgtypedef struct {
2088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  MODE_INFO mic;
2188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  uint8_t *zcoeff_blk;
2287997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *coeff[MAX_MB_PLANE][3];
2387997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *qcoeff[MAX_MB_PLANE][3];
2487997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *dqcoeff[MAX_MB_PLANE][3];
2588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  uint16_t *eobs[MAX_MB_PLANE][3];
2688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
2788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  // dual buffer pointers, 0: in use, 1: best in store
2887997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *coeff_pbuf[MAX_MB_PLANE][3];
2987997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *qcoeff_pbuf[MAX_MB_PLANE][3];
3087997d490ae52aa962a985c95b3cddf7f8832641johannkoenig@chromium.org  tran_low_t *dqcoeff_pbuf[MAX_MB_PLANE][3];
3188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  uint16_t *eobs_pbuf[MAX_MB_PLANE][3];
3288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
3388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int is_coded;
3488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int num_4x4_blk;
3588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int skip;
36d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org  // For current partition, only if all Y, U, and V transform blocks'
37d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org  // coefficients are quantized to 0, skippable is set to 0.
38d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org  int skippable;
39d95585fb0ec024f6abd96f7b02e0df58019d46afjohannkoenig@chromium.org  uint8_t skip_txfm[MAX_MB_PLANE << 2];
4088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int best_mode_index;
4188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int hybrid_pred_diff;
4288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int comp_pred_diff;
4388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int single_pred_diff;
4488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int64_t tx_rd_diff[TX_MODES];
4588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int64_t best_filter_diff[SWITCHABLE_FILTER_CONTEXTS];
4688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
4741294d96d7dbf9bc215b09832a8336c5fb158f0bjohannkoenig@chromium.org#if CONFIG_VP9_TEMPORAL_DENOISING
48ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  unsigned int newmv_sse;
49ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  unsigned int zeromv_sse;
50ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  PREDICTION_MODE best_sse_inter_mode;
51ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  int_mv best_sse_mv;
52ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  MV_REFERENCE_FRAME best_reference_frame;
53ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org  MV_REFERENCE_FRAME best_zeromv_reference_frame;
54ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org#endif
55ac4e313c19203132648a2a271703b6ee76fe4284johannkoenig@chromium.org
5688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  // motion vector cache for adaptive motion search control in partition
5788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  // search loop
5888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  MV pred_mv[MAX_REF_FRAMES];
5988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  INTERP_FILTER pred_interp_filter;
6088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org} PICK_MODE_CONTEXT;
6188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
6288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgtypedef struct PC_TREE {
6388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  int index;
6488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  PARTITION_TYPE partitioning;
6588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  BLOCK_SIZE block_size;
6688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  PICK_MODE_CONTEXT none;
6788b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  PICK_MODE_CONTEXT horizontal[2];
6888b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  PICK_MODE_CONTEXT vertical[2];
6988b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  union {
7088b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org    struct PC_TREE *split[4];
7188b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org    PICK_MODE_CONTEXT *leaf_split[4];
7288b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org  };
7388b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org} PC_TREE;
7488b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.org
7588b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgvoid vp9_setup_pc_tree(struct VP9Common *cm, struct VP9_COMP *cpi);
7688b47b29cc274dd19cddc37c1ce1834d97df282efgalligan@chromium.orgvoid vp9_free_pc_tree(struct VP9_COMP *cpi);
77693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com
78693441efe611de7ca09c00f4e79776f604b689f4joeyparrish@google.com#endif /* VP9_ENCODER_VP9_CONTEXT_TREE_H_ */
79