#include "riff.h"
#include "url.h"
+#include "libavutil/ffversion.h"
+const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
+
/**
* @file
* various utility functions for use within FFmpeg
int default_stream_index = av_find_default_stream_index(s);
if (s->streams[default_stream_index]->pts_wrap_reference == AV_NOPTS_VALUE) {
for (i = 0; i < s->nb_streams; i++) {
+ if (av_find_program_from_stream(s, NULL, i))
+ continue;
s->streams[i]->pts_wrap_reference = pts_wrap_reference;
s->streams[i]->pts_wrap_behavior = pts_wrap_behavior;
}
*pden = 0;
switch (st->codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
- if (st->r_frame_rate.num && !pc) {
+ if (st->r_frame_rate.num && !pc && s->iformat) {
*pnum = st->r_frame_rate.den;
*pden = st->r_frame_rate.num;
} else if (st->time_base.num * 1000LL > st->time_base.den) {
st->last_IP_duration = pkt->duration;
if (pkt->dts != AV_NOPTS_VALUE)
st->cur_dts = pkt->dts + st->last_IP_duration;
+ if (pkt->dts != AV_NOPTS_VALUE &&
+ pkt->pts == AV_NOPTS_VALUE &&
+ st->last_IP_duration > 0 &&
+ ((uint64_t)st->cur_dts - (uint64_t)next_dts + 1) <= 2 &&
+ next_dts != next_pts &&
+ next_pts != AV_NOPTS_VALUE)
+ pkt->pts = next_dts;
+
st->last_IP_duration = pkt->duration;
st->last_IP_pts = pkt->pts;
/* Cannot compute PTS if not present (we can compute it only
return pos_max;
}
- if (ts_min > ts_max)
- return -1;
- else if (ts_min == ts_max)
- pos_limit = pos_min;
+ av_assert0(ts_min < ts_max);
no_change = 0;
while (pos_min < pos_limit) {
av_dlog(s,
"pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%s dts_max=%s\n",
pos_min, pos_max, av_ts2str(ts_min), av_ts2str(ts_max));
- assert(pos_limit <= pos_max);
+ av_assert0(pos_limit <= pos_max);
if (no_change == 0) {
int64_t approximate_keyframe_distance = pos_max - pos_limit;
break;
}
bit_rate += st->codec->bit_rate;
+ } else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->codec_info_nb_frames > 1) {
+ // If we have a videostream with packets but without a bitrate
+ // then consider the sum not known
+ bit_rate = 0;
+ break;
}
}
ic->bit_rate = bit_rate;
st->info->last_dts = AV_NOPTS_VALUE;
st->codec = avcodec_alloc_context3(c);
+ if (!st->codec) {
+ av_free(st->info);
+ av_free(st);
+ return NULL;
+ }
if (s->iformat) {
/* no default bitrate if decoding */
st->codec->bit_rate = 0;