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

Function parse_frames

libavformat/segment.c:526–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524}
525
526static int parse_frames(void *log_ctx, int **frames, int *nb_frames,
527 const char *frames_str)
528{
529 const char *p;
530 int i;
531
532 *nb_frames = 1;
533 for (p = frames_str; *p; p++)
534 if (*p == ',')
535 (*nb_frames)++;
536
537 *frames = av_malloc_array(*nb_frames, sizeof(**frames));
538 if (!*frames) {
539 av_log(log_ctx, AV_LOG_ERROR, "Could not allocate forced frames array\n");
540 return AVERROR(ENOMEM);
541 }
542
543 p = frames_str;
544 for (i = 0; i < *nb_frames; i++) {
545 long int f;
546 char *tailptr;
547
548 if (*p == '\0' || *p == ',') {
549 av_log(log_ctx, AV_LOG_ERROR, "Empty frame specification in frame list %s\n",
550 frames_str);
551 return AVERROR(EINVAL);
552 }
553 f = strtol(p, &tailptr, 10);
554 if (*tailptr != '\0' && *tailptr != ',' || f <= 0 || f >= INT_MAX) {
555 av_log(log_ctx, AV_LOG_ERROR,
556 "Invalid argument '%s', must be a positive integer < INT_MAX\n",
557 p);
558 return AVERROR(EINVAL);
559 }
560 if (*tailptr == ',')
561 tailptr++;
562 p = tailptr;
563 (*frames)[i] = f;
564
565 /* check on monotonicity */
566 if (i && (*frames)[i-1] > (*frames)[i]) {
567 av_log(log_ctx, AV_LOG_ERROR,
568 "Specified frame %d is smaller than the last frame %d\n",
569 (*frames)[i], (*frames)[i-1]);
570 return AVERROR(EINVAL);
571 }
572 }
573
574 return 0;
575}
576
577static int open_null_ctx(AVIOContext **ctx)
578{

Callers 1

seg_initFunction · 0.85

Calls 2

av_malloc_arrayFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected