[FFmpeg-devel] [PATCH 1/2] lavu/bprint: add av_bprint_get_buffer().
Nicolas George
nicolas.george at normalesup.org
Sun Oct 28 15:02:23 CET 2012
It is useful to use bprint to handle a growing buffer
used with another API.
Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
---
libavutil/bprint.c | 9 +++++++++
libavutil/bprint.h | 12 ++++++++++++
libavutil/version.h | 2 +-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index 373a492..9d8e7c1 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -129,6 +129,15 @@ void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
av_bprint_grow(buf, n);
}
+void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
+ unsigned char **mem, unsigned *actual_size)
+{
+ if (size > av_bprint_room(buf))
+ av_bprint_alloc(buf, size);
+ *actual_size = av_bprint_room(buf);
+ *mem = *actual_size ? buf->str + buf->len : NULL;
+}
+
void av_bprint_clear(AVBPrint *buf)
{
if (buf->len) {
diff --git a/libavutil/bprint.h b/libavutil/bprint.h
index 2bef18d..c09b61f 100644
--- a/libavutil/bprint.h
+++ b/libavutil/bprint.h
@@ -126,6 +126,18 @@ void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
/**
+ * Allocate bytes in the buffer for external use.
+ *
+ * @param[in] buf buffer structure
+ * @param[in] size required size
+ * @param[out] mem pointer to the memory area
+ * @param[out] actual_size size of the memory area after allocation;
+ * can be larger or smaller than size
+ */
+void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
+ unsigned char **mem, unsigned *actual_size);
+
+/**
* Reset the string to "" but keep internal allocated data.
*/
void av_bprint_clear(AVBPrint *buf);
diff --git a/libavutil/version.h b/libavutil/version.h
index 94a4a47..60a7450 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -75,7 +75,7 @@
*/
#define LIBAVUTIL_VERSION_MAJOR 52
-#define LIBAVUTIL_VERSION_MINOR 1
+#define LIBAVUTIL_VERSION_MINOR 2
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
--
1.7.10.4
More information about the ffmpeg-devel
mailing list