47 *low_subband_output = av_clip_intp2(subbands[0] + subbands[1], 23);
48 *high_subband_output = av_clip_intp2(subbands[0] - subbands[1], 23);
61 int32_t intermediate_samples[4];
65 for (i = 0; i < 2; i++)
69 &intermediate_samples[0+i],
70 &intermediate_samples[2+i]);
73 for (i = 0; i < 2; i++)
76 &intermediate_samples[2*i],
77 &subband_samples[2*i+0],
78 &subband_samples[2*i+1]);
88 for (i = nb_intervals >> 1; i > 0; i >>= 1)
89 if (
MUL64(factor, intervals[idx + i]) <= ((int64_t)value << 24))
102 int32_t quantized_sample, dithered_sample, parity_change;
103 int32_t d, mean, interval, inv, sample_difference_abs;
106 sample_difference_abs =
FFABS(sample_difference);
107 sample_difference_abs =
FFMIN(sample_difference_abs, (1 << 23) - 1);
113 d = rshift32_clip24(
MULH(dither, dither), 7) - (1 << 23);
116 intervals += quantized_sample;
117 mean = (intervals[1] + intervals[0]) / 2;
118 interval = (intervals[1] - intervals[0]) * (-(sample_difference < 0) | 1);
120 dithered_sample = rshift64_clip24(
MUL64(dither, interval) + ((int64_t)av_clip_intp2(mean + d, 23) << 32), 32);
121 error = ((int64_t)sample_difference_abs << 20) -
MUL64(dithered_sample, quantization_factor);
124 parity_change = quantized_sample;
130 inv = -(sample_difference < 0);
141 for (subband = 0; subband <
NB_SUBBANDS; subband++) {
155 static const int map[] = { 1, 2, 0, 3 };
191 for (channel = 0; channel <
NB_CHANNELS; channel++)
196 for (channel = 0; channel <
NB_CHANNELS; channel++) {
220 for (pos = 0, ipos = 0; pos < output_size; pos += s->
block_size, ipos += 4) {
223 for (channel = 0; channel <
NB_CHANNELS; channel++)
224 for (sample = 0; sample < 4; sample++)
242 #if CONFIG_APTX_ENCODER 257 .supported_samplerates = (
const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
261 #if CONFIG_APTX_HD_ENCODER 276 .supported_samplerates = (
const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
Prediction prediction[NB_SUBBANDS]
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static int shift(int a, int b)
static void aptx_insert_sync(Channel channels[NB_CHANNELS], int32_t *idx)
This structure describes decoded (raw) audio or video data.
static av_cold int init(AVCodecContext *avctx)
static av_always_inline int32_t aptx_qmf_convolution(FilterSignal *signal, const int32_t coeffs[FILTER_TAPS], int shift)
#define AV_CH_LAYOUT_STEREO
static void error(const char *err)
void ff_aptx_invert_quantize_and_prediction(Channel *channel, int hd)
const int32_t * quantize_dither_factors
static void aptx_qmf_tree_analysis(QMFAnalysis *qmf, int32_t samples[4], int32_t subband_samples[4])
static av_always_inline void aptx_qmf_filter_signal_push(FilterSignal *signal, int32_t sample)
static int32_t aptx_quantized_parity(Channel *channel)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static uint16_t aptx_pack_codeword(Channel *channel)
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Quantize quantize[NB_SUBBANDS]
static const int32_t aptx_qmf_inner_coeffs[NB_FILTERS][FILTER_TAPS]
static const int32_t aptx_qmf_outer_coeffs[NB_FILTERS][FILTER_TAPS]
#define i(width, name, range_min, range_max)
void ff_aptx_generate_dither(Channel *channel)
FilterSignal inner_filter_signal[NB_FILTERS][NB_FILTERS]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const uint8_t dither[8][8]
InvertQuantize invert_quantize[NB_SUBBANDS]
const char * name
Name of the codec implementation.
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
static const uint8_t *const tables[]
static void aptx_encode_samples(AptXContext *ctx, int32_t samples[NB_CHANNELS][4], uint8_t *output)
static uint32_t aptxhd_pack_codeword(Channel *channel)
static av_always_inline void aptx_qmf_polyphase_analysis(FilterSignal signal[NB_FILTERS], const int32_t coeffs[NB_FILTERS][FILTER_TAPS], int shift, int32_t samples[NB_FILTERS], int32_t *low_subband_output, int32_t *high_subband_output)
av_cold int ff_aptx_init(AVCodecContext *avctx)
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
int32_t quantized_sample_parity_change
int32_t quantization_factor
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static void aptx_quantize_difference(Quantize *quantize, int32_t sample_difference, int32_t dither, int32_t quantization_factor, ConstTables *tables)
AVCodec ff_aptx_hd_encoder
Channel channels[NB_CHANNELS]
AVSampleFormat
Audio sample formats.
ConstTables ff_aptx_quant_tables[2][NB_SUBBANDS]
main external API structure.
static const uint16_t channel_layouts[7]
static int aptx_check_parity(Channel channels[NB_CHANNELS], int32_t *idx)
static const int factor[16]
const VDPAUPixFmtMap * map
static av_always_inline int32_t aptx_bin_search(int32_t value, int32_t factor, const int32_t *intervals, int32_t nb_intervals)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
FilterSignal outer_filter_signal[NB_FILTERS]
int32_t dither[NB_SUBBANDS]
channel
Use these values when setting the channel map with ebur128_set_channel().
const int32_t * quantize_intervals
static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], int linesize[4], int v1mode, strip_info *info, mb_encoding encoding)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
static void aptx_encode_channel(Channel *channel, int32_t samples[4], int hd)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static av_cold int aptx_close(AVCodecContext *avctx)