FFmpeg: libavutil/dict.c Source File
Go to the documentation of this file. 1 /*
2 * copyright (c) 2009 Michael Niedermayer
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include <string.h>
22
29
33 };
34
36 {
37 return m ? m->
count : 0;
38 }
39
42 {
44
45 if (!m)
47
48 if (prev)
50 else
52
56 for (j = 0;
s[j] ==
key[j] &&
key[j]; j++)
57 ;
58 else
60 ;
62 continue;
64 continue;
66 }
68 }
69
72 {
75 char *oldval =
NULL, *copy_key =
NULL, *copy_value =
NULL;
76
79 }
81 copy_key = (
void *)
key;
82 else
85 copy_value = (
void *)
value;
86 else if (copy_key)
88 if (!m)
90 if (!m || (
key && !copy_key) || (
value && !copy_value))
91 goto err_out;
92
97 return 0;
98 }
101 else
105 } else if (copy_value) {
109 goto err_out;
111 }
112 if (copy_value) {
116 size_t len = strlen(oldval) + strlen(copy_value) + 1;
118 if (!newval)
119 goto err_out;
125 }
127 } else {
129 }
133 }
134
135 return 0;
136
137 err_out:
138 if (m && !m->
count) {
141 }
145 }
146
149 {
150 char valuestr[22];
154 }
155
157 const char *key_val_sep, const char *pairs_sep,
159 {
163
164 if (
key && *
key && strspn(*buf, key_val_sep)) {
165 (*buf)++;
167 }
168
171 else
173
176
178 }
179
181 const char *key_val_sep, const char *pairs_sep,
183 {
185
187 return 0;
188
189 /* ignore STRDUP flags */
191
195
198 }
199
200 return 0;
201 }
202
204 {
206
207 if (m) {
211 }
213 }
215 }
216
218 {
220
225 }
226
227 return 0;
228 }
229
231 const char key_val_sep, const char pairs_sep)
232 {
234 AVBPrint bprint;
235 int cnt = 0;
236 char special_chars[] = {pairs_sep, key_val_sep, '0円'};
237
238 if (!
buffer || pairs_sep ==
'0円' || key_val_sep ==
'0円' || pairs_sep == key_val_sep ||
239 pairs_sep == '\\' || key_val_sep == '\\')
241
245 }
246
249 if (cnt++)
254 }
256 }
257
259 {
260 time_t seconds = timestamp / 1000000;
261 struct tm *ptm, tmbuf;
263 if (ptm) {
264 char buf[32];
265 if (!strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", ptm))
267 av_strlcatf(buf,
sizeof(buf),
".%06dZ", (
int)(timestamp % 1000000));
269 } else {
271 }
272 }
#define AV_BPRINT_SIZE_UNLIMITED
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)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
AVDictionaryEntry * elems
#define AV_DICT_APPEND
If the entry already exists, append to it.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static double val(void *priv, double ch)
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define AVERROR_EXTERNAL
Generic error in an external library.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int parse_key_value_pair(AVDictionary **pm, const char **buf, const char *key_val_sep, const char *pairs_sep, int flags)
#define i(width, name, range_min, range_max)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
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.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
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
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
char * av_strdup(const char *s)
Duplicate a string.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_get_string(const AVDictionary *m, char **buffer, const char key_val_sep, const char pairs_sep)
Get dictionary entries as a string.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
@ AV_ESCAPE_MODE_BACKSLASH
Use backslash escaping.
#define flags(name, subs,...)
int avpriv_dict_set_timestamp(AVDictionary **dict, const char *key, int64_t timestamp)
Set a dictionary value to an ISO-8601 compliant timestamp string.
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
Generated on Wed Aug 24 2022 21:42:22 for FFmpeg by
doxygen
1.8.17