aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2019-08-05 21:50:42 +0200
committerMarton Balint <cus@passwd.hu>2019-08-17 18:39:49 +0200
commita82f8f2f10d0a4d8072919a8e4bdc1c39f4d27b8 (patch)
tree51c8f4f7fd363f309082bb116eb6716884a18e3e /libavformat
parent6a3bdf3148864224c8ef8025e8744f6dd2126303 (diff)
downloadffmpeg-a82f8f2f10d0a4d8072919a8e4bdc1c39f4d27b8.tar.gz
avformat/avio: add avio_print_string_array and avio_print
These functions can be used to print a variable number of strings consecutively to the IO context. Unlike av_bprintf, no temporary buffer is necessary. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avio.h17
-rw-r--r--libavformat/aviobuf.c6
-rw-r--r--libavformat/version.h2
3 files changed, 24 insertions, 1 deletions
diff --git a/libavformat/avio.h b/libavformat/avio.h
index dcb8dcdf93..910e4f1b48 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -575,6 +575,23 @@ int avio_feof(AVIOContext *s);
int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
/**
+ * Write a NULL terminated array of strings to the context.
+ * Usually you don't need to use this function directly but its macro wrapper,
+ * avio_print.
+ */
+void avio_print_string_array(AVIOContext *s, const char *strings[]);
+
+/**
+ * Write strings (const char *) to the context.
+ * This is a convenience macro around avio_print_string_array and it
+ * automatically creates the string array from the variable argument list.
+ * For simple string concatenations this function is more performant than using
+ * avio_printf since it does not need a temporary buffer.
+ */
+#define avio_print(s, ...) \
+ avio_print_string_array(s, (const char*[]){__VA_ARGS__, NULL})
+
+/**
* Force flushing of buffered data.
*
* For write streams, force the buffered data to be immediately written to the output,
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index a69c30e0af..85d809c6cd 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1259,6 +1259,12 @@ int avio_printf(AVIOContext *s, const char *fmt, ...)
return ret;
}
+void avio_print_string_array(AVIOContext *s, const char *strings[])
+{
+ for(; *strings; strings++)
+ avio_write(s, (const unsigned char *)*strings, strlen(*strings));
+}
+
int avio_pause(AVIOContext *s, int pause)
{
if (!s->read_pause)
diff --git a/libavformat/version.h b/libavformat/version.h
index 45efaff9b9..feceaedc08 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
// Also please add any ticket numbers that you believe might be affected here
#define LIBAVFORMAT_VERSION_MAJOR 58
-#define LIBAVFORMAT_VERSION_MINOR 30
+#define LIBAVFORMAT_VERSION_MINOR 31
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \