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 #ifndef AOM_AV1_ENCODER_BITSTREAM_H_
13 #define AOM_AV1_ENCODER_BITSTREAM_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include "av1/encoder/encoder.h"
20 
21 struct aom_write_bit_buffer;
22 
23 // Writes only the OBU Sequence Header payload, and returns the size of the
24 // payload written to 'dst'. This function does not write the OBU header, the
25 // optional extension, or the OBU size to 'dst'.
26 uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst);
27 
28 // Writes the OBU header byte, and the OBU header extension byte when
29 // 'obu_extension' is non-zero. Returns number of bytes written to 'dst'.
30 uint32_t write_obu_header(OBU_TYPE obu_type, int obu_extension,
31                           uint8_t *const dst);
32 
33 int write_uleb_obu_size(uint32_t obu_header_size, uint32_t obu_payload_size,
34                         uint8_t *dest);
35 
36 int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dest, size_t *size);
37 
av1_preserve_existing_gf(AV1_COMP * cpi)38 static INLINE int av1_preserve_existing_gf(AV1_COMP *cpi) {
39   // Do not swap gf and arf indices for internal overlay frames
40   return cpi->rc.is_src_frame_alt_ref && !cpi->rc.is_src_frame_ext_arf;
41 }
42 
43 void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
44                        int blk_row, int blk_col, int plane, TX_SIZE tx_size,
45                        aom_writer *w);
46 
47 #ifdef __cplusplus
48 }  // extern "C"
49 #endif
50 
51 #endif  // AOM_AV1_ENCODER_BITSTREAM_H_
52