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.
Unified · Split
| @@ -30,7 +30,6 @@ · 29 unmodified lines | |||
| 30 | 30 | ||
| 31 | #include "libavutil/attributes.h" | 31 | #include "libavutil/attributes.h" |
| 32 | #include "libavutil/avassert.h" | 32 | #include "libavutil/avassert.h" |
| 33 | #include "libavutil/avstring.h" | ||
| 34 | #include "libavutil/channel_layout.h" | 33 | #include "libavutil/channel_layout.h" |
| 35 | #include "libavutil/crc.h" | 34 | #include "libavutil/crc.h" |
| 36 | #include "libavutil/internal.h" | 35 | #include "libavutil/internal.h" |
| @@ -41,7 +40,6 @@ · 4 unmodified lines | |||
| 41 | #include "codec_internal.h" | 40 | #include "codec_internal.h" |
| 42 | #include "config_components.h" | 41 | #include "config_components.h" |
| 43 | #include "encode.h" | 42 | #include "encode.h" |
| 44 | #include "internal.h" | ||
| 45 | #include "me_cmp.h" | 43 | #include "me_cmp.h" |
| 46 | #include "put_bits.h" | 44 | #include "put_bits.h" |
| 47 | #include "audiodsp.h" | 45 | #include "audiodsp.h" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include "libavutil/attributes.h" | 22 | #include "libavutil/attributes.h" |
| 23 | #include "libavutil/common.h" | 23 | #include "libavutil/common.h" |
| 24 | #include "audio_frame_queue.h" | 24 | #include "audio_frame_queue.h" |
| 25 | #include "internal.h" | 25 | #include "encode.h" |
| 26 | #include "libavutil/avassert.h" | 26 | #include "libavutil/avassert.h" |
| 27 | 27 | ||
| 28 | av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq) | 28 | av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq) |
| @@ -78,4 +78,16 @@ int ff_encode_preinit(AVCodecContext *avctx); · 77 unmodified lines | |||
| 78 | int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, | 78 | int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt, |
| 79 | const AVFrame *frame, int *got_packet); | 79 | const AVFrame *frame, int *got_packet); |
| 80 | 80 | ||
| 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 | |||
| 81 | #endif /* AVCODEC_ENCODE_H */ | 93 | #endif /* AVCODEC_ENCODE_H */ |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | #include "encode.h" | 32 | #include "encode.h" |
| 33 | #include "put_bits.h" | 33 | #include "put_bits.h" |
| 34 | #include "put_golomb.h" | 34 | #include "put_golomb.h" |
| 35 | #include "internal.h" | ||
| 36 | #include "lpc.h" | 35 | #include "lpc.h" |
| 37 | #include "flac.h" | 36 | #include "flac.h" |
| 38 | #include "flacdata.h" | 37 | #include "flacdata.h" |
| @@ -32,7 +32,6 @@ · 31 unmodified lines | |||
| 32 | #include "avcodec.h" | 32 | #include "avcodec.h" |
| 33 | #include "codec_internal.h" | 33 | #include "codec_internal.h" |
| 34 | #include "encode.h" | 34 | #include "encode.h" |
| 35 | #include "internal.h" | ||
| 36 | #include "g722.h" | 35 | #include "g722.h" |
| 37 | #include "libavutil/common.h" | 36 | #include "libavutil/common.h" |
| 38 | 37 | ||
| @@ -181,18 +181,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]); · 180 unmodified lines | |||
| 181 | */ | 181 | */ |
| 182 | #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) | 182 | #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE) |
| 183 | 183 | ||
| 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 | |||
| 196 | /** | 184 | /** |
| 197 | * 2^(x) for integer x | 185 | * 2^(x) for integer x |
| 198 | * @return correctly rounded float | 186 | * @return correctly rounded float |
| @@ -33,7 +33,6 @@ · 32 unmodified lines | |||
| 33 | #include "avcodec.h" | 33 | #include "avcodec.h" |
| 34 | #include "codec_internal.h" | 34 | #include "codec_internal.h" |
| 35 | #include "encode.h" | 35 | #include "encode.h" |
| 36 | #include "internal.h" | ||
| 37 | #include "mpegaudio.h" | 36 | #include "mpegaudio.h" |
| 38 | 37 | ||
| 39 | typedef struct TWOLAMEContext { | 38 | typedef struct TWOLAMEContext { |
| @@ -29,7 +29,6 @@ · 28 unmodified lines | |||
| 29 | #include "avcodec.h" | 29 | #include "avcodec.h" |
| 30 | #include "codec_internal.h" | 30 | #include "codec_internal.h" |
| 31 | #include "encode.h" | 31 | #include "encode.h" |
| 32 | #include "internal.h" | ||
| 33 | 32 | ||
| 34 | #define MAX_PACKET_SIZE (1 + (477 + 7) / 8) | 33 | #define MAX_PACKET_SIZE (1 + (477 + 7) / 8) |
| 35 | 34 | ||
| @@ -28,7 +28,6 @@ · 27 unmodified lines | |||
| 28 | #include "audio_frame_queue.h" | 28 | #include "audio_frame_queue.h" |
| 29 | #include "codec_internal.h" | 29 | #include "codec_internal.h" |
| 30 | #include "encode.h" | 30 | #include "encode.h" |
| 31 | #include "internal.h" | ||
| 32 | #include "version.h" | 31 | #include "version.h" |
| 33 | #include "vorbis.h" | 32 | #include "vorbis.h" |
| 34 | #include "vorbis_parser.h" | 33 | #include "vorbis_parser.h" |
| @@ -28,7 +28,6 @@ · 27 unmodified lines | |||
| 28 | 28 | ||
| 29 | #include "avcodec.h" | 29 | #include "avcodec.h" |
| 30 | #include "encode.h" | 30 | #include "encode.h" |
| 31 | #include "internal.h" | ||
| 32 | #include "put_bits.h" | 31 | #include "put_bits.h" |
| 33 | 32 | ||
| 34 | #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ | 33 | #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ |
| @@ -27,7 +27,6 @@ · 26 unmodified lines | |||
| 27 | #include "avcodec.h" | 27 | #include "avcodec.h" |
| 28 | #include "codec_internal.h" | 28 | #include "codec_internal.h" |
| 29 | #include "encode.h" | 29 | #include "encode.h" |
| 30 | #include "internal.h" | ||
| 31 | #include "wma.h" | 30 | #include "wma.h" |
| 32 | #include "libavutil/avassert.h" | 31 | #include "libavutil/avassert.h" |
| 33 | 32 | ||