63 1, 2, 2, 2, 3, 3, 3, 4,
64 2, 2, 2, 3, 3, 3, 4, 4,
65 2, 2, 3, 3, 3, 4, 4, 4,
66 2, 2, 3, 3, 3, 4, 4, 5,
67 2, 3, 3, 3, 4, 4, 5, 6,
68 3, 3, 3, 4, 4, 5, 6, 7,
69 3, 3, 3, 4, 4, 5, 7, 7,
70 3, 3, 4, 4, 5, 7, 7, 7,
74 1, 5, 6, 7, 8, 9, 9, 11,
75 5, 5, 7, 8, 9, 9, 11, 12,
76 6, 7, 8, 9, 9, 11, 11, 12,
77 7, 7, 8, 9, 9, 11, 12, 13,
78 7, 8, 9, 9, 10, 11, 13, 16,
79 8, 9, 9, 10, 11, 13, 16, 19,
80 8, 9, 9, 11, 12, 15, 18, 23,
81 9, 9, 11, 12, 15, 18, 23, 27
84static const uint8_t
fic_header[7] = { 0, 0, 1,
'F',
'I',
'C',
'V' };
86#define FIC_HEADER_SIZE 27
87#define CURSOR_OFFSET 59
88#define CURSOR_SIZE 4096
92 const unsigned t0 = 27246 *
blk[3 * step] + 18405 *
blk[5 * step];
93 const unsigned t1 = 27246 *
blk[5 * step] - 18405 *
blk[3 * step];
94 const unsigned t2 = 6393 *
blk[7 * step] + 32139 *
blk[1 * step];
95 const unsigned t3 = 6393 *
blk[1 * step] - 32139 *
blk[7 * step];
96 const unsigned t4 = 5793U * ((int)(t2 + t0 + 0x800) >> 12);
97 const unsigned t5 = 5793U * ((int)(t3 + t1 + 0x800) >> 12);
98 const unsigned t6 = t2 - t0;
99 const unsigned t7 = t3 - t1;
100 const unsigned t8 = 17734 *
blk[2 * step] - 42813 *
blk[6 * step];
101 const unsigned t9 = 17734 *
blk[6 * step] + 42814 *
blk[2 * step];
102 const unsigned tA = (
blk[0 * step] -
blk[4 * step]) * 32768 +
rnd;
103 const unsigned tB = (
blk[0 * step] +
blk[4 * step]) * 32768 +
rnd;
104 blk[0 * step] = (int)( t4 + t9 + tB) >>
shift;
105 blk[1 * step] = (int)( t6 + t7 + t8 + tA) >>
shift;
106 blk[2 * step] = (int)( t6 - t7 - t8 + tA) >>
shift;
107 blk[3 * step] = (int)( t5 - t9 + tB) >>
shift;
108 blk[4 * step] = (int)( -t5 - t9 + tB) >>
shift;
109 blk[5 * step] = (int)(-(t6 - t7) - t8 + tA) >>
shift;
110 blk[6 * step] = (int)(-(t6 + t7) + t8 + tA) >>
shift;
111 blk[7 * step] = (int)( -t4 + t9 + tB) >>
shift;
120 fic_idct(ptr++, 8, 13, (1 << 12) + (1 << 17));
121 for (
i = 1;
i < 8;
i++) {
127 for (
i = 0;
i < 8;
i++) {
133 for (j = 0; j < 8; j++) {
134 for (
i = 0;
i < 8;
i++)
160 for (
i = 0;
i < num_coeff;
i++) {
162 if (v < -2048 || v > 2048)
178 const uint8_t *
src = tctx->
src;
181 int y_off = tctx->
y_off;
188 for (p = 0; p < 3; p++) {
190 uint8_t*
dst =
ctx->frame->data[p] + (y_off >> !!p) *
stride;
192 for (y = 0; y < (slice_h >> !!p); y += 8) {
193 for (x = 0; x < (
ctx->aligned_width >> !!p); x += 8) {
218 int cur_x,
int cur_y)
221 const uint8_t *ptr = cursor_buf;
228 for (
i = 0;
i < 1024;
i++) {
229 planes[0][
i] = (( 25 * ptr[0] + 129 * ptr[1] + 66 * ptr[2]) / 255) + 16;
230 planes[1][
i] = ((-38 * ptr[0] + 112 * ptr[1] + -74 * ptr[2]) / 255) + 128;
231 planes[2][
i] = ((-18 * ptr[0] + 112 * ptr[1] + -94 * ptr[2]) / 255) + 128;
238 for (
i = 0;
i < 32;
i += 2)
239 for (j = 0; j < 32; j += 2)
240 for (p = 0; p < 3; p++)
242 planes[p + 1][32 *
i + j + 1] +
243 planes[p + 1][32 * (
i + 1) + j ] +
244 planes[p + 1][32 * (
i + 1) + j + 1]) / 4;
247 for (
i = 0;
i < 3;
i++)
248 dstptr[
i] =
ctx->final_frame->data[
i] +
249 (
ctx->final_frame->linesize[
i] * (cur_y >> !!
i)) +
250 (cur_x >> !!
i) + !!
i;
255 int csize = lsize / 2;
266 dstptr[0] +=
ctx->final_frame->linesize[0] * 2;
267 dstptr[1] +=
ctx->final_frame->linesize[1];
268 dstptr[2] +=
ctx->final_frame->linesize[2];
276 const uint8_t *
src = avpkt->
data;
282 int skip_cursor =
ctx->skip_cursor;
283 const uint8_t *sdata;
297 if (!
ctx->final_frame->data[0]) {
321 "Packet is too small to contain cursor (%d vs %d bytes).\n",
329 if (!skip_cursor && tsize < 32) {
331 "Cursor data too small. Skipping cursor.\n");
338 if (!skip_cursor && (cur_x > avctx->
width || cur_y > avctx->
height)) {
340 "Invalid cursor position: (%d,%d). Skipping cursor.\n",
347 "Invalid cursor size. Skipping cursor.\n");
355 ctx->slice_h = 16 * (
ctx->aligned_height >> 4) / nslices;
356 if (
ctx->slice_h % 16)
363 if (msize <= ctx->aligned_width/8 * (
ctx->aligned_height/8) / 8) {
370 nslices *
sizeof(
ctx->slice_data[0]));
371 if (!
ctx->slice_data_size) {
375 memset(
ctx->slice_data, 0, nslices *
sizeof(
ctx->slice_data[0]));
377 for (slice = 0; slice < nslices; slice++) {
380 int y_off =
ctx->slice_h * slice;
381 int slice_h =
ctx->slice_h;
387 if (slice == nslices - 1) {
392 if (slice_size < slice_off)
396 if (slice_size < slice_off || slice_size > msize)
399 slice_size -= slice_off;
401 ctx->slice_data[slice].src = sdata + slice_off;
402 ctx->slice_data[slice].src_size = slice_size;
403 ctx->slice_data[slice].slice_h = slice_h;
404 ctx->slice_data[slice].y_off = y_off;
411 NULL, nslices,
sizeof(
ctx->slice_data[0]))) < 0)
416 for (slice = 0; slice < nslices; slice++) {
417 if (
ctx->slice_data[slice].p_frame) {
472 if (!
ctx->final_frame)
484 .class_name =
"FIC decoder",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_fic_decoder
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#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...
common internal and external API header
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
#define FF_REGET_BUFFER_FLAG_READONLY
the returned buffer does not need to be writable
int(* init)(AVBSFContext *ctx)
static const AVClass fic_decoder_class
static int fic_decode_slice(AVCodecContext *avctx, void *tdata)
static av_always_inline void fic_idct(int16_t *blk, int step, int shift, int rnd)
static void fic_idct_put(uint8_t *dst, int stride, int16_t *block)
static int fic_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static const uint8_t fic_qmat_hq[64]
static const uint8_t fic_qmat_lq[64]
static av_cold int fic_decode_close(AVCodecContext *avctx)
static void fic_draw_cursor(AVCodecContext *avctx, const uint8_t cursor_buf[CURSOR_SIZE], int cur_x, int cur_y)
static av_always_inline void fic_alpha_blend(uint8_t *dst, uint8_t *src, int size, uint8_t *alpha)
static av_cold int fic_decode_init(AVCodecContext *avctx)
static int fic_decode_block(FICContext *ctx, GetBitContext *gb, uint8_t *dst, int stride, int16_t *block, int *is_p)
static const uint8_t fic_header[7]
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
#define AV_OPT_FLAG_VIDEO_PARAM
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
int av_frame_replace(AVFrame *dst, const AVFrame *src)
Ensure the destination frame refers to the same data described by the source frame,...
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the 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_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
#define LIBAVUTIL_VERSION_INT
static const int16_t alpha[]
static int shift(int a, int b)
static const struct @257111027162314367033347246032313251342043035002 planes[]
const uint8_t ff_zigzag_direct[64]
Memory handling functions.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Describe the class of an AVClass context structure.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
FICThreadContext * slice_data
enum AVPictureType cur_frame_type
static AVFormatContext * ctx