tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

accounting.h (2594B)


      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 AOM_AV1_DECODER_ACCOUNTING_H_
     12 #define AOM_AV1_DECODER_ACCOUNTING_H_
     13 #include <stdlib.h>
     14 #include "aom/aomdx.h"
     15 
     16 #ifdef __cplusplus
     17 extern "C" {
     18 #endif  // __cplusplus
     19 
     20 #define AOM_ACCOUNTING_HASH_SIZE (1021)
     21 
     22 /* Max number of entries for symbol types in the dictionary (increase as
     23   necessary). */
     24 #define MAX_SYMBOL_TYPES (256)
     25 
     26 /*The resolution of fractional-precision bit usage measurements, i.e.,
     27   3 => 1/8th bits.*/
     28 #define AOM_ACCT_BITRES (3)
     29 
     30 typedef struct {
     31  int16_t x;
     32  int16_t y;
     33 } AccountingSymbolContext;
     34 
     35 typedef struct {
     36  AccountingSymbolContext context;
     37  uint32_t id;
     38  /** Number of bits in units of 1/8 bit. */
     39  uint32_t bits;
     40  uint32_t samples;
     41 } AccountingSymbol;
     42 
     43 /** Dictionary for translating strings into id. */
     44 typedef struct {
     45  char *strs[MAX_SYMBOL_TYPES];
     46  int num_strs;
     47 } AccountingDictionary;
     48 
     49 typedef struct {
     50  /** All recorded symbols decoded. */
     51  AccountingSymbol *syms;
     52  /** Number of syntax actually recorded. */
     53  int num_syms;
     54  /** Raw symbol decoding calls for non-binary values. */
     55  int num_multi_syms;
     56  /** Raw binary symbol decoding calls. */
     57  int num_binary_syms;
     58  /** Dictionary for translating strings into id. */
     59  AccountingDictionary dictionary;
     60 } AccountingSymbols;
     61 
     62 struct Accounting {
     63  AccountingSymbols syms;
     64  /** Size allocated for symbols (not all may be used). */
     65  int num_syms_allocated;
     66  int16_t hash_dictionary[AOM_ACCOUNTING_HASH_SIZE];
     67  AccountingSymbolContext context;
     68  uint32_t last_tell_frac;
     69 };
     70 
     71 void aom_accounting_init(Accounting *accounting);
     72 void aom_accounting_reset(Accounting *accounting);
     73 void aom_accounting_clear(Accounting *accounting);
     74 void aom_accounting_set_context(Accounting *accounting, int16_t x, int16_t y);
     75 int aom_accounting_dictionary_lookup(Accounting *accounting, const char *str);
     76 void aom_accounting_record(Accounting *accounting, const char *str,
     77                           uint32_t bits);
     78 void aom_accounting_dump(Accounting *accounting);
     79 #ifdef __cplusplus
     80 }  // extern "C"
     81 #endif  // __cplusplus
     82 #endif  // AOM_AV1_DECODER_ACCOUNTING_H_