chromium/third_party/libaom/source/libaom/aom_scale/yv12config.h

/*
 * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
 *
 * This source code is subject to the terms of the BSD 2 Clause License and
 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
 * was not distributed with this source code in the LICENSE file, you can
 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
 * Media Patent License 1.0 was not distributed with this source code in the
 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
 */

#ifndef AOM_AOM_SCALE_YV12CONFIG_H_
#define AOM_AOM_SCALE_YV12CONFIG_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

#include "config/aom_config.h"

#include "aom/aom_codec.h"
#include "aom/aom_frame_buffer.h"
#include "aom/aom_integer.h"
#include "aom/internal/aom_image_internal.h"

/*!\cond */

#define AOMINNERBORDERINPIXELS
#define AOM_INTERP_EXTEND
#define AOM_BORDER_IN_PIXELS
#define AOM_ENC_NO_SCALE_BORDER
#define AOM_ENC_ALLINTRA_BORDER
#define AOM_DEC_BORDER_IN_PIXELS

#if CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY
struct image_pyramid;
struct corner_list;
#endif  // CONFIG_AV1_ENCODER && !CONFIG_REALTIME_ONLY

/*!\endcond */
/*!
 * \brief YV12 frame buffer data structure
 */
YV12_BUFFER_CONFIG;

/*!\cond */

#define YV12_FLAG_HIGHBITDEPTH

// Allocate a frame buffer
//
// If ybf currently contains an image, all associated memory will be freed and
// then reallocated. In contrast, aom_realloc_frame_buffer() will reuse any
// existing allocations where possible. So, if ybf is likely to already be
// set up, please consider aom_realloc_frame_buffer() instead.
//
// See aom_realloc_frame_buffer() for the meanings of the arguments, and
// available return values.
int aom_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
                           int ss_x, int ss_y, int use_highbitdepth, int border,
                           int byte_alignment, bool alloc_pyramid,
                           int alloc_y_plane_only);

// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
// NULL, then libaom is using the frame buffer callbacks to handle memory.
// If cb is not NULL, libaom will call cb with minimum size in bytes needed
// to decode the current frame. If cb is NULL, libaom will allocate memory
// internally to decode the current frame.
//
// If alloc_pyramid is true, then an image pyramid will be allocated
// for use in global motion estimation. This is only needed if this frame
// buffer will be used to store a source frame or a reference frame in
// the encoder. Any other framebuffers (eg, intermediates for filtering,
// or any buffer in the decoder) can set alloc_pyramid = false.
//
// Returns 0 on success. Returns < 0  on failure.
int aom_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height,
                             int ss_x, int ss_y, int use_highbitdepth,
                             int border, int byte_alignment,
                             aom_codec_frame_buffer_t *fb,
                             aom_get_frame_buffer_cb_fn_t cb, void *cb_priv,
                             bool alloc_pyramid, int alloc_y_plane_only);

int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf);

/*!\endcond */
/*!\brief Removes metadata from YUV_BUFFER_CONFIG struct.
 *
 * Frees metadata in frame buffer.
 * Frame buffer metadata pointer will be set to NULL.
 *
 * \param[in]    ybf       Frame buffer struct pointer
 */
void aom_remove_metadata_from_frame_buffer(YV12_BUFFER_CONFIG *ybf);

/*!\brief Copy metadata to YUV_BUFFER_CONFIG struct.
 *
 * Copies metadata to frame buffer.
 * Frame buffer will clear any previous metadata and will reallocate the
 * metadata array to the new metadata size. Then, it will copy the new metadata
 * array into it.
 * If arr metadata pointer points to the same address as current metadata in the
 * frame buffer, function will do nothing and return 0.
 * Returns 0 on success or -1 on failure.
 *
 * \param[in]    ybf       Frame buffer struct pointer
 * \param[in]    arr       Metadata array struct pointer
 */
int aom_copy_metadata_to_frame_buffer(YV12_BUFFER_CONFIG *ybf,
                                      const aom_metadata_array_t *arr);

/*!\brief Calculate the stride required for the image.
 *
 * Calculates the stride value for an image from aligned width and border.
 * Returns the y stride value.
 *
 * \param[in]    aligned_width       Aligned width of the image
 * \param[in]    border              Border in pixels
 */
static inline int aom_calc_y_stride(int aligned_width, int border) {}

#ifdef __cplusplus
}
#endif

#endif  // AOM_AOM_SCALE_YV12CONFIG_H_