yv12config.h 3.88 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
John Koleszar's avatar
John Koleszar committed
3
 *
4 5 6 7 8 9
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
John Koleszar's avatar
John Koleszar committed
10 11
 */

12 13
#ifndef AOM_SCALE_YV12CONFIG_H_
#define AOM_SCALE_YV12CONFIG_H_
14

John Koleszar's avatar
John Koleszar committed
15
#ifdef __cplusplus
16
extern "C" {
John Koleszar's avatar
John Koleszar committed
17 18
#endif

19 20 21 22
#include "./aom_config.h"
#include "aom/aom_codec.h"
#include "aom/aom_frame_buffer.h"
#include "aom/aom_integer.h"
23

24
#if CONFIG_EXT_PARTITION
25
#define AOMINNERBORDERINPIXELS 160
26
#else
27
#define AOMINNERBORDERINPIXELS 96
28
#endif  // CONFIG_EXT_PARTITION
29
#define AOM_INTERP_EXTEND 4
30 31 32 33

// TODO(jingning): Use unified inter predictor for encoder and
// decoder during the development process. Revisit the frame border
// to improve the decoder performance.
34
#if CONFIG_EXT_PARTITION
35 36
#define AOM_BORDER_IN_PIXELS 288
#else
37
#define AOM_BORDER_IN_PIXELS 160
38
#endif  // CONFIG_EXT_PARTITION
John Koleszar's avatar
John Koleszar committed
39

40
typedef struct yv12_buffer_config {
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  union {
    struct {
      int y_width;
      int uv_width;
      int alpha_width;
    };
    int widths[3];
  };
  union {
    struct {
      int y_height;
      int uv_height;
      int alpha_height;
    };
    int heights[3];
  };
  union {
    struct {
      int y_crop_width;
      int uv_crop_width;
    };
    int crop_widths[2];
  };
  union {
    struct {
      int y_crop_height;
      int uv_crop_height;
    };
    int crop_heights[2];
  };
  union {
    struct {
      int y_stride;
      int uv_stride;
      int alpha_stride;
    };
    int strides[3];
  };
  union {
    struct {
      uint8_t *y_buffer;
      uint8_t *u_buffer;
      uint8_t *v_buffer;
      uint8_t *alpha_buffer;
    };
    uint8_t *buffers[4];
  };
John Koleszar's avatar
John Koleszar committed
88

89 90 91
  // If the frame is stored in a 16-bit buffer, this stores an 8-bit version
  // for use in global motion detection. It is allocated on-demand.
  uint8_t *y_buffer_8bit;
92
  int buf_8bit_valid;
93

94
  uint8_t *buffer_alloc;
95
  size_t buffer_alloc_sz;
96
  int border;
97
  size_t frame_size;
98 99
  int subsampling_x;
  int subsampling_y;
100
  unsigned int bit_depth;
Andrey Norkin's avatar
Andrey Norkin committed
101 102 103 104 105
#if CONFIG_CICP
  aom_color_primaries_t color_primaries;
  aom_transfer_characteristics_t transfer_characteristics;
  aom_matrix_coefficients_t matrix_coefficients;
#else
106
  aom_color_space_t color_space;
107
  aom_transfer_function_t transfer_function;
Andrey Norkin's avatar
Andrey Norkin committed
108
#endif
109
  int monochrome;
110
  aom_chroma_sample_position_t chroma_sample_position;
111
  aom_color_range_t color_range;
112 113
  int render_width;
  int render_height;
114

115 116 117
  int corrupted;
  int flags;
} YV12_BUFFER_CONFIG;
John Koleszar's avatar
John Koleszar committed
118

Yaowu Xu's avatar
Yaowu Xu committed
119
#define YV12_FLAG_HIGHBITDEPTH 8
120

121
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
122 123
                           int ss_x, int ss_y, int use_highbitdepth, int border,
                           int byte_alignment);
124

125 126
// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
127 128 129
// NULL, then libaom is using the frame buffer callbacks to handle memory.
// If cb is not NULL, libaom will call cb with minimum size in bytes needed
// to decode the current frame. If cb is NULL, libaom will allocate memory
130 131
// internally to decode the current frame. Returns 0 on success. Returns < 0
// on failure.
132
int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
133
                             int ss_x, int ss_y, int use_highbitdepth,
134
                             int border, int byte_alignment,
135 136 137
                             aom_codec_frame_buffer_t *fb,
                             aom_get_frame_buffer_cb_fn_t cb, void *cb_priv);
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
138

John Koleszar's avatar
John Koleszar committed
139 140 141 142
#ifdef __cplusplus
}
#endif

143
#endif  // AOM_SCALE_YV12CONFIG_H_