39 #define BITSTREAM_READER_LE
43 #define SMKTREE_BITS 9
44 #define SMK_NODE 0x80000000
80 1, 2, 3, 4, 5, 6, 7, 8,
81 9, 10, 11, 12, 13, 14, 15, 16,
82 17, 18, 19, 20, 21, 22, 23, 24,
83 25, 26, 27, 28, 29, 30, 31, 32,
84 33, 34, 35, 36, 37, 38, 39, 40,
85 41, 42, 43, 44, 45, 46, 47, 48,
86 49, 50, 51, 52, 53, 54, 55, 56,
87 57, 58, 59, 128, 256, 512, 1024, 2048 };
140 if (i1 < 0 || i2 < 0)
146 }
else if(val == ctx->
escapes[1]) {
149 }
else if(val == ctx->
escapes[2]) {
180 VLC vlc[2] = { { 0 } };
185 if(size >= UINT_MAX>>4){
208 tmp1.
lengths,
sizeof(
int),
sizeof(
int),
221 tmp2.
lengths,
sizeof(
int),
sizeof(
int),
238 last[0] = last[1] = last[2] = -1;
249 huff.
length = ((size + 3) >> 2) + 4;
285 int mmap_size, mclr_size, full_size, type_size;
335 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
340 register int *table = recode;
345 table += (*table) & (~SMK_NODE);
350 if(v != recode[last[0]]) {
351 recode[last[2]] = recode[last[1]];
352 recode[last[1]] = recode[last[0]];
366 int blocks,
blk, bw, bh;
371 if (avpkt->
size <= 769)
382 pal = (uint32_t*)smk->
pic.
data[1];
384 flags = bytestream2_get_byteu(&gb2);
392 for(i = 0; i < 256; i++)
393 *pal++ = bytestream2_get_be24u(&gb2);
402 bw = avctx->
width >> 2;
407 while(blk < blocks) {
415 while(run-- && blk < blocks){
420 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
423 for(i = 0; i < 4; i++) {
424 if(map & 1) out[0] = hi;
else out[0] = lo;
425 if(map & 2) out[1] = hi;
else out[1] = lo;
426 if(map & 4) out[2] = hi;
else out[2] = lo;
427 if(map & 8) out[3] = hi;
else out[3] = lo;
440 while(run-- && blk < blocks){
441 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
444 for(i = 0; i < 4; i++) {
454 out[0] = out[1] = pix & 0xFF;
455 out[2] = out[3] = pix >> 8;
457 out[0] = out[1] = pix & 0xFF;
458 out[2] = out[3] = pix >> 8;
461 out[0] = out[1] = pix & 0xFF;
462 out[2] = out[3] = pix >> 8;
464 out[0] = out[1] = pix & 0xFF;
465 out[2] = out[3] = pix >> 8;
469 for(i = 0; i < 2; i++) {
486 while(run-- && blk < blocks)
491 while(run-- && blk < blocks){
493 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
494 col = mode * 0x01010101;
495 for(i = 0; i < 4; i++) {
496 *((uint32_t*)out) = col;
589 int *got_frame_ptr,
AVPacket *avpkt)
593 int buf_size = avpkt->
size;
596 VLC vlc[4] = { { 0 } };
603 int pred[2] = {0, 0};
621 if (stereo ^ (avctx->
channels != 1)) {
640 for(i = 0; i < (1 << (bits + stereo)); i++) {
649 for (; i >= 0; i--) {
659 if(h[i].current > 1) {
661 h[i].lengths,
sizeof(
int),
sizeof(
int),
662 h[i].bits,
sizeof(uint32_t),
sizeof(uint32_t),
INIT_VLC_LE);
670 for(i = stereo; i >= 0; i--)
672 for(i = 0; i <= stereo; i++)
673 *samples++ = pred[i];
674 for(; i < unp_size / 2; i++) {
685 val |= h[3].
values[res] << 8;
687 *samples++ = av_clip_int16(pred[1]);
698 val |= h[1].
values[res] << 8;
700 *samples++ = av_clip_int16(pred[0]);
704 for(i = stereo; i >= 0; i--)
706 for(i = 0; i <= stereo; i++)
707 *samples8++ = pred[i];
708 for(; i < unp_size; i++) {
715 *samples8++ = av_clip_uint8(pred[1]);
722 *samples8++ = av_clip_uint8(pred[0]);
727 for(i = 0; i < 4; i++) {
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
struct SmackerAudioContext SmackerAudioContext
This structure describes decoded (raw) audio or video data.
static const int block_runs[64]
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVFrame * coded_frame
the picture in the bitstream
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AV_CH_LAYOUT_STEREO
static av_cold int decode_init(AVCodecContext *avctx)
int(* reget_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of a frame to get cr buffer for it.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
enum AVSampleFormat sample_fmt
audio sample format
8 bit with PIX_FMT_RGB32 palette
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static av_cold int smka_decode_init(AVCodecContext *avctx)
bitstream reader API header.
#define MKTAG(a, b, c, d)
struct HuffContext HuffContext
Context used for code reconstructing.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int init(AVCodecParserContext *s)
AVCodec ff_smacker_decoder
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t prefix, int length)
Decode local frame tree.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
uint64_t channel_layout
Audio channel layout.
static int smka_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Decode Smacker audio data.
audio channel layout utility functions
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
Context used for code reconstructing.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
static av_cold int decode_end(AVCodecContext *avctx)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int smacker_decode_header_tree(SmackVContext *smk, GetBitContext *gb, int **recodes, int *last, int size)
Store large tree as Libav's vlc codes.
static const float pred[4]
AVCodec ff_smackaud_decoder
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
void avcodec_get_frame_defaults(AVFrame *frame)
Set the fields of the given AVFrame to default values.
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx)
Decode header tree.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int palette_has_changed
Tell user application that palette has changed from previous frame.
#define FF_BUFFER_HINTS_REUSABLE
static av_const int sign_extend(int val, unsigned bits)
#define FF_BUFFER_HINTS_PRESERVE
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
#define AVERROR_INVALIDDATA
static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last)
int channels
number of audio channels
struct SmackVContext SmackVContext
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
#define FF_BUFFER_HINTS_VALID
static int decode_header_trees(SmackVContext *smk)
static av_always_inline void last_reset(int *recode, int *last)
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...