Go to the documentation of this file.
24 #include "config_components.h"
57 timestamp < sti->pts_wrap_reference)
75 #if CONFIG_H264_DECODER
104 static const struct {
134 "Probe with size=%d, packets=%d detected %s with score=%d\n",
137 for (
int i = 0; fmt_id_type[
i].name;
i++) {
138 if (!strcmp(fmt->
name, fmt_id_type[
i].name)) {
166 s, 0,
s->format_probesize);
169 "will be ignored with AVFMT_NOFILE format.\n");
183 s, 0,
s->format_probesize);
189 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
202 #if FF_API_OLD_CHANNEL_LAYOUT
239 av_log(
NULL,
AV_LOG_ERROR,
"Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n");
254 if (!(
s->url =
av_strdup(filename ? filename :
""))) {
261 s->probe_score =
ret;
263 if (!
s->protocol_whitelist &&
s->pb &&
s->pb->protocol_whitelist) {
264 s->protocol_whitelist =
av_strdup(
s->pb->protocol_whitelist);
265 if (!
s->protocol_whitelist) {
271 if (!
s->protocol_blacklist &&
s->pb &&
s->pb->protocol_blacklist) {
272 s->protocol_blacklist =
av_strdup(
s->pb->protocol_blacklist);
273 if (!
s->protocol_blacklist) {
279 if (
s->format_whitelist &&
av_match_list(
s->iformat->name,
s->format_whitelist,
',') <= 0) {
298 if (
s->iformat->priv_data_size > 0) {
299 if (!(
s->priv_data =
av_mallocz(
s->iformat->priv_data_size))) {
303 if (
s->iformat->priv_class) {
304 *(
const AVClass **)
s->priv_data =
s->iformat->priv_class;
315 if (
s->iformat->read_header)
316 if ((
ret =
s->iformat->read_header(
s)) < 0) {
330 if (id3v2_extra_meta) {
331 if (!strcmp(
s->iformat->name,
"mp3") || !strcmp(
s->iformat->name,
"aac") ||
332 !strcmp(
s->iformat->name,
"tta") || !strcmp(
s->iformat->name,
"wav")) {
362 if (
s->iformat->read_close)
363 s->iformat->read_close(
s);
385 if ((
s->iformat && strcmp(
s->iformat->name,
"image2") &&
s->iformat->flags &
AVFMT_NOFILE) ||
390 if (
s->iformat->read_close)
391 s->iformat->read_close(
s);
404 if (
s->video_codec_id)
408 if (
s->audio_codec_id)
412 if (
s->subtitle_codec_id)
416 if (
s->data_codec_id)
437 "Failed to reallocate probe buffer for stream %d\n",
450 "nothing to probe for stream %d\n", st->
index);
479 int pts_wrap_behavior;
480 int64_t pts_wrap_reference;
498 if (!first_program) {
502 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
517 pts_wrap_reference =
program->pts_wrap_reference;
518 pts_wrap_behavior =
program->pts_wrap_behavior;
527 if (
program->pts_wrap_reference != pts_wrap_reference) {
528 for (
unsigned i = 0;
i <
program->nb_stream_indexes;
i++) {
534 program->pts_wrap_reference = pts_wrap_reference;
535 program->pts_wrap_behavior = pts_wrap_behavior;
548 #if FF_API_INIT_PACKET
569 if (
ffstream(st)->request_probe <= 0) {
576 err =
s->iformat->read_packet(
s,
pkt);
585 if (!pktl || err ==
AVERROR(EAGAIN))
587 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
606 "Packet corrupt (stream = %d, dts = %s)",
617 "Invalid stream index.\n");
638 if (
s->use_wallclock_as_timestamps)
677 !codec_framerate.
num &&
684 }
else if (codec_framerate.
den * 1000LL > codec_framerate.
num) {
689 codec_framerate.
num * (int64_t)ticks_per_frame,
730 #if CONFIG_H264_DECODER
765 int64_t best_score = INT64_MAX;
766 for (
int i = 0;
i < delay;
i++) {
769 if (score < best_score) {
776 for (
int i = 0;
i < delay;
i++) {
805 AVStream *
const st =
s->streams[stream_index];
813 for (; pkt_buffer; pkt_buffer =
get_next_pkt(
s, st, pkt_buffer)) {
818 pts_buffer[0] = pkt_buffer->
pkt.
pts;
819 for (
int i = 0; i < delay && pts_buffer[i] > pts_buffer[
i + 1];
i++)
820 FFSWAP(int64_t, pts_buffer[
i], pts_buffer[
i + 1]);
831 AVStream *
const st =
s->streams[stream_index];
853 if (pktl_it->pkt.stream_index != stream_index)
856 pktl_it->pkt.pts +=
shift;
859 pktl_it->pkt.dts +=
shift;
903 av_log(
s,
AV_LOG_DEBUG,
"first_dts %s not matching first dts %s (pts %s, duration %"PRId64
") in the queue\n",
941 int64_t next_dts, int64_t next_pts)
945 int num, den, presentation_delayed, delay;
961 "DTS %"PRIi64
" < %"PRIi64
" out of order\n",
987 presentation_delayed = 0;
993 presentation_delayed = 1;
1011 if ( strcmp(
s->iformat->name,
"mov,mp4,m4a,3gp,3g2,mj2")
1012 && strcmp(
s->iformat->name,
"flv"))
1046 presentation_delayed = 1;
1050 "IN delayed:%d pts:%s, dts:%s cur_dts:%s st:%d pc:%p duration:%"PRId64
" delay:%d onein_oneout:%d\n",
1056 if ((delay == 0 || (delay == 1 && pc)) &&
1058 if (presentation_delayed) {
1076 ((uint64_t)sti->
cur_dts - (uint64_t)next_dts + 1) <= 2 &&
1077 next_dts != next_pts &&
1134 int stream_index,
int flush)
1138 AVStream *st =
s->streams[stream_index];
1149 while (
size > 0 || (
flush && got_output)) {
1150 int64_t next_pts =
pkt->
pts;
1151 int64_t next_dts =
pkt->
dts;
1165 got_output = !!out_pkt->
size;
1176 if (!out_pkt->
buf) {
1256 int ret, got_packet = 0;
1269 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
1288 av_log(
s,
AV_LOG_DEBUG,
"Demuxer context update while decoder is open, closing and trying to re-open\n");
1314 "Invalid timestamps stream=%d, pts=%s, dts=%s, size=%d\n",
1322 "ff_read_packet stream=%d, pts=%s, dts=%s, size=%d, duration=%"PRId64
", flags=%d\n",
1332 "%s, packets or times may be invalid.\n",
1359 #if FF_API_OLD_CHANNEL_LAYOUT
1388 int discard_padding = 0;
1395 sample < sti->last_discard_sample)
1405 AV_WL32(p + 4, discard_padding);
1407 (
unsigned)sti->
skip_samples, (
unsigned)discard_padding);
1412 #if FF_API_AVSTREAM_SIDE_DATA
1413 if (sti->inject_global_side_data) {
1427 memcpy(dst_data, src_sd->
data, src_sd->
size);
1429 sti->inject_global_side_data = 0;
1447 "read_frame_internal stream=%d, pts=%s, dts=%s, "
1448 "size=%d, duration=%"PRId64
", flags=%d\n",
1486 int wrap_bits =
s->streams[next_pkt->
stream_index]->pts_wrap_bits;
1489 int64_t last_dts = next_pkt->
dts;
1500 last_dts = pktl->
pkt.
dts;
1581 int64_t
start_time, start_time1, start_time_text, end_time, end_time1, end_time_text;
1585 start_time_text = INT64_MAX;
1586 end_time = INT64_MIN;
1587 end_time_text = INT64_MIN;
1589 duration_text = INT64_MIN;
1600 start_time_text =
FFMIN(start_time_text, start_time1);
1606 if (end_time1 !=
AV_NOPTS_VALUE && (end_time1 > 0 ? start_time1 <= INT64_MAX - end_time1 : start_time1 >= INT64_MIN - end_time1)) {
1607 end_time1 += start_time1;
1609 end_time_text =
FFMAX(end_time_text, end_time1);
1611 end_time =
FFMAX(end_time, end_time1);
1614 if (p->start_time ==
AV_NOPTS_VALUE || p->start_time > start_time1)
1615 p->start_time = start_time1;
1616 if (p->end_time < end_time1)
1617 p->end_time = end_time1;
1624 duration_text =
FFMAX(duration_text, duration1);
1634 if (end_time == INT64_MIN || (end_time < end_time_text && end_time_text - (uint64_t)end_time <
AV_TIME_BASE))
1635 end_time = end_time_text;
1636 else if (end_time < end_time_text)
1646 if (end_time != INT64_MIN) {
1693 int show_warning = 0;
1697 int64_t bit_rate = 0;
1740 "Estimating duration from bitrate, this may be inaccurate\n");
1743 #define DURATION_MAX_READ_SIZE 250000LL
1744 #define DURATION_MAX_RETRY 6
1751 int num, den, read_size,
ret;
1752 int found_duration = 0;
1768 "start time for stream %d is not set in estimate_timings_from_pts\n",
i);
1777 av_log(ic,
AV_LOG_INFO,
"Skipping duration calculation in estimate_timings_from_pts\n");
1778 goto skip_duration_calc;
1786 is_end = found_duration;
1907 file_size =
FFMAX(0, file_size);
1940 "format: start_time: %s duration: %s (estimate from %s) bitrate=%"PRId64
" kb/s\n",
1965 #define FAIL(errmsg) do { \
1967 *errmsg_ptr = errmsg; \
1973 FAIL(
"unknown codec");
1977 FAIL(
"unspecified frame size");
1980 FAIL(
"unspecified sample format");
1982 FAIL(
"unspecified sample rate");
1984 FAIL(
"unspecified number of channels");
1986 FAIL(
"no decodable DTS frames");
1990 FAIL(
"unspecified size");
1992 FAIL(
"unspecified pixel format");
1995 FAIL(
"no frame in rv30/40 and no sar");
1999 FAIL(
"unspecified size");
2015 int got_picture = 1,
ret = 0;
2018 int do_skip_frame = 0;
2020 int pkt_to_send =
pkt->
size > 0;
2045 if (
s->codec_whitelist)
2069 while ((pkt_to_send || (!
pkt->
data && got_picture)) &&
2103 if (do_skip_frame) {
2123 int64_t max_time = 0;
2126 if (!
s->nb_chapters)
2129 if (
s->duration > 0 &&
s->start_time < INT64_MAX -
s->duration)
2130 max_time =
s->duration +
2133 timetable =
av_memdup(
s->chapters,
s->nb_chapters *
sizeof(*timetable));
2138 for (
unsigned i = 0;
i <
s->nb_chapters;
i++)
2145 if (
i + 1 <
s->nb_chapters) {
2146 const AVChapter *
const ch1 = timetable[
i + 1];
2149 if (next_start > ch->
start && next_start < end)
2152 ch->
end = (end == INT64_MAX || end < ch->
start) ? ch->
start : end;
2161 return (
i + 1) * 1001;
2165 return (
i + 31) * 1001 * 12;
2169 return ((
const int[]) { 80, 120, 240})[
i] * 1001 * 12;
2173 return ((
const int[]) { 24, 30, 60, 12, 15, 48 })[
i] * 1000 * 12;
2194 if (time_base.
den >= 101LL * time_base.
num ||
2195 time_base.
den < 5LL * time_base.
num ||
2211 int64_t last =
info->last_dts;
2214 && ts - (uint64_t)last < INT64_MAX) {
2218 if (!
info->duration_error)
2220 if (!
info->duration_error)
2226 if (
info->duration_error[0][1][
i] < 1e10) {
2229 for (
int j = 0; j < 2; j++) {
2230 int64_t ticks =
llrint(sdts+j*0.5);
2231 double error = sdts - ticks + j*0.5;
2238 info->duration_count++;
2242 if (
info->duration_count % 10 == 0) {
2243 int n =
info->duration_count;
2245 if (
info->duration_error[0][1][
i] < 1e10) {
2246 double a0 =
info->duration_error[0][0][
i] / n;
2247 double error0 =
info->duration_error[0][1][
i] / n -
a0*
a0;
2248 double a1 =
info->duration_error[1][0][
i] / n;
2249 double error1 =
info->duration_error[1][1][
i] / n -
a1*
a1;
2250 if (error0 > 0.04 && error1 > 0.04) {
2251 info->duration_error[0][1][
i] = 2e10;
2252 info->duration_error[1][1][
i] = 2e10;
2263 info->last_dts = ts;
2285 double best_error = 0.01;
2298 for (
int k = 0; k < 2; k++) {
2303 if (error < best_error && best_error> 0.000000001) {
2312 if (num && (!ref_rate.
num || (
double)num/(12*1001) < 1.01 *
av_q2d(ref_rate)))
2426 side_data->
size = 0;
2439 int count = 0,
ret = 0;
2447 int64_t max_stream_analyze_duration;
2448 int64_t max_subtitle_analyze_duration;
2450 int eof_reached = 0;
2453 flush_codecs = probesize > 0;
2457 max_stream_analyze_duration = max_analyze_duration;
2458 max_subtitle_analyze_duration = max_analyze_duration;
2459 if (!max_analyze_duration) {
2460 max_stream_analyze_duration =
2471 av_log(ic,
AV_LOG_DEBUG,
"Before avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d nb_streams:%d\n",
2494 "%s, packets or times may be invalid.\n",
2501 goto find_stream_info_err;
2522 if (codec && !avctx->
codec)
2525 "Failed to open codec in %s\n", __func__);
2537 int analyzed_all_streams;
2549 int fps_analyze_framecount = 20;
2558 fps_analyze_framecount *= 2;
2560 fps_analyze_framecount = 0;
2564 fps_analyze_framecount = 0;
2571 if (count < fps_analyze_framecount)
2589 analyzed_all_streams = 0;
2590 if (!missing_streams || !*missing_streams)
2592 analyzed_all_streams = 1;
2604 if (read_size >= probesize) {
2607 "Probe buffer size limit of %"PRId64
" bytes reached\n", probesize);
2616 "Stream #%d: not enough frames to estimate rate; "
2617 "consider increasing probesize\n",
i);
2638 goto unref_then_goto_end;
2654 goto unref_then_goto_end;
2663 "Non-increasing DTS in stream %d: packet %d with DTS "
2664 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
2680 "DTS discontinuity in stream %d: packet %d with DTS "
2681 "%"PRId64
", packet %d with DTS %"PRId64
"\n",
2714 if (analyzed_all_streams)
limit = max_analyze_duration;
2716 else limit = max_stream_analyze_duration;
2719 av_log(ic,
AV_LOG_VERBOSE,
"max_analyze_duration %"PRId64
" reached at %"PRId64
" microseconds st:%d\n",
2739 #if FF_API_R_FRAME_RATE
2748 goto unref_then_goto_end;
2771 for (
unsigned stream_index = 0; stream_index < ic->
nb_streams; stream_index++) {
2776 if (codec && !avctx->
codec) {
2782 "Failed to open codec in %s\n", __func__);
2812 "decoding for stream %d failed\n", st->
index);
2837 double best_error = 0.01;
2855 if (
error < best_error) {
2857 best_fps = std_fps.
num;
2863 if (
error < best_error) {
2865 best_fps = std_fps.
num;
2871 best_fps, 12 * 1001, INT_MAX);
2936 goto find_stream_info_err;
2942 "Could not find codec parameters for stream %d (%s): %s\n"
2943 "Consider increasing the value for the 'analyzeduration' (%"PRId64
") and 'probesize' (%"PRId64
") options\n",
2952 goto find_stream_info_err;
2962 goto find_stream_info_err;
2978 (uint8_t *)props, cpb_size, 0))
2985 #if FF_API_AVSTREAM_SIDE_DATA
2988 av_assert0(!st->side_data && !st->nb_side_data);
2990 if (!st->side_data) {
2992 goto find_stream_info_err;
3000 goto find_stream_info_err;
3004 st->side_data[j].data =
data;
3012 find_stream_info_err:
3028 av_log(ic,
AV_LOG_DEBUG,
"After avformat_find_stream_info() pos: %"PRId64
" bytes read:%"PRId64
" seeks:%d frames:%d\n",
3033 unref_then_goto_end:
3035 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.
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.
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.
int sample_rate
samples per second
int64_t rc_min_rate
minimum bitrate
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
struct AVBSFContext * bsf
void * av_opt_ptr(const AVClass *class, void *obj, const char *name)
Gets a pointer to the requested field in a struct.
@ 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...
#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.
#define AV_PKT_FLAG_DISCARD
Flag is used to discard packets which are required to maintain valid decoder state but are not requir...
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.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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.
AVStream ** streams
A list of all streams in the file.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
int capabilities
Codec capabilities.
@ 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 ...
AVRational framerate
Video only.
#define AV_LOG_VERBOSE
Detailed information.
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.
enum AVChannelOrder order
Channel order used in this layout.
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)
uint64_t mask
This member must be used for AV_CHANNEL_ORDER_NATIVE, and may be used for AV_CHANNEL_ORDER_AMBISONIC ...
int nb_channels
Number of channels in this layout.
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
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
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
const struct AVCodecDescriptor * codec_desc
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,...
int64_t av_gcd(int64_t a, int64_t b)
Compute the greatest common divisor of two integer operands.
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
#define MAX_STD_TIMEBASES
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
AVChannelLayout ch_layout
Audio channel layout.
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.
int64_t fps_first_dts
Those are used for average framerate estimation.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
#define AVERROR_OPTION_NOT_FOUND
Option not found.
struct AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
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)
union AVChannelLayout::@332 u
Details about which channels are present in this layout.
@ 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.
int metafree
Contexts and child contexts do not contain a metadata option.
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.
struct FFStream::@300 extract_extradata
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 avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, const AVPacket *avpkt)
Decode a subtitle message.
int max_ts_probe
Maximum number of packets to read while waiting for the first timestamp.
#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.
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
This struct describes the properties of a single codec described by an AVCodecID.
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.
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...
FF_ENABLE_DEPRECATION_WARNINGS 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 attribute_align_arg avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder or encoder (when the AV_CODEC_FLAG_RECON_FRAME flag is used...
#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
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
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
#define DURATION_MAX_RETRY
int64_t rc_max_rate
maximum bitrate
int nb_coded_side_data
Amount of entries in coded_side_data.
@ 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)
This structure describes the bitrate properties of an encoded bitstream.
int found_decoder
0 -> decoder has not been searched for yet.
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the then the processing requires a frame on this link and the filter is expected to make efforts in that direction The status of input links is stored by the fifo and status_out fields
#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
int rc_buffer_size
decoder bitstream buffer size
@ 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.
int avcodec_parameters_to_context(AVCodecContext *codec, const struct AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
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.
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.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
int64_t codec_info_duration
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.
int64_t codec_info_duration_fields
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
AVChannelLayout ch_layout
Audio only.
struct PacketListEntry * next
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
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.
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.
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.
#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 int shift(int a, int b)
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
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.
#define AV_CODEC_PROP_FIELDS
Video codec supports separate coding of fields in interlaced frames.
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_*.
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...
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
@ AV_PICTURE_TYPE_NONE
Undefined.
int64_t min_bitrate
Minimum bitrate of the stream, in bits per second.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, AVProbeData *pd)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)
#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
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
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.
@ AV_CHANNEL_ORDER_NATIVE
The native channel order, i.e.
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.
int64_t rfps_duration_sum
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.
#define FFERROR_REDO
Returned by demuxers to indicate that data was consumed but discarded (ignored streams or junk data).
static int64_t filesize(AVIOContext *pb)
int skip_to_keyframe
Indicates that everything up to the next keyframe should be discarded.
double(* duration_error)[2][MAX_STD_TIMEBASES]
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.
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
int64_t pos
Byte position of currently parsed frame in stream.
#define PARSER_FLAG_COMPLETE_FRAMES
#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.
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.
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
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.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_calloc(size_t nmemb, size_t size)
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
static int try_decode_frame(AVFormatContext *s, AVStream *st, const AVPacket *pkt, AVDictionary **options)
static double limit(double x)
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
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)
int64_t buffer_size
The size of the buffer to which the ratecontrol is applied, in bits.
static int tb_unreliable(AVFormatContext *ic, AVStream *st)
@ AV_AUDIO_SERVICE_TYPE_KARAOKE
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
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.
@ 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.
@ AV_PKT_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt, int64_t next_dts, int64_t next_pts)
struct FFStreamInfo * info
Stream information used internally by avformat_find_stream_info()
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.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
int64_t av_gettime(void)
Get the current time in microseconds.
#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)
void(* flush)(AVBSFContext *ctx)
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
int avcodec_parameters_from_context(struct AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
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
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.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
static int has_decode_delay_been_guessed(AVStream *st)
static av_always_inline int is_relative(int64_t ts)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
void ff_reduce_index(AVFormatContext *s, int stream_index)
Ensure the index uses less memory than the maximum specified in AVFormatContext.max_index_size by dis...
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 avpriv_codec_get_cap_skip_frame_fill_param(const AVCodec *codec)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
void av_parser_close(AVCodecParserContext *s)
AVCPBProperties * av_cpb_properties_alloc(size_t *size)
Allocate a CPB properties structure and initialize its fields to default values.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)