LCOV - code coverage report
Current view: top level - media/libvpx/libvpx/vp9/common - vp9_frame_buffers.c (source / functions) Hit Total Coverage
Test: output.info Lines: 0 35 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2014 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             : #include <assert.h>
      12             : 
      13             : #include "vp9/common/vp9_frame_buffers.h"
      14             : #include "vpx_mem/vpx_mem.h"
      15             : 
      16           0 : int vp9_alloc_internal_frame_buffers(InternalFrameBufferList *list) {
      17           0 :   assert(list != NULL);
      18           0 :   vp9_free_internal_frame_buffers(list);
      19             : 
      20           0 :   list->num_internal_frame_buffers =
      21             :       VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS;
      22           0 :   list->int_fb = (InternalFrameBuffer *)vpx_calloc(
      23           0 :       list->num_internal_frame_buffers, sizeof(*list->int_fb));
      24           0 :   return (list->int_fb == NULL);
      25             : }
      26             : 
      27           0 : void vp9_free_internal_frame_buffers(InternalFrameBufferList *list) {
      28             :   int i;
      29             : 
      30           0 :   assert(list != NULL);
      31             : 
      32           0 :   for (i = 0; i < list->num_internal_frame_buffers; ++i) {
      33           0 :     vpx_free(list->int_fb[i].data);
      34           0 :     list->int_fb[i].data = NULL;
      35             :   }
      36           0 :   vpx_free(list->int_fb);
      37           0 :   list->int_fb = NULL;
      38           0 : }
      39             : 
      40           0 : int vp9_get_frame_buffer(void *cb_priv, size_t min_size,
      41             :                          vpx_codec_frame_buffer_t *fb) {
      42             :   int i;
      43           0 :   InternalFrameBufferList *const int_fb_list =
      44             :       (InternalFrameBufferList *)cb_priv;
      45           0 :   if (int_fb_list == NULL) return -1;
      46             : 
      47             :   // Find a free frame buffer.
      48           0 :   for (i = 0; i < int_fb_list->num_internal_frame_buffers; ++i) {
      49           0 :     if (!int_fb_list->int_fb[i].in_use) break;
      50             :   }
      51             : 
      52           0 :   if (i == int_fb_list->num_internal_frame_buffers) return -1;
      53             : 
      54           0 :   if (int_fb_list->int_fb[i].size < min_size) {
      55           0 :     vpx_free(int_fb_list->int_fb[i].data);
      56             :     // The data must be zeroed to fix a valgrind error from the C loop filter
      57             :     // due to access uninitialized memory in frame border. It could be
      58             :     // skipped if border were totally removed.
      59           0 :     int_fb_list->int_fb[i].data = (uint8_t *)vpx_calloc(1, min_size);
      60           0 :     if (!int_fb_list->int_fb[i].data) return -1;
      61           0 :     int_fb_list->int_fb[i].size = min_size;
      62             :   }
      63             : 
      64           0 :   fb->data = int_fb_list->int_fb[i].data;
      65           0 :   fb->size = int_fb_list->int_fb[i].size;
      66           0 :   int_fb_list->int_fb[i].in_use = 1;
      67             : 
      68             :   // Set the frame buffer's private data to point at the internal frame buffer.
      69           0 :   fb->priv = &int_fb_list->int_fb[i];
      70           0 :   return 0;
      71             : }
      72             : 
      73           0 : int vp9_release_frame_buffer(void *cb_priv, vpx_codec_frame_buffer_t *fb) {
      74           0 :   InternalFrameBuffer *const int_fb = (InternalFrameBuffer *)fb->priv;
      75             :   (void)cb_priv;
      76           0 :   if (int_fb) int_fb->in_use = 0;
      77           0 :   return 0;
      78             : }

Generated by: LCOV version 1.13