Go to the documentation of this file.
37 #define SMKTREE_BITS 9
38 #define SMK_NODE 0x80000000
40 #define SMKTREE_DECODE_MAX_RECURSION FFMIN(32, 3 * SMKTREE_BITS)
41 #define SMKTREE_DECODE_BIG_MAX_RECURSION 500
47 #if (6 * SMKTREE_BITS + 1 + 3 + (2 + 3 * 16) + 64) <= 8 * AV_INPUT_BUFFER_PADDING_SIZE
48 #define UNCHECKED_BITSTREAM_READER 1
50 #define BITSTREAM_READER_LE
89 1, 2, 3, 4, 5, 6, 7, 8,
90 9, 10, 11, 12, 13, 14, 15, 16,
91 17, 18, 19, 20, 21, 22, 23, 24,
92 25, 26, 27, 28, 29, 30, 31, 32,
93 33, 34, 35, 36, 37, 38, 39, 40,
94 41, 42, 43, 44, 45, 46, 47, 48,
95 49, 50, 51, 52, 53, 54, 55, 56,
96 57, 58, 59, 128, 256, 512, 1024, 2048 };
149 if (
ctx->current >=
ctx->length) {
161 val = i1 | (i2 << 8);
162 if(
val ==
ctx->escapes[0]) {
163 ctx->last[0] =
ctx->current;
165 }
else if(
val ==
ctx->escapes[1]) {
166 ctx->last[1] =
ctx->current;
168 }
else if(
val ==
ctx->escapes[2]) {
169 ctx->last[2] =
ctx->current;
199 VLC vlc[2] = { { 0 } };
204 if(
size >= UINT_MAX>>4){
209 for (
int i = 0;
i < 2;
i++) {
224 &
h.entries[0].length,
sizeof(*
h.entries),
225 &
h.entries[0].value,
sizeof(*
h.entries), 1,
232 ctx.vals[
i] =
h.entries[0].value;
239 last[0] = last[1] = last[2] = -1;
241 ctx.escapes[0] = escapes[0];
242 ctx.escapes[1] = escapes[1];
243 ctx.escapes[2] = escapes[2];
254 *recodes =
ctx.values;
260 if (
ctx.last[0] == -1)
ctx.last[0] =
ctx.current++;
261 if (
ctx.last[1] == -1)
ctx.last[1] =
ctx.current++;
262 if (
ctx.last[2] == -1)
ctx.last[2] =
ctx.current++;
266 for (
int i = 0;
i < 2;
i++) {
275 int mmap_size, mclr_size, full_size, type_size,
ret;
346 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
352 register int *
table = recode;
364 if(v != recode[last[0]]) {
365 recode[last[2]] = recode[last[1]];
366 recode[last[1]] = recode[last[0]];
380 int blocks,
blk, bw, bh;
385 if (avpkt->
size <= 769)
392 pal = (uint32_t*)smk->
pic->
data[1];
394 flags = bytestream2_get_byteu(&gb2);
395 #if FF_API_PALETTE_HAS_CHANGED
408 for(
i = 0;
i < 256;
i++)
409 *pal++ = 0xFFU << 24 | bytestream2_get_be24u(&gb2);
419 bw = avctx->
width >> 2;
423 while(
blk < blocks) {
433 while(
run-- &&
blk < blocks){
441 for(
i = 0;
i < 4;
i++) {
442 if(
map & 1)
out[0] = hi;
else out[0] = lo;
443 if(
map & 2)
out[1] = hi;
else out[1] = lo;
444 if(
map & 4)
out[2] = hi;
else out[2] = lo;
445 if(
map & 8)
out[3] = hi;
else out[3] = lo;
460 while(
run-- &&
blk < blocks){
464 for(
i = 0;
i < 4;
i++) {
474 out[0] =
out[1] = pix & 0xFF;
475 out[2] =
out[3] = pix >> 8;
477 out[0] =
out[1] = pix & 0xFF;
478 out[2] =
out[3] = pix >> 8;
481 out[0] =
out[1] = pix & 0xFF;
482 out[2] =
out[3] = pix >> 8;
484 out[0] =
out[1] = pix & 0xFF;
485 out[2] =
out[3] = pix >> 8;
488 for(
i = 0;
i < 2;
i++) {
505 while(
run-- &&
blk < blocks)
510 while(
run-- &&
blk < blocks){
513 col =
mode * 0x01010101
U;
514 for(
i = 0;
i < 4;
i++) {
515 *((uint32_t*)
out) = col;
596 int *got_frame_ptr,
AVPacket *avpkt)
598 const uint8_t *buf = avpkt->
data;
599 int buf_size = avpkt->
size;
601 VLC vlc[4] = { { 0 } };
617 if (unp_size > (1
U<<24)) {
645 "The buffer does not contain an integer number of samples\n");
654 for(
i = 0;
i < (1 << (
bits + stereo));
i++) {
663 &
h.entries[0].length,
sizeof(*
h.entries),
664 &
h.entries[0].value,
sizeof(*
h.entries), 1,
675 for(
i = stereo;
i >= 0;
i--)
677 for(
i = 0;
i <= stereo;
i++)
682 vlc[2*stereo].
table || vlc[2*stereo+1].
table) {
683 for(;
i < unp_size ;
i++) {
684 unsigned idx = 2 * (
i & stereo);
694 if (vlc[++idx].
table)
705 for(;
i < unp_size;
i+=2) {
713 for(;
i < unp_size;
i++) {
719 for(
i = stereo;
i >= 0;
i--)
721 for(
i = 0;
i <= stereo;
i++)
722 *samples8++ =
pred[
i];
723 for(;
i < unp_size;
i++) {
724 unsigned idx =
i & stereo;
734 *samples8++ =
pred[idx];
742 for(
i = 0;
i < 4;
i++) {
750 .
p.
name =
"smackvid",
763 .
p.
name =
"smackaud",
static void error(const char *err)
const FFCodec ff_smacker_decoder
#define FF_ENABLE_DEPRECATION_WARNINGS
int ff_vlc_init_from_lengths(VLC *vlc, 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()
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_left(GetBitContext *gb)
attribute_deprecated int palette_has_changed
Tell user application that palette has changed from previous frame.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
Context used for code reconstructing.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static const int block_runs[64]
This structure describes decoded (raw) audio or video data.
static const uint16_t table[]
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static int smacker_decode_bigtree(AVCodecContext *avctx, GetBitContext *gb, DBCtx *ctx, int length)
Decode header tree.
int nb_channels
Number of channels in this layout.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
const FFCodec ff_smackaud_decoder
AVChannelLayout ch_layout
Audio channel layout.
#define SMKTREE_DECODE_BIG_MAX_RECURSION
static double val(void *priv, double ch)
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 type
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
static av_cold int decode_init(AVCodecContext *avctx)
#define FF_CODEC_DECODE_CB(func)
static av_cold int smka_decode_init(AVCodecContext *avctx)
int(* init)(AVBSFContext *ctx)
#define CODEC_LONG_NAME(str)
static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode Smacker audio data.
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
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 SMKTREE_DECODE_MAX_RECURSION
static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
Store large tree as FFmpeg's vlc codes.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
enum AVPictureType pict_type
Picture type of the frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static av_cold int decode_end(AVCodecContext *avctx)
enum AVSampleFormat sample_fmt
audio sample format
static void skip_bits1(GetBitContext *s)
#define AV_LOG_INFO
Standard information.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
#define av_malloc_array(a, b)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
void ff_vlc_free(VLC *vlc)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
static const float pred[4]
static av_always_inline void last_reset(int *recode, int *last)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
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 values
Filter the word “frame” indicates either a video frame or a group of audio samples
#define FF_DISABLE_DEPRECATION_WARNINGS
@ AV_PICTURE_TYPE_P
Predicted.
#define VLC_INIT_OUTPUT_LE
const VDPAUPixFmtMap * map
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
static int decode_header_trees(SmackVContext *smk)
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last)
static int smacker_decode_tree(AVCodecContext *avctx, GetBitContext *gb, HuffContext *hc, int length)
Decode local frame tree.