27 #define BITSTREAM_READER_LE
33 #define MAX_BACKWARD_FILTER_ORDER 36
34 #define MAX_BACKWARD_FILTER_LEN 40
35 #define MAX_BACKWARD_FILTER_NONREC 35
37 #define RA288_BLOCK_SIZE 5
38 #define RA288_BLOCKS_PER_FRAME 32
104 float *gain_block = ractx->
gain_hist + 28;
106 memmove(ractx->
sp_hist + 70, ractx->
sp_hist + 75, 36*
sizeof(*block));
110 for (i=0; i < 10; i++)
111 sum -= gain_block[9-i] * ractx->
gain_lpc[i];
114 sum = av_clipf(sum, 0, 60);
118 sumsum = exp(sum * 0.1151292546497) * gain * (1.0/(1<<23));
120 for (i=0; i < 5; i++)
121 buffer[i] =
codetable[cb_coef][i] * sumsum;
125 sum =
FFMAX(sum, 5.0 / (1<<24));
128 memmove(gain_block, gain_block + 1, 9 *
sizeof(*gain_block));
130 gain_block[9] = 10 * log10(sum) + (10*log10(((1<<24)/5.)) - 32);
148 int order,
int n,
int non_rec,
float *
out,
149 float *hist,
float *out2,
const float *window)
162 convolve(buffer1, work + order , n , order);
163 convolve(buffer2, work + order + n, non_rec, order);
165 for (i=0; i <= order; i++) {
166 out2[i] = out2[i] * 0.5625 + buffer1[i];
167 out [i] = out2[i] + buffer2[i];
171 *out *= 257.0 / 256.0;
178 float *hist,
float *rec,
const float *window,
179 float *lpc,
const float *
tab,
180 int order,
int n,
int non_rec,
int move_size)
189 memmove(hist, hist + n, move_size*
sizeof(*hist));
193 int *got_frame_ptr,
AVPacket *avpkt)
197 int buf_size = avpkt->
size;
203 if (buf_size < avctx->block_align) {
205 "Error! Input buffer is too small [%d<%d]\n",
214 out = (
float *)frame->
data[0];
220 int cb_coef =
get_bits(&gb, 6 + (i&1));
222 decode(ractx, gain, cb_coef);
float sp_lpc[FFALIGN(36, 16)]
LPC coefficients for speech data (spec: A)
static av_cold int ra288_decode_close(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
float gain_lpc[FFALIGN(10, 16)]
LPC coefficients for gain (spec: GB)
static void backward_filter(RA288Context *ractx, float *hist, float *rec, const float *window, float *lpc, const float *tab, int order, int n, int non_rec, int move_size)
Backward synthesis filter, find the LPC coefficients from past speech data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define MAX_BACKWARD_FILTER_ORDER
static av_cold int init(AVCodecContext *avctx)
#define DECLARE_ALIGNED(n, t, v)
static void decode(RA288Context *ractx, float gain, int cb_coef)
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
static const float amptable[8]
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors.
float sp_hist[111]
speech data history (spec: SB).
enum AVSampleFormat sample_fmt
audio sample format
#define MAX_BACKWARD_FILTER_NONREC
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
float gain_hist[38]
log-gain history (spec: SBLG).
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
bitstream reader API header.
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void(* vector_fmul)(float *dst, const float *src0, const float *src1, int len)
Calculate the entry wise product of two vectors of floats and store the result in a vector of floats...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define MAX_BACKWARD_FILTER_LEN
const char * name
Name of the codec implementation.
static void convolve(float *tgt, const float *src, int len, int n)
Libavcodec external API header.
static const float syn_window[FFALIGN(111, 16)]
uint64_t channel_layout
Audio channel layout.
AVCodec ff_ra_288_decoder
common internal API header
audio channel layout utility functions
#define RA288_BLOCKS_PER_FRAME
static const float gain_window[FFALIGN(38, 16)]
static const float syn_bw_tab[FFALIGN(36, 16)]
synthesis bandwidth broadening table
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const int16_t codetable[128][5]
float sp_rec[37]
speech part of the gain autocorrelation (spec: REXP)
static int compute_lpc_coefs(const LPC_TYPE *autoc, int max_order, LPC_TYPE *lpc, int lpc_stride, int fail, int normalize)
Levinson-Durbin recursion.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
static void do_hybrid_window(RA288Context *ractx, int order, int n, int non_rec, float *out, float *hist, float *out2, const float *window)
Hybrid window filtering, see blocks 36 and 49 of the G.728 specification.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static const float gain_bw_tab[FFALIGN(10, 16)]
gain bandwidth broadening table
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int ra288_decode_init(AVCodecContext *avctx)
static int ra288_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
common internal api header.
#define LOCAL_ALIGNED(a, t, v,...)
float gain_rec[11]
recursive part of the gain autocorrelation (spec: REXPLG)
int channels
number of audio channels
static const struct twinvq_data tab
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame