24 #define BITSTREAM_READER_LE
67 ((unsigned)avctx->
height / 8);
77 for (i = 0; i < 3; i++)
103 for (i = 0; i <
size; i++) {
104 unsigned mask_bits =
get_bits(gb, 4);
108 for (j = 0; j < 4; j++) {
109 if (mask_bits & (1 << j))
130 if (value != (1 + ((1 << 3) - 1)))
134 if (value != (1 + ((1 << 3) - 1)) + ((1 << 7) - 1))
141 int* codebook_index,
int superblock_index)
145 unsigned block_index,
depth;
148 static const char transitions[3][2] = { {2, 1}, {0, 2}, {1, 0} };
149 *codebook_index = transitions[*codebook_index][
get_bits1(gb)];
157 block_index = depth ?
get_bits(gb, depth) : 0;
159 if (*codebook_index == 1) {
173 uint32_t *dst = sb->
pixels32 + index + (index & -4);
181 uint16_t* src,
unsigned src_stride)
185 for (y = 0; y < 8; y++)
186 memcpy(dest + y * dest_stride, src + y * src_stride,
187 sizeof(uint16_t) * 8);
189 for (y = 0; y < 8; y++)
190 memset(dest + y * dest_stride, 0,
sizeof(uint16_t) * 8);
194 0x4, 0x8, 0x40, 0x80,
195 0x100, 0x200, 0x1000, 0x2000,
196 0x400, 0x800, 0x4000, 0x8000};
199 void *
data,
int *data_size,
202 const uint8_t *buf = avpkt->
data;
203 int buf_size = avpkt->
size;
207 unsigned frame_flags, frame_size;
210 unsigned superblock_index, cb_index = 1,
211 superblock_col_index = 0,
212 superblocks_per_row = avctx->
width / 8, skip = -1;
214 uint16_t* old_frame_data, *new_frame_data;
215 unsigned old_stride, new_stride;
231 if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
240 for (i = 0; i < 3; i++) {
241 if (frame_flags & (1 << (17 + i))) {
242 unsigned cb_depth, cb_size;
247 cb_depth = av_log2(cb_size - 1) + 1;
253 cb_size = 1 << cb_depth;
274 new_frame_data = (uint16_t*)new_frame.
data[0];
275 new_stride = new_frame.
linesize[0] / 2;
276 old_frame_data = (uint16_t*)s->
frame.
data[0];
280 superblock_index++) {
283 unsigned multi_mask = 0;
293 old_frame_data, old_stride);
296 old_frame_data, old_stride);
303 for (i = 0; i < 16; i++) {
311 unsigned inv_mask =
get_bits(&gb, 4);
312 for (i = 0; i < 4; i++) {
313 if (inv_mask & (1 << i)) {
314 multi_mask ^= 0xF << i*4;
316 multi_mask ^=
get_bits(&gb, 4) << i*4;
320 for (i = 0; i < 16; i++) {
329 }
else if (frame_flags & (1 << 16)) {
339 superblock_col_index++;
343 if (superblock_col_index == superblocks_per_row) {
344 new_frame_data += new_stride * 8 - superblocks_per_row * 8;
346 old_frame_data += old_stride * 8 - superblocks_per_row * 8;
347 superblock_col_index = 0;
353 "Escape sizes: %i, %i, %i\n",
int(* get_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called at the beginning of each frame to get a buffer for it.
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
static const uint16_t mask_matrix[]
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
union MacroBlock MacroBlock
union SuperBlock SuperBlock
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)
static void copy_superblock(uint16_t *dest, unsigned dest_stride, uint16_t *src, unsigned src_stride)
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static int init(AVCodecParserContext *s)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_left(GetBitContext *gb)
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]
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
static av_cold int escape124_decode_close(AVCodecContext *avctx)
int width
picture width / height.
struct AVFrame AVFrame
Audio Video Frame.
AVCodec ff_escape124_decoder
struct Escape124Context Escape124Context
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static unsigned int get_bits1(GetBitContext *s)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int escape124_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_cold int escape124_decode_init(AVCodecContext *avctx)
Initialize the decoder.
static MacroBlock decode_macroblock(Escape124Context *s, GetBitContext *gb, int *codebook_index, int superblock_index)