93 int crop_unit_x, crop_unit_y;
99 { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
100 { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
101 { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
102 { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
110 if (num == sar_idc[i].num &&
111 den == sar_idc[i].den)
125 #define SET_OR_INFER(field, value, present_flag, infer) do { \
129 } else if (!present_flag) \
181 UINT32_MAX > INT_MAX ? UINT32_MAX : INT_MAX);
201 #define CROP(border, unit) do { \
202 if (ctx->crop_ ## border >= 0) { \
203 if (ctx->crop_ ## border % unit != 0) { \
204 av_log(bsf, AV_LOG_ERROR, "Invalid value for crop_%s: " \
205 "must be a multiple of %d.\n", #border, unit); \
206 return AVERROR(EINVAL); \
208 sps->frame_crop_ ## border ## _offset = \
209 ctx->crop_ ## border / unit; \
210 sps->frame_cropping_flag = 1; \
213 CROP(left, crop_unit_x);
214 CROP(right, crop_unit_x);
215 CROP(top, crop_unit_y);
216 CROP(bottom, crop_unit_y);
234 bit_rate = bit_rate * 6 / 5;
250 "conform to any level: using level 6.2.\n");
254 level_idc = ctx->
level;
257 if (level_idc == 9) {
282 int err, i, j, has_sps;
285 size_t displaymatrix_side_data_size = 0;
309 static const int primary_pic_type_table[] = {
319 int primary_pic_type_mask = 0xff;
321 for (i = 0; i < au->
nb_units; i++) {
326 if (!(primary_pic_type_table[j] &
328 primary_pic_type_mask &= ~(1 << j);
333 if (primary_pic_type_mask & (1 << j))
337 "invalid slice types?\n");
344 .primary_pic_type = j,
357 for (i = 0; i < au->
nb_units; i++) {
382 v = (c <=
'9' ? c -
'0' : c -
'a' + 10);
384 goto invalid_user_data;
408 "message to access unit.\n");
415 "must be \"UUID+string\".\n");
422 for (i = 0; i < au->
nb_units; i++) {
446 "filler SEI message.\n");
460 for (i = 0; i < au->
nb_units; i++) {
481 "display orientation SEI message.\n");
503 displaymatrix_side_data = (
uint8_t*)matrix;
504 displaymatrix_side_data_size = 9 *
sizeof(
int32_t);
519 if (data && size >= 9 *
sizeof(
int32_t)) {
524 memcpy(matrix, data,
sizeof(matrix));
527 if (matrix[0] < 0 && matrix[4] > 0)
529 else if (matrix[0] > 0 && matrix[4] < 0)
535 if (!(angle >= -180.0 && angle <= 180.0 ) ||
536 matrix[2] != 0 || matrix[5] != 0 ||
537 matrix[6] != 0 || matrix[7] != 0) {
539 "representable in H.264 parameters.\n");
544 (uint16_t)
rint((angle >= 0.0 ? angle
572 "SEI message to access unit.\n");
588 if (displaymatrix_side_data) {
590 displaymatrix_side_data,
591 displaymatrix_side_data_size);
594 "displaymatrix side data to packet.\n");
597 displaymatrix_side_data =
NULL;
631 for (i = 0; i < au->
nb_units; i++) {
658 #define OFFSET(x) offsetof(H264MetadataContext, x)
659 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM)
661 {
"aud",
"Access Unit Delimiter NAL units",
665 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"aud" },
667 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"aud" },
669 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"aud" },
671 {
"sample_aspect_ratio",
"Set sample aspect ratio (table E-1)",
673 { .dbl = 0.0 }, 0, 65535,
FLAGS },
675 {
"video_format",
"Set video format (table E-2)",
677 { .i64 = -1 }, -1, 7,
FLAGS},
678 {
"video_full_range_flag",
"Set video full range flag",
680 { .i64 = -1 }, -1, 1,
FLAGS },
681 {
"colour_primaries",
"Set colour primaries (table E-3)",
683 { .i64 = -1 }, -1, 255,
FLAGS },
684 {
"transfer_characteristics",
"Set transfer characteristics (table E-4)",
686 { .i64 = -1 }, -1, 255,
FLAGS },
687 {
"matrix_coefficients",
"Set matrix coefficients (table E-5)",
689 { .i64 = -1 }, -1, 255,
FLAGS },
691 {
"chroma_sample_loc_type",
"Set chroma sample location type (figure E-1)",
693 { .i64 = -1 }, -1, 6,
FLAGS },
695 {
"tick_rate",
"Set VUI tick rate (num_units_in_tick / time_scale)",
697 { .dbl = 0.0 }, 0, UINT_MAX,
FLAGS },
698 {
"fixed_frame_rate_flag",
"Set VUI fixed frame rate flag",
700 { .i64 = -1 }, -1, 1,
FLAGS },
702 {
"crop_left",
"Set left border crop offset",
705 {
"crop_right",
"Set right border crop offset",
708 {
"crop_top",
"Set top border crop offset",
711 {
"crop_bottom",
"Set bottom border crop offset",
715 {
"sei_user_data",
"Insert SEI user data (UUID+string)",
718 {
"delete_filler",
"Delete all filler (both NAL and SEI)",
721 {
"display_orientation",
"Display orientation SEI",
725 { .i64 =
PASS }, .flags =
FLAGS, .unit =
"disp_or" },
727 { .i64 =
INSERT }, .flags =
FLAGS, .unit =
"disp_or" },
729 { .i64 =
REMOVE }, .flags =
FLAGS, .unit =
"disp_or" },
731 { .i64 =
EXTRACT }, .flags =
FLAGS, .unit =
"disp_or" },
733 {
"rotate",
"Set rotation in display orientation SEI (anticlockwise angle in degrees)",
735 { .dbl =
NAN }, -360.0, +360.0,
FLAGS },
736 {
"flip",
"Set flip in display orientation SEI",
739 {
"horizontal",
"Set hor_flip",
742 {
"vertical",
"Set ver_flip",
746 {
"level",
"Set level (table A-1)",
749 {
"auto",
"Attempt to guess level from stream properties",
752 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
753 { .i64 = value }, .flags = FLAGS, .unit = "level"
756 {
LEVEL(
"1.1", 11) },
757 {
LEVEL(
"1.2", 12) },
758 {
LEVEL(
"1.3", 13) },
760 {
LEVEL(
"2.1", 21) },
761 {
LEVEL(
"2.2", 22) },
763 {
LEVEL(
"3.1", 31) },
764 {
LEVEL(
"3.2", 32) },
766 {
LEVEL(
"4.1", 41) },
767 {
LEVEL(
"4.2", 42) },
769 {
LEVEL(
"5.1", 51) },
770 {
LEVEL(
"5.2", 52) },
772 {
LEVEL(
"6.1", 61) },
773 {
LEVEL(
"6.2", 62) },
791 .
name =
"h264_metadata",
793 .priv_class = &h264_metadata_class,
int chroma_sample_loc_type
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.
ptrdiff_t const GLvoid * data
union H264RawSEIPayload::@50 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.
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.
int ff_cbs_h264_delete_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *access_unit, CodedBitstreamUnit *nal_unit, int position)
Delete an SEI message from an access unit.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void * priv_data
Opaque filter-specific private data.
uint8_t max_dec_frame_buffering
uint8_t fixed_frame_rate_flag
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)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
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.
H264RawNALUnitHeader nal_unit_header
uint8_t nal_hrd_parameters_present_flag
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
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
void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free all allocated memory in a fragment.
static void flip(AVCodecContext *avctx, AVFrame *frame)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
const H264LevelDescriptor * ff_h264_guess_level(int profile_idc, int64_t bitrate, int width, int height, int max_dec_frame_buffering)
Guess the level of a stream from some parameters.
uint8_t transfer_characteristics
uint8_t frame_mbs_only_flag
int fixed_frame_rate_flag
uint8_t timing_info_present_flag
uint8_t video_full_range_flag
H264RawSEIUserDataUnregistered user_data_unregistered
static const struct TransferCharacteristics transfer_characteristics[AVCOL_TRC_NB]
int transfer_characteristics
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
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
int ff_cbs_delete_unit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int position)
Delete a unit from a fragment and free all memory it uses.
uint8_t chroma_format_idc
#define FF_ARRAY_ELEMS(a)
uint32_t bit_rate_value_minus1[H264_MAX_CPB_CNT]
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]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
Describe the class of an AVClass context structure.
Context structure for coded bitstream operations.
uint8_t matrix_coefficients
Rational number (pair of numerator and denominator).
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...
int ff_cbs_h264_add_sei_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *access_unit, const H264RawSEIPayload *payload)
Add an SEI message to an access unit.
common internal and external API header
static enum AVCodecID codec_ids[]
int ff_bsf_get_packet(AVBSFContext *ctx, AVPacket **pkt)
Called by the bitstream filters to get the next packet for filtering.
H264RawSEIDisplayOrientation display_orientation
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
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
This structure stores compressed data.
AVCodecParameters * par_in
Parameters of the input stream.
uint8_t vcl_hrd_parameters_present_flag
H264RawHRD vcl_hrd_parameters
uint8_t constraint_set3_flag