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

          Line data    Source code
       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             : #include "dboolhuff.h"
      12             : #include "vp8/common/common.h"
      13             : #include "vpx_dsp/vpx_dsp_common.h"
      14             : 
      15           0 : int vp8dx_start_decode(BOOL_DECODER *br, const unsigned char *source,
      16             :                        unsigned int source_sz, vpx_decrypt_cb decrypt_cb,
      17             :                        void *decrypt_state) {
      18           0 :   br->user_buffer_end = source + source_sz;
      19           0 :   br->user_buffer = source;
      20           0 :   br->value = 0;
      21           0 :   br->count = -8;
      22           0 :   br->range = 255;
      23           0 :   br->decrypt_cb = decrypt_cb;
      24           0 :   br->decrypt_state = decrypt_state;
      25             : 
      26           0 :   if (source_sz && !source) return 1;
      27             : 
      28             :   /* Populate the buffer */
      29           0 :   vp8dx_bool_decoder_fill(br);
      30             : 
      31           0 :   return 0;
      32             : }
      33             : 
      34           0 : void vp8dx_bool_decoder_fill(BOOL_DECODER *br) {
      35           0 :   const unsigned char *bufptr = br->user_buffer;
      36           0 :   VP8_BD_VALUE value = br->value;
      37           0 :   int count = br->count;
      38           0 :   int shift = VP8_BD_VALUE_SIZE - CHAR_BIT - (count + CHAR_BIT);
      39           0 :   size_t bytes_left = br->user_buffer_end - bufptr;
      40           0 :   size_t bits_left = bytes_left * CHAR_BIT;
      41           0 :   int x = shift + CHAR_BIT - (int)bits_left;
      42           0 :   int loop_end = 0;
      43             :   unsigned char decrypted[sizeof(VP8_BD_VALUE) + 1];
      44             : 
      45           0 :   if (br->decrypt_cb) {
      46           0 :     size_t n = VPXMIN(sizeof(decrypted), bytes_left);
      47           0 :     br->decrypt_cb(br->decrypt_state, bufptr, decrypted, (int)n);
      48           0 :     bufptr = decrypted;
      49             :   }
      50             : 
      51           0 :   if (x >= 0) {
      52           0 :     count += VP8_LOTS_OF_BITS;
      53           0 :     loop_end = x;
      54             :   }
      55             : 
      56           0 :   if (x < 0 || bits_left) {
      57           0 :     while (shift >= loop_end) {
      58           0 :       count += CHAR_BIT;
      59           0 :       value |= (VP8_BD_VALUE)*bufptr << shift;
      60           0 :       ++bufptr;
      61           0 :       ++br->user_buffer;
      62           0 :       shift -= CHAR_BIT;
      63             :     }
      64             :   }
      65             : 
      66           0 :   br->value = value;
      67           0 :   br->count = count;
      68           0 : }

Generated by: LCOV version 1.13