From 91a28b0e8e4f09a8256727e8a514bf98da81e186 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Feb 2012 15:37:45 -0500 Subject: avcodec: add ff_samples_to_time_base() convenience function to internal.h --- libavcodec/internal.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'libavcodec/internal.h') diff --git a/libavcodec/internal.h b/libavcodec/internal.h index b435a359fb..bedb2ed85d 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -26,6 +26,7 @@ #include +#include "libavutil/mathematics.h" #include "libavutil/pixfmt.h" #include "avcodec.h" @@ -127,4 +128,14 @@ int avpriv_unlock_avformat(void); */ int ff_alloc_packet(AVPacket *avpkt, int size); +/** + * Rescale from sample rate to AVCodecContext.time_base. + */ +static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, + int64_t samples) +{ + return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate }, + avctx->time_base); +} + #endif /* AVCODEC_INTERNAL_H */ -- cgit v1.2.3