summaryrefslogtreecommitdiff
path: root/libavcodec/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/internal.h')
-rw-r--r--libavcodec/internal.h11
1 files changed, 11 insertions, 0 deletions
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 <stdint.h>
+#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 */