LCOV - app.info - media/libvpx/vpx_scale/generic/yv12config.c

LCOV - code coverage report
| Current view: | directory - media/libvpx/vpx_scale/generic - yv12config.c (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 34 | 0 | 0.0 %
| Date: | 2012-07-07 | Functions: | 2 | 0 | 0.0 %

           1                 : /*
           2                 :  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
           3                 :  *
           4                 :  *  Use of this source code is governed by a BSD-style license
           5                 :  *  that can be found in the LICENSE file in the root of the source
           6                 :  *  tree. An additional intellectual property rights grant can be found
           7                 :  *  in the file PATENTS.  All contributing project authors may
           8                 :  *  be found in the AUTHORS file in the root of the source tree.
           9                 :  */
          10                 :
          11                 :
          12                 : #include "vpx_scale/yv12config.h"
          13                 : #include "vpx_mem/vpx_mem.h"
          14                 :
          15                 : /****************************************************************************
          16                 : *  Exports
          17                 : ****************************************************************************/
          18                 :
          19                 : /****************************************************************************
          20                 :  *
          21                 :  ****************************************************************************/
          22                 : int
          23               0 : vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf)
          24                 : {
          25               0 :     if (ybf)
          26                 :     {
          27               0 :         vpx_free(ybf->buffer_alloc);
          28                 :
          29                 :         /* buffer_alloc isn't accessed by most functions.  Rather y_buffer,
          30                 :           u_buffer and v_buffer point to buffer_alloc and are used.  Clear out
          31                 :           all of this so that a freed pointer isn't inadvertently used */
          32               0 :         vpx_memset (ybf, 0, sizeof (YV12_BUFFER_CONFIG));
          33                 :     }
          34                 :     else
          35                 :     {
          36               0 :         return -1;
          37                 :     }
          38                 :
          39               0 :     return 0;
          40                 : }
          41                 :
          42                 : /****************************************************************************
          43                 :  *
          44                 :  ****************************************************************************/
          45                 : int
          46               0 : vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int border)
          47                 : {
          48                 : /*NOTE:*/
          49                 :
          50               0 :     if (ybf)
          51                 :     {
          52               0 :         int y_stride = ((width + 2 * border) + 31) & ~31;
          53               0 :         int yplane_size = (height + 2 * border) * y_stride;
          54               0 :         int uv_width = width >> 1;
          55               0 :         int uv_height = height >> 1;
          56                 :         /** There is currently a bunch of code which assumes
          57                 :           *  uv_stride == y_stride/2, so enforce this here. */
          58               0 :         int uv_stride = y_stride >> 1;
          59               0 :         int uvplane_size = (uv_height + border) * uv_stride;
          60                 :
          61               0 :         vp8_yv12_de_alloc_frame_buffer(ybf);
          62                 :
          63                 :         /** Only support allocating buffers that have a height and width that
          64                 :           *  are multiples of 16, and a border that's a multiple of 32.
          65                 :           * The border restriction is required to get 16-byte alignment of the
          66                 :           *  start of the chroma rows without intoducing an arbitrary gap
          67                 :           *  between planes, which would break the semantics of things like
          68                 :           *  vpx_img_set_rect(). */
          69               0 :         if ((width & 0xf) | (height & 0xf) | (border & 0x1f))
          70               0 :             return -3;
          71                 :
          72               0 :         ybf->y_width  = width;
          73               0 :         ybf->y_height = height;
          74               0 :         ybf->y_stride = y_stride;
          75                 :
          76               0 :         ybf->uv_width = uv_width;
          77               0 :         ybf->uv_height = uv_height;
          78               0 :         ybf->uv_stride = uv_stride;
          79                 :
          80               0 :         ybf->border = border;
          81               0 :         ybf->frame_size = yplane_size + 2 * uvplane_size;
          82                 :
          83               0 :         ybf->buffer_alloc = (unsigned char *) vpx_memalign(32, ybf->frame_size);
          84                 :
          85               0 :         if (ybf->buffer_alloc == NULL)
          86               0 :             return -1;
          87                 :
          88               0 :         ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
          89               0 :         ybf->u_buffer = ybf->buffer_alloc + yplane_size + (border / 2  * uv_stride) + border / 2;
          90               0 :         ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size + (border / 2  * uv_stride) + border / 2;
          91                 :
          92               0 :         ybf->corrupted = 0; /* assume not currupted by errors */
          93                 :     }
          94                 :     else
          95                 :     {
          96               0 :         return -2;
          97                 :     }
          98                 :
          99               0 :     return 0;
         100                 : }

Generated by: LCOV version 1.7