/* * Copyright (c) 2018, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #include <stdio.h> #include <string.h> #include "aom/aom_image.h" #include "aom/aom_integer.h" #include "aom_dsp/bitreader_buffer.h" #include "aom_dsp/bitwriter_buffer.h" #include "av1/common/obu_util.h" #include "common/av1_config.h" #include "config/aom_config.h" // Helper macros to reduce verbosity required to check for read errors. // // Note that when using these macros, even single line if statements should use // curly braces to avoid unexpected behavior because all but the // AV1C_POP_ERROR_HANDLER_DATA() macro consist of multiple statements. #define AV1C_READ_BIT_OR_RETURN_ERROR … #define AV1C_READ_BITS_OR_RETURN_ERROR … // Helper macros for setting/restoring the error handler data in // aom_read_bit_buffer. #define AV1C_PUSH_ERROR_HANDLER_DATA … #define AV1C_POP_ERROR_HANDLER_DATA … static const size_t kAv1cSize = …; static void bitreader_error_handler(void *data) { … } // Parse the AV1 timing_info() structure: // timing_info( ) { // num_units_in_display_tick f(32) // time_scale f(32) // equal_picture_interval f(1) // if (equal_picture_interval) // num_ticks_per_picture_minus_1 uvlc() // } static int parse_timing_info(struct aom_read_bit_buffer *reader) { … } // Parse the AV1 decoder_model_info() structure: // decoder_model_info( ) { // buffer_delay_length_minus_1 f(5) // num_units_in_decoding_tick f(32) // buffer_removal_time_length_minus_1 f(5) // frame_presentation_time_length_minus_1 f(5) // } // // Returns -1 upon failure, or the value of buffer_delay_length_minus_1 + 1. static int parse_decoder_model_info(struct aom_read_bit_buffer *reader) { … } // Parse the AV1 operating_parameters_info() structure: // operating_parameters_info( op ) { // n = buffer_delay_length_minus_1 + 1 // decoder_buffer_delay[ op ] f(n) // encoder_buffer_delay[ op ] f(n) // low_delay_mode_flag[ op ] f(1) // } static int parse_operating_parameters_info(struct aom_read_bit_buffer *reader, int buffer_delay_length_minus_1) { … } // Parse the AV1 color_config() structure..See: // https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=44 static int parse_color_config(struct aom_read_bit_buffer *reader, Av1Config *config) { … } // Parse AV1 Sequence Header OBU. See: // https://aomediacodec.github.io/av1-spec/av1-spec.pdf#page=41 static int parse_sequence_header(const uint8_t *const buffer, size_t length, Av1Config *config) { … } int get_av1config_from_obu(const uint8_t *buffer, size_t length, int is_annexb, Av1Config *config) { … } int read_av1config(const uint8_t *buffer, size_t buffer_length, size_t *bytes_read, Av1Config *config) { … } int write_av1config(const Av1Config *config, size_t capacity, size_t *bytes_written, uint8_t *buffer) { … } #undef AV1C_READ_BIT_OR_RETURN_ERROR #undef AV1C_READ_BITS_OR_RETURN_ERROR #undef AV1C_PUSH_ERROR_HANDLER_DATA #undef AV1C_POP_ERROR_HANDLER_DATA