We do this by switching to AVBPrint. v2: Also set IO context error flag in case of ENOMEM.
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2017-10-21 · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | API changes, most recent first: | 16 | API changes, most recent first: |
| 17 | 17 | ||
| 18 | 2019-08-xx - xxxxxxxxxx - lavf 58.31.101 - avio.h | ||
| 19 | 4K limit removed from avio_printf. | ||
| 20 | |||
| 18 | 2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h | 21 | 2019-08-xx - xxxxxxxxxx - lavf 58.31.100 - avio.h |
| 19 | Add avio_print_string_array and avio_print. | 22 | Add avio_print_string_array and avio_print. |
| 20 | 23 | ||
| @@ -571,7 +571,10 @@ int64_t avio_size(AVIOContext *s); · 570 unmodified lines | |||
| 571 | */ | 571 | */ |
| 572 | int avio_feof(AVIOContext *s); | 572 | int avio_feof(AVIOContext *s); |
| 573 | 573 | ||
| 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 | */ | ||
| 575 | int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); | 578 | int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); |
| 576 | 579 | ||
| 577 | /** | 580 | /** |
| @@ -1249,14 +1249,20 @@ int avio_closep(AVIOContext **s) · 1248 unmodified lines | |||
| 1249 | int avio_printf(AVIOContext *s, const char *fmt, ...) | 1249 | int avio_printf(AVIOContext *s, const char *fmt, ...) |
| 1250 | { | 1250 | { |
| 1251 | va_list ap; | 1251 | va_list ap; |
| 1252 | char buf[4096]; /* update doc entry in avio.h if changed */ | 1252 | AVBPrint bp; |
| 1253 | int ret; | ||
| 1254 | 1253 | ||
| 1254 | av_bprint_init(&bp, 0, INT_MAX); | ||
| 1255 | va_start(ap, fmt); | 1255 | va_start(ap, fmt); |
| 1256 | ret = vsnprintf(buf, sizeof(buf), fmt, ap); | 1256 | av_vbprintf(&bp, fmt, ap); |
| 1257 | va_end(ap); | 1257 | va_end(ap); |
| 1258 | avio_write(s, buf, strlen(buf)); | 1258 | if (!av_bprint_is_complete(&bp)) { |
| 1259 | return ret; | 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; | ||
| 1260 | } | 1266 | } |
| 1261 | 1267 | ||
| 1262 | void avio_print_string_array(AVIOContext *s, const char *strings[]) | 1268 | void avio_print_string_array(AVIOContext *s, const char *strings[]) |
| @@ -33,7 +33,7 @@ · 32 unmodified lines | |||
| 33 | // Also please add any ticket numbers that you believe might be affected here | 33 | // Also please add any ticket numbers that you believe might be affected here |
| 34 | #define LIBAVFORMAT_VERSION_MAJOR 58 | 34 | #define LIBAVFORMAT_VERSION_MAJOR 58 |
| 35 | #define LIBAVFORMAT_VERSION_MINOR 31 | 35 | #define LIBAVFORMAT_VERSION_MINOR 31 |
| 36 | #define LIBAVFORMAT_VERSION_MICRO 100 | 36 | #define LIBAVFORMAT_VERSION_MICRO 101 |
| 37 | 37 | ||
| 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | 38 | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |
| 39 | LIBAVFORMAT_VERSION_MINOR, \ | 39 | LIBAVFORMAT_VERSION_MINOR, \ |