mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avformat/seek: add ff_rescale_interval() function
Refactors a function used by avformat/concat and avformat/imf. Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
This commit is contained in:
parent
22e1175e39
commit
b172c0f8c5
@ -1023,4 +1023,24 @@ void avpriv_register_devices(const AVOutputFormat * const o[], const AVInputForm
|
|||||||
*/
|
*/
|
||||||
int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size);
|
int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rescales a timestamp and the endpoints of an interval to which the temstamp
|
||||||
|
* belongs, from a timebase `tb_in` to a timebase `tb_out`.
|
||||||
|
*
|
||||||
|
* The upper (lower) bound of the output interval is rounded up (down) such that
|
||||||
|
* the output interval always falls within the intput interval. The timestamp is
|
||||||
|
* rounded to the nearest integer and halfway cases away from zero, and can
|
||||||
|
* therefore fall outside of the output interval.
|
||||||
|
*
|
||||||
|
* Useful to simplify the rescaling of the arguments of AVInputFormat::read_seek2()
|
||||||
|
*
|
||||||
|
* @param[in] tb_in Timebase of the input `min_ts`, `ts` and `max_ts`
|
||||||
|
* @param[in] tb_out Timebase of the ouput `min_ts`, `ts` and `max_ts`
|
||||||
|
* @param[in,out] min_ts Lower bound of the interval
|
||||||
|
* @param[in,out] ts Timestamp
|
||||||
|
* @param[in,out] max_ts Upper bound of the interval
|
||||||
|
*/
|
||||||
|
void ff_rescale_interval(AVRational tb_in, AVRational tb_out,
|
||||||
|
int64_t *min_ts, int64_t *ts, int64_t *max_ts);
|
||||||
|
|
||||||
#endif /* AVFORMAT_INTERNAL_H */
|
#endif /* AVFORMAT_INTERNAL_H */
|
||||||
|
@ -751,3 +751,13 @@ int avformat_flush(AVFormatContext *s)
|
|||||||
ff_read_frame_flush(s);
|
ff_read_frame_flush(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ff_rescale_interval(AVRational tb_in, AVRational tb_out,
|
||||||
|
int64_t *min_ts, int64_t *ts, int64_t *max_ts)
|
||||||
|
{
|
||||||
|
*ts = av_rescale_q (* ts, tb_in, tb_out);
|
||||||
|
*min_ts = av_rescale_q_rnd(*min_ts, tb_in, tb_out,
|
||||||
|
AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
|
||||||
|
*max_ts = av_rescale_q_rnd(*max_ts, tb_in, tb_out,
|
||||||
|
AV_ROUND_DOWN | AV_ROUND_PASS_MINMAX);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user