AOMedia AV1 Codec: aom_scale/yv12config.h Source File

| AOMedia AV1 Codec

yv12config.h
1 /*
2 * Copyright (c) 2016, 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_AOM_SCALE_YV12CONFIG_H_
13 #define AOM_AOM_SCALE_YV12CONFIG_H_
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 #include "config/aom_config.h"
20
21 #include "aom/aom_codec.h"
22 #include "aom/aom_frame_buffer.h"
23 #include "aom/aom_integer.h"
24 #include "aom/internal/aom_image_internal.h"
25
28 #define AOMINNERBORDERINPIXELS 160
29 #define AOM_INTERP_EXTEND 4
30 #define AOM_BORDER_IN_PIXELS 288
31 #define AOM_ENC_NO_SCALE_BORDER 160
32 #define AOM_DEC_BORDER_IN_PIXELS 64
33
38 typedef struct yv12_buffer_config {
40 union {
41 struct {
42 int y_width;
43 int uv_width;
44 };
45 int widths[2];
46 };
47 union {
48 struct {
49 int y_height;
50 int uv_height;
51 };
52 int heights[2];
53 };
54 union {
55 struct {
56 int y_crop_width;
57 int uv_crop_width;
58 };
59 int crop_widths[2];
60 };
61 union {
62 struct {
63 int y_crop_height;
64 int uv_crop_height;
65 };
66 int crop_heights[2];
67 };
68 union {
69 struct {
70 int y_stride;
71 int uv_stride;
72 };
73 int strides[2];
74 };
75 union {
76 struct {
77 uint8_t *y_buffer;
78 uint8_t *u_buffer;
79 uint8_t *v_buffer;
80 };
81 uint8_t *buffers[3];
82 };
83
84 // Indicate whether y_buffer, u_buffer, and v_buffer points to the internally
85 // allocated memory or external buffers.
86 int use_external_reference_buffers;
87 // This is needed to store y_buffer, u_buffer, and v_buffer when set reference
88 // uses an external refernece, and restore those buffer pointers after the
89 // external reference frame is no longer used.
90 uint8_t *store_buf_adr[3];
91
92 // If the frame is stored in a 16-bit buffer, this stores an 8-bit version
93 // for use in global motion detection. It is allocated on-demand.
94 uint8_t *y_buffer_8bit;
95 int buf_8bit_valid;
96
97 uint8_t *buffer_alloc;
98 size_t buffer_alloc_sz;
99 int border;
100 size_t frame_size;
101 int subsampling_x;
102 int subsampling_y;
103 unsigned int bit_depth;
104 aom_color_primaries_t color_primaries;
105 aom_transfer_characteristics_t transfer_characteristics;
106 aom_matrix_coefficients_t matrix_coefficients;
107 uint8_t monochrome;
108 aom_chroma_sample_position_t chroma_sample_position;
109 aom_color_range_t color_range;
110 int render_width;
111 int render_height;
112
113 int corrupted;
114 int flags;
115 aom_metadata_array_t *metadata;
117 } YV12_BUFFER_CONFIG;
118
121 #define YV12_FLAG_HIGHBITDEPTH 8
122
123 int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
124 int ss_x, int ss_y, int use_highbitdepth, int border,
125 int byte_alignment);
126
127 // Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
128 // be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
129 // NULL, then libaom is using the frame buffer callbacks to handle memory.
130 // If cb is not NULL, libaom will call cb with minimum size in bytes needed
131 // to decode the current frame. If cb is NULL, libaom will allocate memory
132 // internally to decode the current frame. Returns 0 on success. Returns < 0
133 // on failure.
134 int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
135 int ss_x, int ss_y, int use_highbitdepth,
136 int border, int byte_alignment,
137 aom_codec_frame_buffer_t *fb,
138 aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
139 int alloc_y_buffer_8bit);
140
141 int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
142
151 void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf);
152
166 int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
167 const aom_metadata_array_t *arr);
168
169 #ifdef __cplusplus
170 }
171 #endif
172
173 #endif // AOM_AOM_SCALE_YV12CONFIG_H_
aom_codec.h
Describes the codec algorithm interface to applications.
aom_frame_buffer.h
Describes the decoder external frame buffer interface.
aom_get_frame_buffer_cb_fn_t
int(* aom_get_frame_buffer_cb_fn_t)(void *priv, size_t min_size, aom_codec_frame_buffer_t *fb)
get frame buffer callback prototype
Definition: aom_frame_buffer.h:64
aom_chroma_sample_position_t
enum aom_chroma_sample_position aom_chroma_sample_position_t
List of chroma sample positions.
aom_metadata_array_t
struct aom_metadata_array aom_metadata_array_t
Array of aom_metadata structs for an image.
Definition: aom_image.h:160
aom_transfer_characteristics_t
enum aom_transfer_characteristics aom_transfer_characteristics_t
List of supported transfer functions.
aom_color_range_t
enum aom_color_range aom_color_range_t
List of supported color range.
aom_color_primaries_t
enum aom_color_primaries aom_color_primaries_t
List of supported color primaries.
aom_matrix_coefficients_t
enum aom_matrix_coefficients aom_matrix_coefficients_t
List of supported matrix coefficients.
aom_codec_frame_buffer
External frame buffer.
Definition: aom_frame_buffer.h:40
yv12_buffer_config
YV12 frame buffer data structure.
Definition: yv12config.h:38