From 4690b0782cf57aaa76385f162e9939001d6fcdf6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Tue, 12 Jul 2022 14:51:46 +0200 Subject: lavc: move ff_samples_to_time_base() to encode.h This function should only be used by encoders, since AVCodecContext.time_base is not used by audio decoders. --- libavcodec/audio_frame_queue.c | 1 + libavcodec/encode.h | 15 +++++++++++++++ libavcodec/internal.h | 12 ------------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/libavcodec/audio_frame_queue.c b/libavcodec/audio_frame_queue.c index f2ccd69281..d64423e69d 100644 --- a/libavcodec/audio_frame_queue.c +++ b/libavcodec/audio_frame_queue.c @@ -22,6 +22,7 @@ #include "libavutil/attributes.h" #include "libavutil/common.h" #include "audio_frame_queue.h" +#include "encode.h" #include "internal.h" #include "libavutil/avassert.h" diff --git a/libavcodec/encode.h b/libavcodec/encode.h index bc77918d8f..d660a81d87 100644 --- a/libavcodec/encode.h +++ b/libavcodec/encode.h @@ -21,7 +21,10 @@ #ifndef AVCODEC_ENCODE_H #define AVCODEC_ENCODE_H +#include "libavutil/attributes.h" +#include "libavutil/avutil.h" #include "libavutil/frame.h" +#include "libavutil/mathematics.h" #include "avcodec.h" #include "packet.h" @@ -75,4 +78,16 @@ int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size); */ int ff_encode_preinit(AVCodecContext *avctx); +/** + * Rescale from sample rate to AVCodecContext.time_base. + */ +static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, + int64_t samples) +{ + if(samples == AV_NOPTS_VALUE) + return AV_NOPTS_VALUE; + return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate }, + avctx->time_base); +} + #endif /* AVCODEC_ENCODE_H */ diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 52e7f111c1..fae7e38ee1 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -181,18 +181,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); */ #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_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) -{ - if(samples == AV_NOPTS_VALUE) - return AV_NOPTS_VALUE; - return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate }, - avctx->time_base); -} - /** * 2^(x) for integer x * @return correctly rounded float -- cgit v1.2.3