#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/thread.h"
#include "libavutil/time.h"
#include "libavutil/time_internal.h"
#include "libavutil/timestamp.h"
#include "libavutil/ffversion.h"
const char av_format_ffversion[] = "FFmpeg version " FFMPEG_VERSION;
+static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;
+
/**
* @file
* various utility functions for use within FFmpeg
return LICENSE_PREFIX FFMPEG_LICENSE + sizeof(LICENSE_PREFIX) - 1;
}
+int ff_lock_avformat(void)
+{
+ return ff_mutex_lock(&avformat_mutex) ? -1 : 0;
+}
+
+int ff_unlock_avformat(void)
+{
+ return ff_mutex_unlock(&avformat_mutex) ? -1 : 0;
+}
+
#define RELATIVE_TS_BASE (INT64_MAX - (1LL<<48))
static int is_relative(int64_t ts) {
#if FF_API_FORMAT_GET_SET
MAKE_ACCESSORS(AVStream, stream, AVRational, r_frame_rate)
+#if FF_API_LAVF_FFSERVER
+FF_DISABLE_DEPRECATION_WARNINGS
MAKE_ACCESSORS(AVStream, stream, char *, recommended_encoder_configuration)
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, video_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, audio_codec)
MAKE_ACCESSORS(AVFormatContext, format, AVCodec *, subtitle_codec)
goto fail;
if ((ret = ff_id3v2_parse_chapters(s, &id3v2_extra_meta)) < 0)
goto fail;
+ if ((ret = ff_id3v2_parse_priv(s, &id3v2_extra_meta)) < 0)
+ goto fail;
} else
av_log(s, AV_LOG_DEBUG, "demuxer does not support additional id3 data, skipping\n");
}
// last dts seen for this stream. if any of packets following
// current one had no dts, we will set this to AV_NOPTS_VALUE.
int64_t last_dts = next_pkt->dts;
+ av_assert2(wrap_bits <= 64);
while (pktl && next_pkt->pts == AV_NOPTS_VALUE) {
if (pktl->pkt.stream_index == next_pkt->stream_index &&
- (av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2LL << (wrap_bits - 1)) < 0)) {
- if (av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2LL << (wrap_bits - 1))) {
+ av_compare_mod(next_pkt->dts, pktl->pkt.dts, 2ULL << (wrap_bits - 1)) < 0) {
+ if (av_compare_mod(pktl->pkt.pts, pktl->pkt.dts, 2ULL << (wrap_bits - 1))) {
// not B-frame
next_pkt->pts = pktl->pkt.dts;
}
ret = avcodec_parameters_from_context(st->codecpar, st->internal->avctx);
if (ret < 0)
goto find_stream_info_err;
+#if FF_API_LOWRES
// The decoder might reduce the video size by the lowres factor.
- if (av_codec_get_lowres(st->internal->avctx) && orig_w) {
+ if (st->internal->avctx->lowres && orig_w) {
st->codecpar->width = orig_w;
st->codecpar->height = orig_h;
}
+#endif
}
#if FF_API_LAVF_AVCTX
if (ret < 0)
goto find_stream_info_err;
+#if FF_API_LOWRES
// The old API (AVStream.codec) "requires" the resolution to be adjusted
// by the lowres factor.
- if (av_codec_get_lowres(st->internal->avctx) && st->internal->avctx->width) {
- av_codec_set_lowres(st->codec, av_codec_get_lowres(st->internal->avctx));
+ if (st->internal->avctx->lowres && st->internal->avctx->width) {
+ st->codec->lowres = st->internal->avctx->lowres;
st->codec->width = st->internal->avctx->width;
st->codec->height = st->internal->avctx->height;
}
+#endif
if (st->codec->codec_tag != MKTAG('t','m','c','d')) {
st->codec->time_base = st->internal->avctx->time_base;
}
}
+#if FF_API_LAVF_FFSERVER
+FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&dst->recommended_encoder_configuration);
if (src->recommended_encoder_configuration) {
const char *conf_str = src->recommended_encoder_configuration;
if (!dst->recommended_encoder_configuration)
return AVERROR(ENOMEM);
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
return 0;
}
if (st->info)
av_freep(&st->info->duration_error);
av_freep(&st->info);
+#if FF_API_LAVF_FFSERVER
+FF_DISABLE_DEPRECATION_WARNINGS
av_freep(&st->recommended_encoder_configuration);
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
av_freep(pst);
}
s->time_base = new_tb;
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
- av_codec_set_pkt_timebase(s->codec, new_tb);
+ s->codec->pkt_timebase = new_tb;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
- av_codec_set_pkt_timebase(s->internal->avctx, new_tb);
+ s->internal->avctx->pkt_timebase = new_tb;
s->pts_wrap_bits = pts_wrap_bits;
}
{
#if CONFIG_NETWORK
int ret;
- ff_network_inited_globally = 1;
if ((ret = ff_network_init()) < 0)
return ret;
if ((ret = ff_tls_init()) < 0)
#if CONFIG_NETWORK
ff_network_close();
ff_tls_deinit();
- ff_network_inited_globally = 0;
#endif
return 0;
}
*pb = NULL;
}
+int ff_is_http_proto(char *filename) {
+ const char *proto = avio_find_protocol_name(filename);
+ return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0;
+}
+
int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds)
{
AVDictionaryEntry *entry;