| 1213 | } |
| 1214 | |
| 1215 | int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) |
| 1216 | { |
| 1217 | void *dst, *target_obj; |
| 1218 | const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); |
| 1219 | uint8_t *out, buf[128]; |
| 1220 | int ret; |
| 1221 | |
| 1222 | if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST)) |
| 1223 | return AVERROR_OPTION_NOT_FOUND; |
| 1224 | |
| 1225 | if (o->flags & AV_OPT_FLAG_DEPRECATED) |
| 1226 | av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", name, o->help); |
| 1227 | |
| 1228 | dst = (uint8_t *)target_obj + o->offset; |
| 1229 | |
| 1230 | if (o->type & AV_OPT_TYPE_FLAG_ARRAY) { |
| 1231 | ret = opt_get_array(o, dst, out_val); |
| 1232 | if (ret < 0) |
| 1233 | return ret; |
| 1234 | if (!*out_val && !(search_flags & AV_OPT_ALLOW_NULL)) { |
| 1235 | *out_val = av_strdup(""); |
| 1236 | if (!*out_val) |
| 1237 | return AVERROR(ENOMEM); |
| 1238 | } |
| 1239 | return 0; |
| 1240 | } |
| 1241 | |
| 1242 | buf[0] = 0; |
| 1243 | out = buf; |
| 1244 | ret = opt_get_elem(o, &out, sizeof(buf), dst, search_flags); |
| 1245 | if (ret < 0) |
| 1246 | return ret; |
| 1247 | if (out != buf) { |
| 1248 | *out_val = out; |
| 1249 | return 0; |
| 1250 | } |
| 1251 | |
| 1252 | if (ret >= sizeof(buf)) |
| 1253 | return AVERROR(EINVAL); |
| 1254 | *out_val = av_strdup(out); |
| 1255 | return *out_val ? 0 : AVERROR(ENOMEM); |
| 1256 | } |
| 1257 | |
| 1258 | static int get_number(void *obj, const char *name, double *num, int *den, int64_t *intnum, |
| 1259 | int search_flags) |