John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 1 | /* |
Adrian Grange | ee9843d | 2016-03-24 12:08:51 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 3 | * |
Adrian Grange | ee9843d | 2016-03-24 12:08:51 -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. |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 10 | */ |
| 11 | |
Adrian Grange | ff00fc0 | 2016-03-25 12:57:08 -0700 | [diff] [blame] | 12 | #ifndef AOM_SCALE_YV12CONFIG_H_ |
| 13 | #define AOM_SCALE_YV12CONFIG_H_ |
Ronald S. Bultje | 4cca47b | 2012-12-18 15:31:19 -0800 | [diff] [blame] | 14 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 15 | #ifdef __cplusplus |
Ronald S. Bultje | 4cca47b | 2012-12-18 15:31:19 -0800 | [diff] [blame] | 16 | extern "C" { |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 17 | #endif |
| 18 | |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -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" |
Ronald S. Bultje | 4cca47b | 2012-12-18 15:31:19 -0800 | [diff] [blame] | 23 | |
Adrian Grange | dd1a5c8 | 2016-03-25 14:24:04 -0700 | [diff] [blame] | 24 | #define AOMBORDERINPIXELS 32 |
Adrian Grange | ff00fc0 | 2016-03-25 12:57:08 -0700 | [diff] [blame] | 25 | #define AOMINNERBORDERINPIXELS 96 |
| 26 | #define AOM_INTERP_EXTEND 4 |
Jingning Han | e2721a6 | 2016-06-06 09:39:20 -0700 | [diff] [blame] | 27 | |
| 28 | // TODO(jingning): Use unified inter predictor for encoder and |
| 29 | // decoder during the development process. Revisit the frame border |
| 30 | // to improve the decoder performance. |
| 31 | #define AOM_BORDER_IN_PIXELS 160 |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 32 | |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 33 | typedef struct yv12_buffer_config { |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 34 | int y_width; |
| 35 | int y_height; |
| 36 | int y_crop_width; |
| 37 | int y_crop_height; |
| 38 | int y_stride; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 39 | |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 40 | int uv_width; |
| 41 | int uv_height; |
| 42 | int uv_crop_width; |
| 43 | int uv_crop_height; |
| 44 | int uv_stride; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 45 | |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 46 | int alpha_width; |
| 47 | int alpha_height; |
| 48 | int alpha_stride; |
Dmitry Kovalev | b7a4f8a | 2013-05-15 16:29:20 -0700 | [diff] [blame] | 49 | |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 50 | uint8_t *y_buffer; |
| 51 | uint8_t *u_buffer; |
| 52 | uint8_t *v_buffer; |
| 53 | uint8_t *alpha_buffer; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 54 | |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 55 | uint8_t *buffer_alloc; |
| 56 | int buffer_alloc_sz; |
| 57 | int border; |
| 58 | int frame_size; |
Alex Converse | a0befb9 | 2014-10-01 11:23:57 -0700 | [diff] [blame] | 59 | int subsampling_x; |
| 60 | int subsampling_y; |
Alex Converse | b932c6c | 2014-09-02 12:25:44 -0700 | [diff] [blame] | 61 | unsigned int bit_depth; |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 62 | aom_color_space_t color_space; |
| 63 | aom_color_range_t color_range; |
Ronald S. Bultje | 812945a | 2015-09-25 21:51:55 -0400 | [diff] [blame] | 64 | int render_width; |
| 65 | int render_height; |
Henrik Lundin | 67fb3a5 | 2010-12-16 16:46:31 +0100 | [diff] [blame] | 66 | |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 67 | int corrupted; |
| 68 | int flags; |
| 69 | } YV12_BUFFER_CONFIG; |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 70 | |
Yaowu Xu | dd27307 | 2015-02-06 16:32:20 -0800 | [diff] [blame] | 71 | #define YV12_FLAG_HIGHBITDEPTH 8 |
Deb Mukherjee | 5acfafb | 2014-08-26 12:35:15 -0700 | [diff] [blame] | 72 | |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 73 | int aom_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 74 | int border); |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 75 | int aom_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 76 | int height, int border); |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 77 | int aom_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf); |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 78 | |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 79 | int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 80 | int ss_x, int ss_y, |
Yaowu Xu | 01dee0b | 2016-03-25 12:43:01 -0700 | [diff] [blame] | 81 | #if CONFIG_AOM_HIGHBITDEPTH |
Deb Mukherjee | 5acfafb | 2014-08-26 12:35:15 -0700 | [diff] [blame] | 82 | int use_highbitdepth, |
| 83 | #endif |
Frank Galligan | c4f7079 | 2014-12-15 12:00:09 -0800 | [diff] [blame] | 84 | int border, int byte_alignment); |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 85 | |
Frank Galligan | c4f7079 | 2014-12-15 12:00:09 -0800 | [diff] [blame] | 86 | // Updates the yv12 buffer config with the frame buffer. |byte_alignment| must |
| 87 | // be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not |
Yaowu Xu | 3d26d91 | 2016-03-22 12:33:42 -0700 | [diff] [blame] | 88 | // NULL, then libaom is using the frame buffer callbacks to handle memory. |
| 89 | // If cb is not NULL, libaom will call cb with minimum size in bytes needed |
| 90 | // to decode the current frame. If cb is NULL, libaom will allocate memory |
James Zern | 9bd76da | 2014-02-10 20:08:28 -0800 | [diff] [blame] | 91 | // internally to decode the current frame. Returns 0 on success. Returns < 0 |
| 92 | // on failure. |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 93 | int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 94 | int ss_x, int ss_y, |
Yaowu Xu | 01dee0b | 2016-03-25 12:43:01 -0700 | [diff] [blame] | 95 | #if CONFIG_AOM_HIGHBITDEPTH |
Deb Mukherjee | 5acfafb | 2014-08-26 12:35:15 -0700 | [diff] [blame] | 96 | int use_highbitdepth, |
| 97 | #endif |
clang-format | 99e28b8 | 2016-01-27 12:42:45 -0800 | [diff] [blame] | 98 | int border, int byte_alignment, |
Adrian Grange | cebe6f0 | 2016-03-25 12:11:05 -0700 | [diff] [blame] | 99 | aom_codec_frame_buffer_t *fb, |
| 100 | aom_get_frame_buffer_cb_fn_t cb, void *cb_priv); |
| 101 | int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf); |
John Koleszar | da58436 | 2013-05-06 15:52:06 -0700 | [diff] [blame] | 102 | |
John Koleszar | 0ea50ce | 2010-05-18 11:58:33 -0400 | [diff] [blame] | 103 | #ifdef __cplusplus |
| 104 | } |
| 105 | #endif |
| 106 | |
Adrian Grange | ff00fc0 | 2016-03-25 12:57:08 -0700 | [diff] [blame] | 107 | #endif // AOM_SCALE_YV12CONFIG_H_ |