This allows simplifying a few expressions.
Signed-off-by: Mans Rullgard <mans@mansr.com>
... | ... |
@@ -797,8 +797,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, |
797 | 797 |
AVFilterContext *first_filter = in->filter_ctx; |
798 | 798 |
AVFilter *filter = avfilter_get_by_name("buffer"); |
799 | 799 |
InputStream *ist = ifilter->ist; |
800 |
- AVRational tb = ist->framerate.num ? (AVRational){ist->framerate.den, |
|
801 |
- ist->framerate.num} : |
|
800 |
+ AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) : |
|
802 | 801 |
ist->st->time_base; |
803 | 802 |
AVRational sar; |
804 | 803 |
char args[255], name[255]; |
... | ... |
@@ -2197,8 +2196,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt) |
2197 | 2197 |
if (avpkt.duration) |
2198 | 2198 |
ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q); |
2199 | 2199 |
else if (ist->st->avg_frame_rate.num) |
2200 |
- ist->next_dts += av_rescale_q(1, (AVRational){ist->st->avg_frame_rate.den, |
|
2201 |
- ist->st->avg_frame_rate.num}, |
|
2200 |
+ ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate), |
|
2202 | 2201 |
AV_TIME_BASE_Q); |
2203 | 2202 |
else if (ist->st->codec->time_base.num != 0) { |
2204 | 2203 |
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 : |
... | ... |
@@ -115,6 +115,17 @@ AVRational av_add_q(AVRational b, AVRational c) av_const; |
115 | 115 |
AVRational av_sub_q(AVRational b, AVRational c) av_const; |
116 | 116 |
|
117 | 117 |
/** |
118 |
+ * Invert a rational. |
|
119 |
+ * @param q value |
|
120 |
+ * @return 1 / q |
|
121 |
+ */ |
|
122 |
+static av_always_inline AVRational av_inv_q(AVRational q) |
|
123 |
+{ |
|
124 |
+ AVRational r = { q.den, q.num }; |
|
125 |
+ return r; |
|
126 |
+} |
|
127 |
+ |
|
128 |
+/** |
|
118 | 129 |
* Convert a double precision floating point number to a rational. |
119 | 130 |
* inf is expressed as {1,0} or {-1,0} depending on the sign. |
120 | 131 |
* |