History

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.

Andreas Rheinhardt committed 4 years ago

Commit 59eadb51 parent b9eaf7711 files · +13 −22Browse files

Unified · Split

11 files
  1. libavcodec/ac3enc.c +0 −2
  2. libavcodec/audio_frame_queue.c +1 −1
  3. libavcodec/encode.h +12 −0
  4. libavcodec/flacenc.c +0 −1
  5. libavcodec/g722enc.c +0 −1
  6. libavcodec/internal.h +0 −12
  7. libavcodec/libtwolame.c +0 −1
  8. libavcodec/libvo-amrwbenc.c +0 −1
  9. libavcodec/libvorbisenc.c +0 −1
  10. libavcodec/mpegaudioenc_template.c +0 −1
  11. libavcodec/wmaenc.c +0 −1
libavcodec/ac3enc.c+0−2
@@ -30,7 +30,6 @@ · 29 unmodified lines
3030
3131 #include "libavutil/attributes.h"
3232 #include "libavutil/avassert.h"
33−#include "libavutil/avstring.h"
3433 #include "libavutil/channel_layout.h"
3534 #include "libavutil/crc.h"
3635 #include "libavutil/internal.h"
@@ -41,7 +40,6 @@ · 4 unmodified lines
4140 #include "codec_internal.h"
4241 #include "config_components.h"
4342 #include "encode.h"
44−#include "internal.h"
4543 #include "me_cmp.h"
4644 #include "put_bits.h"
4745 #include "audiodsp.h"
libavcodec/audio_frame_queue.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 #include "libavutil/attributes.h"
2323 #include "libavutil/common.h"
2424 #include "audio_frame_queue.h"
25−#include "internal.h"
25+#include "encode.h"
2626 #include "libavutil/avassert.h"
2727
2828 av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
libavcodec/encode.h+12−0
@@ -78,4 +78,16 @@ int ff_encode_preinit(AVCodecContext *avctx); · 77 unmodified lines
7878 int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
7979 const AVFrame *frame, int *got_packet);
8080
81+/**
82+ * Rescale from sample rate to AVCodecContext.time_base.
83+ */
84+static av_always_inline int64_t ff_samples_to_time_base(const AVCodecContext *avctx,
85+ int64_t samples)
86+{
87+ if (samples == AV_NOPTS_VALUE)
88+ return AV_NOPTS_VALUE;
89+ return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate },
90+ avctx->time_base);
91+}
92+
8193 #endif /* AVCODEC_ENCODE_H */
libavcodec/flacenc.c+0−1
@@ -32,7 +32,6 @@ · 31 unmodified lines
3232 #include "encode.h"
3333 #include "put_bits.h"
3434 #include "put_golomb.h"
35−#include "internal.h"
3635 #include "lpc.h"
3736 #include "flac.h"
3837 #include "flacdata.h"
libavcodec/g722enc.c+0−1
@@ -32,7 +32,6 @@ · 31 unmodified lines
3232 #include "avcodec.h"
3333 #include "codec_internal.h"
3434 #include "encode.h"
35−#include "internal.h"
3635 #include "g722.h"
3736 #include "libavutil/common.h"
3837
libavcodec/internal.h+0−12
@@ -181,18 +181,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); · 180 unmodified lines
181181 */
182182 #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
183183
184−/**
185− * Rescale from sample rate to AVCodecContext.time_base.
186− */
187−static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx,
188− int64_t samples)
189−{
190− if(samples == AV_NOPTS_VALUE)
191− return AV_NOPTS_VALUE;
192− return av_rescale_q(samples, (AVRational){ 1, avctx->sample_rate },
193− avctx->time_base);
194−}
195−
196184 /**
197185 * 2^(x) for integer x
198186 * @return correctly rounded float
libavcodec/libtwolame.c+0−1
@@ -33,7 +33,6 @@ · 32 unmodified lines
3333 #include "avcodec.h"
3434 #include "codec_internal.h"
3535 #include "encode.h"
36−#include "internal.h"
3736 #include "mpegaudio.h"
3837
3938 typedef struct TWOLAMEContext {
libavcodec/libvo-amrwbenc.c+0−1
@@ -29,7 +29,6 @@ · 28 unmodified lines
2929 #include "avcodec.h"
3030 #include "codec_internal.h"
3131 #include "encode.h"
32−#include "internal.h"
3332
3433 #define MAX_PACKET_SIZE (1 + (477 + 7) / 8)
3534
libavcodec/libvorbisenc.c+0−1
@@ -28,7 +28,6 @@ · 27 unmodified lines
2828 #include "audio_frame_queue.h"
2929 #include "codec_internal.h"
3030 #include "encode.h"
31−#include "internal.h"
3231 #include "version.h"
3332 #include "vorbis.h"
3433 #include "vorbis_parser.h"
libavcodec/mpegaudioenc_template.c+0−1
@@ -28,7 +28,6 @@ · 27 unmodified lines
2828
2929 #include "avcodec.h"
3030 #include "encode.h"
31−#include "internal.h"
3231 #include "put_bits.h"
3332
3433 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
libavcodec/wmaenc.c+0−1
@@ -27,7 +27,6 @@ · 26 unmodified lines
2727 #include "avcodec.h"
2828 #include "codec_internal.h"
2929 #include "encode.h"
30−#include "internal.h"
3130 #include "wma.h"
3231 #include "libavutil/avassert.h"
3332

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t