]> git.sesse.net Git - ffmpeg/commitdiff
avformat/avio: add avio_print_string_array and avio_print
authorMarton Balint <cus@passwd.hu>
Mon, 5 Aug 2019 19:50:42 +0000 (21:50 +0200)
committerMarton Balint <cus@passwd.hu>
Sat, 17 Aug 2019 16:39:49 +0000 (18:39 +0200)
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>
doc/APIchanges
libavformat/avio.h
libavformat/aviobuf.c
libavformat/version.h

index 6603a8229e48e9b6031d60b2a6156cbad6ad6a9b..ba35b847d972a414a3fb15393bf2296e789b1865 100644 (file)
@@ -15,6 +15,9 @@ libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h
+  Add avio_print_string_array and avio_print.
+
 2019-07-27 - xxxxxxxxxx - lavu 56.33.100 - tx.h
   Add AV_TX_DOUBLE_FFT and AV_TX_DOUBLE_MDCT
 
index dcb8dcdf93ade80ba2bb767f2f008fb26ac168cc..910e4f1b48713c15cb1ab64202d4bb618a78382a 100644 (file)
@@ -574,6 +574,23 @@ int avio_feof(AVIOContext *s);
 /** @warning Writes up to 4 KiB per call */
 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.
  *
index a69c30e0af9cd9a376a060ea3512379963cdf843..85d809c6cdabf4619df323a1be6945c8a15634cb 100644 (file)
@@ -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)
index 45efaff9b98aaa76cc24466d446c8d74737f7c39..feceaedc08508b540864135569e62fe0631b182a 100644 (file)
@@ -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, \