Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AOM_SCALE_YV12CONFIG_H_ |
| 13 | #define AOM_SCALE_YV12CONFIG_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 19 | #include "./aom_config.h" |
| 20 | #include "aom/aom_codec.h" |
| 21 | #include "aom/aom_frame_buffer.h" |
| 22 | #include "aom/aom_integer.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 23 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 24 | #define AOMINNERBORDERINPIXELS 160 |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 25 | #define AOM_INTERP_EXTEND 4 |
Yaowu Xu | 671f2bd | 2016-09-30 15:07:57 -0700 | [diff] [blame] | 26 | |
| 27 | // TODO(jingning): Use unified inter predictor for encoder and |
| 28 | // decoder during the development process. Revisit the frame border |
| 29 | // to improve the decoder performance. |
Debargha Mukherjee | 5433fa4 | 2017-10-10 09:55:51 -0700 | [diff] [blame] | 30 | #define AOM_BORDER_IN_PIXELS 288 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 31 | |
| 32 | typedef struct yv12_buffer_config { |
Rupert Swarbrick | 82529d2 | 2017-09-20 13:36:39 +0100 | [diff] [blame] | 33 | union { |
| 34 | struct { |
| 35 | int y_width; |
| 36 | int uv_width; |
| 37 | int alpha_width; |
| 38 | }; |
| 39 | int widths[3]; |
| 40 | }; |
| 41 | union { |
| 42 | struct { |
| 43 | int y_height; |
| 44 | int uv_height; |
| 45 | int alpha_height; |
| 46 | }; |
| 47 | int heights[3]; |
| 48 | }; |
| 49 | union { |
| 50 | struct { |
| 51 | int y_crop_width; |
| 52 | int uv_crop_width; |
| 53 | }; |
| 54 | int crop_widths[2]; |
| 55 | }; |
| 56 | union { |
| 57 | struct { |
| 58 | int y_crop_height; |
| 59 | int uv_crop_height; |
| 60 | }; |
| 61 | int crop_heights[2]; |
| 62 | }; |
| 63 | union { |
| 64 | struct { |
| 65 | int y_stride; |
| 66 | int uv_stride; |
| 67 | int alpha_stride; |
| 68 | }; |
| 69 | int strides[3]; |
| 70 | }; |
| 71 | union { |
| 72 | struct { |
| 73 | uint8_t *y_buffer; |
| 74 | uint8_t *u_buffer; |
| 75 | uint8_t *v_buffer; |
| 76 | uint8_t *alpha_buffer; |
| 77 | }; |
| 78 | uint8_t *buffers[4]; |
| 79 | }; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 80 | |
David Barker | 557ce7b | 2016-11-16 10:22:24 +0000 | [diff] [blame] | 81 | // If the frame is stored in a 16-bit buffer, this stores an 8-bit version |
| 82 | // for use in global motion detection. It is allocated on-demand. |
| 83 | uint8_t *y_buffer_8bit; |
Yaowu Xu | 9b0f703 | 2017-07-31 11:01:19 -0700 | [diff] [blame] | 84 | int buf_8bit_valid; |
David Barker | 557ce7b | 2016-11-16 10:22:24 +0000 | [diff] [blame] | 85 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | uint8_t *buffer_alloc; |
| 87 | size_t buffer_alloc_sz; |
| 88 | int border; |
| 89 | size_t frame_size; |
| 90 | int subsampling_x; |
| 91 | int subsampling_y; |
| 92 | unsigned int bit_depth; |
Andrey Norkin | 9e69463 | 2017-12-21 18:50:57 -0800 | [diff] [blame] | 93 | aom_color_primaries_t color_primaries; |
| 94 | aom_transfer_characteristics_t transfer_characteristics; |
| 95 | aom_matrix_coefficients_t matrix_coefficients; |
Debargha Mukherjee | f340fec | 2018-01-10 18:12:22 -0800 | [diff] [blame] | 96 | int monochrome; |
anorkin | 76fb126 | 2017-03-22 15:12:12 -0700 | [diff] [blame] | 97 | aom_chroma_sample_position_t chroma_sample_position; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 98 | aom_color_range_t color_range; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 99 | int render_width; |
| 100 | int render_height; |
| 101 | |
| 102 | int corrupted; |
| 103 | int flags; |
| 104 | } YV12_BUFFER_CONFIG; |
| 105 | |
| 106 | #define YV12_FLAG_HIGHBITDEPTH 8 |
| 107 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 108 | int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
Yaowu Xu | d3e7c68 | 2017-12-21 14:08:25 -0800 | [diff] [blame] | 109 | int ss_x, int ss_y, int use_highbitdepth, int border, |
| 110 | int byte_alignment); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 111 | |
| 112 | // Updates the yv12 buffer config with the frame buffer. |byte_alignment| must |
| 113 | // be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not |
| 114 | // NULL, then libaom is using the frame buffer callbacks to handle memory. |
| 115 | // If cb is not NULL, libaom will call cb with minimum size in bytes needed |
| 116 | // to decode the current frame. If cb is NULL, libaom will allocate memory |
| 117 | // internally to decode the current frame. Returns 0 on success. Returns < 0 |
| 118 | // on failure. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 119 | int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
Yaowu Xu | d3e7c68 | 2017-12-21 14:08:25 -0800 | [diff] [blame] | 120 | int ss_x, int ss_y, int use_highbitdepth, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 121 | int border, int byte_alignment, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 122 | aom_codec_frame_buffer_t *fb, |
| 123 | aom_get_frame_buffer_cb_fn_t cb, void *cb_priv); |
| 124 | int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 125 | |
| 126 | #ifdef __cplusplus |
| 127 | } |
| 128 | #endif |
| 129 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 130 | #endif // AOM_SCALE_YV12CONFIG_H_ |