• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_ENCODER_INTERP_FILTER_SEARCH_H_
13 #define AOM_AV1_ENCODER_INTERP_FILTER_SEARCH_H_
14 
15 #include "av1/encoder/block.h"
16 #include "av1/encoder/encoder.h"
17 #include "av1/encoder/rdopt_utils.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define MAX_INTERP_FILTER_STATS 128
24 #define DUAL_FILTER_SET_SIZE (SWITCHABLE_FILTERS * SWITCHABLE_FILTERS)
25 
26 typedef struct {
27   int_interpfilters filters;
28   int_mv mv[2];
29   int8_t ref_frames[2];
30   COMPOUND_TYPE comp_type;
31   int compound_idx;
32   int64_t rd;
33   unsigned int pred_sse;
34 } INTERPOLATION_FILTER_STATS;
35 
36 typedef struct {
37   // OBMC secondary prediction buffers and respective strides
38   uint8_t *above_pred_buf[MAX_MB_PLANE];
39   int above_pred_stride[MAX_MB_PLANE];
40   uint8_t *left_pred_buf[MAX_MB_PLANE];
41   int left_pred_stride[MAX_MB_PLANE];
42   int_mv (*single_newmv)[REF_FRAMES];
43   // Pointer to array of motion vectors to use for each ref and their rates
44   // Should point to first of 2 arrays in 2D array
45   int (*single_newmv_rate)[REF_FRAMES];
46   int (*single_newmv_valid)[REF_FRAMES];
47   // Pointer to array of predicted rate-distortion
48   // Should point to first of 2 arrays in 2D array
49   int64_t (*modelled_rd)[MAX_REF_MV_SEARCH][REF_FRAMES];
50   int ref_frame_cost;
51   int single_comp_cost;
52   int64_t (*simple_rd)[MAX_REF_MV_SEARCH][REF_FRAMES];
53   int skip_motion_mode;
54   INTERINTRA_MODE *inter_intra_mode;
55   int single_ref_first_pass;
56   SimpleRDState *simple_rd_state;
57   // [comp_idx][saved stat_idx]
58   INTERPOLATION_FILTER_STATS interp_filter_stats[MAX_INTERP_FILTER_STATS];
59   int interp_filter_stats_idx;
60 } HandleInterModeArgs;
61 
62 static const int_interpfilters filter_sets[DUAL_FILTER_SET_SIZE] = {
63   { 0x00000000 }, { 0x00010000 }, { 0x00020000 },  // y = 0
64   { 0x00000001 }, { 0x00010001 }, { 0x00020001 },  // y = 1
65   { 0x00000002 }, { 0x00010002 }, { 0x00020002 },  // y = 2
66 };
67 
68 int av1_find_interp_filter_match(
69     MB_MODE_INFO *const mbmi, const AV1_COMP *const cpi,
70     const InterpFilter assign_filter, const int need_search,
71     INTERPOLATION_FILTER_STATS *interp_filter_stats,
72     int interp_filter_stats_idx);
73 
74 int64_t av1_interpolation_filter_search(
75     MACROBLOCK *const x, const AV1_COMP *const cpi,
76     const TileDataEnc *tile_data, BLOCK_SIZE bsize,
77     const BUFFER_SET *const tmp_dst, const BUFFER_SET *const orig_dst,
78     int64_t *const rd, int *const switchable_rate, int *skip_build_pred,
79     HandleInterModeArgs *args, int64_t ref_best_rd);
80 
81 #ifdef __cplusplus
82 }  // extern "C"
83 #endif
84 
85 #endif  // AOM_AV1_ENCODER_INTERP_FILTER_SEARCH_H_
86