37 int off, start_pos,
type, temporal_id, spatial_id;
43 }
state = START_NOT_FOUND;
48 &
type, &temporal_id, &spatial_id);
57 if (
state == START_FOUND)
61 if (
state == START_NOT_FOUND) {
64 }
else if (
state == END_FOUND) {
65 state = OFFSET_IMPOSSIBLE;
125 int leading_zeros = 0;
133 if (leading_zeros >= 32)
146 seq_params->
bitdepth = 8 + (high_bitdepth * 2) + (twelve_bit * 2);
208 int reduced_still_picture_header;
209 int frame_width_bits_minus_1, frame_height_bits_minus_1;
220 memset(seq_params, 0,
sizeof(*seq_params));
225 reduced_still_picture_header =
get_bits1(&gb);
227 if (reduced_still_picture_header) {
229 seq_params->
tier = 0;
231 int initial_display_delay_present_flag, operating_points_cnt_minus_1;
232 int decoder_model_info_present_flag, buffer_delay_length_minus_1;
241 decoder_model_info_present_flag =
get_bits1(&gb);
242 if (decoder_model_info_present_flag) {
243 buffer_delay_length_minus_1 =
get_bits(&gb, 5);
249 decoder_model_info_present_flag = 0;
251 initial_display_delay_present_flag =
get_bits1(&gb);
253 operating_points_cnt_minus_1 =
get_bits(&gb, 5);
254 for (
int i = 0;
i <= operating_points_cnt_minus_1;
i++) {
255 int seq_level_idx, seq_tier;
260 if (seq_level_idx > 7)
265 if (decoder_model_info_present_flag) {
273 if (initial_display_delay_present_flag) {
279 seq_params->
level = seq_level_idx;
280 seq_params->
tier = seq_tier;
285 frame_width_bits_minus_1 =
get_bits(&gb, 4);
286 frame_height_bits_minus_1 =
get_bits(&gb, 4);
288 skip_bits(&gb, frame_width_bits_minus_1 + 1);
289 skip_bits(&gb, frame_height_bits_minus_1 + 1);
291 if (!reduced_still_picture_header) {
298 if (!reduced_still_picture_header) {
299 int enable_order_hint, seq_force_screen_content_tools;
305 if (enable_order_hint)
309 seq_force_screen_content_tools = 2;
311 seq_force_screen_content_tools =
get_bits1(&gb);
313 if (seq_force_screen_content_tools) {
318 if (enable_order_hint)
337 int start_pos,
type, temporal_id, spatial_id;
344 &
type, &temporal_id, &spatial_id);
372 int start_pos,
type, temporal_id, spatial_id;
373 int ret, nb_seq = 0, seq_size, meta_size;
382 int config_record_version = buf[0] & 0x7f;
383 if (config_record_version != 1 ||
size < 4) {
398 &
type, &temporal_id, &spatial_id);
407 if (!obu_size || nb_seq > 1) {
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
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)
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.
#define FF_PROFILE_AV1_HIGH
#define FF_PROFILE_AV1_MAIN
#define FF_PROFILE_AV1_PROFESSIONAL
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.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
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 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 RP177 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)
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
static const uint8_t offset[127][2]