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

Function set_string_binary

libavutil/opt.c:368–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366}
367
368static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst)
369{
370 int *lendst = (int *)(dst + 1);
371 uint8_t *bin, *ptr;
372 int len;
373
374 av_freep(dst);
375 *lendst = 0;
376
377 if (!val || !(len = strlen(val)))
378 return 0;
379
380 if (len & 1)
381 return AVERROR(EINVAL);
382 len /= 2;
383
384 ptr = bin = av_malloc(len);
385 if (!ptr)
386 return AVERROR(ENOMEM);
387 while (*val) {
388 int a = hexchar2int(*val++);
389 int b = hexchar2int(*val++);
390 if (a < 0 || b < 0) {
391 av_free(bin);
392 return AVERROR(EINVAL);
393 }
394 *ptr++ = (a << 4) | b;
395 }
396 *dst = bin;
397 *lendst = len;
398
399 return 0;
400}
401
402static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst)
403{

Callers 3

opt_set_elemFunction · 0.85
av_opt_set_defaults2Function · 0.85
av_opt_is_set_to_defaultFunction · 0.85

Calls 4

av_freepFunction · 0.85
hexchar2intFunction · 0.85
av_mallocFunction · 0.70
av_freeFunction · 0.70

Tested by

no test coverage detected