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

Generated by: LCOV version 1.13