36 #define BITSTREAM_READER_LE 43 #define SMKTREE_BITS 9 44 #define SMK_NODE 0x80000000 46 #define SMKTREE_DECODE_MAX_RECURSION 32 47 #define SMKTREE_DECODE_BIG_MAX_RECURSION 500 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 };
152 if (i1 < 0 || i2 < 0)
158 }
else if(val == ctx->
escapes[1]) {
161 }
else if(val == ctx->
escapes[2]) {
192 VLC vlc[2] = { { 0 } };
197 if(size >= UINT_MAX>>4){
230 tmp1.
lengths,
sizeof(
int),
sizeof(
int),
251 tmp2.
lengths,
sizeof(
int),
sizeof(
int),
268 last[0] = last[1] = last[2] = -1;
279 huff.
length = ((size + 3) >> 2) + 4;
321 int mmap_size, mclr_size, full_size, type_size, ret;
392 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
397 register int *
table = recode;
404 table += (*table) & (~SMK_NODE);
409 if(v != recode[last[0]]) {
410 recode[last[2]] = recode[last[1]];
411 recode[last[1]] = recode[last[0]];
425 int blocks,
blk, bw, bh;
430 if (avpkt->
size <= 769)
437 pal = (uint32_t*)smk->
pic->
data[1];
439 flags = bytestream2_get_byteu(&gb2);
447 for(i = 0; i < 256; i++)
448 *pal++ = 0xFFU << 24 | bytestream2_get_be24u(&gb2);
458 bw = avctx->
width >> 2;
462 while(blk < blocks) {
472 while(run-- && blk < blocks){
477 out = smk->
pic->
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
480 for(i = 0; i < 4; i++) {
481 if(map & 1) out[0] = hi;
else out[0] = lo;
482 if(map & 2) out[1] = hi;
else out[1] = lo;
483 if(map & 4) out[2] = hi;
else out[2] = lo;
484 if(map & 8) out[3] = hi;
else out[3] = lo;
499 while(run-- && blk < blocks){
500 out = smk->
pic->
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
503 for(i = 0; i < 4; i++) {
513 out[0] = out[1] = pix & 0xFF;
514 out[2] = out[3] = pix >> 8;
516 out[0] = out[1] = pix & 0xFF;
517 out[2] = out[3] = pix >> 8;
520 out[0] = out[1] = pix & 0xFF;
521 out[2] = out[3] = pix >> 8;
523 out[0] = out[1] = pix & 0xFF;
524 out[2] = out[3] = pix >> 8;
527 for(i = 0; i < 2; i++) {
544 while(run-- && blk < blocks)
549 while(run-- && blk < blocks){
551 out = smk->
pic->
data[0] + (blk / bw) * (stride * 4) + (blk % bw) * 4;
552 col = mode * 0x01010101
U;
553 for(i = 0; i < 4; i++) {
554 *((uint32_t*)out) = col;
635 int *got_frame_ptr,
AVPacket *avpkt)
639 int buf_size = avpkt->
size;
642 VLC vlc[4] = { { 0 } };
649 int pred[2] = {0, 0};
658 if (unp_size > (1
U<<24)) {
673 if (stereo ^ (avctx->
channels != 1)) {
684 if (unp_size % (avctx->
channels * (bits + 1))) {
686 "The buffer does not contain an integer number of samples\n");
691 samples = (int16_t *)frame->
data[0];
692 samples8 = frame->
data[0];
695 for(i = 0; i < (1 << (bits + stereo)); i++) {
702 if (!h[i].bits || !h[i].lengths || !h[i].values) {
712 if(h[i].current > 1) {
714 h[i].lengths,
sizeof(
int),
sizeof(
int),
715 h[i].bits,
sizeof(uint32_t),
sizeof(uint32_t),
INIT_VLC_LE);
725 for(i = stereo; i >= 0; i--)
727 for(i = 0; i <= stereo; i++)
728 *samples++ = pred[i];
729 for(; i < unp_size / 2; i++) {
754 val |= h[3].
values[res] << 8;
756 *samples++ = pred[1];
777 val |= h[1].
values[res] << 8;
779 *samples++ = pred[0];
783 for(i = stereo; i >= 0; i--)
785 for(i = 0; i <= stereo; i++)
786 *samples8++ = pred[i];
787 for(; i < unp_size; i++) {
803 *samples8++ = pred[1];
815 *samples8++ = pred[0];
824 for(i = 0; i < 4; i++) {
static int smacker_decode_bigtree(GetBitContext *gb, HuffContext *hc, DBCtx *ctx, int length)
Decode header tree.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static const int block_runs[64]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
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 void error(const char *err)
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static av_cold int decode_init(AVCodecContext *avctx)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
8 bits with AV_PIX_FMT_RGB32 palette
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
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 SMKTREE_DECODE_BIG_MAX_RECURSION
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static const uint16_t table[]
static int get_bits_left(GetBitContext *gb)
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodec ff_smacker_decoder
#define SMKTREE_DECODE_MAX_RECURSION
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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. ...
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...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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.
int width
picture width / height.
Context used for code reconstructing.
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 FFmpeg's vlc codes.
static const float pred[4]
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
AVCodec ff_smackaud_decoder
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits1(GetBitContext *s)
int palette_has_changed
Tell user application that palette has changed from previous frame.
const VDPAUPixFmtMap * map
static av_const int sign_extend(int val, unsigned bits)
#define flags(name, subs,...)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last)
int channels
number of audio channels
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
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)
static double val(void *priv, double ch)
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
mode
Use these values in ebur128_init (or'ed).
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.
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().