blob: 76bfe9d7b19176946c13565f8af2b28cd515fea6 [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_SCALE_YV12CONFIG_H_
13#define AOM_SCALE_YV12CONFIG_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
Yaowu Xuf883b422016-08-30 14:01:10 -070019#include "./aom_config.h"
20#include "aom/aom_codec.h"
21#include "aom/aom_frame_buffer.h"
22#include "aom/aom_integer.h"
Yaowu Xuc27fc142016-08-22 16:08:15 -070023
Yaowu Xuc27fc142016-08-22 16:08:15 -070024#if CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -070025#define AOMINNERBORDERINPIXELS 160
Yaowu Xuc27fc142016-08-22 16:08:15 -070026#else
Yaowu Xuf883b422016-08-30 14:01:10 -070027#define AOMINNERBORDERINPIXELS 96
Yaowu Xuc27fc142016-08-22 16:08:15 -070028#endif // CONFIG_EXT_PARTITION
Yaowu Xuf883b422016-08-30 14:01:10 -070029#define AOM_INTERP_EXTEND 4
Yaowu Xu671f2bd2016-09-30 15:07:57 -070030
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 Xuc27fc142016-08-22 16:08:15 -070035
36typedef 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
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020058#if CONFIG_HIGHBITDEPTH && CONFIG_GLOBAL_MOTION
David Barker557ce7b2016-11-16 10:22:24 +000059 // 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 Xuc27fc142016-08-22 16:08:15 -070064 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 Xuf883b422016-08-30 14:01:10 -070071 aom_color_space_t color_space;
anorkin76fb1262017-03-22 15:12:12 -070072#if CONFIG_COLORSPACE_HEADERS
73 aom_transfer_function_t transfer_function;
74 aom_chroma_sample_position_t chroma_sample_position;
75#endif
Yaowu Xuf883b422016-08-30 14:01:10 -070076 aom_color_range_t color_range;
Yaowu Xuc27fc142016-08-22 16:08:15 -070077 int render_width;
78 int render_height;
79
80 int corrupted;
81 int flags;
82} YV12_BUFFER_CONFIG;
83
84#define YV12_FLAG_HIGHBITDEPTH 8
85
Yaowu Xuf883b422016-08-30 14:01:10 -070086int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
Yaowu Xuc27fc142016-08-22 16:08:15 -070087 int ss_x, int ss_y,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +020088#if CONFIG_HIGHBITDEPTH
Yaowu Xuc27fc142016-08-22 16:08:15 -070089 int use_highbitdepth,
90#endif
91 int border, int byte_alignment);
92
93// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
94// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
95// NULL, then libaom is using the frame buffer callbacks to handle memory.
96// If cb is not NULL, libaom will call cb with minimum size in bytes needed
97// to decode the current frame. If cb is NULL, libaom will allocate memory
98// internally to decode the current frame. Returns 0 on success. Returns < 0
99// on failure.
Yaowu Xuf883b422016-08-30 14:01:10 -0700100int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
Yaowu Xuc27fc142016-08-22 16:08:15 -0700101 int ss_x, int ss_y,
Sebastien Alaiwan71e87842017-04-12 16:03:28 +0200102#if CONFIG_HIGHBITDEPTH
Yaowu Xuc27fc142016-08-22 16:08:15 -0700103 int use_highbitdepth,
104#endif
105 int border, int byte_alignment,
Yaowu Xuf883b422016-08-30 14:01:10 -0700106 aom_codec_frame_buffer_t *fb,
107 aom_get_frame_buffer_cb_fn_t cb, void *cb_priv);
108int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700109
110#ifdef __cplusplus
111}
112#endif
113
Yaowu Xuf883b422016-08-30 14:01:10 -0700114#endif // AOM_SCALE_YV12CONFIG_H_