Go to the documentation of this file.
33 #define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
34 #define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
38 char *old_str, *new_str;
39 unsigned min_size, new_size;
41 if (buf->size == buf->size_max)
45 min_size = buf->len + 1 +
FFMIN(UINT_MAX - buf->len - 1, room);
46 new_size = buf->size > buf->size_max / 2 ? buf->size_max : buf->size * 2;
47 if (new_size < min_size)
48 new_size =
FFMIN(buf->size_max, min_size);
54 memcpy(new_str, buf->str, buf->len + 1);
63 extra_len =
FFMIN(extra_len, UINT_MAX - 5 - buf->len);
64 buf->len += extra_len;
66 buf->str[
FFMIN(buf->len, buf->size - 1)] = 0;
71 unsigned size_auto = (
char *)buf +
sizeof(*buf) -
72 buf->reserved_internal_buffer;
76 buf->str = buf->reserved_internal_buffer;
103 dst = room ? buf->str + buf->len :
NULL;
105 extra_len =
vsnprintf(dst, room, fmt, vl);
109 if (extra_len < room)
126 dst = room ? buf->str + buf->len :
NULL;
128 extra_len =
vsnprintf(dst, room, fmt, vl);
132 if (extra_len < room)
142 unsigned room, real_n;
152 real_n =
FFMIN(n, room - 1);
153 memset(buf->str + buf->len,
c, real_n);
160 unsigned room, real_n;
171 memcpy(buf->str + buf->len,
data, real_n);
185 if (room && (l = strftime(buf->str + buf->len, room, fmt, tm)))
189 room = !room ? strlen(fmt) + 1 :
190 room <= INT_MAX / 2 ? room * 2 : INT_MAX;
199 if ((l = strftime(buf2,
sizeof(buf2), fmt, tm))) {
207 static const char txt[] =
"[truncated strftime output]";
208 memset(buf->str + buf->len,
'!', room);
209 memcpy(buf->str + buf->len, txt,
FFMIN(
sizeof(txt) - 1, room));
219 unsigned char **mem,
unsigned *actual_size)
224 *mem = *actual_size ? buf->str + buf->len :
NULL;
237 unsigned real_size =
FFMIN(buf->len + 1, buf->size);
257 buf->size = real_size;
261 #define WHITESPACES " \n\t\r"
292 case '&' :
av_bprintf(dstbuf,
"%s",
"&");
break;
293 case '<' :
av_bprintf(dstbuf,
"%s",
"<");
break;
294 case '>' :
av_bprintf(dstbuf,
"%s",
">");
break;
297 goto XML_DEFAULT_HANDLING;
303 goto XML_DEFAULT_HANDLING;
307 XML_DEFAULT_HANDLING:
319 int is_strictly_special = special_chars && strchr(special_chars, *
src);
321 is_strictly_special || strchr(
"'\\", *
src) ||
324 if (is_strictly_special ||
326 (is_special || (is_ws && is_first_last))))
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm)
Append a formatted date and time to a print buffer.
#define AV_ESCAPE_FLAG_XML_SINGLE_QUOTES
Within AV_ESCAPE_MODE_XML, additionally escape single quotes for single quoted attributes.
static void av_bprint_grow(AVBPrint *buf, unsigned extra_len)
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
#define AV_ESCAPE_FLAG_STRICT
Escape only specified special characters.
#define AV_ESCAPE_FLAG_WHITESPACE
Consider spaces special and escape them even in the middle of the string.
#define AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES
Within AV_ESCAPE_MODE_XML, additionally escape double quotes for double quoted attributes.
#define av_bprint_room(buf)
unsigned unsigned size_max
void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg)
Append a formatted string to a print buffer.
@ AV_ESCAPE_MODE_QUOTE
Use single-quote escaping.
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
@ AV_ESCAPE_MODE_AUTO
Use auto-selected escaping mode.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
void av_bprint_get_buffer(AVBPrint *buf, unsigned size, unsigned char **mem, unsigned *actual_size)
Allocate bytes in the buffer for external use.
#define av_bprint_is_allocated(buf)
@ AV_ESCAPE_MODE_XML
Use XML non-markup character data escaping.
#define va_copy(dst, src)
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars, enum AVEscapeMode mode, int flags)
Escape the content in src and append it to dstbuf.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
static const char * ret_str(int v)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
@ AV_ESCAPE_MODE_BACKSLASH
Use backslash escaping.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int av_bprint_alloc(AVBPrint *buf, unsigned room)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.