tor-browser

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

av1_config.h (3090B)


      1 /*
      2 * Copyright (c) 2018, 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_COMMON_AV1_CONFIG_H_
     12 #define AOM_COMMON_AV1_CONFIG_H_
     13 
     14 #include "aom/aom_integer.h"
     15 
     16 #ifdef __cplusplus
     17 extern "C" {
     18 #endif
     19 
     20 // Struct representing ISOBMFF/Matroska AV1 config. See:
     21 // https://aomediacodec.github.io/av1-isobmff/#av1codecconfigurationbox-syntax
     22 //
     23 // The AV1 config has the following format:
     24 //
     25 // unsigned int (1) marker = 1;
     26 // unsigned int (7) version = 1;
     27 // unsigned int (3) seq_profile;
     28 // unsigned int (5) seq_level_idx_0;
     29 // unsigned int (1) seq_tier_0;
     30 // unsigned int (1) high_bitdepth;
     31 // unsigned int (1) twelve_bit;
     32 // unsigned int (1) monochrome;
     33 // unsigned int (1) chroma_subsampling_x;
     34 // unsigned int (1) chroma_subsampling_y;
     35 // unsigned int (2) chroma_sample_position;
     36 // unsigned int (3) reserved = 0;
     37 //
     38 // unsigned int (1) initial_presentation_delay_present;
     39 // if (initial_presentation_delay_present) {
     40 //   unsigned int (4) initial_presentation_delay_minus_one;
     41 // } else {
     42 //   unsigned int (4) reserved = 0;
     43 // }
     44 //
     45 // unsigned int (8)[] configOBUs;
     46 //
     47 // Note: get_av1config_from_obu() does not currently store 'configOBUs' data, so
     48 // the field is omitted.
     49 typedef struct _Av1Config {
     50  uint8_t marker;
     51  uint8_t version;
     52  uint8_t seq_profile;
     53  uint8_t seq_level_idx_0;
     54  uint8_t seq_tier_0;
     55  uint8_t high_bitdepth;
     56  uint8_t twelve_bit;
     57  uint8_t monochrome;
     58  uint8_t chroma_subsampling_x;
     59  uint8_t chroma_subsampling_y;
     60  uint8_t chroma_sample_position;
     61  uint8_t initial_presentation_delay_present;
     62  uint8_t initial_presentation_delay_minus_one;
     63 } Av1Config;
     64 
     65 // Attempts to parse a Sequence Header OBU and set the paramenters of 'config'.
     66 // Returns 0 upon success, and -1 upon failure. 'buffer' can contain multiple
     67 // OBUs, but the Sequence Header OBU must be the first OBU within the buffer.
     68 int get_av1config_from_obu(const uint8_t *buffer, size_t length, int is_annexb,
     69                           Av1Config *config);
     70 
     71 // Attempts to parse an AV1 config from 'buffer'. Returns 0 upon success.
     72 // Returns -1 when 'buffer_length' is less than 4, when passed NULL pointers, or
     73 // when parsing of 'buffer' fails.
     74 int read_av1config(const uint8_t *buffer, size_t buffer_length,
     75                   size_t *bytes_read, Av1Config *config);
     76 
     77 // Writes 'config' to 'buffer'. Returns 0 upon successful write to 'buffer'.
     78 // Returns -1 when passed NULL pointers or when 'capacity' insufficient.
     79 int write_av1config(const Av1Config *config, size_t capacity,
     80                    size_t *bytes_written, uint8_t *buffer);
     81 
     82 #ifdef __cplusplus
     83 } /* extern "C" */
     84 #endif
     85 
     86 #endif  // AOM_COMMON_AV1_CONFIG_H_