summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-07-12 14:51:46 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-23 16:50:33 +0200
commit4690b0782cf57aaa76385f162e9939001d6fcdf6 (patch)
tree4b8bc0e6be1eae35f1b6e1cbdf87358fd986db5c
parent79c3d8332ce4cf0ab194b212676a8c5fee7436fc (diff)
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.
-rw-r--r--libavcodec/audio_frame_queue.c1
-rw-r--r--libavcodec/encode.h15
-rw-r--r--libavcodec/internal.h12
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
@@ -182,18 +182,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
*/