Go to the documentation of this file.
63 int32_t intermediate_samples[4];
67 for (
i = 0;
i < 2;
i++)
71 &intermediate_samples[0+
i],
72 &intermediate_samples[2+
i]);
75 for (
i = 0;
i < 2;
i++)
78 &intermediate_samples[2*
i],
79 &subband_samples[2*
i+0],
80 &subband_samples[2*
i+1]);
90 for (
i = nb_intervals >> 1;
i > 0;
i >>= 1)
104 int32_t quantized_sample, dithered_sample, parity_change;
108 sample_difference_abs =
FFABS(sample_difference);
109 sample_difference_abs =
FFMIN(sample_difference_abs, (1 << 23) - 1);
113 intervals,
tables->tables_size);
116 d = rshift64(
MUL64(
d,
tables->quantize_dither_factors[quantized_sample]), 23);
118 intervals += quantized_sample;
119 mean = (intervals[1] + intervals[0]) / 2;
120 interval = (intervals[1] - intervals[0]) * (-(sample_difference < 0) | 1);
123 error = ((int64_t)sample_difference_abs << 20) -
MUL64(dithered_sample, quantization_factor);
126 parity_change = quantized_sample;
132 inv = -(sample_difference < 0);
133 quantize->quantized_sample = quantized_sample ^ inv;
134 quantize->quantized_sample_parity_change = parity_change ^ inv;
143 for (subband = 0; subband <
NB_SUBBANDS; subband++) {
147 channel->invert_quantize[subband].quantization_factor,
157 static const int map[] = { 1, 2, 0, 3 };
161 if (
c->quantize[
map[
i]].error <
min->error)
166 min->quantized_sample =
min->quantized_sample_parity_change;
173 return (((
channel->quantize[3].quantized_sample & 0x06) |
parity) << 13)
174 | (((
channel->quantize[2].quantized_sample & 0x03) ) << 11)
175 | (((
channel->quantize[1].quantized_sample & 0x0F) ) << 7)
176 | (((
channel->quantize[0].quantized_sample & 0x7F) ) << 0);
182 return (((
channel->quantize[3].quantized_sample & 0x01E) |
parity) << 19)
183 | (((
channel->quantize[2].quantized_sample & 0x00F) ) << 15)
184 | (((
channel->quantize[1].quantized_sample & 0x03F) ) << 9)
185 | (((
channel->quantize[0].quantized_sample & 0x1FF) ) << 0);
218 output_size =
s->block_size *
frame->nb_samples/4;
222 for (
pos = 0, ipos = 0;
pos < output_size;
pos +=
s->block_size, ipos += 4) {
244 #if CONFIG_APTX_ENCODER
259 .supported_samplerates = (
const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
263 #if CONFIG_APTX_HD_ENCODER
278 .supported_samplerates = (
const int[]) {8000, 16000, 24000, 32000, 44100, 48000, 0},
ConstTables ff_aptx_quant_tables[2][NB_SUBBANDS]
static void error(const char *err)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
static int32_t aptx_quantized_parity(Channel *channel)
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
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
This structure describes decoded (raw) audio or video data.
void ff_aptx_generate_dither(Channel *channel)
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
FilterSignal inner_filter_signal[NB_FILTERS][NB_FILTERS]
static void aptx_qmf_tree_analysis(QMFAnalysis *qmf, int32_t samples[4], int32_t subband_samples[4])
static int quantize(CinepakEncContext *s, int h, uint8_t *data[4], int linesize[4], int v1mode, strip_info *info, mb_encoding encoding)
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
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
#define AV_CH_LAYOUT_STEREO
static uint16_t aptx_pack_codeword(Channel *channel)
static uint32_t aptxhd_pack_codeword(Channel *channel)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
FilterSignal outer_filter_signal[NB_FILTERS]
static av_always_inline int32_t aptx_qmf_convolution(FilterSignal *signal, const int32_t coeffs[FILTER_TAPS], int shift)
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)
static const int32_t aptx_qmf_outer_coeffs[NB_FILTERS][FILTER_TAPS]
static void aptx_encode_samples(AptXContext *ctx, int32_t samples[NB_CHANNELS][4], uint8_t *output)
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
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const int32_t aptx_qmf_inner_coeffs[NB_FILTERS][FILTER_TAPS]
static void aptx_quantize_difference(Quantize *quantize, int32_t sample_difference, int32_t dither, int32_t quantization_factor, ConstTables *tables)
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVSampleFormat
Audio sample formats.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
static av_always_inline void aptx_qmf_filter_signal_push(FilterSignal *signal, int32_t sample)
const char * name
Name of the codec implementation.
const AVCodec ff_aptx_hd_encoder
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
av_cold int ff_aptx_init(AVCodecContext *avctx)
main external API structure.
void ff_aptx_invert_quantize_and_prediction(Channel *channel, int hd)
static av_always_inline int32_t aptx_bin_search(int32_t value, int32_t factor, const int32_t *intervals, int32_t nb_intervals)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
const AVCodec ff_aptx_encoder
Filter the word “frame” indicates either a video frame or a group of audio samples
static float mean(const float *input, int size)
static const int factor[16]
static int shift(int a, int b)
const VDPAUPixFmtMap * map
static av_always_inline int diff(const uint32_t a, const uint32_t b)
This structure stores compressed data.
static const uint16_t channel_layouts[7]
static void aptx_encode_channel(Channel *channel, int32_t samples[4], int hd)
static av_cold int aptx_close(AVCodecContext *avctx)
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
static void aptx_insert_sync(Channel channels[NB_CHANNELS], int32_t *idx)
static int aptx_check_parity(Channel channels[NB_CHANNELS], int32_t *idx)
static const uint8_t dither[8][8]