*/
/**
- * @file smacker.c
+ * @file libavcodec/smacker.c
* Smacker decoder
*/
#include "avcodec.h"
#define ALT_BITSTREAM_READER_LE
-#include "bitstream.h"
+#include "get_bits.h"
#include "bytestream.h"
#define SMKTREE_BITS 9
return v;
}
-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
SmackVContext * const smk = avctx->priv_data;
uint8_t *out;
uint32_t *pal;
case 2:
for(i = 0; i < 2; i++) {
uint16_t pix1, pix2;
- pix1 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
pix2 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
+ pix1 = smk_get_code(&gb, smk->full_tbl, smk->full_last);
AV_WL16(out,pix1);
AV_WL16(out+2,pix2);
out += stride;
c->avctx = avctx;
- c->pic.data[0] = NULL;
-
- if (avcodec_check_dimensions(avctx, avctx->width, avctx->height) < 0) {
- return 1;
- }
-
avctx->pix_fmt = PIX_FMT_PAL8;
static av_cold int smka_decode_init(AVCodecContext *avctx)
{
- avctx->sample_fmt = SAMPLE_FMT_S16;
+ avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
+ avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? SAMPLE_FMT_U8 : SAMPLE_FMT_S16;
return 0;
}
/**
* Decode Smacker audio data
*/
-static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size)
+static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
GetBitContext gb;
HuffContext h[4];
VLC vlc[4];
int16_t *samples = data;
+ int8_t *samples8 = data;
int val;
int i, res;
int unp_size;
}
stereo = get_bits1(&gb);
bits = get_bits1(&gb);
- if (unp_size & 0xC0000000 || (unp_size << !bits) > *data_size) {
+ if (unp_size & 0xC0000000 || unp_size > *data_size) {
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1;
}
for(i = stereo; i >= 0; i--)
pred[i] = get_bits(&gb, 8);
for(i = 0; i < stereo; i++)
- *samples++ = (pred[i] - 0x80) << 8;
+ *samples8++ = pred[i];
for(i = 0; i < unp_size; i++) {
if(i & stereo){
if(vlc[1].table)
else
res = 0;
pred[1] += (int8_t)h[1].values[res];
- *samples++ = (pred[1] - 0x80) << 8;
+ *samples8++ = pred[1];
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
pred[0] += (int8_t)h[0].values[res];
- *samples++ = (pred[0] - 0x80) << 8;
+ *samples8++ = pred[0];
}
}
- unp_size *= 2;
}
for(i = 0; i < 4; i++) {
NULL,
decode_end,
decode_frame,
+ CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Smacker video"),
};