25 #define BITSTREAM_READER_LE
68 ((unsigned)avctx->
height / 8);
82 for (i = 0; i < 3; i++)
107 for (i = 0; i <
size; i++) {
108 unsigned mask_bits =
get_bits(gb, 4);
112 for (j = 0; j < 4; j++) {
113 if (mask_bits & (1 << j))
134 if (value != (1 + ((1 << 3) - 1)))
138 if (value != (1 + ((1 << 3) - 1)) + ((1 << 7) - 1))
145 int* codebook_index,
int superblock_index)
149 unsigned block_index, depth;
152 static const char transitions[3][2] = { {2, 1}, {0, 2}, {1, 0} };
153 *codebook_index = transitions[*codebook_index][
get_bits1(gb)];
161 block_index = depth ?
get_bits(gb, depth) : 0;
163 if (*codebook_index == 1) {
177 uint32_t *dst = sb->
pixels32 + index + (index & -4);
185 uint16_t* src,
unsigned src_stride)
189 for (y = 0; y < 8; y++)
190 memcpy(dest + y * dest_stride, src + y * src_stride,
191 sizeof(uint16_t) * 8);
193 for (y = 0; y < 8; y++)
194 memset(dest + y * dest_stride, 0,
sizeof(uint16_t) * 8);
198 0x4, 0x8, 0x40, 0x80,
199 0x100, 0x200, 0x1000, 0x2000,
200 0x400, 0x800, 0x4000, 0x8000};
203 void *
data,
int *got_frame,
207 int buf_size = avpkt->
size;
215 unsigned superblock_index, cb_index = 1,
216 superblock_col_index = 0,
217 superblocks_per_row = avctx->
width / 8, skip = -1;
219 uint16_t* old_frame_data, *new_frame_data;
220 unsigned old_stride, new_stride;
235 if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
248 for (i = 0; i < 3; i++) {
249 if (frame_flags & (1 << (17 + i))) {
250 unsigned cb_depth, cb_size;
255 cb_depth =
av_log2(cb_size - 1) + 1;
261 cb_size = 1 << cb_depth;
281 new_frame_data = (uint16_t*)frame->
data[0];
282 new_stride = frame->
linesize[0] / 2;
283 old_frame_data = (uint16_t*)s->
frame->
data[0];
287 superblock_index++) {
290 unsigned multi_mask = 0;
300 old_frame_data, old_stride);
303 old_frame_data, old_stride);
310 for (i = 0; i < 16; i++) {
318 unsigned inv_mask =
get_bits(&gb, 4);
319 for (i = 0; i < 4; i++) {
320 if (inv_mask & (1 << i)) {
321 multi_mask ^= 0xF << i*4;
323 multi_mask ^=
get_bits(&gb, 4) << i*4;
327 for (i = 0; i < 16; i++) {
336 }
else if (frame_flags & (1 << 16)) {
346 superblock_col_index++;
350 if (superblock_col_index == superblocks_per_row) {
351 new_frame_data += new_stride * 8 - superblocks_per_row * 8;
353 old_frame_data += old_stride * 8 - superblocks_per_row * 8;
354 superblock_col_index = 0;
360 "Escape sizes: %i, %i, %i\n",
static const uint16_t mask_matrix[]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static void insert_mb_into_sb(SuperBlock *sb, MacroBlock mb, unsigned index)
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static unsigned decode_skip_count(GetBitContext *gb)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
const char * name
Name of the codec implementation.
static void copy_superblock(uint16_t *dest, unsigned dest_stride, uint16_t *src, unsigned src_stride)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static const uint8_t frame_size[4]
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static const uint16_t mask[17]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Libavcodec external API header.
static av_cold int escape124_decode_close(AVCodecContext *avctx)
int width
picture width / height.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVCodec ff_escape124_decoder
#define AV_PIX_FMT_RGB555
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int get_bits1(GetBitContext *s)
static CodeBook unpack_codebook(GetBitContext *gb, unsigned depth, unsigned size)
static int can_safely_read(GetBitContext *gb, int bits)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
common internal api header.
static av_cold int init(AVCodecParserContext *s)
static av_cold int escape124_decode_init(AVCodecContext *avctx)
Initialize the decoder.
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static MacroBlock decode_macroblock(Escape124Context *s, GetBitContext *gb, int *codebook_index, int superblock_index)
static int escape124_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)