#ifndef AOM_AV1_ENCODER_BITSTREAM_H_
#define AOM_AV1_ENCODER_BITSTREAM_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "av1/common/av1_common_int.h"
#include "av1/common/blockd.h"
#include "av1/common/enums.h"
#include "av1/encoder/level.h"
#include "aom_dsp/bitwriter.h"
#include "aom_util/aom_pthread.h"
struct aom_write_bit_buffer;
struct AV1_COMP;
struct ThreadData;
TileBufferEnc;
FrameHeaderInfo;
PackBSParams;
PackBSTileOrder;
AV1EncPackBSSync;
uint32_t av1_write_sequence_header_obu(const SequenceHeader *seq_params,
uint8_t *const dst, size_t dst_size);
uint32_t av1_write_obu_header(AV1LevelParams *const level_params,
int *frame_header_count, OBU_TYPE obu_type,
bool has_nonzero_operating_point_idc,
int obu_extension, uint8_t *const dst);
int av1_write_uleb_obu_size(size_t obu_header_size, size_t obu_payload_size,
uint8_t *dest, size_t dest_size);
int av1_write_uleb_obu_size_unsafe(size_t obu_header_size,
size_t obu_payload_size, uint8_t *dest);
void av1_pack_tile_info(struct AV1_COMP *const cpi, struct ThreadData *const td,
PackBSParams *const pack_bs_params);
void av1_write_last_tile_info(
struct AV1_COMP *const cpi, const FrameHeaderInfo *fh_info,
struct aom_write_bit_buffer *saved_wb, size_t *curr_tg_data_size,
uint8_t *curr_tg_start, uint32_t *const total_size,
uint8_t **tile_data_start, int *const largest_tile_id,
int *const is_first_tg, uint32_t obu_header_size, uint8_t obu_extn_header);
int av1_pack_bitstream(struct AV1_COMP *const cpi, uint8_t *dst,
size_t dst_size, size_t *size,
int *const largest_tile_id);
void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
TX_TYPE tx_type, TX_SIZE tx_size, aom_writer *w);
void av1_reset_pack_bs_thread_data(struct ThreadData *const td);
void av1_accumulate_pack_bs_thread_data(struct AV1_COMP *const cpi,
struct ThreadData const *td);
void av1_write_obu_tg_tile_headers(struct AV1_COMP *const cpi,
MACROBLOCKD *const xd,
PackBSParams *const pack_bs_params,
const int tile_idx);
int av1_neg_interleave(int x, int ref, int max);
#ifdef __cplusplus
}
#endif
#endif