avcodec/internal: Move ff_samples_to_time_base() to encode.h

It is only used by encoders; in fact, AVCodecContext.time_base
is only used by encoders, so it is only useful for encoders.

Also constify the AVCodecContext parameter in it.

Also fixup the other headers a bit while removing now unnecessary
internal.h inclusions.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-08-24 23:04:14 +02:00
parent b9eaf77ed1
commit 59eadb5060
11 changed files with 13 additions and 22 deletions

View file

@ -78,4 +78,16 @@ int ff_encode_preinit(AVCodecContext *avctx);
int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet);
/**
* Rescale from sample rate to AVCodecContext.time_base.
*/
static av_always_inline int64_t ff_samples_to_time_base(const 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 */