summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2019-08-05 22:27:47 +0200
committerMarton Balint <cus@passwd.hu>2019-08-17 18:39:49 +0200
commit95fa73a2b48fe8e73fb2b25d3b272da1bbd167b3 (patch)
treef5e49d23de3b4f00227c7763139b2066bdf2528e
parent61b4daf78ce09534b258aae6b86934ce98d2b27f (diff)
downloadffmpeg-streaming-95fa73a2b48fe8e73fb2b25d3b272da1bbd167b3.zip
ffmpeg-streaming-95fa73a2b48fe8e73fb2b25d3b272da1bbd167b3.tar.gz
avformat/avio: remove 4k limit from avio_printf
We do this by switching to AVBPrint. v2: Also set IO context error flag in case of ENOMEM. Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r--doc/APIchanges3
-rw-r--r--libavformat/avio.h5
-rw-r--r--libavformat/aviobuf.c16
-rw-r--r--libavformat/version.h2
4 files changed, 19 insertions, 7 deletions
diff --git a/doc/APIchanges b/doc/APIchanges
index ba35b84..682b67a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2017-10-21
API changes, most recent first:
+2019-08-xx - xxxxxxxxxx - lavf 58.31.101 - avio.h
+ 4K limit removed from avio_printf.
+
2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h
Add avio_print_string_array and avio_print.
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 910e4f1..9141642 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -571,7 +571,10 @@ int64_t avio_size(AVIOContext *s);
*/
int avio_feof(AVIOContext *s);
-/** @warning Writes up to 4 KiB per call */
+/**
+ * Writes a formatted string to the context.
+ * @return number of bytes written, < 0 on error.
+ */
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
/**
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 85d809c..2dfce8a 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1249,14 +1249,20 @@ int avio_closep(AVIOContext **s)
int avio_printf(AVIOContext *s, const char *fmt, ...)
{
va_list ap;
- char buf[4096]; /* update doc entry in avio.h if changed */
- int ret;
+ AVBPrint bp;
+ av_bprint_init(&bp, 0, INT_MAX);
va_start(ap, fmt);
- ret = vsnprintf(buf, sizeof(buf), fmt, ap);
+ av_vbprintf(&bp, fmt, ap);
va_end(ap);
- avio_write(s, buf, strlen(buf));
- return ret;
+ if (!av_bprint_is_complete(&bp)) {
+ av_bprint_finalize(&bp, NULL);
+ s->error = AVERROR(ENOMEM);
+ return AVERROR(ENOMEM);
+ }
+ avio_write(s, bp.str, bp.len);
+ av_bprint_finalize(&bp, NULL);
+ return bp.len;
}
void avio_print_string_array(AVIOContext *s, const char *strings[])
diff --git a/libavformat/version.h b/libavformat/version.h
index feceaed..9814db8 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
#define LIBAVFORMAT_VERSION_MINOR 31
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
OpenPOWER on IntegriCloud