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;
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.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce output
GLsizei GLboolean const GLfloat * value
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]
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 float mean(const float *input, int size)
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
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#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
Writing a table generator This documentation is preliminary Parts of the API are not good and should be changed Basic concepts A table generator consists of two *_tablegen c and *_tablegen h The h file will provide the variable declarations and initialization code for the tables
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.
Filter the word “frame” indicates either a video frame or a group of audio samples
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)