85 int max_dec_pic_buffering = 0;
130 bit_rate = bit_rate * 11 / 10;
136 max_dec_pic_buffering);
139 "level %s.\n", desc->
name);
156 "of stream: using level 8.5.\n");
162 *level_idc = ctx->
level;
176 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
202 int crop_unit_x, crop_unit_y;
208 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
209 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
210 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
211 { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
219 if (num == sar_idc[i].num &&
220 den == sar_idc[i].den)
234 #define SET_OR_INFER(field, value, present_flag, infer) do { \ 238 } else if (!present_flag) \ 290 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
314 #define CROP(border, unit) do { \ 315 if (ctx->crop_ ## border >= 0) { \ 316 if (ctx->crop_ ## border % unit != 0) { \ 317 av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \ 318 "must be a multiple of %d.\n", #border, unit); \ 319 return AVERROR(EINVAL); \ 321 sps->conf_win_ ## border ## _offset = \ 322 ctx->crop_ ## border / unit; \ 323 sps->conformance_window_flag = 1; \ 326 CROP(left, crop_unit_x);
327 CROP(right, crop_unit_x);
328 CROP(top, crop_unit_y);
329 CROP(bottom, crop_unit_y);
362 for (i = 0; i < au->
nb_units; i++) {
424 int pic_type = 0, temporal_id = 8, layer_id = 0;
426 for (i = 0; i < au->
nb_units; i++) {
447 .nuh_layer_id = layer_id,
448 .nuh_temporal_id_plus1 = temporal_id + 1,
464 for (i = 0; i < au->
nb_units; i++) {
513 for (i = 0; i < au->
nb_units; i++) {
547 #define OFFSET(x) offsetof(H265MetadataContext, x) 548 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) 550 {
"aud",
"Access Unit Delimiter NAL units",
554 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"aud" },
556 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"aud" },
558 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"aud" },
560 {
"sample_aspect_ratio",
"Set sample aspect ratio (table E-1)",
562 { .dbl = 0.0 }, 0, 65535,
FLAGS },
564 {
"video_format",
"Set video format (table E-2)",
566 { .i64 = -1 }, -1, 7,
FLAGS },
567 {
"video_full_range_flag",
"Set video full range flag",
569 { .i64 = -1 }, -1, 1,
FLAGS },
570 {
"colour_primaries",
"Set colour primaries (table E-3)",
572 { .i64 = -1 }, -1, 255,
FLAGS },
573 {
"transfer_characteristics",
"Set transfer characteristics (table E-4)",
575 { .i64 = -1 }, -1, 255,
FLAGS },
576 {
"matrix_coefficients",
"Set matrix coefficients (table E-5)",
578 { .i64 = -1 }, -1, 255,
FLAGS },
580 {
"chroma_sample_loc_type",
"Set chroma sample location type (figure E-1)",
582 { .i64 = -1 }, -1, 6,
FLAGS },
585 "Set VPS and VUI tick rate (num_units_in_tick / time_scale)",
587 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
588 {
"num_ticks_poc_diff_one",
589 "Set VPS and VUI number of ticks per POC increment",
591 { .i64 = -1 }, -1, INT_MAX, FLAGS },
593 {
"crop_left",
"Set left border crop offset",
596 {
"crop_right",
"Set right border crop offset",
599 {
"crop_top",
"Set top border crop offset",
602 {
"crop_bottom",
"Set bottom border crop offset",
606 {
"level",
"Set level (tables A.6 and A.7)",
609 {
"auto",
"Attempt to guess level from stream properties",
612 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ 613 { .i64 = value }, .flags = FLAGS, .unit = "level" 616 {
LEVEL(
"2.1", 63) },
618 {
LEVEL(
"3.1", 93) },
620 {
LEVEL(
"4.1", 123) },
622 {
LEVEL(
"5.1", 153) },
623 {
LEVEL(
"5.2", 156) },
625 {
LEVEL(
"6.1", 183) },
626 {
LEVEL(
"6.2", 186) },
627 {
LEVEL(
"8.5", 255) },
645 .
name =
"hevc_metadata",
647 .priv_class = &h265_metadata_class,
uint32_t bit_rate_value_minus1[HEVC_MAX_CPB_CNT]
int nb_units
Number of units in this fragment.
int chroma_sample_loc_type
uint8_t transfer_characteristics
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVCodecParameters * par_out
Parameters of the output stream.
uint8_t vps_poc_proportional_to_timing_flag
int transfer_characteristics
H265RawHRDParameters hrd_parameters
uint8_t nal_hrd_parameters_present_flag
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
int ff_cbs_write_packet(CodedBitstreamContext *ctx, AVPacket *pkt, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to a packet.
static av_cold int init(AVCodecContext *avctx)
uint8_t vui_timing_info_present_flag
int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
void ff_cbs_delete_unit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position)
Delete a unit from a fragment and free all memory it uses.
CodedBitstreamUnitType type
Codec-specific type of this unit.
The bitstream filter state.
const char * av_default_item_name(void *ptr)
Return the context name.
uint8_t tiles_enabled_flag
int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
H265RawProfileTierLevel profile_tier_level
uint8_t vui_parameters_present_flag
void * priv_data
Opaque filter-specific private data.
uint32_t vps_num_units_in_tick
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
uint16_t pic_height_in_luma_samples
H265RawSubLayerHRDParameters nal_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS]
uint8_t vps_timing_info_present_flag
int ff_cbs_read_packet(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVPacket *pkt)
Read the data bitstream from a packet into a fragment, then split into units and decompose.
const H265RawProfileTierLevel * ptl
uint8_t matrix_coefficients
uint8_t aspect_ratio_info_present_flag
Coded bitstream unit structure.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
void * content
Pointer to the decomposed form of this unit.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
uint8_t video_full_range_flag
uint8_t chroma_sample_loc_type_bottom_field
uint8_t video_signal_type_present_flag
size_t data_size
The number of bytes in the bitstream.
void ff_cbs_fragment_free(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free the units array of a fragment in addition to what ff_cbs_fragment_reset does.
uint32_t vui_num_ticks_poc_diff_one_minus1
uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
#define i(width, name, range_min, range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
uint8_t chroma_loc_info_present_flag
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
uint8_t chroma_sample_loc_type_top_field
H265RawHRDParameters hrd_parameters[HEVC_MAX_LAYER_SETS]
H265RawNALUnitHeader nal_unit_header
H265RawProfileTierLevel profile_tier_level
int ff_cbs_write_extradata(CodedBitstreamContext *ctx, AVCodecParameters *par, CodedBitstreamFragment *frag)
Write the bitstream of a fragment to the extradata in codec parameters.
uint8_t vui_hrd_parameters_present_flag
uint16_t pic_width_in_luma_samples
uint8_t vcl_hrd_parameters_present_flag
H265RawSubLayerHRDParameters vcl_sub_layer_hrd_parameters[HEVC_MAX_SUB_LAYERS]
uint8_t * data
Pointer to the bitstream form of this fragment.
#define FF_ARRAY_ELEMS(a)
int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Write the content of the fragment to its own internal buffer.
uint16_t vps_num_hrd_parameters
CodedBitstreamContext * cbc
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
const H265LevelDescriptor * ff_h265_guess_level(const H265RawProfileTierLevel *ptl, int64_t bitrate, int width, int height, int slice_segments, int tile_rows, int tile_cols, int max_dec_pic_buffering)
Guess the level of a stream from some parameters.
int video_full_range_flag
Coded bitstream fragment structure, combining one or more units.
uint8_t general_level_idc
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint32_t vui_num_units_in_tick
CodedBitstreamFragment access_unit
Describe the class of an AVClass context structure.
void ff_cbs_fragment_reset(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment's own data buffer, but not the units a...
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Context structure for coded bitstream operations.
Rational number (pair of numerator and denominator).
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
uint8_t chroma_format_idc
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
int ff_cbs_read_extradata(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const AVCodecParameters *par)
Read the extradata bitstream found in codec parameters into a fragment, then split into units and dec...
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
uint8_t vui_poc_proportional_to_timing_flag
common internal and external API header
int num_ticks_poc_diff_one
uint8_t num_tile_rows_minus1
static enum AVCodecID codec_ids[]
uint8_t num_tile_columns_minus1
H265RawSliceHeader header
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
int poc_proportional_to_timing_flag
uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
AVRational sample_aspect_ratio
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const uint8_t *data, size_t size)
Read a bitstream from a memory region into a fragment, then split into units and decompose.
uint32_t vps_num_ticks_poc_diff_one_minus1
uint8_t separate_colour_plane_flag
uint8_t colour_description_present_flag
This structure stores compressed data.
AVCodecParameters * par_in
Parameters of the input stream.
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.