mirror of https://git.ffmpeg.org/ffmpeg.git
swr: make audio convert code explicitely private.
Only what's declared in libswresample/swresample.h is public.
This commit is contained in:
parent
3a5fc38574
commit
fc6351d019
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
typedef void (conv_func_type)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end);
|
typedef void (conv_func_type)(uint8_t *po, const uint8_t *pi, int is, int os, uint8_t *end);
|
||||||
|
|
||||||
struct AVAudioConvert {
|
struct AudioConvert {
|
||||||
int channels;
|
int channels;
|
||||||
conv_func_type *conv_f;
|
conv_func_type *conv_f;
|
||||||
const int *ch_map;
|
const int *ch_map;
|
||||||
|
@ -108,17 +108,17 @@ conv_func_type *fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB*AV_SAMPLE_FMT_NB] =
|
||||||
FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL),
|
FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL),
|
||||||
};
|
};
|
||||||
|
|
||||||
AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
|
AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
|
||||||
enum AVSampleFormat in_fmt,
|
enum AVSampleFormat in_fmt,
|
||||||
int channels, const int *ch_map,
|
int channels, const int *ch_map,
|
||||||
int flags)
|
int flags)
|
||||||
{
|
{
|
||||||
AVAudioConvert *ctx;
|
AudioConvert *ctx;
|
||||||
conv_func_type *f = fmt_pair_to_conv_functions[out_fmt + AV_SAMPLE_FMT_NB*in_fmt];
|
conv_func_type *f = fmt_pair_to_conv_functions[out_fmt + AV_SAMPLE_FMT_NB*in_fmt];
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
return NULL;
|
return NULL;
|
||||||
ctx = av_malloc(sizeof(AVAudioConvert));
|
ctx = av_malloc(sizeof(*ctx));
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
ctx->channels = channels;
|
ctx->channels = channels;
|
||||||
|
@ -127,12 +127,12 @@ AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swr_audio_convert_free(AVAudioConvert **ctx)
|
void swri_audio_convert_free(AudioConvert **ctx)
|
||||||
{
|
{
|
||||||
av_freep(ctx);
|
av_freep(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
int swr_audio_convert(AVAudioConvert *ctx, AudioData *out, AudioData*in, int len)
|
int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len)
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
const uint8_t null_input[8] = {0};
|
const uint8_t null_input[8] = {0};
|
||||||
|
|
|
@ -33,8 +33,8 @@
|
||||||
#include "libavutil/cpu.h"
|
#include "libavutil/cpu.h"
|
||||||
#include "libavutil/audioconvert.h"
|
#include "libavutil/audioconvert.h"
|
||||||
|
|
||||||
struct AVAudioConvert;
|
struct AudioConvert;
|
||||||
typedef struct AVAudioConvert AVAudioConvert;
|
typedef struct AudioConvert AudioConvert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an audio sample format converter context
|
* Create an audio sample format converter context
|
||||||
|
@ -46,16 +46,16 @@ typedef struct AVAudioConvert AVAudioConvert;
|
||||||
* if all channels must be selected
|
* if all channels must be selected
|
||||||
* @return NULL on error
|
* @return NULL on error
|
||||||
*/
|
*/
|
||||||
AVAudioConvert *swr_audio_convert_alloc(enum AVSampleFormat out_fmt,
|
AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt,
|
||||||
enum AVSampleFormat in_fmt,
|
enum AVSampleFormat in_fmt,
|
||||||
int channels, const int *ch_map,
|
int channels, const int *ch_map,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free audio sample format converter context.
|
* Free audio sample format converter context.
|
||||||
* and set the pointer to NULL
|
* and set the pointer to NULL
|
||||||
*/
|
*/
|
||||||
void swr_audio_convert_free(AVAudioConvert **ctx);
|
void swri_audio_convert_free(AudioConvert **ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert between audio sample formats
|
* Convert between audio sample formats
|
||||||
|
@ -63,6 +63,6 @@ void swr_audio_convert_free(AVAudioConvert **ctx);
|
||||||
* @param[in] in array of input buffers for each channel
|
* @param[in] in array of input buffers for each channel
|
||||||
* @param len length of audio frame size (measured in samples)
|
* @param len length of audio frame size (measured in samples)
|
||||||
*/
|
*/
|
||||||
int swr_audio_convert(AVAudioConvert *ctx, AudioData *out, AudioData *in, int len);
|
int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len);
|
||||||
|
|
||||||
#endif /* AUDIOCONVERT_H */
|
#endif /* AUDIOCONVERT_H */
|
||||||
|
|
|
@ -119,9 +119,9 @@ void swr_free(SwrContext **ss){
|
||||||
free_temp(&s->midbuf);
|
free_temp(&s->midbuf);
|
||||||
free_temp(&s->preout);
|
free_temp(&s->preout);
|
||||||
free_temp(&s->in_buffer);
|
free_temp(&s->in_buffer);
|
||||||
swr_audio_convert_free(&s-> in_convert);
|
swri_audio_convert_free(&s-> in_convert);
|
||||||
swr_audio_convert_free(&s->out_convert);
|
swri_audio_convert_free(&s->out_convert);
|
||||||
swr_audio_convert_free(&s->full_convert);
|
swri_audio_convert_free(&s->full_convert);
|
||||||
swr_resample_free(&s->resample);
|
swr_resample_free(&s->resample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,9 +136,9 @@ int swr_init(SwrContext *s){
|
||||||
free_temp(&s->midbuf);
|
free_temp(&s->midbuf);
|
||||||
free_temp(&s->preout);
|
free_temp(&s->preout);
|
||||||
free_temp(&s->in_buffer);
|
free_temp(&s->in_buffer);
|
||||||
swr_audio_convert_free(&s-> in_convert);
|
swri_audio_convert_free(&s-> in_convert);
|
||||||
swr_audio_convert_free(&s->out_convert);
|
swri_audio_convert_free(&s->out_convert);
|
||||||
swr_audio_convert_free(&s->full_convert);
|
swri_audio_convert_free(&s->full_convert);
|
||||||
|
|
||||||
s-> in.planar= s-> in_sample_fmt >= 0x100;
|
s-> in.planar= s-> in_sample_fmt >= 0x100;
|
||||||
s->out.planar= s->out_sample_fmt >= 0x100;
|
s->out.planar= s->out_sample_fmt >= 0x100;
|
||||||
|
@ -209,15 +209,15 @@ av_assert0(s->out.ch_count);
|
||||||
s->out.bps= av_get_bytes_per_sample(s->out_sample_fmt);
|
s->out.bps= av_get_bytes_per_sample(s->out_sample_fmt);
|
||||||
|
|
||||||
if(!s->resample && !s->rematrix && !s->channel_map){
|
if(!s->resample && !s->rematrix && !s->channel_map){
|
||||||
s->full_convert = swr_audio_convert_alloc(s->out_sample_fmt,
|
s->full_convert = swri_audio_convert_alloc(s->out_sample_fmt,
|
||||||
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
|
s-> in_sample_fmt, s-> in.ch_count, NULL, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
s->in_convert = swr_audio_convert_alloc(s->int_sample_fmt,
|
s->in_convert = swri_audio_convert_alloc(s->int_sample_fmt,
|
||||||
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
|
s-> in_sample_fmt, s->used_ch_count, s->channel_map, 0);
|
||||||
s->out_convert= swr_audio_convert_alloc(s->out_sample_fmt,
|
s->out_convert= swri_audio_convert_alloc(s->out_sample_fmt,
|
||||||
s->int_sample_fmt, s->out.ch_count, NULL, 0);
|
s->int_sample_fmt, s->out.ch_count, NULL, 0);
|
||||||
|
|
||||||
|
|
||||||
s->postin= s->in;
|
s->postin= s->in;
|
||||||
|
@ -335,7 +335,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
|
||||||
|
|
||||||
if(s->full_convert){
|
if(s->full_convert){
|
||||||
av_assert0(!s->resample);
|
av_assert0(!s->resample);
|
||||||
swr_audio_convert(s->full_convert, out, in, in_count);
|
swri_audio_convert(s->full_convert, out, in, in_count);
|
||||||
return out_count;
|
return out_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
|
||||||
}
|
}
|
||||||
|
|
||||||
if(in != postin){
|
if(in != postin){
|
||||||
swr_audio_convert(s->in_convert, postin, in, in_count);
|
swri_audio_convert(s->in_convert, postin, in, in_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(s->resample_first){
|
if(s->resample_first){
|
||||||
|
@ -402,7 +402,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
|
||||||
|
|
||||||
if(preout != out){
|
if(preout != out){
|
||||||
//FIXME packed doesnt need more than 1 chan here!
|
//FIXME packed doesnt need more than 1 chan here!
|
||||||
swr_audio_convert(s->out_convert, out, preout, out_count);
|
swri_audio_convert(s->out_convert, out, preout, out_count);
|
||||||
}
|
}
|
||||||
if(!in_arg)
|
if(!in_arg)
|
||||||
s->in_buffer_count = 0;
|
s->in_buffer_count = 0;
|
||||||
|
|
|
@ -58,9 +58,9 @@ typedef struct SwrContext { //FIXME find unused fields
|
||||||
int in_buffer_count;
|
int in_buffer_count;
|
||||||
int resample_in_constraint;
|
int resample_in_constraint;
|
||||||
|
|
||||||
struct AVAudioConvert *in_convert;
|
struct AudioConvert *in_convert;
|
||||||
struct AVAudioConvert *out_convert;
|
struct AudioConvert *out_convert;
|
||||||
struct AVAudioConvert *full_convert;
|
struct AudioConvert *full_convert;
|
||||||
struct AVResampleContext *resample;
|
struct AVResampleContext *resample;
|
||||||
|
|
||||||
float matrix[SWR_CH_MAX][SWR_CH_MAX];
|
float matrix[SWR_CH_MAX][SWR_CH_MAX];
|
||||||
|
|
Loading…
Reference in New Issue