mirror of https://git.ffmpeg.org/ffmpeg.git
rational: add av_inv_q() returning the inverse of an AVRational
This allows simplifying a few expressions. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
parent
965efc1673
commit
82494835c4
6
avconv.c
6
avconv.c
|
@ -797,8 +797,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||||
AVFilterContext *first_filter = in->filter_ctx;
|
AVFilterContext *first_filter = in->filter_ctx;
|
||||||
AVFilter *filter = avfilter_get_by_name("buffer");
|
AVFilter *filter = avfilter_get_by_name("buffer");
|
||||||
InputStream *ist = ifilter->ist;
|
InputStream *ist = ifilter->ist;
|
||||||
AVRational tb = ist->framerate.num ? (AVRational){ist->framerate.den,
|
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||||
ist->framerate.num} :
|
|
||||||
ist->st->time_base;
|
ist->st->time_base;
|
||||||
AVRational sar;
|
AVRational sar;
|
||||||
char args[255], name[255];
|
char args[255], name[255];
|
||||||
|
@ -2197,8 +2196,7 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
|
||||||
if (avpkt.duration)
|
if (avpkt.duration)
|
||||||
ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
|
ist->next_dts += av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q);
|
||||||
else if (ist->st->avg_frame_rate.num)
|
else if (ist->st->avg_frame_rate.num)
|
||||||
ist->next_dts += av_rescale_q(1, (AVRational){ist->st->avg_frame_rate.den,
|
ist->next_dts += av_rescale_q(1, av_inv_q(ist->st->avg_frame_rate),
|
||||||
ist->st->avg_frame_rate.num},
|
|
||||||
AV_TIME_BASE_Q);
|
AV_TIME_BASE_Q);
|
||||||
else if (ist->st->codec->time_base.num != 0) {
|
else if (ist->st->codec->time_base.num != 0) {
|
||||||
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
|
int ticks = ist->st->parser ? ist->st->parser->repeat_pict + 1 :
|
||||||
|
|
|
@ -114,6 +114,17 @@ AVRational av_add_q(AVRational b, AVRational c) av_const;
|
||||||
*/
|
*/
|
||||||
AVRational av_sub_q(AVRational b, AVRational c) av_const;
|
AVRational av_sub_q(AVRational b, AVRational c) av_const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invert a rational.
|
||||||
|
* @param q value
|
||||||
|
* @return 1 / q
|
||||||
|
*/
|
||||||
|
static av_always_inline AVRational av_inv_q(AVRational q)
|
||||||
|
{
|
||||||
|
AVRational r = { q.den, q.num };
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a double precision floating point number to a rational.
|
* Convert a double precision floating point number to a rational.
|
||||||
* inf is expressed as {1,0} or {-1,0} depending on the sign.
|
* inf is expressed as {1,0} or {-1,0} depending on the sign.
|
||||||
|
|
Loading…
Reference in New Issue