blob: 74a0d5502eafc9874ec0ac69b452c8fc6ca47cdf [file] [log] [blame]
John Koleszar0ea50ce2010-05-18 11:58:33 -04001/*
Adrian Grangeee9843d2016-03-24 12:08:51 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
John Koleszar0ea50ce2010-05-18 11:58:33 -04003 *
Adrian Grangeee9843d2016-03-24 12:08:51 -07004 * 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 Koleszar0ea50ce2010-05-18 11:58:33 -040010 */
11
Adrian Grangeff00fc02016-03-25 12:57:08 -070012#ifndef AOM_SCALE_YV12CONFIG_H_
13#define AOM_SCALE_YV12CONFIG_H_
Ronald S. Bultje4cca47b2012-12-18 15:31:19 -080014
John Koleszar0ea50ce2010-05-18 11:58:33 -040015#ifdef __cplusplus
Ronald S. Bultje4cca47b2012-12-18 15:31:19 -080016extern "C" {
John Koleszar0ea50ce2010-05-18 11:58:33 -040017#endif
18
Adrian Grangecebe6f02016-03-25 12:11:05 -070019#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. Bultje4cca47b2012-12-18 15:31:19 -080023
Adrian Grangedd1a5c82016-03-25 14:24:04 -070024#define AOMBORDERINPIXELS 32
Adrian Grangeff00fc02016-03-25 12:57:08 -070025#define AOMINNERBORDERINPIXELS 96
26#define AOM_INTERP_EXTEND 4
Jingning Hane2721a62016-06-06 09:39:20 -070027
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 Koleszar0ea50ce2010-05-18 11:58:33 -040032
James Zern9bd76da2014-02-10 20:08:28 -080033typedef struct yv12_buffer_config {
clang-format99e28b82016-01-27 12:42:45 -080034 int y_width;
35 int y_height;
36 int y_crop_width;
37 int y_crop_height;
38 int y_stride;
John Koleszar0ea50ce2010-05-18 11:58:33 -040039
clang-format99e28b82016-01-27 12:42:45 -080040 int uv_width;
41 int uv_height;
42 int uv_crop_width;
43 int uv_crop_height;
44 int uv_stride;
John Koleszar0ea50ce2010-05-18 11:58:33 -040045
clang-format99e28b82016-01-27 12:42:45 -080046 int alpha_width;
47 int alpha_height;
48 int alpha_stride;
Dmitry Kovalevb7a4f8a2013-05-15 16:29:20 -070049
James Zern9bd76da2014-02-10 20:08:28 -080050 uint8_t *y_buffer;
51 uint8_t *u_buffer;
52 uint8_t *v_buffer;
53 uint8_t *alpha_buffer;
John Koleszar0ea50ce2010-05-18 11:58:33 -040054
James Zern9bd76da2014-02-10 20:08:28 -080055 uint8_t *buffer_alloc;
56 int buffer_alloc_sz;
57 int border;
58 int frame_size;
Alex Conversea0befb92014-10-01 11:23:57 -070059 int subsampling_x;
60 int subsampling_y;
Alex Converseb932c6c2014-09-02 12:25:44 -070061 unsigned int bit_depth;
Adrian Grangecebe6f02016-03-25 12:11:05 -070062 aom_color_space_t color_space;
63 aom_color_range_t color_range;
Ronald S. Bultje812945a2015-09-25 21:51:55 -040064 int render_width;
65 int render_height;
Henrik Lundin67fb3a52010-12-16 16:46:31 +010066
James Zern9bd76da2014-02-10 20:08:28 -080067 int corrupted;
68 int flags;
69} YV12_BUFFER_CONFIG;
John Koleszar0ea50ce2010-05-18 11:58:33 -040070
Yaowu Xudd273072015-02-06 16:32:20 -080071#define YV12_FLAG_HIGHBITDEPTH 8
Deb Mukherjee5acfafb2014-08-26 12:35:15 -070072
Adrian Grangecebe6f02016-03-25 12:11:05 -070073int aom_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
clang-format99e28b82016-01-27 12:42:45 -080074 int border);
Adrian Grangecebe6f02016-03-25 12:11:05 -070075int aom_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width,
clang-format99e28b82016-01-27 12:42:45 -080076 int height, int border);
Adrian Grangecebe6f02016-03-25 12:11:05 -070077int aom_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf);
John Koleszar0ea50ce2010-05-18 11:58:33 -040078
Adrian Grangecebe6f02016-03-25 12:11:05 -070079int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
clang-format99e28b82016-01-27 12:42:45 -080080 int ss_x, int ss_y,
Yaowu Xu01dee0b2016-03-25 12:43:01 -070081#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee5acfafb2014-08-26 12:35:15 -070082 int use_highbitdepth,
83#endif
Frank Galliganc4f70792014-12-15 12:00:09 -080084 int border, int byte_alignment);
James Zern9bd76da2014-02-10 20:08:28 -080085
Frank Galliganc4f70792014-12-15 12:00:09 -080086// 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 Xu3d26d912016-03-22 12:33:42 -070088// 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 Zern9bd76da2014-02-10 20:08:28 -080091// internally to decode the current frame. Returns 0 on success. Returns < 0
92// on failure.
Adrian Grangecebe6f02016-03-25 12:11:05 -070093int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
clang-format99e28b82016-01-27 12:42:45 -080094 int ss_x, int ss_y,
Yaowu Xu01dee0b2016-03-25 12:43:01 -070095#if CONFIG_AOM_HIGHBITDEPTH
Deb Mukherjee5acfafb2014-08-26 12:35:15 -070096 int use_highbitdepth,
97#endif
clang-format99e28b82016-01-27 12:42:45 -080098 int border, int byte_alignment,
Adrian Grangecebe6f02016-03-25 12:11:05 -070099 aom_codec_frame_buffer_t *fb,
100 aom_get_frame_buffer_cb_fn_t cb, void *cb_priv);
101int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
John Koleszarda584362013-05-06 15:52:06 -0700102
John Koleszar0ea50ce2010-05-18 11:58:33 -0400103#ifdef __cplusplus
104}
105#endif
106
Adrian Grangeff00fc02016-03-25 12:57:08 -0700107#endif // AOM_SCALE_YV12CONFIG_H_