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 };
137 int val, i1, i2, b1, b2;
144 if (i1 < 0 || i2 < 0)
150 }
else if(val == ctx->
escapes[1]) {
153 }
else if(val == ctx->
escapes[2]) {
189 if(size >= UINT_MAX>>4){
208 memset(&vlc[0], 0,
sizeof(
VLC));
209 memset(&vlc[1], 0,
sizeof(
VLC));
215 tmp1.
lengths,
sizeof(
int),
sizeof(
int),
228 tmp2.
lengths,
sizeof(
int),
sizeof(
int),
245 last[0] = last[1] = last[2] = -1;
256 huff.
length = ((size + 3) >> 2) + 4;
292 int mmap_size, mclr_size, full_size, type_size;
342 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
347 register int *table = recode;
353 table += (*table) & (~SMK_NODE);
359 if(v != recode[last[0]]) {
360 recode[last[2]] = recode[last[1]];
361 recode[last[1]] = recode[last[0]];
369 const uint8_t *buf = avpkt->
data;
370 int buf_size = avpkt->
size;
375 int blocks,
blk, bw, bh;
390 pal = (uint32_t*)smk->
pic.
data[1];
399 for(i = 0; i < 256; i++)
400 *pal++ = bytestream_get_be24(&buf);
410 bw = avctx->
width >> 2;
415 while(blk < blocks) {
423 while(run-- && blk < blocks){
428 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
431 for(i = 0; i < 4; i++) {
432 if(map & 1) out[0] = hi;
else out[0] = lo;
433 if(map & 2) out[1] = hi;
else out[1] = lo;
434 if(map & 4) out[2] = hi;
else out[2] = lo;
435 if(map & 8) out[3] = hi;
else out[3] = lo;
448 while(run-- && blk < blocks){
449 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
452 for(i = 0; i < 4; i++) {
462 out[0] = out[1] = pix & 0xFF;
463 out[2] = out[3] = pix >> 8;
465 out[0] = out[1] = pix & 0xFF;
466 out[2] = out[3] = pix >> 8;
469 out[0] = out[1] = pix & 0xFF;
470 out[2] = out[3] = pix >> 8;
472 out[0] = out[1] = pix & 0xFF;
473 out[2] = out[3] = pix >> 8;
477 for(i = 0; i < 2; i++) {
494 while(run-- && blk < blocks)
499 while(run-- && blk < blocks){
501 out = smk->
pic.
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
502 col = mode * 0x01010101;
503 for(i = 0; i < 4; i++) {
504 *((uint32_t*)out) = col;
597 int *got_frame_ptr,
AVPacket *avpkt)
600 const uint8_t *buf = avpkt->
data;
601 int buf_size = avpkt->
size;
611 int pred[2] = {0, 0};
629 if (stereo ^ (avctx->
channels != 1)) {
647 memset(vlc, 0,
sizeof(
VLC) * 4);
650 for(i = 0; i < (1 << (bits + stereo)); i++) {
659 for (; i >= 0; i--) {
669 if(h[i].current > 1) {
671 h[i].lengths,
sizeof(
int),
sizeof(
int),
672 h[i].bits,
sizeof(uint32_t),
sizeof(uint32_t),
INIT_VLC_LE);
680 for(i = stereo; i >= 0; i--)
682 for(i = 0; i <= stereo; i++)
683 *samples++ = pred[i];
684 for(; i < unp_size / 2; i++) {
695 val |= h[3].
values[res] << 8;
697 *samples++ = av_clip_int16(pred[1]);
708 val |= h[1].
values[res] << 8;
710 *samples++ = av_clip_int16(pred[0]);
714 for(i = stereo; i >= 0; i--)
716 for(i = 0; i <= stereo; i++)
717 *samples8++ = pred[i];
718 for(; i < unp_size; i++) {
725 *samples8++ = av_clip_uint8(pred[1]);
732 *samples8++ = av_clip_uint8(pred[0]);
737 for(i = 0; i < 4; i++) {
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
struct SmackerAudioContext SmackerAudioContext
#define FF_BUFFER_HINTS_VALID
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
#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
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static av_cold int smka_decode_init(AVCodecContext *avctx)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
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)
audio conversion routines
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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.
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
int width
picture width / height.
Context used for code reconstructing.
struct AVFrame AVFrame
Audio Video Frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
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.
#define FF_BUFFER_HINTS_REUSABLE
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)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define FF_BUFFER_HINTS_PRESERVE
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.
static av_const int sign_extend(int val, unsigned bits)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
8 bit with PIX_FMT_RGB32 palette
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
void avcodec_get_frame_defaults(AVFrame *pic)
Set the fields of the given AVFrame to default values.
static int decode_header_trees(SmackVContext *smk)
static av_always_inline void last_reset(int *recode, int *last)
#define AV_CH_LAYOUT_MONO
#define MKTAG(a, b, c, d)
void ff_free_vlc(VLC *vlc)
int nb_samples
number of audio samples (per channel) described by this frame