1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include <stddef.h>
20
24
26 {
28
29 #define TEST_MATCH(frame_rate, code, ext_n, ext_d) do { \
30 AVRational fr = frame_rate; \
31 int c, n, d; \
32 ff_mpeg12_find_best_frame_rate(fr, &c, &n, &d, 0); \
33 if (c != code || n != ext_n || d != ext_d) { \
34 av_log(NULL, AV_LOG_ERROR, "Failed to match %d/%d: " \
35 "code = %d, ext_n = %d, ext_d = %d.\n", \
36 fr.num, fr.den, c, n, d); \
37 return 1; \
38 } \
39 } while (0)
40 #define TEST_EXACT(frn, frd) do { \
41 AVRational fr = (AVRational) { frn, frd }; \
42 int c, n, d; \
43 ff_mpeg12_find_best_frame_rate(fr, &c, &n, &d, 0); \
44 if (av_cmp_q(fr, av_mul_q(ff_mpeg12_frame_rate_tab[c], \
45 (AVRational) { n + 1, d + 1 })) != 0) { \
46 av_log(NULL, AV_LOG_ERROR, "Failed to find exact %d/%d: " \
47 "code = %d, ext_n = %d, ext_d = %d.\n", \
48 fr.num, fr.den, c, n, d); \
49 return 1; \
50 } \
51 } while (0)
52
53 // Framerates in the table must be chosen exactly.
54 for (
i = 1;
i <= 8;
i++)
56
57 // As should the same ones with small perturbations.
58 // (1/1000 used here to be smaller than half the difference
59 // between 24 and 24000/1001.)
60 for (
i = 1;
i <= 8;
i++) {
65 }
66
67 // Exactly constructable framerates should be exact. Note that some
68 // values can be made in multiple ways (e.g. 12 = 24 / 2 == 60 / 5),
69 // and there is no reason to favour any particular choice.
79
80 // Values higher than 240 (the highest representable, as 60 * 4 / 1)
81 // should be mapped to 240.
82 for (
i = 240;
i < 1000;
i += 10)
84 // Values lower than 24000/32032 (the lowest representable, as
85 // 24000/1001 * 1 / 32) should be mapped to 24000/32032.
86 for (
i = 74;
i > 0;
i--)
88
89 return 0;
90 }