39#define SMK_NODE 0x80000000
41#define SMKTREE_DECODE_MAX_RECURSION FFMIN(32, 3 * SMKTREE_BITS)
42#define SMKTREE_DECODE_BIG_MAX_RECURSION 500
48#if (6 * SMKTREE_BITS + 1 + 3 + (2 + 3 * 16) + 64) <= 8 * AV_INPUT_BUFFER_PADDING_SIZE
49#define UNCHECKED_BITSTREAM_READER 1
51#define BITSTREAM_READER_LE
90 1, 2, 3, 4, 5, 6, 7, 8,
91 9, 10, 11, 12, 13, 14, 15, 16,
92 17, 18, 19, 20, 21, 22, 23, 24,
93 25, 26, 27, 28, 29, 30, 31, 32,
94 33, 34, 35, 36, 37, 38, 39, 40,
95 41, 42, 43, 44, 45, 46, 47, 48,
96 49, 50, 51, 52, 53, 54, 55, 56,
97 57, 58, 59, 128, 256, 512, 1024, 2048 };
150 if (
ctx->current >=
ctx->length) {
162 val = i1 | (i2 << 8);
163 if(
val ==
ctx->escapes[0]) {
164 ctx->last[0] =
ctx->current;
166 }
else if(
val ==
ctx->escapes[1]) {
167 ctx->last[1] =
ctx->current;
169 }
else if(
val ==
ctx->escapes[2]) {
170 ctx->last[2] =
ctx->current;
200 VLC vlc[2] = { { 0 } };
205 if(
size >= UINT_MAX>>4){
210 for (
int i = 0;
i < 2;
i++) {
225 &
h.entries[0].length,
sizeof(*
h.entries),
226 &
h.entries[0].value,
sizeof(*
h.entries), 1,
233 ctx.vals[
i] =
h.entries[0].value;
240 last[0] = last[1] = last[2] = -1;
242 ctx.escapes[0] = escapes[0];
243 ctx.escapes[1] = escapes[1];
244 ctx.escapes[2] = escapes[2];
255 *recodes =
ctx.values;
261 if (
ctx.last[0] == -1)
ctx.last[0] =
ctx.current++;
262 if (
ctx.last[1] == -1)
ctx.last[1] =
ctx.current++;
263 if (
ctx.last[2] == -1)
ctx.last[2] =
ctx.current++;
267 for (
int i = 0;
i < 2;
i++) {
276 int mmap_size, mclr_size, full_size, type_size, ret;
347 recode[last[0]] = recode[last[1]] = recode[last[2]] = 0;
353 register int *
table = recode;
365 if(v != recode[last[0]]) {
366 recode[last[2]] = recode[last[1]];
367 recode[last[1]] = recode[last[0]];
381 int blocks,
blk, bw, bh;
386 if (avpkt->
size <= 769)
393 pal = (uint32_t*)smk->
pic->
data[1];
395 flags = bytestream2_get_byteu(&gb2);
404 for(
i = 0;
i < 256;
i++)
405 *pal++ = 0xFFU << 24 | bytestream2_get_be24u(&gb2);
415 bw = avctx->
width >> 2;
419 while(
blk < blocks) {
429 while(
run-- &&
blk < blocks){
437 for(
i = 0;
i < 4;
i++) {
438 if(
map & 1)
out[0] = hi;
else out[0] = lo;
439 if(
map & 2)
out[1] = hi;
else out[1] = lo;
440 if(
map & 4)
out[2] = hi;
else out[2] = lo;
441 if(
map & 8)
out[3] = hi;
else out[3] = lo;
456 while(
run-- &&
blk < blocks){
460 for(
i = 0;
i < 4;
i++) {
484 for(
i = 0;
i < 2;
i++) {
501 while(
run-- &&
blk < blocks)
506 while(
run-- &&
blk < blocks){
509 col =
mode * 0x01010101U;
510 for(
i = 0;
i < 4;
i++) {
511 *((uint32_t*)
out) = col;
592 int *got_frame_ptr,
AVPacket *avpkt)
594 const uint8_t *buf = avpkt->
data;
595 int buf_size = avpkt->
size;
597 VLC vlc[4] = { { 0 } };
613 if (unp_size > (1U<<24)) {
641 "The buffer does not contain an integer number of samples\n");
646 for(
i = 0;
i < (1 << (
bits + stereo));
i++) {
655 &
h.entries[0].length,
sizeof(*
h.entries),
656 &
h.entries[0].value,
sizeof(*
h.entries), 1,
663 values[
i] =
h.entries[0].value;
672 samples = (int16_t *)
frame->data[0];
673 samples8 =
frame->data[0];
677 for(
i = stereo;
i >= 0;
i--)
679 for(
i = 0;
i <= stereo;
i++)
680 *samples++ =
pred[
i];
684 vlc[2*stereo].
table || vlc[2*stereo+1].
table) {
685 for(;
i < unp_size ;
i++) {
686 unsigned idx = 2 * (
i & stereo);
696 if (vlc[++idx].
table)
702 *samples++ =
pred[idx / 2];
705 val = 256*values[1] + values[0];
706 val2 = 256*values[3] + values[2];
707 for(;
i < unp_size;
i+=2) {
710 *samples++ =
pred[0];
711 *samples++ =
pred[1];
714 val = 256*values[1] + values[0];
715 for(;
i < unp_size;
i++) {
717 *samples++ =
pred[0];
721 for(
i = stereo;
i >= 0;
i--)
723 for(
i = 0;
i <= stereo;
i++)
724 *samples8++ =
pred[
i];
725 for(;
i < unp_size;
i++) {
726 unsigned idx =
i & stereo;
736 *samples8++ =
pred[idx];
744 for(
i = 0;
i < 4;
i++) {
752 .p.name =
"smackvid",
765 .p.name =
"smackaud",
static double val(void *priv, double ch)
const FFCodec ff_smackaud_decoder
const FFCodec ff_smacker_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
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.
int(* init)(AVBSFContext *ctx)
static const uint8_t bits[8]
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void skip_bits1(GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_S16
signed 16 bits
const VDPAUPixFmtMap * map
static av_cold int decode_init(AVCodecContext *avctx)
static av_cold int decode_end(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
static int smacker_decode_bigtree(AVCodecContext *avctx, GetBitContext *gb, DBCtx *ctx, int length)
Decode header tree.
#define SMKTREE_DECODE_MAX_RECURSION
static int decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static int smka_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode Smacker audio data.
static int smacker_decode_tree(AVCodecContext *avctx, GetBitContext *gb, HuffContext *hc, int length)
Decode local frame tree.
static int decode_header_trees(SmackVContext *smk)
static av_cold int decode_init(AVCodecContext *avctx)
static const int block_runs[64]
static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int smka_decode_init(AVCodecContext *avctx)
static av_always_inline int smk_get_code(GetBitContext *gb, int *recode, int *last)
static av_always_inline void last_reset(int *recode, int *last)
#define SMKTREE_DECODE_BIG_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.
#define MKTAG(a, b, c, d)
Memory handling functions.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
static const uint16_t table[]
static const float pred[4]
int nb_channels
Number of channels in this layout.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
Context used for code reconstructing.
#define av_malloc_array(a, b)
static void error(const char *err)
static AVFormatContext * ctx
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()
void ff_vlc_free(VLC *vlc)
#define VLC_INIT_OUTPUT_LE