LCOV - code coverage report
Current view: top level - third_party/aom/av1 - av1_iface_common.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 86 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
       3             :  *
       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.
      10             :  */
      11             : #ifndef AV1_AV1_IFACE_COMMON_H_
      12             : #define AV1_AV1_IFACE_COMMON_H_
      13             : 
      14             : #include "aom_ports/mem.h"
      15             : 
      16           0 : static void yuvconfig2image(aom_image_t *img, const YV12_BUFFER_CONFIG *yv12,
      17             :                             void *user_priv) {
      18             :   /** aom_img_wrap() doesn't allow specifying independent strides for
      19             :     * the Y, U, and V planes, nor other alignment adjustments that
      20             :     * might be representable by a YV12_BUFFER_CONFIG, so we just
      21             :     * initialize all the fields.*/
      22             :   int bps;
      23           0 :   if (!yv12->subsampling_y) {
      24           0 :     if (!yv12->subsampling_x) {
      25           0 :       img->fmt = AOM_IMG_FMT_I444;
      26           0 :       bps = 24;
      27             :     } else {
      28           0 :       img->fmt = AOM_IMG_FMT_I422;
      29           0 :       bps = 16;
      30             :     }
      31             :   } else {
      32           0 :     if (!yv12->subsampling_x) {
      33           0 :       img->fmt = AOM_IMG_FMT_I440;
      34           0 :       bps = 16;
      35             :     } else {
      36           0 :       img->fmt = AOM_IMG_FMT_I420;
      37           0 :       bps = 12;
      38             :     }
      39             :   }
      40           0 :   img->cs = yv12->color_space;
      41           0 :   img->range = yv12->color_range;
      42           0 :   img->bit_depth = 8;
      43           0 :   img->w = yv12->y_stride;
      44           0 :   img->h = ALIGN_POWER_OF_TWO(yv12->y_height + 2 * AOM_BORDER_IN_PIXELS, 3);
      45           0 :   img->d_w = yv12->y_crop_width;
      46           0 :   img->d_h = yv12->y_crop_height;
      47           0 :   img->r_w = yv12->render_width;
      48           0 :   img->r_h = yv12->render_height;
      49           0 :   img->x_chroma_shift = yv12->subsampling_x;
      50           0 :   img->y_chroma_shift = yv12->subsampling_y;
      51           0 :   img->planes[AOM_PLANE_Y] = yv12->y_buffer;
      52           0 :   img->planes[AOM_PLANE_U] = yv12->u_buffer;
      53           0 :   img->planes[AOM_PLANE_V] = yv12->v_buffer;
      54           0 :   img->planes[AOM_PLANE_ALPHA] = NULL;
      55           0 :   img->stride[AOM_PLANE_Y] = yv12->y_stride;
      56           0 :   img->stride[AOM_PLANE_U] = yv12->uv_stride;
      57           0 :   img->stride[AOM_PLANE_V] = yv12->uv_stride;
      58           0 :   img->stride[AOM_PLANE_ALPHA] = yv12->y_stride;
      59             : #if CONFIG_HIGHBITDEPTH
      60           0 :   if (yv12->flags & YV12_FLAG_HIGHBITDEPTH) {
      61             :     // aom_image_t uses byte strides and a pointer to the first byte
      62             :     // of the image.
      63           0 :     img->fmt = (aom_img_fmt_t)(img->fmt | AOM_IMG_FMT_HIGHBITDEPTH);
      64           0 :     img->bit_depth = yv12->bit_depth;
      65           0 :     img->planes[AOM_PLANE_Y] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->y_buffer);
      66           0 :     img->planes[AOM_PLANE_U] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->u_buffer);
      67           0 :     img->planes[AOM_PLANE_V] = (uint8_t *)CONVERT_TO_SHORTPTR(yv12->v_buffer);
      68           0 :     img->planes[AOM_PLANE_ALPHA] = NULL;
      69           0 :     img->stride[AOM_PLANE_Y] = 2 * yv12->y_stride;
      70           0 :     img->stride[AOM_PLANE_U] = 2 * yv12->uv_stride;
      71           0 :     img->stride[AOM_PLANE_V] = 2 * yv12->uv_stride;
      72           0 :     img->stride[AOM_PLANE_ALPHA] = 2 * yv12->y_stride;
      73             :   }
      74             : #endif  // CONFIG_HIGHBITDEPTH
      75           0 :   img->bps = bps;
      76           0 :   img->user_priv = user_priv;
      77           0 :   img->img_data = yv12->buffer_alloc;
      78           0 :   img->img_data_owner = 0;
      79           0 :   img->self_allocd = 0;
      80           0 : }
      81             : 
      82           0 : static aom_codec_err_t image2yuvconfig(const aom_image_t *img,
      83             :                                        YV12_BUFFER_CONFIG *yv12) {
      84           0 :   yv12->y_buffer = img->planes[AOM_PLANE_Y];
      85           0 :   yv12->u_buffer = img->planes[AOM_PLANE_U];
      86           0 :   yv12->v_buffer = img->planes[AOM_PLANE_V];
      87             : 
      88           0 :   yv12->y_crop_width = img->d_w;
      89           0 :   yv12->y_crop_height = img->d_h;
      90           0 :   yv12->render_width = img->r_w;
      91           0 :   yv12->render_height = img->r_h;
      92           0 :   yv12->y_width = img->d_w;
      93           0 :   yv12->y_height = img->d_h;
      94             : 
      95           0 :   yv12->uv_width =
      96           0 :       img->x_chroma_shift == 1 ? (1 + yv12->y_width) / 2 : yv12->y_width;
      97           0 :   yv12->uv_height =
      98           0 :       img->y_chroma_shift == 1 ? (1 + yv12->y_height) / 2 : yv12->y_height;
      99           0 :   yv12->uv_crop_width = yv12->uv_width;
     100           0 :   yv12->uv_crop_height = yv12->uv_height;
     101             : 
     102           0 :   yv12->y_stride = img->stride[AOM_PLANE_Y];
     103           0 :   yv12->uv_stride = img->stride[AOM_PLANE_U];
     104           0 :   yv12->color_space = img->cs;
     105           0 :   yv12->color_range = img->range;
     106             : 
     107             : #if CONFIG_HIGHBITDEPTH
     108           0 :   if (img->fmt & AOM_IMG_FMT_HIGHBITDEPTH) {
     109             :     // In aom_image_t
     110             :     //     planes point to uint8 address of start of data
     111             :     //     stride counts uint8s to reach next row
     112             :     // In YV12_BUFFER_CONFIG
     113             :     //     y_buffer, u_buffer, v_buffer point to uint16 address of data
     114             :     //     stride and border counts in uint16s
     115             :     // This means that all the address calculations in the main body of code
     116             :     // should work correctly.
     117             :     // However, before we do any pixel operations we need to cast the address
     118             :     // to a uint16 ponter and double its value.
     119           0 :     yv12->y_buffer = CONVERT_TO_BYTEPTR(yv12->y_buffer);
     120           0 :     yv12->u_buffer = CONVERT_TO_BYTEPTR(yv12->u_buffer);
     121           0 :     yv12->v_buffer = CONVERT_TO_BYTEPTR(yv12->v_buffer);
     122           0 :     yv12->y_stride >>= 1;
     123           0 :     yv12->uv_stride >>= 1;
     124           0 :     yv12->flags = YV12_FLAG_HIGHBITDEPTH;
     125             :   } else {
     126           0 :     yv12->flags = 0;
     127             :   }
     128           0 :   yv12->border = (yv12->y_stride - img->w) / 2;
     129             : #else
     130             :   yv12->border = (img->stride[AOM_PLANE_Y] - img->w) / 2;
     131             : #endif  // CONFIG_HIGHBITDEPTH
     132           0 :   yv12->subsampling_x = img->x_chroma_shift;
     133           0 :   yv12->subsampling_y = img->y_chroma_shift;
     134           0 :   return AOM_CODEC_OK;
     135             : }
     136             : 
     137           0 : static AOM_REFFRAME ref_frame_to_av1_reframe(aom_ref_frame_type_t frame) {
     138           0 :   switch (frame) {
     139           0 :     case AOM_LAST_FRAME: return AOM_LAST_FLAG;
     140           0 :     case AOM_GOLD_FRAME: return AOM_GOLD_FLAG;
     141           0 :     case AOM_ALTR_FRAME: return AOM_ALT_FLAG;
     142             :   }
     143           0 :   assert(0 && "Invalid Reference Frame");
     144             :   return AOM_LAST_FLAG;
     145             : }
     146             : #endif  // AV1_AV1_IFACE_COMMON_H_

Generated by: LCOV version 1.13