39#define CBPLO_VLC_BITS 6
40#define CBPHI_VLC_BITS 6
41#define BLKTYPE_VLC_BITS 9
42#define BLOCK_VLC_BITS 12
68static const uint8_t
cbplo[][2] = {
69 { 0,-6 }, { 0x01, 6 }, { 0x02, 6 }, { 0x03, 6 }, { 0x00, 4 },
70 { 0x01, 3 }, { 0x02, 3 }, { 0x03, 3 }, { 0x00, 1 },
74 4, 5, 5, 4, 5, 4, 6, 4, 5, 6, 4, 4, 4, 4, 4, 2
78 3, 5, 4, 9, 3, 7, 2, 11, 2, 3, 5, 10, 4, 8, 6, 3
82 { 0,-8 }, { 0x34, 9 }, { 0,-9 }, { 0x14, 9 }, { 0,-9 },
83 { 0x23, 8 }, { 0x13, 8 }, { 0x32, 8 }, { 0x33, 7 }, { 0x22, 7 },
84 { 0x12, 7 }, { 0x21, 7 }, { 0x11, 7 }, { 0x04, 6 }, { 0x30, 6 },
85 { 0x03, 5 }, { 0x20, 4 }, { 0x10, 4 }, { 0x02, 3 }, { 0x01, 3 },
90 0, 0x4082, 0x4003, 0x000B, 0x000A, 0x4E01, 0x4D81, 0x4D01, 0x4C81,
91 0x0482, 0x0402, 0x0382, 0x0302, 0x0282, 0x0183, 0x0103, 0x0084, 0x000C,
92 0x0085, 0x0B81, 0x0C01, 0x4E81, 0x4F01, 0x4F81, 0x5001, 0x0086, 0x0104,
93 0x0203, 0x0283, 0x0303, 0x0502, 0x0C81, 0x0D01, 0x5081, 0x5101, 0x5181,
94 0x5201, 0x5281, 0x5301, 0x5381, 0x5401, 0x0000, 0x0009, 0x0008, 0x4C01,
95 0x4B81, 0x4B01, 0x4A81, 0x4A01, 0x4981, 0x4901, 0x4881, 0x4002, 0x0B01,
96 0x0A81, 0x0A01, 0x0981, 0x0901, 0x0881, 0x0801, 0x0781, 0x0202, 0x0182,
97 0x0007, 0x0006, 0x4801, 0x4781, 0x4701, 0x4681, 0x4601, 0x4581, 0x4501,
98 0x4481, 0x0701, 0x0681, 0x0102, 0x0083, 0x0005, 0x4401, 0x4381, 0x4301,
99 0x4281, 0x0601, 0x0581, 0x0501, 0x0004, 0x4201, 0x4181, 0x4101, 0x4081,
100 0x0481, 0x0401, 0x0381, 0x0301, 0x0082, 0x0003, 0x0281, 0x0201, 0x0181,
101 0x4001, 0x0001, 0x0081, 0x0101, 0x0002,
105 -9, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11,
106 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
107 12, 12, 12, 7, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
108 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
109 8, 8, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6,
110 6, 5, 5, 5, 4, 2, 3, 4, 4,
133 const uint8_t *idct_permutation =
s->idsp.idct_permutation;
134 int i, last,
len, factor2;
147 factor2 =
value & 0x7F;
148 last = (
value >> 14) & 1;
161 if (
s->hi == 2 && flag2 &&
block < 4) {
163 s->block[
block][idct_permutation[0]] *= 2;
164 s->block[
block][idct_permutation[1]] *= 2;
165 s->block[
block][idct_permutation[8]] *= 2;
166 s->block[
block][idct_permutation[16]] *= 2;
173 unsigned cbp,
int flag,
int offset,
unsigned flag2)
176 const uint8_t *idct_permutation =
s->idsp.idct_permutation;
179 memset(
s->block, 0,
sizeof(
s->block));
181 for (
i = 0;
i < 6;
i++) {
189 s->block[
i][idct_permutation[0]] = x;
192 if (cbp & (1 << (5 -
i))) {
205 int ret, x, y,
offset = 0;
212 s->factor =
s->lo * 2;
222 for (y = 0; y < avctx->
height; y += 16) {
223 for (x = 0; x < avctx->
width; x += 16) {
238 s->idsp.idct_put(
frame->data[0] + y *
frame->linesize[0] + x,
239 frame->linesize[0],
s->block[0]);
240 s->idsp.idct_put(
frame->data[0] + y *
frame->linesize[0] + x + 8,
241 frame->linesize[0],
s->block[1]);
242 s->idsp.idct_put(
frame->data[0] + (y + 8) *
frame->linesize[0] + x,
243 frame->linesize[0],
s->block[2]);
244 s->idsp.idct_put(
frame->data[0] + (y + 8) *
frame->linesize[0] + x + 8,
245 frame->linesize[0],
s->block[3]);
246 s->idsp.idct_put(
frame->data[1] + (y >> 1) *
frame->linesize[1] + (x >> 1),
247 frame->linesize[1],
s->block[4]);
248 s->idsp.idct_put(
frame->data[2] + (y >> 1) *
frame->linesize[2] + (x >> 1),
249 frame->linesize[2],
s->block[5]);
260 int ret, x, y,
offset = 0;
267 s->factor =
s->lo * 2;
277 for (y = 0; y < avctx->
height; y += 16) {
278 for (x = 0; x < avctx->
width; x += 16) {
280 unsigned cbplo, flag2 = 0;
288 prev->
data[1] + (y >> 1) * prev->
linesize[1] + (x >> 1),
291 prev->
data[2] + (y >> 1) * prev->
linesize[2] + (x >> 1),
300 intra_block =
value & 0x07;
315 s->idsp.idct_put(
frame->data[0] + y *
frame->linesize[0] + x,
316 frame->linesize[0],
s->block[0]);
317 s->idsp.idct_put(
frame->data[0] + y *
frame->linesize[0] + x + 8,
318 frame->linesize[0],
s->block[1]);
319 s->idsp.idct_put(
frame->data[0] + (y + 8) *
frame->linesize[0] + x,
320 frame->linesize[0],
s->block[2]);
321 s->idsp.idct_put(
frame->data[0] + (y + 8) *
frame->linesize[0] + x + 8,
322 frame->linesize[0],
s->block[3]);
323 s->idsp.idct_put(
frame->data[1] + (y >> 1) *
frame->linesize[1] + (x >> 1),
324 frame->linesize[1],
s->block[4]);
325 s->idsp.idct_put(
frame->data[2] + (y >> 1) *
frame->linesize[2] + (x >> 1),
326 frame->linesize[2],
s->block[5]);
338 prev->
data[1] + (y >> 1) * prev->
linesize[1] + (x >> 1),
341 prev->
data[2] + (y >> 1) * prev->
linesize[2] + (x >> 1),
344 s->idsp.idct_add(
frame->data[0] + y *
frame->linesize[0] + x,
345 frame->linesize[0],
s->block[0]);
346 s->idsp.idct_add(
frame->data[0] + y *
frame->linesize[0] + x + 8,
347 frame->linesize[0],
s->block[1]);
348 s->idsp.idct_add(
frame->data[0] + (y + 8) *
frame->linesize[0] + x,
349 frame->linesize[0],
s->block[2]);
350 s->idsp.idct_add(
frame->data[0] + (y + 8) *
frame->linesize[0] + x + 8,
351 frame->linesize[0],
s->block[3]);
352 s->idsp.idct_add(
frame->data[1] + (y >> 1) *
frame->linesize[1] + (x >> 1),
353 frame->linesize[1],
s->block[4]);
354 s->idsp.idct_add(
frame->data[2] + (y >> 1) *
frame->linesize[2] + (x >> 1),
355 frame->linesize[2],
s->block[5]);
372 if (avpkt->
size <= 32)
380 s->bdsp.bswap_buf((uint32_t *)
s->bitstream,
381 (uint32_t *)avpkt->
data,
382 (avpkt->
size + 3) >> 2);
393 scaled = avpkt->
data[8];
472 if (!
s->prev_frame->data[0]) {
535 s->bitstream_size = 0;
static av_cold void decode_flush(AVCodecContext *avctx)
const FFCodec ff_imm4_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#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...
static void copy_block8(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
static void copy_block16(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
static uint64_t reverse(uint64_t p, unsigned int deg)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
static int get_sbits(GetBitContext *s, int n)
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
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.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same 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_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
static av_cold void decode_flush(AVCodecContext *avctx)
static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame, AVFrame *prev)
static const uint8_t intra_cb[]
static VLCElem cbphi_tab[1<< CBPHI_VLC_BITS]
static int decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static VLCElem blktype_tab[1<< BLKTYPE_VLC_BITS]
static av_cold int decode_close(AVCodecContext *avctx)
static const uint8_t block_bits[]
static int get_cbphi(GetBitContext *gb, int x)
static av_cold int decode_init(AVCodecContext *avctx)
static const uint8_t cbphi_codes[]
static av_cold void imm4_init_static_data(void)
static int decode_block(AVCodecContext *avctx, GetBitContext *gb, int block, int factor, int flag, int offset, int flag2)
static const uint16_t block_symbols[]
static const uint8_t cbplo[][2]
static VLCElem cbplo_tab[1<< CBPLO_VLC_BITS]
static const uint8_t cbphi_bits[]
static int decode_blocks(AVCodecContext *avctx, GetBitContext *gb, unsigned cbp, int flag, int offset, unsigned flag2)
static VLCElem block_tab[1<< BLOCK_VLC_BITS]
static const uint8_t inter_cb[]
static const uint8_t blktype[][2]
static av_cold int decode_init(AVCodecContext *avctx)
static int decode_frame(AVCodecContext *avctx, AVFrame *picture, int *got_frame, AVPacket *avpkt)
static av_cold int decode_close(AVCodecContext *avctx)
av_cold void ff_bswapdsp_init(BswapDSPContext *c)
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
static const int factor[16]
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.
#define avpriv_request_sample(...)
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
#define VLC_INIT_STATIC_TABLE_FROM_LENGTHS(vlc_table, nb_bits, nb_codes, lens, lens_wrap, syms, syms_wrap, syms_size, offset, flags)