Workarounds for rounding differences between platforms should not be
needed any more.
Signed-off-by: Paul B Mahol <onemda@gmail.com>
... | ... |
@@ -949,11 +949,11 @@ Trim the input so that the output contains one continuous subpart of the input. |
949 | 949 |
This filter accepts the following options: |
950 | 950 |
@table @option |
951 | 951 |
@item start |
952 |
-Timestamp (in seconds) of the start of the kept section. I.e. the audio sample |
|
952 |
+Specify time of the start of the kept section, i.e. the audio sample |
|
953 | 953 |
with the timestamp @var{start} will be the first sample in the output. |
954 | 954 |
|
955 | 955 |
@item end |
956 |
-Timestamp (in seconds) of the first audio sample that will be dropped. I.e. the |
|
956 |
+Specify time of the first audio sample that will be dropped, i.e. the |
|
957 | 957 |
audio sample immediately preceding the one with the timestamp @var{end} will be |
958 | 958 |
the last sample in the output. |
959 | 959 |
|
... | ... |
@@ -966,7 +966,7 @@ Same as @var{end}, except this option sets the end timestamp in samples instead |
966 | 966 |
of seconds. |
967 | 967 |
|
968 | 968 |
@item duration |
969 |
-Maximum duration of the output in seconds. |
|
969 |
+Specify maximum duration of the output. |
|
970 | 970 |
|
971 | 971 |
@item start_sample |
972 | 972 |
Number of the first sample that should be passed to output. |
... | ... |
@@ -975,6 +975,10 @@ Number of the first sample that should be passed to output. |
975 | 975 |
Number of the first sample that should be dropped. |
976 | 976 |
@end table |
977 | 977 |
|
978 |
+@option{start}, @option{end}, @option{duration} are expressed as time |
|
979 |
+duration specifications, check the "Time duration" section in the |
|
980 |
+ffmpeg-utils manual. |
|
981 |
+ |
|
978 | 982 |
Note that the first two sets of the start/end options and the @option{duration} |
979 | 983 |
option look at the frame timestamp, while the _sample options simply count the |
980 | 984 |
samples that pass through the filter. So start/end_pts and start/end_sample will |
... | ... |
@@ -7066,11 +7070,11 @@ Trim the input so that the output contains one continuous subpart of the input. |
7066 | 7066 |
This filter accepts the following options: |
7067 | 7067 |
@table @option |
7068 | 7068 |
@item start |
7069 |
-Timestamp (in seconds) of the start of the kept section. I.e. the frame with the |
|
7069 |
+Specify time of the start of the kept section, i.e. the frame with the |
|
7070 | 7070 |
timestamp @var{start} will be the first frame in the output. |
7071 | 7071 |
|
7072 | 7072 |
@item end |
7073 |
-Timestamp (in seconds) of the first frame that will be dropped. I.e. the frame |
|
7073 |
+Specify time of the first frame that will be dropped, i.e. the frame |
|
7074 | 7074 |
immediately preceding the one with the timestamp @var{end} will be the last |
7075 | 7075 |
frame in the output. |
7076 | 7076 |
|
... | ... |
@@ -7083,7 +7087,7 @@ Same as @var{end}, except this option sets the end timestamp in timebase units |
7083 | 7083 |
instead of seconds. |
7084 | 7084 |
|
7085 | 7085 |
@item duration |
7086 |
-Maximum duration of the output in seconds. |
|
7086 |
+Specify maximum duration of the output. |
|
7087 | 7087 |
|
7088 | 7088 |
@item start_frame |
7089 | 7089 |
Number of the first frame that should be passed to output. |
... | ... |
@@ -7092,6 +7096,10 @@ Number of the first frame that should be passed to output. |
7092 | 7092 |
Number of the first frame that should be dropped. |
7093 | 7093 |
@end table |
7094 | 7094 |
|
7095 |
+@option{start}, @option{end}, @option{duration} are expressed as time |
|
7096 |
+duration specifications, check the "Time duration" section in the |
|
7097 |
+ffmpeg-utils manual. |
|
7098 |
+ |
|
7095 | 7099 |
Note that the first two sets of the start/end options and the @option{duration} |
7096 | 7100 |
option look at the frame timestamp, while the _frame variants simply count the |
7097 | 7101 |
frames that pass through the filter. Also note that this filter does not modify |
... | ... |
@@ -16,9 +16,6 @@ |
16 | 16 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 |
*/ |
18 | 18 |
|
19 |
-#include <float.h> |
|
20 |
-#include <math.h> |
|
21 |
- |
|
22 | 19 |
#include "config.h" |
23 | 20 |
|
24 | 21 |
#include "libavutil/avassert.h" |
... | ... |
@@ -39,8 +36,8 @@ typedef struct TrimContext { |
39 | 39 |
/* |
40 | 40 |
* AVOptions |
41 | 41 |
*/ |
42 |
- double duration; |
|
43 |
- double start_time, end_time; |
|
42 |
+ int64_t duration; |
|
43 |
+ int64_t start_time, end_time; |
|
44 | 44 |
int64_t start_frame, end_frame; |
45 | 45 |
/* |
46 | 46 |
* in the link timebase for video, |
... | ... |
@@ -87,18 +84,18 @@ static int config_input(AVFilterLink *inlink) |
87 | 87 |
AVRational tb = (inlink->type == AVMEDIA_TYPE_VIDEO) ? |
88 | 88 |
inlink->time_base : (AVRational){ 1, inlink->sample_rate }; |
89 | 89 |
|
90 |
- if (s->start_time != DBL_MAX) { |
|
91 |
- int64_t start_pts = lrint(s->start_time / av_q2d(tb)); |
|
90 |
+ if (s->start_time != INT64_MAX) { |
|
91 |
+ int64_t start_pts = av_rescale_q(s->start_time, AV_TIME_BASE_Q, tb); |
|
92 | 92 |
if (s->start_pts == AV_NOPTS_VALUE || start_pts < s->start_pts) |
93 | 93 |
s->start_pts = start_pts; |
94 | 94 |
} |
95 |
- if (s->end_time != DBL_MAX) { |
|
96 |
- int64_t end_pts = lrint(s->end_time / av_q2d(tb)); |
|
95 |
+ if (s->end_time != INT64_MAX) { |
|
96 |
+ int64_t end_pts = av_rescale_q(s->end_time, AV_TIME_BASE_Q, tb); |
|
97 | 97 |
if (s->end_pts == AV_NOPTS_VALUE || end_pts > s->end_pts) |
98 | 98 |
s->end_pts = end_pts; |
99 | 99 |
} |
100 | 100 |
if (s->duration) |
101 |
- s->duration_tb = lrint(s->duration / av_q2d(tb)); |
|
101 |
+ s->duration_tb = av_rescale_q(s->duration, AV_TIME_BASE_Q, tb); |
|
102 | 102 |
|
103 | 103 |
return 0; |
104 | 104 |
} |
... | ... |
@@ -111,15 +108,15 @@ static int config_output(AVFilterLink *outlink) |
111 | 111 |
|
112 | 112 |
#define OFFSET(x) offsetof(TrimContext, x) |
113 | 113 |
#define COMMON_OPTS \ |
114 |
- { "start", "Timestamp in seconds of the first frame that " \ |
|
115 |
- "should be passed", OFFSET(start_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX }, -DBL_MAX, DBL_MAX, FLAGS }, \ |
|
116 |
- { "end", "Timestamp in seconds of the first frame that " \ |
|
117 |
- "should be dropped again", OFFSET(end_time), AV_OPT_TYPE_DOUBLE, { .dbl = DBL_MAX }, -DBL_MAX, DBL_MAX, FLAGS }, \ |
|
114 |
+ { "start", "Timestamp of the first frame that " \ |
|
115 |
+ "should be passed", OFFSET(start_time), AV_OPT_TYPE_DURATION, { .i64 = INT64_MAX }, INT64_MIN, INT64_MAX, FLAGS }, \ |
|
116 |
+ { "end", "Timestamp of the first frame that " \ |
|
117 |
+ "should be dropped again", OFFSET(end_time), AV_OPT_TYPE_DURATION, { .i64 = INT64_MAX }, INT64_MIN, INT64_MAX, FLAGS }, \ |
|
118 | 118 |
{ "start_pts", "Timestamp of the first frame that should be " \ |
119 | 119 |
" passed", OFFSET(start_pts), AV_OPT_TYPE_INT64, { .i64 = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, FLAGS }, \ |
120 | 120 |
{ "end_pts", "Timestamp of the first frame that should be " \ |
121 | 121 |
"dropped again", OFFSET(end_pts), AV_OPT_TYPE_INT64, { .i64 = AV_NOPTS_VALUE }, INT64_MIN, INT64_MAX, FLAGS }, \ |
122 |
- { "duration", "Maximum duration of the output in seconds", OFFSET(duration), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0, DBL_MAX, FLAGS }, |
|
122 |
+ { "duration", "Maximum duration of the output", OFFSET(duration), AV_OPT_TYPE_DURATION, { .i64 = 0 }, 0, INT64_MAX, FLAGS }, |
|
123 | 123 |
|
124 | 124 |
|
125 | 125 |
#if CONFIG_TRIM_FILTER |
... | ... |
@@ -31,7 +31,7 @@ |
31 | 31 |
|
32 | 32 |
#define LIBAVFILTER_VERSION_MAJOR 3 |
33 | 33 |
#define LIBAVFILTER_VERSION_MINOR 80 |
34 |
-#define LIBAVFILTER_VERSION_MICRO 100 |
|
34 |
+#define LIBAVFILTER_VERSION_MICRO 101 |
|
35 | 35 |
|
36 | 36 |
#define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ |
37 | 37 |
LIBAVFILTER_VERSION_MINOR, \ |