[FFmpeg-devel] Modified force_key_frames option to accept frame numbers

Michael Niedermayer michaelni at gmx.at
Fri Nov 14 04:40:23 CET 2014


On Sun, Nov 09, 2014 at 11:42:32PM +0000, Sylvester Zaluga wrote:
[...]

> @@ -2333,6 +2338,12 @@ static InputStream *get_input_stream(OutputStream *ost)
>      return NULL;
>  }
>  
> +static int compare_int(const void *a, const void *b)
> +{
> +    int va = *(int *)a, vb = *(int *)b;
> +    return va < vb ? -1 : va > vb ? +1 : 0;
> +}

if you use a int64 array then this is unneeded


> +
>  static int compare_int64(const void *a, const void *b)
>  {
>      int64_t va = *(int64_t *)a, vb = *(int64_t *)b;
> @@ -2402,6 +2413,53 @@ static void parse_forced_key_frames(char *kf, OutputStream *ost,
>      ost->forced_kf_pts   = pts;
>  }
>  
> +static void parse_forced_key_frames_n(char *kf, OutputStream *ost,
> +                                      AVCodecContext *avctx)
> +{
> +    char *p;
> +    int n = 1, i, size, index = 0;
> +    int kf_n, kf_n_prev, *pts;
> +
> +    for (p = kf; *p; p++)
> +        if (*p == ',')
> +            n++;
> +    size = n;
> +    pts = av_malloc_array(size, sizeof(*pts));
> +    if (!pts) {
> +        av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n");
> +        exit_program(1);
> +    }
> +
> +    p = kf;
> +    for (i = 0; i < n; i++) {
> +        char *next = strchr(p, ',');
> +
> +        if (next)
> +            *next++ = 0;
> +
> +        kf_n = parse_number_or_die("force_key_frames (numbers)", p, OPT_INT, 0, INT_MAX);
> +        av_assert1(index < size);
> +        pts[index++] = kf_n;
> +
> +        p = next;
> +    }
> +
> +    av_assert0(index == size);
> +    qsort(pts, size, sizeof(*pts), compare_int);
> +    
> +    kf_n_prev = -1;
> +    for (i = 0; i < n; i++) {
> +        if (pts[i] == kf_n_prev) {
> +            av_log(NULL, AV_LOG_FATAL, "Duplicated forced key frame number.\n");
> +            exit_program(1);
> +        }
> +        kf_n_prev = pts[i];
> +    }
> +        
> +    ost->forced_kf_n_count = size;
> +    ost->forced_kf_n_pts   = pts;
> +}

this is quite similar to parse_forced_key_frames()
cant the same fuction be used for both ?


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 3
"Rare item" - "Common item with rare defect or maybe just a lie"
"Professional" - "'Toy' made in china, not functional except as doorstop"
"Experts will know" - "The seller hopes you are not an expert"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141114/c34f5757/attachment.asc>


More information about the ffmpeg-devel mailing list