diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2012-02-07 15:37:45 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-02-20 15:20:17 -0500 |
commit | 91a28b0e8e4f09a8256727e8a514bf98da81e186 (patch) | |
tree | f079d9cee0c0b4f51e5f5909d4cd98176a5dcf64 /libavcodec/internal.h | |
parent | 41ac9bb253c371e95abc854786334c857bbe4065 (diff) | |
download | ffmpeg-91a28b0e8e4f09a8256727e8a514bf98da81e186.tar.gz |
avcodec: add ff_samples_to_time_base() convenience function to internal.h
Diffstat (limited to 'libavcodec/internal.h')
-rw-r--r-- | libavcodec/internal.h | 11 |
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 */ |