Go to the documentation of this file.
54 timestamp < sti->pts_wrap_reference)
72 #if CONFIG_H264_DECODER
101 static const struct {
129 "Probe with size=%d, packets=%d detected %s with score=%d\n",
132 for (
int i = 0; fmt_id_type[
i].name;
i++) {
133 if (!strcmp(fmt->
name, fmt_id_type[
i].name)) {
161 s, 0,
s->format_probesize);
164 "will be ignored with AVFMT_NOFILE format.\n");
178 s, 0,
s->format_probesize);
184 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
220 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
235 if (!(
s->url =
av_strdup(filename ? filename :
""))) {
242 s->probe_score =
ret;
244 if (!
s->protocol_whitelist &&
s->pb &&
s->pb->protocol_whitelist) {
245 s->protocol_whitelist =
av_strdup(
s->pb->protocol_whitelist);
246 if (!
s->protocol_whitelist) {
252 if (!
s->protocol_blacklist &&
s->pb &&
s->pb->protocol_blacklist) {
253 s->protocol_blacklist =
av_strdup(
s->pb->protocol_blacklist);
254 if (!
s->protocol_blacklist) {
260 if (
s->format_whitelist &&
av_match_list(
s->iformat->name,
s->format_whitelist,
',') <= 0) {
279 if (
s->iformat->priv_data_size > 0) {
280 if (!(
s->priv_data =
av_mallocz(
s->iformat->priv_data_size))) {
284 if (
s->iformat->priv_class) {
285 *(
const AVClass **)
s->priv_data =
s->iformat->priv_class;
296 if (
s->iformat->read_header)
297 if ((
ret =
s->iformat->read_header(
s)) < 0) {
311 if (id3v2_extra_meta) {
312 if (!strcmp(
s->iformat->name,
"mp3") || !strcmp(
s->iformat->name,
"aac") ||
313 !strcmp(
s->iformat->name,
"tta") || !strcmp(
s->iformat->name,
"wav")) {
343 if (
s->iformat->read_close)
344 s->iformat->read_close(
s);
366 if ((
s->iformat && strcmp(
s->iformat->name,
"image2") &&
s->iformat->flags &
AVFMT_NOFILE) ||
371 if (
s->iformat->read_close)
372 s->iformat->read_close(
s);
385 if (
s->video_codec_id)
389 if (
s->audio_codec_id)
393 if (
s->subtitle_codec_id)
397 if (
s->data_codec_id)
418 "Failed to reallocate probe buffer for stream %d\n",
431 "nothing to probe for stream %d\n", st->
index);
460 int pts_wrap_behavior;
461 int64_t pts_wrap_reference;
479 if (!first_program) {
483 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
498 pts_wrap_reference =
program->pts_wrap_reference;
499 pts_wrap_behavior =
program->pts_wrap_behavior;
508 if (
program->pts_wrap_reference != pts_wrap_reference) {
509 for (
unsigned i = 0;
i <
program->nb_stream_indexes;
i++) {
515 program->pts_wrap_reference = pts_wrap_reference;
516 program->pts_wrap_behavior = pts_wrap_behavior;
529 #if FF_API_INIT_PACKET
550 if (
ffstream(st)->request_probe <= 0) {
557 err =
s->iformat->read_packet(
s,
pkt);
566 if (!pktl || err ==
AVERROR(EAGAIN))
568 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
587 "Packet corrupt (stream = %d, dts = %s)",
598 "Invalid stream index.\n");
619 if (
s->use_wallclock_as_timestamps)
660 }
else if (codec_framerate.
den * 1000LL > codec_framerate.
num) {
704 #if CONFIG_H264_DECODER
738 int64_t best_score = INT64_MAX;
739 for (
int i = 0;
i < delay;
i++) {
742 if (score < best_score) {
749 for (
int i = 0;
i < delay;
i++) {
778 AVStream *
const st =
s->streams[stream_index];
786 for (; pkt_buffer; pkt_buffer =
get_next_pkt(
s, st, pkt_buffer)) {
791 pts_buffer[0] = pkt_buffer->
pkt.
pts;
792 for (
int i = 0; i < delay && pts_buffer[i] > pts_buffer[
i + 1];
i++)
793 FFSWAP(int64_t, pts_buffer[
i], pts_buffer[
i + 1]);
804 AVStream *
const st =
s->streams[stream_index];
826 if (pktl_it->pkt.stream_index != stream_index)
829 pktl_it->pkt.pts +=
shift;
832 pktl_it->pkt.dts +=
shift;
876 av_log(
s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
914 int64_t next_dts, int64_t next_pts)
918 int num, den, presentation_delayed, delay;
933 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
959 presentation_delayed = 0;
965 presentation_delayed = 1;
983 if ( strcmp(
s->iformat->name,
"mov,mp4,m4a,3gp,3g2,mj2")
984 && strcmp(
s->iformat->name,
"flv"))
1018 presentation_delayed = 1;
1022 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1028 if ((delay == 0 || (delay == 1 && pc)) &&
1030 if (presentation_delayed) {
1048 ((uint64_t)sti->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1049 next_dts != next_pts &&
1106 int stream_index,
int flush)
1110 AVStream *st =
s->streams[stream_index];
1121 while (
size > 0 || (
flush && got_output)) {
1122 int64_t next_pts =
pkt->
pts;
1123 int64_t next_dts =
pkt->
dts;
1137 got_output = !!out_pkt->
size;
1148 if (!out_pkt->
buf) {
1223 int ret, got_packet = 0;
1236 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
1255 av_log(
s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1279 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1287 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1297 "%s, packets or times may be invalid.\n",
1345 int discard_padding = 0;
1352 sample < sti->last_discard_sample)
1361 AV_WL32(p + 4, discard_padding);
1381 memcpy(dst_data, src_sd->
data, src_sd->
size);
1397 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1398 "size=%d, duration=%"PRId64
", flags=%d\n",
1436 int wrap_bits =
s->streams[next_pkt->
stream_index]->pts_wrap_bits;
1439 int64_t last_dts = next_pkt->
dts;
1450 last_dts = pktl->
pkt.
dts;
1531 int64_t
start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
1532 int64_t
duration, duration1, duration_text, filesize;
1535 start_time_text = INT64_MAX;
1536 end_time = INT64_MIN;
1537 end_time_text = INT64_MIN;
1539 duration_text = INT64_MIN;
1550 start_time_text =
FFMIN(start_time_text, start_time1);
1556 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
1557 end_time1 += start_time1;
1559 end_time_text =
FFMAX(end_time_text, end_time1);
1561 end_time =
FFMAX(end_time, end_time1);
1564 if (p->start_time ==
AV_NOPTS_VALUE || p->start_time > start_time1)
1565 p->start_time = start_time1;
1566 if (p->end_time < end_time1)
1567 p->end_time = end_time1;
1574 duration_text =
FFMAX(duration_text, duration1);
1584 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time <
AV_TIME_BASE))
1585 end_time = end_time_text;
1586 else if (end_time < end_time_text)
1596 if (end_time != INT64_MIN) {
1643 int show_warning = 0;
1647 int64_t bit_rate = 0;
1690 "Estimating duration from bitrate, this may be inaccurate\n");
1693 #define DURATION_MAX_READ_SIZE 250000LL
1694 #define DURATION_MAX_RETRY 6
1701 int num, den, read_size,
ret;
1702 int found_duration = 0;
1718 "start time for stream %d is not set in estimate_timings_from_pts\n",
i);
1727 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
1728 goto skip_duration_calc;
1736 is_end = found_duration;
1857 file_size =
FFMAX(0, file_size);
1890 "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64
" kb/s\n",
1915 #define FAIL(errmsg) do { \
1917 *errmsg_ptr = errmsg; \
1923 FAIL(
"unknown codec");
1927 FAIL(
"unspecified frame size");
1930 FAIL(
"unspecified sample format");
1932 FAIL(
"unspecified sample rate");
1934 FAIL(
"unspecified number of channels");
1936 FAIL(
"no decodable DTS frames");
1940 FAIL(
"unspecified size");
1942 FAIL(
"unspecified pixel format");
1945 FAIL(
"no frame in rv30/40 and no sar");
1949 FAIL(
"unspecified size");
1965 int got_picture = 1,
ret = 0;
1969 int do_skip_frame = 0;
1995 if (
s->codec_whitelist)
2039 &got_picture, &
pkt);
2053 if (do_skip_frame) {
2073 int64_t max_time = 0;
2076 if (!
s->nb_chapters)
2079 if (
s->duration > 0 &&
s->start_time < INT64_MAX -
s->duration)
2080 max_time =
s->duration +
2083 timetable =
av_memdup(
s->chapters,
s->nb_chapters *
sizeof(*timetable));
2088 for (
unsigned i = 0;
i <
s->nb_chapters;
i++)
2095 if (
i + 1 <
s->nb_chapters) {
2096 const AVChapter *
const ch1 = timetable[
i + 1];
2099 if (next_start > ch->
start && next_start < end)
2102 ch->
end = (end == INT64_MAX || end < ch->
start) ? ch->
start : end;
2111 return (
i + 1) * 1001;
2115 return (
i + 31) * 1001 * 12;
2119 return ((
const int[]) { 80, 120, 240})[
i] * 1001 * 12;
2123 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[
i] * 1000 * 12;
2134 if (
c->time_base.den >= 101LL *
c->time_base.num ||
2135 c->time_base.den < 5LL *
c->time_base.num ||
2153 && ts - (uint64_t)last < INT64_MAX) {
2168 for (
int j = 0; j < 2; j++) {
2169 int64_t ticks =
llrint(sdts+j*0.5);
2170 double error = sdts - ticks + j*0.5;
2189 if (error0 > 0.04 && error1 > 0.04) {
2224 double best_error = 0.01;
2237 for (
int k = 0; k < 2; k++) {
2242 if (error < best_error && best_error> 0.000000001) {
2251 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
2365 side_data->
size = 0;
2383 memcpy(dst_data, sd_src->
data, sd_src->
size);
2391 int count = 0,
ret = 0;
2399 int64_t max_stream_analyze_duration;
2400 int64_t max_subtitle_analyze_duration;
2402 int eof_reached = 0;
2405 flush_codecs = probesize > 0;
2409 max_stream_analyze_duration = max_analyze_duration;
2410 max_subtitle_analyze_duration = max_analyze_duration;
2411 if (!max_analyze_duration) {
2412 max_stream_analyze_duration =
2423 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
2454 "%s, packets or times may be invalid.\n",
2461 goto find_stream_info_err;
2482 if (codec && !avctx->
codec)
2485 "Failed to open codec in %s\n",__FUNCTION__);
2497 int analyzed_all_streams;
2509 int fps_analyze_framecount = 20;
2518 fps_analyze_framecount *= 2;
2520 fps_analyze_framecount = 0;
2524 fps_analyze_framecount = 0;
2531 if (count < fps_analyze_framecount)
2549 analyzed_all_streams = 0;
2550 if (!missing_streams || !*missing_streams)
2552 analyzed_all_streams = 1;
2564 if (read_size >= probesize) {
2567 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
2576 "Stream #%d: not enough frames to estimate rate; "
2577 "consider increasing probesize\n",
i);
2598 goto unref_then_goto_end;
2614 goto unref_then_goto_end;
2623 "Non-increasing DTS in stream %d: packet %d with DTS "
2624 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
2640 "DTS discontinuity in stream %d: packet %d with DTS "
2641 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
2674 if (analyzed_all_streams)
limit = max_analyze_duration;
2676 else limit = max_stream_analyze_duration;
2679 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
2698 #if FF_API_R_FRAME_RATE
2707 goto unref_then_goto_end;
2730 for (
unsigned stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
2735 if (codec && !avctx->
codec) {
2741 "Failed to open codec in %s\n",__FUNCTION__);
2771 "decoding for stream %d failed\n", st->
index);
2796 double best_error = 0.01;
2814 if (
error < best_error) {
2816 best_fps = std_fps.
num;
2822 if (
error < best_error) {
2824 best_fps = std_fps.
num;
2830 best_fps, 12 * 1001, INT_MAX);
2893 goto find_stream_info_err;
2899 "Could not find codec parameters for stream %d (%s): %s\n"
2900 "Consider increasing the value for the 'analyzeduration' (%"PRId64
") and 'probesize' (%"PRId64
") options\n",
2909 goto find_stream_info_err;
2919 goto find_stream_info_err;
2922 goto find_stream_info_err;
2928 find_stream_info_err:
2941 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
2946 unref_then_goto_end:
2948 goto find_stream_info_err;
static void error(const char *err)
av_cold int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
int frame_size
Number of samples per channel in an audio frame.
int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts)
add frame for rfps calculation.
#define FF_ENABLE_DEPRECATION_WARNINGS
AVCodecParameters * par_in
Parameters of the input stream.
#define AV_LOG_WARNING
Something somehow does not look correct.
int avpriv_packet_list_put(PacketList *packet_buffer, AVPacket *pkt, int(*copy)(AVPacket *dst, const AVPacket *src), int flags)
Append an AVPacket to the list.
int skip_samples
Number of samples to skip at the start of the frame decoded from the next packet.
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 minimum maximum flags name is the option name
int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
int inject_global_side_data
Internal data to inject global side data.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C program
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
int prefer_codec_framerate
enum AVMediaType codec_type
General type of the encoded data.
int av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Probe a bytestream to determine the input format.
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
uint64_t channel_layout
Audio channel layout.
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.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc)
Add a value to a timestamp.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int64_t first_dts
Timestamp corresponding to the last dts sync point.
int64_t rfps_duration_sum
int sample_rate
samples per second
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
void * av_opt_ptr(const AVClass *class, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
#define AVERROR_EOF
End of file.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
int64_t codec_info_duration_fields
int duration
Duration of the current frame.
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
int64_t codec_info_duration
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
int64_t first_discard_sample
If not 0, the first audio sample that should be discarded from the stream.
This structure describes decoded (raw) audio or video data.
static int try_decode_frame(AVFormatContext *s, AVStream *st, const AVPacket *avpkt, AVDictionary **options)
AVStream ** streams
A list of all streams in the file.
int capabilities
Codec capabilities.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
@ AV_CODEC_ID_DVB_TELETEXT
static int extract_extradata_check(AVStream *st)
AVRational avg_frame_rate
Average framerate.
static int has_duration(AVFormatContext *ic)
Return TRUE if the stream has accurate duration in any stream.
enum AVDurationEstimationMethod duration_estimation_method
The duration field can be estimated through various ways, and this field can be used to know how the ...
#define AV_LOG_VERBOSE
Detailed information.
struct FFStream::@259 extract_extradata
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static int64_t ts_to_samples(AVStream *st, int64_t ts)
int buf_size
Size of buf except extra allocated bytes.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
int64_t probesize
Maximum number of bytes read from input in order to determine stream properties.
static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int avcodec_is_open(AVCodecContext *s)
static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp)
int64_t last_dts_for_order_check
Internal data to analyze DTS and detect faulty mpeg streams.
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
int64_t avio_size(AVIOContext *s)
Get the filesize.
static void update_stream_timings(AVFormatContext *ic)
Estimate the stream timings from the one of each components.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define DURATION_MAX_READ_SIZE
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt)
Return a value representing the fourCC code associated to the pixel format pix_fmt,...
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
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...
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
int avformat_queue_attached_pictures(AVFormatContext *s)
void avformat_close_input(AVFormatContext **ps)
Close an opened input AVFormatContext.
int64_t offset
byte offset from starting packet start
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int key_frame
Set by parser to 1 for key frames and 0 for non-key frames.
static void force_codec_ids(AVFormatContext *s, AVStream *st)
const struct AVCodec * codec
static void update_initial_timestamps(AVFormatContext *s, int stream_index, int64_t dts, int64_t pts, AVPacket *pkt)
enum AVDiscard skip_frame
Skip decoding for selected frames.
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.
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
AVCodecParserContext * av_parser_init(int codec_id)
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
const AVInputFormat * av_probe_input_format3(const AVProbeData *pd, int is_opened, int *score_ret)
Guess the file format.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static int extract_extradata_init(AVStream *st)
#define FFDIFFSIGN(x, y)
Comparator.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *cur)
Create chapters for all CHAP tags found in the ID3v2 header.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_CODEC_ID_DVB_SUBTITLE
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int max_ts_probe
Maximum number of packets to read while waiting for the first timestamp.
void av_init_packet(AVPacket *pkt)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static int chapter_start_cmp(const void *p1, const void *p2)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
struct FFStream::@260 * info
Stream information used internally by avformat_find_stream_info()
int ctx_flags
Flags signalling stream properties.
int avformat_open_input(AVFormatContext **ps, const char *filename, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
int has_b_frames
Size of the frame reordering buffer in the decoder.
PacketList parse_queue
Packets split by the parser get queued here.
int64_t end
chapter start/end time in time_base units
double(* duration_error)[2][MAX_STD_TIMEBASES]
PacketList packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
int flags
Flags modifying the (de)muxer behaviour.
AVRational sample_aspect_ratio
Video only.
static const char *const duration_name[]
const struct AVInputFormat * iformat
The input container format.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int nb_decoded_frames
Number of internally decoded frames, used internally in libavformat, do not access its lifetime diffe...
int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags)
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t data_offset
offset of the first packet
static int tb_unreliable(AVCodecContext *c)
int codec_info_nb_frames
Number of frames that have been demuxed during avformat_find_stream_info()
AVRational time_base_in
The timebase used for the timestamps of the input packets.
uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVRational display_aspect_ratio
display aspect ratio (0 if unknown)
@ AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED
#define DURATION_MAX_RETRY
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
int64_t pts_reorder_error[MAX_REORDER_DELAY+1]
Internal data to generate dts from pts.
static int determinable_frame_size(const AVCodecContext *avctx)
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
const AVInputFormat * av_probe_input_format2(const AVProbeData *pd, int is_opened, int *score_max)
Guess the file format.
static int get_std_framerate(int i)
static int has_codec_parameters(const AVStream *st, const char **errmsg_ptr)
int repeat_pict
This field is used for proper frame duration computation in lavf.
enum AVStreamParseType need_parsing
@ AVDISCARD_ALL
discard all
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static void flush(AVCodecContext *avctx)
int avctx_inited
1 if avctx has been initialized with the values from the codec parameters
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
int av_match_list(const char *name, const char *list, char separator)
Check if a name is in a list.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
int fps_probe_size
The number of frames used for determining the framerate in avformat_find_stream_info().
Rational number (pair of numerator and denominator).
int64_t bit_rate
the average bitrate
enum AVPacketSideDataType type
static void update_initial_durations(AVFormatContext *s, AVStream *st, int stream_index, int64_t duration)
@ AV_PICTURE_TYPE_I
Intra.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
AVIOContext * pb
I/O context.
static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
This structure contains the data a format has to probe a file.
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
static PacketListEntry * get_next_pkt(AVFormatContext *s, AVStream *st, PacketListEntry *pktl)
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int skip_estimate_duration_from_pts
Skip duration calcuation in estimate_timings_from_pts.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
struct PacketListEntry * next
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
static int add_coded_side_data(AVStream *st, AVCodecContext *avctx)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int sample_rate
Audio only.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
static const char * duration_estimate_name(enum AVDurationEstimationMethod method)
AVCodecID
Identify the syntax and semantics of the bitstream.
int64_t fps_first_dts
Those are used for average framerate estimation.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
AVDictionary * id3v2_meta
ID3v2 tag useful for MP3 demuxing.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int av_codec_is_decoder(const AVCodec *codec)
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.
const OptionDef options[]
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
int found_decoder
0 -> decoder has not been searched for yet.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list, unsigned fourcc)
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static int init_input(AVFormatContext *s, const char *filename, AVDictionary **options)
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static int64_t start_time
enum AVSampleFormat sample_fmt
audio sample format
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_index, AVPacket *pkt)
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
@ AV_PICTURE_TYPE_NONE
Undefined.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeData *pd)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
static int update_stream_avctx(AVFormatContext *s)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
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 offset
int pts_wrap_behavior
Options for behavior, when a wrap is detected.
int raw_packet_buffer_size
Sum of the size of packets in raw_packet_buffer, in bytes.
int flags
A combination of AV_PKT_FLAG values.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int update_initial_durations_done
Internal data to prevent doing update_initial_durations() twice.
int64_t start_skip_samples
If not 0, the number of samples that should be skipped from the start of the stream (the samples are ...
static void estimate_timings_from_bit_rate(AVFormatContext *ic)
int probe_packets
Number of packets to buffer for codec probing.
void ff_rfps_calculate(AVFormatContext *ic)
#define AV_LOG_INFO
Standard information.
int channels
number of audio channels
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
int skip_to_keyframe
Indicates that everything up to the next keyframe should be discarded.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
PacketList raw_packet_buffer
Raw packets from the demuxer, prior to parsing and decoding.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int64_t pos
Byte position of currently parsed frame in stream.
#define PARSER_FLAG_COMPLETE_FRAMES
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
#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...
int ff_read_packet(AVFormatContext *s, AVPacket *pkt)
Read a transport packet from a media file.
int64_t id
unique ID to identify the chapter
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size)
Get side information from packet.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
static const AVCodec * find_probe_decoder(AVFormatContext *s, const AVStream *st, enum AVCodecID codec_id)
#define AV_TIME_BASE
Internal time base represented as integer.
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
char * codec_whitelist
',' separated list of allowed decoders.
static void compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt)
Return the frame duration in seconds.
@ AV_ROUND_DOWN
Round toward -infinity.
int64_t ff_wrap_timestamp(const AVStream *st, int64_t timestamp)
Wrap a given time stamp, if there is an indication for an overflow.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
int av_find_default_stream_index(AVFormatContext *s)
@ AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
New fields can be added to the end with minor version bumps.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
static double limit(double x)
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare the remainders of two integer operands divided by a common divisor.
int id
Format-specific stream ID.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define FFSWAP(type, a, b)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int nb_side_data
The number of elements in the AVStream.side_data array.
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
int index
stream index in AVFormatContext
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
@ 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...
@ AV_AUDIO_SERVICE_TYPE_COMMENTARY
static void update_dts_from_pts(AVFormatContext *s, int stream_index, PacketListEntry *pkt_buffer)
Updates the dts of packets of a stream in pkt_buffer, by re-ordering the pts of the packets in a wind...
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
#define PARSER_FLAG_USE_CODEC_TS
static int ref[MAX_W *MAX_W]
AVRational r_frame_rate
Real base framerate of the stream.
static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt, int64_t next_dts, int64_t next_pts)
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
Parse a packet, add all split parts to parse_queue.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int64_t av_gettime(void)
Get the current time in microseconds.
static int shift(int a, int b)
#define FF_DISABLE_DEPRECATION_WARNINGS
#define AVIO_FLAG_READ
read-only
enum AVMediaType codec_type
char * av_strdup(const char *s)
Duplicate a string.
int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int64_t pts, int64_t dts, int64_t pos)
Parse a packet.
static int extract_extradata(FFFormatContext *si, AVStream *st, const AVPacket *pkt)
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
static av_always_inline int diff(const uint32_t a, const uint32_t b)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
@ AV_AUDIO_SERVICE_TYPE_EFFECTS
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static void fill_all_stream_timings(AVFormatContext *ic)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t dts)
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int64_t pos
byte position in stream, -1 if unknown
uint64_t channel_layout
Audio only.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
int width
picture width / height.
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
struct AVCodecParserContext * parser
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void estimate_timings(AVFormatContext *ic, int64_t old_offset)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
static int has_decode_delay_been_guessed(AVStream *st)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
int pts_wrap_bits
Number of bits in timestamps.
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
void * priv_data
Format private data.
int64_t pts_wrap_reference
Internal data to check for wrapping of the time stamp.
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
static int compute_chapters_end(AVFormatContext *s)
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
int avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
void av_parser_close(AVCodecParserContext *s)