85 if((t << 1) > size) mask = ~mask;
98 vlc->
table = &vlc_buf[*buf_offset];
101 for (
int i = 16;
i > 0;
i--)
102 for (
unsigned tmp = num + codes_counts[
i - 1]; num <
tmp; num++)
123 for (
int i = 0;
i < 2;
i++){
132 &q_syms, -48 - 16 * i);
133 for (
int j = 0; j < 4; j++)
135 &q_syms, -((8 << j) - 1));
181 int *got_frame_ptr,
AVPacket *avpkt)
185 int buf_size = avpkt->
size;
188 int i, j, k, ch, cnt, res, t;
191 int maxband, keyframe;
197 memset(c->
Q, 0,
sizeof(c->
Q));
209 if(maxband > 32) maxband -= 33;
225 last[0] = last[1] = 0;
226 for(i = maxband - 1; i >= 0; i--){
227 for(ch = 0; ch < 2; ch++){
229 if(last[ch] > 15) last[ch] -= 17;
230 bands[
i].
res[ch] = last[ch];
237 for(i = 0; i < maxband; i++)
238 if(bands[i].res[0] || bands[i].res[1])
242 for(i = maxband - 1; i >= 0; i--)
243 if(bands[i].res[0] || bands[i].res[1]){
244 bands[
i].
msf = mask & 1;
249 for(i = maxband; i < c->
maxbands; i++)
250 bands[i].res[0] = bands[i].res[1] = 0;
253 for(i = 0; i < 32; i++)
257 for(i = 0; i < maxband; i++){
258 if(bands[i].res[0] || bands[i].res[1]){
259 cnt = !!bands[
i].
res[0] + !!bands[
i].
res[1] - 1;
262 if(bands[i].res[0]) bands[
i].
scfi[0] = t >> (2 * cnt);
263 if(bands[i].res[1]) bands[
i].
scfi[1] = t & 3;
268 for(i = 0; i < maxband; i++){
269 for(ch = 0; ch < 2; ch++){
270 if(!bands[i].res[ch])
continue;
281 for(j = 0; j < 2; j++){
282 if((bands[i].scfi[ch] << j) & 2)
283 bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j];
288 bands[
i].
scf_idx[ch][j + 1] = ((bands[
i].
scf_idx[ch][j] + t - 25) & 0x7F) - 6;
295 for(ch = 0; ch < 2; ch++){
296 res = bands[
i].
res[ch];
308 for(k = 0; k < SAMPLES_PER_BAND / 2; k++)
309 c->
Q[ch][off + j + k] = t & (1 << (SAMPLES_PER_BAND / 2 - k - 1))
327 c->
Q[ch][off + j + 1] = t >> 4;
339 cnt = (cnt >> 1) +
FFABS(c->
Q[ch][off + j]);
346 c->
Q[ch][off + j] <<= res - 9;
347 c->
Q[ch][off + j] |=
get_bits(gb, res - 9);
349 c->
Q[ch][off + j] -= (1 << (res - 2)) - 1;
void ff_mpc_dequantize_and_synth(MPCContext *c, int maxband, int16_t **out, int channels)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
#define avpriv_request_sample(...)
static const uint8_t mpc8_q_syms[]
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
#define FF_ARRAY_ELEMS(a)
#define AV_CH_LAYOUT_STEREO
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static const uint32_t mpc8_cnk_lost[16][33]
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
enum AVSampleFormat sample_fmt
audio sample format
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 offset
static const uint8_t mpc8_bands_syms[MPC8_BANDS_SIZE]
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
static const uint8_t mpc8_res_syms[]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static const uint16_t table[]
static const int8_t mpc8_huffq2[5 *5 *5]
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define MPC8_MAX_VLC_SIZE
static const int8_t mpc8_idx50[125]
static const uint16_t mask[17]
static av_cold int mpc8_decode_init(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static VLC quant_vlc[4][2]
static av_cold void build_vlc(VLC *vlc, unsigned *buf_offset, const uint8_t codes_counts[16], const uint8_t **syms, int offset)
const char * name
Name of the codec implementation.
static const uint8_t mpc8_q5_8_len_counts[2][4][16]
static av_cold void mpc8_init_static(void)
uint64_t channel_layout
Audio channel layout.
static av_cold void mpc8_decode_flush(AVCodecContext *avctx)
void ff_mpa_synth_init_fixed(void)
static const int8_t mpc8_idx51[125]
audio channel layout utility functions
static int mpc8_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static int mpc8_get_mod_golomb(GetBitContext *gb, int m)
static const uint8_t mpc8_dscf_syms[]
static const uint8_t mpc8_q9up_len_counts[16]
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 av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint8_t mpc8_cnk_len[16][33]
static const uint8_t mpc8_dscf_len_counts[2][16]
static const uint8_t mpc8_bands_len_counts[16]
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static const uint8_t mpc8_q1_len_counts[16]
static const uint8_t mpc8_res_len_counts[2][16]
Libavcodec external API header.
Musepack decoder MPEG Audio Layer 1/2 -like codec with frames of 1152 samples divided into 32 subband...
AVSampleFormat
Audio sample formats.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
static const float bands[]
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
int ff_init_vlc_from_lengths(VLC *vlc_arg, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags, void *logctx)
Build VLC decoding tables suitable for use with get_vlc2()
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static const uint32_t mpc8_cnk[16][32]
static int mpc8_dec_base(GetBitContext *gb, int k, int n)
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static const uint8_t mpc8_q34_len_counts[2][16]
static const unsigned int mpc8_thres[]
static av_const int sign_extend(int val, unsigned bits)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static const uint8_t mpc8_scfi_syms[]
common internal api header.
static const int8_t mpc8_idx52[125]
static const uint8_t mpc8_scfi_len_counts[2][16]
int channels
number of audio channels
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
static const uint8_t mpc8_q2_len_counts[2][16]
static int mpc8_get_mask(GetBitContext *gb, int size, int t)
static VLC_TYPE vlc_buf[16716][2]
static enum AVSampleFormat sample_fmts[]
uint8_t ** extended_data
pointers to the data planes/channels.
#define AV_CH_LAYOUT_MONO
#define INIT_VLC_STATIC_OVERLONG
Subband structure - hold all variables for each subband.
This structure stores compressed data.
av_cold void ff_mpadsp_init(MPADSPContext *s)
static int mpc8_dec_enum(GetBitContext *gb, int k, int n)
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.