aboutsummaryrefslogtreecommitdiff
path: root/libvpx/vp9/vp9_iface_common.h
diff options
context:
space:
mode:
authorJohann <johannkoenig@google.com>2019-12-19 15:13:14 -0800
committerJohann <johannkoenig@google.com>2020-01-13 15:18:33 -0800
commit6ec360e770aae975eb3702467d9df6f76bc29700 (patch)
tree2aefc46ce3861ac17b136a0d66f82212c5bfa5ab /libvpx/vp9/vp9_iface_common.h
parentf95b460169fe5b77f1d493fd2e58b31a2dbf816b (diff)
downloadlibvpx-6ec360e770aae975eb3702467d9df6f76bc29700.tar.gz
libvpx: Pull from upstream
Current HEAD: 7ec7a33a081aeeb53fed1a8d87e4cbd189152527 git log from upstream: 7ec7a33a0 Release v1.8.2 Pekin Duck Test: upstream Change-Id: If7ab690a76b3cd93a3c922d5e9fc9a3996668005
Diffstat (limited to 'libvpx/vp9/vp9_iface_common.h')
-rw-r--r--libvpx/vp9/vp9_iface_common.h137
1 files changed, 18 insertions, 119 deletions
diff --git a/libvpx/vp9/vp9_iface_common.h b/libvpx/vp9/vp9_iface_common.h
index a1921db63..e646917c6 100644
--- a/libvpx/vp9/vp9_iface_common.h
+++ b/libvpx/vp9/vp9_iface_common.h
@@ -10,130 +10,24 @@
#ifndef VPX_VP9_VP9_IFACE_COMMON_H_
#define VPX_VP9_VP9_IFACE_COMMON_H_
+#include <assert.h>
#include "vpx_ports/mem.h"
+#include "vpx/vp8.h"
+#include "vpx_scale/yv12config.h"
+#include "common/vp9_enums.h"
-static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
- void *user_priv) {
- /** vpx_img_wrap() doesn't allow specifying independent strides for
- * the Y, U, and V planes, nor other alignment adjustments that
- * might be representable by a YV12_BUFFER_CONFIG, so we just
- * initialize all the fields.*/
- int bps;
- if (!yv12->subsampling_y) {
- if (!yv12->subsampling_x) {
- img->fmt = VPX_IMG_FMT_I444;
- bps = 24;
- } else {
- img->fmt = VPX_IMG_FMT_I422;
- bps = 16;
- }
- } else {
- if (!yv12->subsampling_x) {
- img->fmt = VPX_IMG_FMT_I440;
- bps = 16;
- } else {
- img->fmt = VPX_IMG_FMT_I420;
- bps = 12;
- }
- }
- img->cs = yv12->color_space;
- img->range = yv12->color_range;
- img->bit_depth = 8;
- img->w = yv12->y_stride;
- img->h = ALIGN_POWER_OF_TWO(yv12->y_height + 2 * VP9_ENC_BORDER_IN_PIXELS, 3);
- img->d_w = yv12->y_crop_width;
- img->d_h = yv12->y_crop_height;
- img->r_w = yv12->render_width;
- img->r_h = yv12->render_height;
- img->x_chroma_shift = yv12->subsampling_x;
- img->y_chroma_shift = yv12->subsampling_y;
- img->planes[VPX_PLANE_Y] = yv12->y_buffer;
- img->planes[VPX_PLANE_U] = yv12->u_buffer;
- img->planes[VPX_PLANE_V] = yv12->v_buffer;
- img->planes[VPX_PLANE_ALPHA] = NULL;
- img->stride[VPX_PLANE_Y] = yv12->y_stride;
- img->stride[VPX_PLANE_U] = yv12->uv_stride;
- img->stride[VPX_PLANE_V] = yv12->uv_stride;
- img->stride[VPX_PLANE_ALPHA] = yv12->y_stride;
-#if CONFIG_VP9_HIGHBITDEPTH
- if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) {
- // vpx_image_t uses byte strides and a pointer to the first byte
- // of the image.
- img->fmt = (vpx_img_fmt_t)(img->fmt | VPX_IMG_FMT_HIGHBITDEPTH);
- img->bit_depth = yv12->bit_depth;
- img->planes[VPX_PLANE_Y] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->y_buffer);
- img->planes[VPX_PLANE_U] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->u_buffer);
- img->planes[VPX_PLANE_V] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->v_buffer);
- img->planes[VPX_PLANE_ALPHA] = NULL;
- img->stride[VPX_PLANE_Y] = 2 * yv12->y_stride;
- img->stride[VPX_PLANE_U] = 2 * yv12->uv_stride;
- img->stride[VPX_PLANE_V] = 2 * yv12->uv_stride;
- img->stride[VPX_PLANE_ALPHA] = 2 * yv12->y_stride;
- }
-#endif // CONFIG_VP9_HIGHBITDEPTH
- img->bps = bps;
- img->user_priv = user_priv;
- img->img_data = yv12->buffer_alloc;
- img->img_data_owner = 0;
- img->self_allocd = 0;
-}
-
-static vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
- YV12_BUFFER_CONFIG *yv12) {
- yv12->y_buffer = img->planes[VPX_PLANE_Y];
- yv12->u_buffer = img->planes[VPX_PLANE_U];
- yv12->v_buffer = img->planes[VPX_PLANE_V];
-
- yv12->y_crop_width = img->d_w;
- yv12->y_crop_height = img->d_h;
- yv12->render_width = img->r_w;
- yv12->render_height = img->r_h;
- yv12->y_width = img->d_w;
- yv12->y_height = img->d_h;
+#ifdef __cplusplus
+extern "C" {
+#endif
- yv12->uv_width =
- img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2 : yv12->y_width;
- yv12->uv_height =
- img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height;
- yv12->uv_crop_width = yv12->uv_width;
- yv12->uv_crop_height = yv12->uv_height;
+void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12,
+ void *user_priv);
- yv12->y_stride = img->stride[VPX_PLANE_Y];
- yv12->uv_stride = img->stride[VPX_PLANE_U];
- yv12->color_space = img->cs;
- yv12->color_range = img->range;
+vpx_codec_err_t image2yuvconfig(const vpx_image_t *img,
+ YV12_BUFFER_CONFIG *yv12);
-#if CONFIG_VP9_HIGHBITDEPTH
- if (img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) {
- // In vpx_image_t
- // planes point to uint8 address of start of data
- // stride counts uint8s to reach next row
- // In YV12_BUFFER_CONFIG
- // y_buffer, u_buffer, v_buffer point to uint16 address of data
- // stride and border counts in uint16s
- // This means that all the address calculations in the main body of code
- // should work correctly.
- // However, before we do any pixel operations we need to cast the address
- // to a uint16 ponter and double its value.
- yv12->y_buffer = CONVERT_TO_BYTEPTR(yv12->y_buffer);
- yv12->u_buffer = CONVERT_TO_BYTEPTR(yv12->u_buffer);
- yv12->v_buffer = CONVERT_TO_BYTEPTR(yv12->v_buffer);
- yv12->y_stride >>= 1;
- yv12->uv_stride >>= 1;
- yv12->flags = YV12_FLAG_HIGHBITDEPTH;
- } else {
- yv12->flags = 0;
- }
- yv12->border = (yv12->y_stride - img->w) / 2;
-#else
- yv12->border = (img->stride[VPX_PLANE_Y] - img->w) / 2;
-#endif // CONFIG_VP9_HIGHBITDEPTH
- yv12->subsampling_x = img->x_chroma_shift;
- yv12->subsampling_y = img->y_chroma_shift;
- return VPX_CODEC_OK;
-}
-
-static VP9_REFFRAME ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) {
+static INLINE VP9_REFFRAME
+ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) {
switch (frame) {
case VP8_LAST_FRAME: return VP9_LAST_FLAG;
case VP8_GOLD_FRAME: return VP9_GOLD_FLAG;
@@ -142,4 +36,9 @@ static VP9_REFFRAME ref_frame_to_vp9_reframe(vpx_ref_frame_type_t frame) {
assert(0 && "Invalid Reference Frame");
return VP9_LAST_FLAG;
}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif // VPX_VP9_VP9_IFACE_COMMON_H_