MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / av_opt_get_array

Function av_opt_get_array

libavutil/opt.c:2199–2285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2197}
2198
2199int av_opt_get_array(void *obj, const char *name, int search_flags,
2200 unsigned int start_elem, unsigned int nb_elems,
2201 enum AVOptionType out_type, void *out_val)
2202{
2203 const size_t elem_size_out = opt_type_desc[TYPE_BASE(out_type)].size;
2204
2205 const AVOption *o;
2206 void *target_obj;
2207
2208 const void *parray;
2209 unsigned array_size;
2210
2211 int ret;
2212
2213 o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
2214 if (!o || !target_obj)
2215 return AVERROR_OPTION_NOT_FOUND;
2216 if (!(o->type & AV_OPT_TYPE_FLAG_ARRAY) ||
2217 (out_type & AV_OPT_TYPE_FLAG_ARRAY))
2218 return AVERROR(EINVAL);
2219
2220 parray = (uint8_t *)target_obj + o->offset;
2221 array_size = *opt_array_pcount(parray);
2222
2223 if (start_elem >= array_size ||
2224 array_size - start_elem < nb_elems)
2225 return AVERROR(EINVAL);
2226
2227 for (unsigned i = 0; i < nb_elems; i++) {
2228 const void *src = opt_array_pelem(o, *(void**)parray, start_elem + i);
2229 void *dst = (uint8_t*)out_val + i * elem_size_out;
2230
2231 if (out_type == TYPE_BASE(o->type)) {
2232 ret = opt_copy_elem(obj, out_type, dst, src);
2233 if (ret < 0)
2234 goto fail;
2235 } else if (out_type == AV_OPT_TYPE_STRING) {
2236 uint8_t buf[128], *out = buf;
2237
2238 ret = opt_get_elem(o, &out, sizeof(buf), src, search_flags);
2239 if (ret < 0)
2240 goto fail;
2241
2242 if (out == buf) {
2243 out = av_strdup(buf);
2244 if (!out) {
2245 ret = AVERROR(ENOMEM);
2246 goto fail;
2247 }
2248 }
2249
2250 *(uint8_t**)dst = out;
2251 } else if (out_type == AV_OPT_TYPE_INT64 ||
2252 out_type == AV_OPT_TYPE_DOUBLE ||
2253 out_type == AV_OPT_TYPE_RATIONAL) {
2254 double num = 1.0;
2255 int den = 1;
2256 int64_t intnum = 1;

Callers 2

mainFunction · 0.85
multiview_setupFunction · 0.85

Calls 9

av_opt_find2Function · 0.85
opt_array_pcountFunction · 0.85
opt_array_pelemFunction · 0.85
opt_copy_elemFunction · 0.85
opt_get_elemFunction · 0.85
av_strdupFunction · 0.85
read_numberFunction · 0.85
double_to_rationalFunction · 0.85
opt_free_elemFunction · 0.85

Tested by 1

mainFunction · 0.68