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 | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 24 | #if CONFIG_EXT_PARTITION |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 25 | #define AOMINNERBORDERINPIXELS 160 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 26 | #else |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 27 | #define AOMINNERBORDERINPIXELS 96 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | #endif // CONFIG_EXT_PARTITION |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 29 | #define AOM_INTERP_EXTEND 4 |
Yaowu Xu | 671f2bd | 2016-09-30 15:07:57 -0700 | [diff] [blame] | 30 | |
| 31 | // TODO(jingning): Use unified inter predictor for encoder and |
| 32 | // decoder during the development process. Revisit the frame border |
| 33 | // to improve the decoder performance. |
| 34 | #define AOM_BORDER_IN_PIXELS 160 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 35 | |
| 36 | typedef struct yv12_buffer_config { |
| 37 | int y_width; |
| 38 | int y_height; |
| 39 | int y_crop_width; |
| 40 | int y_crop_height; |
| 41 | int y_stride; |
| 42 | |
| 43 | int uv_width; |
| 44 | int uv_height; |
| 45 | int uv_crop_width; |
| 46 | int uv_crop_height; |
| 47 | int uv_stride; |
| 48 | |
| 49 | int alpha_width; |
| 50 | int alpha_height; |
| 51 | int alpha_stride; |
| 52 | |
| 53 | uint8_t *y_buffer; |
| 54 | uint8_t *u_buffer; |
| 55 | uint8_t *v_buffer; |
| 56 | uint8_t *alpha_buffer; |
| 57 | |
David Barker | 557ce7b | 2016-11-16 10:22:24 +0000 | [diff] [blame] | 58 | #if CONFIG_AOM_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION |
| 59 | // If the frame is stored in a 16-bit buffer, this stores an 8-bit version |
| 60 | // for use in global motion detection. It is allocated on-demand. |
| 61 | uint8_t *y_buffer_8bit; |
| 62 | #endif |
| 63 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 64 | uint8_t *buffer_alloc; |
| 65 | size_t buffer_alloc_sz; |
| 66 | int border; |
| 67 | size_t frame_size; |
| 68 | int subsampling_x; |
| 69 | int subsampling_y; |
| 70 | unsigned int bit_depth; |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 71 | aom_color_space_t color_space; |
| 72 | aom_color_range_t color_range; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 73 | int render_width; |
| 74 | int render_height; |
| 75 | |
| 76 | int corrupted; |
| 77 | int flags; |
| 78 | } YV12_BUFFER_CONFIG; |
| 79 | |
| 80 | #define YV12_FLAG_HIGHBITDEPTH 8 |
| 81 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 82 | int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 83 | int ss_x, int ss_y, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 84 | #if CONFIG_AOM_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 85 | int use_highbitdepth, |
| 86 | #endif |
| 87 | int border, int byte_alignment); |
| 88 | |
| 89 | // Updates the yv12 buffer config with the frame buffer. |byte_alignment| must |
| 90 | // be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not |
| 91 | // NULL, then libaom is using the frame buffer callbacks to handle memory. |
| 92 | // If cb is not NULL, libaom will call cb with minimum size in bytes needed |
| 93 | // to decode the current frame. If cb is NULL, libaom will allocate memory |
| 94 | // internally to decode the current frame. Returns 0 on success. Returns < 0 |
| 95 | // on failure. |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 96 | int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 97 | int ss_x, int ss_y, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 98 | #if CONFIG_AOM_HIGHBITDEPTH |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 99 | int use_highbitdepth, |
| 100 | #endif |
| 101 | int border, int byte_alignment, |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 102 | aom_codec_frame_buffer_t *fb, |
| 103 | aom_get_frame_buffer_cb_fn_t cb, void *cb_priv); |
| 104 | int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 105 | |
| 106 | #ifdef __cplusplus |
| 107 | } |
| 108 | #endif |
| 109 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 110 | #endif // AOM_SCALE_YV12CONFIG_H_ |