Go to the documentation of this file.
22 #define BITSTREAM_READER_LE
63 s->num_superblocks = ((unsigned)avctx->
width / 8) *
64 ((unsigned)avctx->
height / 8);
78 for (
i = 0;
i < 3;
i++)
104 unsigned mask_bits =
get_bits(gb, 4);
108 for (j = 0; j < 4; j++) {
109 if (mask_bits & (1 << j))
110 cb.blocks[
i].pixels[j] = color1;
112 cb.blocks[
i].pixels[j] = color0;
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 int8_t transitions[3][2] = { {2, 1}, {0, 2}, {1, 0} };
150 *codebook_index = transitions[*codebook_index][
value];
153 depth =
s->codebooks[*codebook_index].depth;
160 if (*codebook_index == 1) {
161 block_index += superblock_index <<
s->codebooks[1].depth;
166 if (block_index >=
s->codebooks[*codebook_index].size)
169 return s->codebooks[*codebook_index].blocks[block_index];
177 dst[0] =
mb.pixels32[0];
178 dst[4] =
mb.pixels32[1];
182 uint16_t*
src, ptrdiff_t src_stride)
186 for (y = 0; y < 8; y++)
187 memcpy(dest + y * dest_stride,
src + y * src_stride,
188 sizeof(uint16_t) * 8);
190 for (y = 0; y < 8; y++)
191 memset(dest + y * dest_stride, 0,
sizeof(uint16_t) * 8);
195 0x4, 0x8, 0x40, 0x80,
196 0x100, 0x200, 0x1000, 0x2000,
197 0x400, 0x800, 0x4000, 0x8000};
202 int buf_size = avpkt->
size;
209 unsigned superblock_index, cb_index = 1,
210 superblock_col_index = 0,
211 superblocks_per_row = avctx->
width / 8,
skip = -1;
213 uint16_t* old_frame_data, *new_frame_data;
214 ptrdiff_t old_stride, new_stride;
235 if (!(frame_flags & 0x114) || !(frame_flags & 0x7800000)) {
236 if (!
s->frame->data[0])
248 for (
i = 0;
i < 3;
i++) {
249 if (frame_flags & (1 << (17 +
i))) {
250 unsigned cb_depth, cb_size;
259 cb_depth =
av_log2(cb_size - 1) + 1;
265 cb_size = 1 << cb_depth;
270 cb_size =
s->num_superblocks << cb_depth;
273 if (
s->num_superblocks >= INT_MAX >> cb_depth) {
280 if (!
s->codebooks[
i].blocks)
288 new_frame_data = (uint16_t*)
frame->data[0];
289 new_stride =
frame->linesize[0] / 2;
290 old_frame_data = (uint16_t*)
s->frame->data[0];
291 old_stride =
s->frame->linesize[0] / 2;
293 for (superblock_index = 0; superblock_index <
s->num_superblocks;
294 superblock_index++) {
297 unsigned multi_mask = 0;
307 old_frame_data, old_stride);
310 old_frame_data, old_stride);
317 for (
i = 0;
i < 16;
i++) {
325 unsigned inv_mask =
get_bits(&gb, 4);
326 for (
i = 0;
i < 4;
i++) {
327 if (inv_mask & (1 <<
i)) {
328 multi_mask ^= 0xF <<
i*4;
334 for (
i = 0;
i < 16;
i++) {
341 }
else if (frame_flags & (1 << 16)) {
351 superblock_col_index++;
355 if (superblock_col_index == superblocks_per_row) {
356 new_frame_data += new_stride * 8 - superblocks_per_row * 8;
358 old_frame_data += old_stride * 8 - superblocks_per_row * 8;
359 superblock_col_index = 0;
365 "Escape sizes: %i, %i, %i\n",
379 .
p.
name =
"escape124",
static void copy_superblock(uint16_t *dest, ptrdiff_t dest_stride, uint16_t *src, ptrdiff_t src_stride)
static void insert_mb_into_sb(SuperBlock *sb, MacroBlock mb, unsigned index)
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static const uint16_t mask_matrix[]
static double cb(void *priv, double x, double y)
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
static int get_bits_count(const GetBitContext *s)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
static MacroBlock decode_macroblock(Escape124Context *s, GetBitContext *gb, int *codebook_index, int superblock_index)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
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.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static const uint16_t mask[17]
#define FF_CODEC_DECODE_CB(func)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
int(* init)(AVBSFContext *ctx)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define CODEC_LONG_NAME(str)
static int escape124_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
static unsigned int get_bits1(GetBitContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
const FFCodec ff_escape124_decoder
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define i(width, name, range_min, range_max)
static CodeBook unpack_codebook(GetBitContext *gb, unsigned depth, unsigned size)
static av_cold int escape124_decode_close(AVCodecContext *avctx)
#define AV_PIX_FMT_RGB555
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
main external API structure.
static av_cold int escape124_decode_init(AVCodecContext *avctx)
Initialize the decoder.
static av_always_inline int get_bitsz(GetBitContext *s, int n)
Read 0-25 bits.
This structure stores compressed data.
static unsigned decode_skip_count(GetBitContext *gb)
int width
picture width / height.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void BS_FUNC() skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.