36 const uint8_t *start = buf, *end = buf +
size;
43 }
state = START_NOT_FOUND;
48 int start_pos,
type, temporal_id, spatial_id;
50 &
type, &temporal_id, &spatial_id);
59 if (
state == START_FOUND)
63 if (
state == START_NOT_FOUND) {
66 }
else if (
state == END_FOUND) {
67 state = OFFSET_IMPOSSIBLE;
100 *
out = (uint8_t *)in;
127 int leading_zeros = 0;
129 while (leading_zeros < 32) {
135 if (leading_zeros >= 32)
148 seq_params->
bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2);
210 int reduced_still_picture_header;
211 int frame_width_bits_minus_1, frame_height_bits_minus_1;
222 memset(seq_params, 0,
sizeof(*seq_params));
227 reduced_still_picture_header =
get_bits1(&gb);
229 if (reduced_still_picture_header) {
231 seq_params->
tier = 0;
233 int initial_display_delay_present_flag, operating_points_cnt_minus_1;
234 int decoder_model_info_present_flag, buffer_delay_length_minus_1;
243 decoder_model_info_present_flag =
get_bits1(&gb);
244 if (decoder_model_info_present_flag) {
245 buffer_delay_length_minus_1 =
get_bits(&gb, 5);
251 decoder_model_info_present_flag = 0;
253 initial_display_delay_present_flag =
get_bits1(&gb);
255 operating_points_cnt_minus_1 =
get_bits(&gb, 5);
256 for (
int i = 0;
i <= operating_points_cnt_minus_1;
i++) {
257 int seq_level_idx, seq_tier;
262 if (seq_level_idx > 7)
267 if (decoder_model_info_present_flag) {
275 if (initial_display_delay_present_flag) {
281 seq_params->
level = seq_level_idx;
282 seq_params->
tier = seq_tier;
287 frame_width_bits_minus_1 =
get_bits(&gb, 4);
288 frame_height_bits_minus_1 =
get_bits(&gb, 4);
290 skip_bits(&gb, frame_width_bits_minus_1 + 1);
291 skip_bits(&gb, frame_height_bits_minus_1 + 1);
293 if (!reduced_still_picture_header) {
300 if (!reduced_still_picture_header) {
301 int enable_order_hint, seq_force_screen_content_tools;
307 if (enable_order_hint)
311 seq_force_screen_content_tools = 2;
313 seq_force_screen_content_tools =
get_bits1(&gb);
315 if (seq_force_screen_content_tools) {
320 if (enable_order_hint)
343 is_av1c = !!(buf[0] & 0x80);
346 int ret,
version = buf[0] & 0x7F;
355 memset(seq, 0,
sizeof(*seq));
377 int start_pos,
type, temporal_id, spatial_id;
379 &
type, &temporal_id, &spatial_id);
400 int write_seq_header)
407 int ret, nb_seq = 0, seq_size, meta_size;
416 int config_record_version = buf[0] & 0x7f;
417 if (config_record_version != 1 ||
size < 4) {
432 int start_pos,
type, temporal_id, spatial_id;
434 &
type, &temporal_id, &spatial_id);
443 if (!obu_size || nb_seq > 1) {
490 if (write_seq_header) {
int ff_av1_parse_seq_header(AV1SequenceParameters *seq, const uint8_t *buf, int size)
Parses a Sequence Header from the the provided buffer.
static int av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size, int *offset)
static void uvlc(GetBitContext *gb)
int ff_av1_filter_obus_buf(const uint8_t *in, uint8_t **out, int *size, int *offset)
Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and return the result in a data bu...
int ff_isom_write_av1c(AVIOContext *pb, const uint8_t *buf, int size, int write_seq_header)
Writes AV1 extradata (Sequence Header and Metadata OBUs) to the provided AVIOContext.
static int parse_color_config(AV1SequenceParameters *seq_params, GetBitContext *gb)
int ff_av1_filter_obus(AVIOContext *pb, const uint8_t *buf, int size)
Filter out AV1 OBUs not meant to be present in ISOBMFF sample data and write the resulting bitstream ...
static int parse_sequence_header(AV1SequenceParameters *seq_params, const uint8_t *buf, int size)
static int parse_obu_header(const uint8_t *buf, int buf_size, int64_t *obu_size, int *start_pos, int *type, int *temporal_id, int *spatial_id)
static int get_obu_bit_length(const uint8_t *buf, int size, int type)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
void ffio_init_write_context(FFIOContext *s, uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for writing.
#define i(width, name, range_min, range_max)
Misc types and constants that do not belong anywhere else.
#define AV_PROFILE_AV1_HIGH
#define AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_PROFESSIONAL
static struct @346255127015250356166251341105367306144006377143 state
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
@ AV1_OBU_TEMPORAL_DELIMITER
@ AV1_OBU_REDUNDANT_FRAME_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Memory handling functions.
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
@ AVCOL_TRC_IEC61966_2_1
IEC 61966-2-1 (sRGB or sYCC)
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static const uint8_t header[24]
uint8_t color_description_present_flag
uint8_t chroma_sample_position
uint8_t transfer_characteristics
uint8_t chroma_subsampling_x
uint8_t chroma_subsampling_y
uint8_t matrix_coefficients