84 int max_dec_pic_buffering = 0;
129 bit_rate = bit_rate * 11 / 10;
135 max_dec_pic_buffering);
138 "level %s.\n", desc->
name);
155 "of stream: using level 8.5.\n");
161 *level_idc = ctx->
level;
175 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
201 int crop_unit_x, crop_unit_y;
207 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
208 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
209 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
210 { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
218 if (num == sar_idc[i].num &&
219 den == sar_idc[i].den)
233 #define SET_OR_INFER(field, value, present_flag, infer) do { \ 237 } else if (!present_flag) \ 289 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
313 #define CROP(border, unit) do { \ 314 if (ctx->crop_ ## border >= 0) { \ 315 if (ctx->crop_ ## border % unit != 0) { \ 316 av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \ 317 "must be a multiple of %d.\n", #border, unit); \ 318 return AVERROR(EINVAL); \ 320 sps->conf_win_ ## border ## _offset = \ 321 ctx->crop_ ## border / unit; \ 322 sps->conformance_window_flag = 1; \ 325 CROP(left, crop_unit_x);
326 CROP(right, crop_unit_x);
327 CROP(top, crop_unit_y);
328 CROP(bottom, crop_unit_y);
368 int pic_type = 0, temporal_id = 8, layer_id = 0;
370 for (i = 0; i < au->
nb_units; i++) {
391 .nuh_layer_id = layer_id,
392 .nuh_temporal_id_plus1 = temporal_id + 1,
408 for (i = 0; i < au->
nb_units; i++) {
457 for (i = 0; i < au->
nb_units; i++) {
491 #define OFFSET(x) offsetof(H265MetadataContext, x) 492 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) 494 {
"aud",
"Access Unit Delimiter NAL units",
498 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"aud" },
500 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"aud" },
502 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"aud" },
504 {
"sample_aspect_ratio",
"Set sample aspect ratio (table E-1)",
506 { .dbl = 0.0 }, 0, 65535,
FLAGS },
508 {
"video_format",
"Set video format (table E-2)",
510 { .i64 = -1 }, -1, 7,
FLAGS },
511 {
"video_full_range_flag",
"Set video full range flag",
513 { .i64 = -1 }, -1, 1,
FLAGS },
514 {
"colour_primaries",
"Set colour primaries (table E-3)",
516 { .i64 = -1 }, -1, 255,
FLAGS },
517 {
"transfer_characteristics",
"Set transfer characteristics (table E-4)",
519 { .i64 = -1 }, -1, 255,
FLAGS },
520 {
"matrix_coefficients",
"Set matrix coefficients (table E-5)",
522 { .i64 = -1 }, -1, 255,
FLAGS },
524 {
"chroma_sample_loc_type",
"Set chroma sample location type (figure E-1)",
526 { .i64 = -1 }, -1, 6,
FLAGS },
529 "Set VPS and VUI tick rate (num_units_in_tick / time_scale)",
531 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
532 {
"num_ticks_poc_diff_one",
533 "Set VPS and VUI number of ticks per POC increment",
535 { .i64 = -1 }, -1, INT_MAX, FLAGS },
537 {
"crop_left",
"Set left border crop offset",
540 {
"crop_right",
"Set right border crop offset",
543 {
"crop_top",
"Set top border crop offset",
546 {
"crop_bottom",
"Set bottom border crop offset",
550 {
"level",
"Set level (tables A.6 and A.7)",
553 {
"auto",
"Attempt to guess level from stream properties",
556 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ 557 { .i64 = value }, .flags = FLAGS, .unit = "level" 560 {
LEVEL(
"2.1", 63) },
562 {
LEVEL(
"3.1", 93) },
564 {
LEVEL(
"4.1", 123) },
566 {
LEVEL(
"5.1", 153) },
567 {
LEVEL(
"5.2", 156) },
569 {
LEVEL(
"6.1", 183) },
570 {
LEVEL(
"6.2", 186) },
571 {
LEVEL(
"8.5", 255) },
589 .
name =
"hevc_metadata",
591 .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
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 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]
#define FF_ARRAY_ELEMS(a)
uint16_t vps_num_hrd_parameters
CodedBitstreamContext * cbc
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
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.