Go to the documentation of this file.
52 for (
int j = 2; j < 14; j += 1 + (j > 2))
53 while (q.
den / q.
num < min_precision && q.
num % j == 0)
55 while (q.
den / q.
num < min_precision && q.
den < (1<<24))
85 int lsf, mpeg25, sample_rate_index, bitrate_index,
frame_size;
87 unsigned int header = 0xFFF00000;
89 lsf = sample_rate < (24000 + 32000) / 2;
90 mpeg25 = sample_rate < (12000 + 16000) / 2;
91 sample_rate <<= lsf + mpeg25;
92 if (sample_rate < (32000 + 44100) / 2) sample_rate_index = 2;
93 else if (sample_rate < (44100 + 48000) / 2) sample_rate_index = 0;
94 else sample_rate_index = 1;
98 for (bitrate_index = 2; bitrate_index < 30; bitrate_index++) {
109 header |= (4 - layer) << 17;
114 if (bitrate_index == 30)
117 header |= (bitrate_index >> 1) << 12;
118 header |= sample_rate_index << 10;
119 header |= (bitrate_index & 1) << 9;
151 static const uint8_t
headers[][5] = {
152 { 3, 0x00, 0x00, 0x01 },
153 { 4, 0x00, 0x00, 0x01, 0xB6},
173 int keyframe_0_esc =
s->nb_streams > 2;
183 if (keyframe_0_esc) {
191 for (stream_id = 0; stream_id <
s->nb_streams; stream_id++) {
192 int start2 = start + (end - start) * stream_id /
s->nb_streams;
193 int end2 = start + (end - start) * (stream_id + 1) /
s->nb_streams;
206 if (
f.den == 1 &&
f.num>0)
212 for (key_frame = 0; key_frame < 2; key_frame++) {
213 if (!
intra_only || !keyframe_0_esc || key_frame != 0) {
231 if (par->block_align > 0) {
232 frame_bytes = par->block_align;
260 if (par->video_delay) {
278 int start3 = start2 + (end2 - start2) *
pred / pred_count;
279 int end3 = start2 + (end2 - start2) * (
pred + 1) / pred_count;
340 size_t len = strlen(
string);
354 uint8_t *dyn_buf =
NULL;
356 int forw_ptr = dyn_size + 4;
374 int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields,
393 tmp_match = 1 - (1LL << 62);
395 for (
i = 0;
i < 256; ) {
414 for (j = 0;
i < 256; j++,
i++) {
428 if (j != tmp_mul - tmp_size)
431 put_v(bc, tmp_flags);
432 put_v(bc, tmp_fields);
433 if (tmp_fields > 0)
put_s(bc, tmp_pts);
434 if (tmp_fields > 1)
put_v(bc, tmp_mul);
435 if (tmp_fields > 2)
put_v(bc, tmp_stream);
436 if (tmp_fields > 3)
put_v(bc, tmp_size);
437 if (tmp_fields > 4)
put_v(bc, 0 );
438 if (tmp_fields > 5)
put_v(bc, j);
439 if (tmp_fields > 6)
put_v(bc, tmp_match);
440 if (tmp_fields > 7)
put_v(bc, tmp_head_idx);
463 default:
put_v(bc, 3);
break;
522 uint8_t *dyn_buf =
NULL;
523 int count = 0, dyn_size;
550 uint8_t *dyn_buf=
NULL;
551 int count=0, dyn_size,
i;
568 count +=
add_info(dyn_bc,
"r_frame_rate", buf);
573 put_v(bc, stream_id + 1);
590 uint8_t *dyn_buf =
NULL;
593 int ret, dyn_size, count = 0;
629 dummy.pos = next_node[1]->pos;
650 for (k= j - n; k<=j && k<nut->
sp_count; k++) {
660 payload_size =
avio_tell(bc) - startpos + 8 + 4;
662 avio_wb64(bc, 8 + payload_size +
av_log2(payload_size) / 7 + 1 + 4*(payload_size > 4096));
730 "The additional syncpoint modes require version %d, "
731 "that is currently not finalized, "
732 "please set -f_strict experimental in order to enable it.\n",
744 for (
i = 0;
i <
s->nb_streams;
i++) {
767 if (INT64_C(1000) * time_base.
num >= time_base.
den)
775 for (
i = 0;
i <
s->nb_chapters;
i++) {
799 if (
s->avoid_negative_ts < 0)
800 s->avoid_negative_ts = 1;
855 int ret,
i, dyn_size;
858 int sm_data_count = 0;
869 const uint8_t *data_end =
data +
size;
878 while (
data < data_end) {
882 if(
val >= data_end) {
922 put_s(dyn_bc, bytestream_get_le32(&
data));
927 put_s(dyn_bc, bytestream_get_le32(&
data));
929 put_s(dyn_bc, bytestream_get_le32(&
data));
955 put_v(bc, sm_data_count);
970 int best_length, frame_code,
flags, needed_flags,
i, header_idx;
977 uint8_t *sm_buf =
NULL;
981 "Negative pts not supported stream %d, pts %"PRId64
"\n",
998 data_size += sm_size;
1017 for (
i = 0;
i <
s->nb_streams;
i++) {
1055 if ((1ll<<60) % nut->
sp_count == 0)
1056 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
1064 j < 2 * nut->sp_count; j++)
1077 best_length = INT_MAX;
1079 for (
i = 0;
i < 256;
i++) {
1090 flags = needed_flags;
1093 if ((
flags & needed_flags) != needed_flags)
1102 if (data_size %
fc->size_mul !=
fc->size_lsb)
1119 length += 1 - nut->
header_len[best_header_idx];
1128 if (length < best_length) {
1129 best_length = length;
1138 header_idx =
fc->header_idx;
1144 flags = needed_flags;
1216 for (
i=0;
i<
s->nb_streams;
i++)
1224 #define OFFSET(x) offsetof(NUTContext, x)
1225 #define E AV_OPT_FLAG_ENCODING_PARAM
1228 {
"default",
"", 0,
AV_OPT_TYPE_CONST, {.i64 = 0}, INT_MIN, INT_MAX,
E, .unit =
"syncpoints" },
1229 {
"none",
"Disable syncpoints, low overhead and unseekable", 0,
AV_OPT_TYPE_CONST, {.i64 =
NUT_PIPE}, INT_MIN, INT_MAX,
E, .unit =
"syncpoints" },
1230 {
"timestamped",
"Extend syncpoints with a wallclock timestamp", 0,
AV_OPT_TYPE_CONST, {.i64 =
NUT_BROADCAST}, INT_MIN, INT_MAX,
E, .unit =
"syncpoints" },
1235 static const AVClass class = {
1245 .p.mime_type =
"video/x-nut",
1246 .p.extensions =
"nut",
1257 .p.priv_class = &
class,
static int write_streaminfo(NUTContext *nut, AVIOContext *bc, int stream_id)
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
static void write_mainheader(NUTContext *nut, AVIOContext *bc)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static int write_globalinfo(NUTContext *nut, AVIOContext *bc)
static int get_v_length(uint64_t val)
Get the length in bytes which is needed to store val as v.
enum AVMediaType codec_type
General type of the encoded data.
unsigned int time_base_count
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
static int get_needed_flags(NUTContext *nut, StreamContext *nus, FrameCode *fc, AVPacket *pkt)
@ AV_PKT_DATA_QUALITY_STATS
This side data contains quality related information from the encoder.
unsigned int nb_chapters
Number of chapters in AVChapter array.
This struct describes the properties of an encoded stream.
unsigned int max_distance
static int nut_write_trailer(AVFormatContext *s)
@ AV_PKT_DATA_NEW_EXTRADATA
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
static AVRational choose_timebase(AVFormatContext *s, AVStream *st, int min_precision)
Chooses a timebase for muxing the specified stream.
#define SYNCPOINT_STARTCODE
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
AVStream ** streams
A list of all streams in the file.
static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
const Dispositions ff_nut_dispositions[]
int64_t last_syncpoint_pos
AVRational avg_frame_rate
Average framerate.
@ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE
#define fc(width, name, range_min, range_max)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val)
static int write_chapter(NUTContext *nut, AVIOContext *bc, int id)
int nb_channels
Number of channels in this layout.
int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
unsigned long ffio_get_checksum(AVIOContext *s)
int ff_nut_sp_pos_cmp(const void *a, const void *b)
void ff_nut_free_sp(NUTContext *nut)
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
static int find_best_header_idx(NUTContext *nut, AVPacket *pkt)
static int nut_write_header(AVFormatContext *s)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
const uint8_t * header[128]
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
static void put_str(AVIOContext *bc, const char *string)
Store a string as vb.
@ AV_PKT_DATA_PARAM_CHANGE
An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows:
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
@ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS
int64_t end
chapter start/end time in time_base units
const AVMetadataConv ff_nut_metadata_conv[]
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc, AVStream *st, int i)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
const FFOutputFormat ff_nut_muxer
static int write_index(NUTContext *nut, AVIOContext *bc)
static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, uint64_t startcode)
static int find_expected_header(AVCodecParameters *p, int size, int key_frame, uint8_t out[64])
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const AVOption options[]
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Rational number (pair of numerator and denominator).
enum AVPacketSideDataType type
const char * av_default_item_name(void *ptr)
Return the context name.
void avio_w8(AVIOContext *s, int b)
AVChannelLayout ch_layout
Audio only.
static void build_elision_headers(AVFormatContext *s)
static int write_headers(AVFormatContext *avctx, AVIOContext *bc)
int sample_rate
Audio only.
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static void put_tt(NUTContext *nut, AVRational *time_base, AVIOContext *bc, uint64_t val)
@ AV_ROUND_DOWN
Round toward -infinity.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
static void put_s(AVIOContext *bc, int64_t val)
void ffio_reset_dyn_buf(AVIOContext *s)
Reset a dynamic buffer.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int ff_standardize_creation_time(AVFormatContext *s)
Standardize creation_time metadata in AVFormatContext to an ISO-8601 timestamp string.
static int add_info(AVIOContext *bc, const char *type, const char *value)
@ AV_PKT_DATA_METADATA_UPDATE
A list of zero terminated key/value strings.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
#define NUT_STABLE_VERSION
static void build_frame_code(AVFormatContext *s)
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static const uint8_t header[24]
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
void avio_wl32(AVIOContext *s, unsigned int val)
int flags
A combination of AV_PKT_FLAG values.
static int find_header_idx(AVFormatContext *s, AVCodecParameters *p, int size, int frame_type)
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
@ AV_PKT_DATA_STRINGS_METADATA
A list of zero terminated key/value strings.
int ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts)
struct AVTreeNode * syncpoints
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t ff_lsb2full(StreamContext *stream, int64_t lsb)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
void * av_calloc(size_t nmemb, size_t size)
FrameCode frame_code[256]
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
@ AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL
Data found in BlockAdditional element of matroska container.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static const float pred[4]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void ff_parse_specific_params(AVStream *st, int *au_rate, int *au_ssize, int *au_scale)
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
const AVCodecTag *const ff_nut_codec_tags[]
const uint16_t ff_mpa_freq_tab[3]
AVRational r_frame_rate
Real base framerate of the stream.
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
static int write_sm_data(AVFormatContext *s, AVIOContext *bc, AVPacket *pkt, int is_meta)
void * av_tree_find(const AVTreeNode *t, void *key, int(*cmp)(const void *key, const void *b), void *next[2])
void avio_wb64(AVIOContext *s, uint64_t val)
int64_t av_gettime(void)
Get the current time in microseconds.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
int video_delay
Video only.
const FF_VISIBILITY_PUSH_HIDDEN uint16_t ff_mpa_bitrate_tab[2][3][15]
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets fate list failing List the fate tests that failed the last time they were executed fate clear reports Remove the test reports from previous test libraries and programs examples Build all examples located in doc examples checkheaders Check headers dependencies alltools Build all tools in tools directory config Reconfigure the project with the current configuration tools target_dec_< decoder > _fuzzer Build fuzzer to fuzz the specified decoder tools target_bsf_< filter > _fuzzer Build fuzzer to fuzz the specified bitstream filter Useful standard make this is useful to reduce unneeded rebuilding when changing headers
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static void nut_write_deinit(AVFormatContext *s)
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
#define flags(name, subs,...)
AVRational time_base
time base in which the start/end timestamps are specified
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
void * priv_data
Format private data.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
static void put_v(AVIOContext *bc, uint64_t val)
Put val using a variable number of bytes.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.