History

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.

Marton Balint committed 7 years ago

Commit 95fa73a1 parent 61b4daf4 files · +19 −7Browse files

Unified · Split

4 files
  1. doc/APIchanges +3 −0
  2. libavformat/avio.h +4 −1
  3. libavformat/aviobuf.c +11 −5
  4. libavformat/version.h +1 −1
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines
1515
1616 API changes, most recent first:
1717
18+2019-08-xx - xxxxxxxxxx - lavf 58.31.101 - avio.h
19+ 4K limit removed from avio_printf.
20+
1821 2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h
1922 Add avio_print_string_array and avio_print.
2023
libavformat/avio.h+4−1
@@ -571,7 +571,10 @@ int64_t avio_size(AVIOContext *s); · 570 unmodified lines
571571 */
572572 int avio_feof(AVIOContext *s);
573573
574−/** @warning Writes up to 4 KiB per call */
574+/**
575+ * Writes a formatted string to the context.
576+ * @return number of bytes written, < 0 on error.
577+ */
575578 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
576579
577580 /**
libavformat/aviobuf.c+11−5
@@ -1249,14 +1249,20 @@ int avio_closep(AVIOContext **s) · 1248 unmodified lines
12491249 int avio_printf(AVIOContext *s, const char *fmt, ...)
12501250 {
12511251 va_list ap;
1252− char buf[4096]; /* update doc entry in avio.h if changed */
1253− int ret;
1252+ AVBPrint bp;
12541253
1254+ av_bprint_init(&bp, 0, INT_MAX);
12551255 va_start(ap, fmt);
1256− ret = vsnprintf(buf, sizeof(buf), fmt, ap);
1256+ av_vbprintf(&bp, fmt, ap);
12571257 va_end(ap);
1258− avio_write(s, buf, strlen(buf));
1259− return ret;
1258+ if (!av_bprint_is_complete(&bp)) {
1259+ av_bprint_finalize(&bp, NULL);
1260+ s->error = AVERROR(ENOMEM);
1261+ return AVERROR(ENOMEM);
1262+ }
1263+ avio_write(s, bp.str, bp.len);
1264+ av_bprint_finalize(&bp, NULL);
1265+ return bp.len;
12601266 }
12611267
12621268 void avio_print_string_array(AVIOContext *s, const char *strings[])
libavformat/version.h+1−1
@@ -33,7 +33,7 @@ · 32 unmodified lines
3333 // Also please add any ticket numbers that you believe might be affected here
3434 #define LIBAVFORMAT_VERSION_MAJOR 58
3535 #define LIBAVFORMAT_VERSION_MINOR 31
36−#define LIBAVFORMAT_VERSION_MICRO 100
36+#define LIBAVFORMAT_VERSION_MICRO 101
3737
3838 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
3939 LIBAVFORMAT_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t