| 366 | } |
| 367 | |
| 368 | static 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 | |
| 402 | static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst) |
| 403 | { |
no test coverage detected