96 int crop_unit_x, crop_unit_y;
102 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
103 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
104 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
105 { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
113 if (num == sar_idc[i].num &&
114 den == sar_idc[i].den)
128 #define SET_VUI_FIELD(field) do { \ 129 if (ctx->field >= 0) { \ 130 sps->vui.field = ctx->field; \ 176 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
194 #define CROP(border, unit) do { \ 195 if (ctx->crop_ ## border >= 0) { \ 196 if (ctx->crop_ ## border % unit != 0) { \ 197 av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \ 198 "must be a multiple of %d.\n", #border, unit); \ 199 return AVERROR(EINVAL); \ 201 sps->frame_crop_ ## border ## _offset = \ 202 ctx->crop_ ## border / unit; \ 203 sps->frame_cropping_flag = 1; \ 206 CROP(left, crop_unit_x);
207 CROP(right, crop_unit_x);
208 CROP(top, crop_unit_y);
209 CROP(bottom, crop_unit_y);
228 bit_rate = bit_rate * 6 / 5;
247 width, height, dpb_frames);
252 "conform to any level: using level 6.2.\n");
256 level_idc = ctx->
level;
259 if (level_idc == 9) {
298 for (i = 0; i < au->
nb_units; i++) {
326 int err,
i, j, has_sps;
355 static const int primary_pic_type_table[] = {
365 int primary_pic_type_mask = 0xff;
367 for (i = 0; i < au->
nb_units; i++) {
372 if (!(primary_pic_type_table[j] &
374 primary_pic_type_mask &= ~(1 << j);
379 if (primary_pic_type_mask & (1 << j))
383 "invalid slice types?\n");
390 .primary_pic_type = j,
403 for (i = 0; i < au->
nb_units; i++) {
428 v = (c <=
'9' ? c -
'0' : c -
'a' + 10);
430 goto invalid_user_data;
454 "message to access unit.\n");
461 "must be \"UUID+string\".\n");
468 for (i = au->
nb_units - 1; i >= 0; i--) {
489 for (i = au->
nb_units - 1; i >= 0; i--) {
530 "displaymatrix side data to packet.\n");
548 if (data && size >= 9 *
sizeof(
int32_t)) {
553 memcpy(matrix, data,
sizeof(matrix));
556 if (matrix[0] < 0 && matrix[4] > 0)
558 else if (matrix[0] > 0 && matrix[4] < 0)
564 if (!(angle >= -180.0 && angle <= 180.0 ) ||
565 matrix[2] != 0 || matrix[5] != 0 ||
566 matrix[6] != 0 || matrix[7] != 0) {
568 "representable in H.264 parameters.\n");
573 (uint16_t)
rint((angle >= 0.0 ? angle
601 "SEI message to access unit.\n");
642 for (i = 0; i < au->
nb_units; i++) {
671 #define OFFSET(x) offsetof(H264MetadataContext, x) 672 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) 674 {
"aud",
"Access Unit Delimiter NAL units",
678 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"aud" },
680 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"aud" },
682 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"aud" },
684 {
"sample_aspect_ratio",
"Set sample aspect ratio (table E-1)",
686 { .dbl = 0.0 }, 0, 65535,
FLAGS },
688 {
"overscan_appropriate_flag",
"Set VUI overscan appropriate flag",
690 { .i64 = -1 }, -1, 1,
FLAGS },
692 {
"video_format",
"Set video format (table E-2)",
694 { .i64 = -1 }, -1, 7,
FLAGS},
695 {
"video_full_range_flag",
"Set video full range flag",
697 { .i64 = -1 }, -1, 1,
FLAGS },
698 {
"colour_primaries",
"Set colour primaries (table E-3)",
700 { .i64 = -1 }, -1, 255,
FLAGS },
701 {
"transfer_characteristics",
"Set transfer characteristics (table E-4)",
703 { .i64 = -1 }, -1, 255,
FLAGS },
704 {
"matrix_coefficients",
"Set matrix coefficients (table E-5)",
706 { .i64 = -1 }, -1, 255,
FLAGS },
708 {
"chroma_sample_loc_type",
"Set chroma sample location type (figure E-1)",
710 { .i64 = -1 }, -1, 6,
FLAGS },
712 {
"tick_rate",
"Set VUI tick rate (num_units_in_tick / time_scale)",
714 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
715 {
"fixed_frame_rate_flag",
"Set VUI fixed frame rate flag",
717 { .i64 = -1 }, -1, 1, FLAGS },
719 {
"crop_left",
"Set left border crop offset",
722 {
"crop_right",
"Set right border crop offset",
725 {
"crop_top",
"Set top border crop offset",
728 {
"crop_bottom",
"Set bottom border crop offset",
732 {
"sei_user_data",
"Insert SEI user data (UUID+string)",
735 {
"delete_filler",
"Delete all filler (both NAL and SEI)",
738 {
"display_orientation",
"Display orientation SEI",
742 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"disp_or" },
744 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"disp_or" },
746 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"disp_or" },
748 { .i64 =
EXTRACT }, .flags =
FLAGS, .unit =
"disp_or" },
750 {
"rotate",
"Set rotation in display orientation SEI (anticlockwise angle in degrees)",
752 { .dbl =
NAN }, -360.0, +360.0, FLAGS },
753 {
"flip",
"Set flip in display orientation SEI",
756 {
"horizontal",
"Set hor_flip",
759 {
"vertical",
"Set ver_flip",
763 {
"level",
"Set level (table A-1)",
766 {
"auto",
"Attempt to guess level from stream properties",
769 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ 770 { .i64 = value }, .flags = FLAGS, .unit = "level" 773 {
LEVEL(
"1.1", 11) },
774 {
LEVEL(
"1.2", 12) },
775 {
LEVEL(
"1.3", 13) },
777 {
LEVEL(
"2.1", 21) },
778 {
LEVEL(
"2.2", 22) },
780 {
LEVEL(
"3.1", 31) },
781 {
LEVEL(
"3.2", 32) },
783 {
LEVEL(
"4.1", 41) },
784 {
LEVEL(
"4.2", 42) },
786 {
LEVEL(
"5.1", 51) },
787 {
LEVEL(
"5.2", 52) },
789 {
LEVEL(
"6.1", 61) },
790 {
LEVEL(
"6.2", 62) },
808 .
name =
"h264_metadata",
810 .priv_class = &h264_metadata_class,
int chroma_sample_loc_type
int overscan_appropriate_flag
int video_full_range_flag
int nb_units
Number of units in this fragment.
const char * sei_user_data
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVCodecParameters * par_out
Parameters of the output stream.
union H264RawSEIPayload::@28 payload
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
uint8_t chroma_sample_loc_type_bottom_field
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)
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.
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.
void * priv_data
Opaque filter-specific private data.
uint8_t max_dec_frame_buffering
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure counterclockwise rotation by the specified angle...
H264RawHRD nal_hrd_parameters
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)
uint8_t overscan_info_present_flag
uint16_t pic_width_in_mbs_minus1
uint16_t display_orientation_repetition_period
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
uint32_t num_units_in_tick
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.
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.
H264RawNALUnitHeader nal_unit_header
uint8_t nal_hrd_parameters_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.
H.264 common definitions.
static av_const int av_tolower(int c)
Locale-independent conversion of ASCII characters to lowercase.
uint8_t chroma_sample_loc_type_top_field
#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.
CodedBitstreamContext * cbc
uint8_t aspect_ratio_info_present_flag
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
void ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *access_unit, CodedBitstreamUnit *nal_unit, int position)
Delete an SEI message from an access unit.
uint8_t frame_mbs_only_flag
int fixed_frame_rate_flag
uint8_t timing_info_present_flag
H264RawSEIUserDataUnregistered user_data_unregistered
int transfer_characteristics
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 separate_colour_plane_flag
CodedBitstreamFragment access_unit
uint8_t vui_parameters_present_flag
uint8_t colour_description_present_flag
uint8_t video_signal_type_present_flag
uint8_t chroma_format_idc
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.
uint32_t bit_rate_value_minus1[H264_MAX_CPB_CNT]
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
uint8_t chroma_loc_info_present_flag
uint16_t anticlockwise_rotation
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Coded bitstream fragment structure, combining one or more units.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * data
The data buffer.
uint8_t uuid_iso_iec_11578[16]
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...
Context structure for coded bitstream operations.
Rational number (pair of numerator and denominator).
FF_ENABLE_DEPRECATION_WARNINGS int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size)
Wrap an existing array as a packet side data.
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
static av_const int av_isxdigit(int c)
Locale-independent conversion of ASCII isxdigit.
H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS]
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...
common internal and external API header
static enum AVCodecID codec_ids[]
H264RawSEIDisplayOrientation display_orientation
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
uint8_t bitstream_restriction_flag
H264RawSliceHeader header
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVRational sample_aspect_ratio
double av_display_rotation_get(const int32_t matrix[9])
Extract the rotation component of the transformation matrix.
uint16_t pic_height_in_map_units_minus1
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.
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.
int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *access_unit, H264RawSEIPayload *payload)
Add an SEI message to an access unit.
uint8_t vcl_hrd_parameters_present_flag
const H264LevelDescriptor * ff_h264_guess_level(int profile_idc, int64_t bitrate, int framerate, int width, int height, int max_dec_frame_buffering)
Guess the level of a stream from some parameters.
H264RawHRD vcl_hrd_parameters
uint8_t constraint_set3_flag