aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-04-14 03:21:38 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-04-14 03:21:38 +0200
commitc55780dcef1ba87564d8003cded7d045dce9ba34 (patch)
treef685b7150db1c7e0f5e65fb2761f3f8bd843f056 /libavformat
parentff5278d8f6203a9486c0cd63a3aecef4bc2e4f6f (diff)
parent651b276ef7ad8d89e89bfc94a4232ab6c36f3a8a (diff)
downloadffmpeg-c55780dcef1ba87564d8003cded7d045dce9ba34.tar.gz
Merge remote branch 'qatar/master'
* qatar/master: (32 commits) libopencore-amr, libvo-amrwbenc: Allow enabling DTX via private AVOptions libopencore-amr, libvo-amrwbenc: Only check the bitrate when changed libopencore-amr, libvo-amrwbenc: Find the closest matching bitrate libvo-*: Fix up the long codec names libavcodec: Mark AVCodec->priv_class const swscale: Factorize FAST_BGR2YV12 definition. libvo-aacenc: Only produce extradata if the global header flag is set lavf: postpone removal of public metadata conversion API lavc: postpone removal of request_channels lavc: postpone removal of audioconvert and sample_fmt wrappers lavf: postpone removal of deprecated avio functions libopencore-amr: Cosmetics: Rewrap and align libopencore-amr, libvo-amrbwenc: Rename variables and functions libopencore-amr: Convert commented out debug logging into av_dlog libopencore-amr: Remove an unused state variable libvo-amrwbenc: Don't explicitly store bitrate modes in the bitrate table libopencore-amr: Remove a useless local variable libopencore-amr, libvo-amrwbenc: Make the bitrate/mode mapping array static const libopencore-amr, libvo-amrwbenc: Return proper error codes in most places libopencore-amr: Don't print carriage returns in log messages ... Conflicts: doc/developer.texi libavcodec/avcodec.h libavcodec/libvo-aacenc.c libavcodec/libvo-amrwbenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/applehttp.c11
-rw-r--r--libavformat/avformat.h4
-rw-r--r--libavformat/avio.c21
-rw-r--r--libavformat/avio.h33
-rw-r--r--libavformat/file.c16
-rw-r--r--libavformat/url.h1
-rw-r--r--libavformat/utils.c5
-rw-r--r--libavformat/version.h2
8 files changed, 83 insertions, 10 deletions
diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c
index 7592dc3cc3..7e6d2d79e5 100644
--- a/libavformat/applehttp.c
+++ b/libavformat/applehttp.c
@@ -309,10 +309,13 @@ reload:
c->end_of_segment = 1;
c->cur_seq_no = v->cur_seq_no;
- v->needed = 0;
- for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams; i++) {
- if (v->parent->streams[i]->discard < AVDISCARD_ALL)
- v->needed = 1;
+ if (v->ctx) {
+ v->needed = 0;
+ for (i = v->stream_offset; i < v->stream_offset + v->ctx->nb_streams;
+ i++) {
+ if (v->parent->streams[i]->discard < AVDISCARD_ALL)
+ v->needed = 1;
+ }
}
if (!v->needed) {
av_log(v->parent, AV_LOG_INFO, "No longer receiving variant %d\n",
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3eb4a1e3fb..423b135039 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -317,7 +317,7 @@ typedef struct AVOutputFormat {
enum CodecID subtitle_codec; /**< default subtitle codec */
-#if FF_API_OLD_METADATA
+#if FF_API_OLD_METADATA2
const AVMetadataConv *metadata_conv;
#endif
@@ -437,7 +437,7 @@ typedef struct AVInputFormat {
*/
int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
-#if FF_API_OLD_METADATA
+#if FF_API_OLD_METADATA2
const AVMetadataConv *metadata_conv;
#endif
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 934fa213e9..725a95f768 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -363,6 +363,7 @@ int ffurl_close(URLContext *h)
return ret;
}
+#if FF_API_OLD_AVIO
int url_exist(const char *filename)
{
URLContext *h;
@@ -371,6 +372,26 @@ int url_exist(const char *filename)
ffurl_close(h);
return 1;
}
+#endif
+
+int avio_check(const char *url, int flags)
+{
+ URLContext *h;
+ int ret = ffurl_alloc(&h, url, flags);
+ if (ret)
+ return ret;
+
+ if (h->prot->url_check) {
+ ret = h->prot->url_check(h, flags);
+ } else {
+ ret = ffurl_connect(h);
+ if (ret >= 0)
+ ret = flags;
+ }
+
+ ffurl_close(h);
+ return ret;
+}
int64_t ffurl_size(URLContext *h)
{
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 7deca337cf..9d805822d4 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -134,6 +134,7 @@ typedef struct URLProtocol {
int priv_data_size;
const AVClass *priv_data_class;
int flags;
+ int (*url_check)(URLContext *h, int mask);
} URLProtocol;
typedef struct URLPollEntry {
@@ -335,13 +336,31 @@ attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_siz
/** return the written or read size */
attribute_deprecated int url_close_buf(AVIOContext *s);
-#endif // FF_API_OLD_AVIO
/**
* Return a non-zero value if the resource indicated by url
* exists, 0 otherwise.
+ * @deprecated Use avio_check instead.
*/
-int url_exist(const char *url);
+attribute_deprecated int url_exist(const char *url);
+#endif // FF_API_OLD_AVIO
+
+/**
+ * Return AVIO_* access flags corresponding to the access permissions
+ * of the resource in url, or a negative value corresponding to an
+ * AVERROR code in case of failure. The returned access flags are
+ * masked by the value in flags.
+ *
+ * @note This function is intrinsically unsafe, in the sense that the
+ * checked resource may change its existence or permission status from
+ * one call to another. Thus you should not trust the returned value,
+ * unless you are sure that no other processes are accessing the
+ * checked resource.
+ *
+ * @note This function is slightly broken until next major bump
+ * because of AVIO_RDONLY == 0. Don't use it until then.
+ */
+int avio_check(const char *url, int flags);
/**
* The callback is called in blocking functions to test regulary if
@@ -537,9 +556,15 @@ int url_resetbuf(AVIOContext *s, int flags);
* constants, optionally ORed with other flags.
* @{
*/
+#if LIBAVFORMAT_VERSION_MAJOR < 53
#define AVIO_RDONLY 0 /**< read-only */
#define AVIO_WRONLY 1 /**< write-only */
#define AVIO_RDWR 2 /**< read-write */
+#else
+#define AVIO_RDONLY 1 /**< read-only */
+#define AVIO_WRONLY 2 /**< write-only */
+#define AVIO_RDWR 4 /**< read-write */
+#endif
/**
* @}
*/
@@ -556,7 +581,11 @@ int url_resetbuf(AVIOContext *s, int flags);
* Warning: non-blocking protocols is work-in-progress; this flag may be
* silently ignored.
*/
+#if LIBAVFORMAT_VERSION_MAJOR < 53
#define AVIO_FLAG_NONBLOCK 4
+#else
+#define AVIO_FLAG_NONBLOCK 8
+#endif
/**
* Create and initialize a AVIOContext for accessing the
diff --git a/libavformat/file.c b/libavformat/file.c
index 64f8782c97..9d28a89327 100644
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -95,6 +95,20 @@ static int file_close(URLContext *h)
return close(fd);
}
+static int file_check(URLContext *h, int mask)
+{
+ struct stat st;
+ int ret = stat(h->filename, &st);
+ if (ret < 0)
+ return AVERROR(errno);
+
+ ret |= st.st_mode&S_IRUSR ? mask&AVIO_RDONLY : 0;
+ ret |= st.st_mode&S_IWUSR ? mask&AVIO_WRONLY : 0;
+ ret |= st.st_mode&S_IWUSR && st.st_mode&S_IRUSR ? mask&AVIO_RDWR : 0;
+
+ return ret;
+}
+
URLProtocol ff_file_protocol = {
.name = "file",
.url_open = file_open,
@@ -103,6 +117,7 @@ URLProtocol ff_file_protocol = {
.url_seek = file_seek,
.url_close = file_close,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_FILE_PROTOCOL */
@@ -137,6 +152,7 @@ URLProtocol ff_pipe_protocol = {
.url_read = file_read,
.url_write = file_write,
.url_get_file_handle = file_get_handle,
+ .url_check = file_check,
};
#endif /* CONFIG_PIPE_PROTOCOL */
diff --git a/libavformat/url.h b/libavformat/url.h
index 3f96f73763..56366644aa 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -59,6 +59,7 @@ typedef struct URLProtocol {
int priv_data_size;
const AVClass *priv_data_class;
int flags;
+ int (*url_check)(URLContext *h, int mask);
} URLProtocol;
#endif
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 0ea8ca94a9..1919f61d6a 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3086,7 +3086,10 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke
AVStream *st2= s->streams[ next->stream_index];
int64_t a= st2->time_base.num * (int64_t)st ->time_base.den;
int64_t b= st ->time_base.num * (int64_t)st2->time_base.den;
- return av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN) < next->dts;
+ int64_t dts1 = av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN);
+ if (dts1==next->dts && dts1==av_rescale_rnd(pkt->dts, b, a, AV_ROUND_UP))
+ return pkt->stream_index < next->stream_index;
+ return dts1 < next->dts;
}
int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){
diff --git a/libavformat/version.h b/libavformat/version.h
index dad6161607..e795263a6d 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -24,7 +24,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 106
+#define LIBAVFORMAT_VERSION_MINOR 107
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \