[FFmpeg-devel] [PATCH 18/20] mpeg12: Move finding the best frame rate to common code

Michael Niedermayer michael at niedermayer.cc
Thu Sep 14 03:48:23 EEST 2017


On Wed, Sep 13, 2017 at 12:44:08AM +0100, Mark Thompson wrote:
> Previously in the mpeg2_metadata filter.  Also adds a test.
[...]
> +    for (c = 1; c <= max_code; c++) {
> +        for (n = 1; n <= (mpeg2 ? 4 : 1); n++) {
> +            for (d = 1; d <= (mpeg2 ? 32 : 1); d++) {
> +                AVRational test, error;
> +                int cmp;
> +
> +                test = av_mul_q(ff_mpeg12_frame_rate_tab[c],
> +                                (AVRational) { n, d });
> +
> +                cmp = av_cmp_q(test, frame_rate);
> +                if (cmp == 0) {
> +                    best_c = c;
> +                    best_n = n;
> +                    best_d = d;
> +                    goto found;
> +                }
> +
> +                if (cmp < 0)
> +                    error = av_div_q(frame_rate, test);
> +                else
> +                    error = av_div_q(test, frame_rate);
> +
> +                cmp = av_cmp_q(error, best_error);
> +                if (cmp < 0 || (cmp == 0 && n == 1 && d == 1)) {
> +                    best_c = c;
> +                    best_n = n;
> +                    best_d = d;
> +                    best_error = error;
> +                }
> +            }
> +        }
> +    }
[...]
> -        for (i = 1; i < FF_ARRAY_ELEMS(frame_rate_table); i++) {
> -            AVRational fr, error;
> -            int n, d, cmp;
> -            for (n = 1; n <= 4; n++) {
> -                for (d = 1; d <= 32; d++) {
> -                    fr = av_mul_q(frame_rate_table[i],
> -                                  (AVRational) { n, d });
> -                    cmp = av_cmp_q(fr, ctx->frame_rate);
> -                    if (cmp == 0) {
> -                        code  = i;
> -                        ext_n = n;
> -                        ext_d = d;
> -                        goto found_frame_rate;
> -                    }
> -                    if (cmp < 0)
> -                        error = av_div_q(ctx->frame_rate, fr);
> -                    else
> -                        error = av_div_q(fr, ctx->frame_rate);
> -                    cmp = av_cmp_q(error, best_error);
> -                    if (cmp < 0 || (cmp == 0 && n == 1 && d == 1)) {
> -                        code  = i;
> -                        ext_n = n;
> -                        ext_d = d;
> -                        best_error = error;
> -                    }
> -                }
> -            }
> -        }

This doesnt just move the code, it also changes it
(this makes it harder to determine if the chnages are just cosmetic or
 not)

[...]

--
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170914/86392dcb/attachment.sig>


More information about the ffmpeg-devel mailing list