63 12, 12, 15, 19, 25, 34, 40, 48,
64 12, 12, 18, 22, 27, 44, 47, 46,
65 17, 18, 21, 26, 35, 46, 52, 47,
66 18, 20, 24, 28, 40, 61, 59, 51,
67 20, 24, 32, 43, 50, 72, 72, 63,
68 25, 31, 42, 48, 58, 72, 81, 75,
69 38, 46, 54, 61, 71, 84, 88, 85,
70 50, 61, 65, 68, 79, 78, 86, 91,
74 12, 16, 24, 47, 99, 99, 99, 99,
75 16, 21, 26, 66, 99, 99, 99, 99,
76 24, 26, 56, 99, 99, 99, 99, 99,
77 47, 66, 99, 99, 99, 99, 99, 99,
78 99, 99, 99, 99, 99, 99, 99, 99,
79 99, 99, 99, 99, 99, 99, 99, 99,
80 99, 99, 99, 99, 99, 99, 99, 99,
81 99, 99, 99, 99, 99, 99, 99, 99,
85 0, 1, 8, 9, 16, 2, 3, 10,
86 17, 24, 32, 25, 18, 11, 4, 5,
87 12, 19, 26, 33, 40, 48, 41, 34,
88 27, 20, 13, 6, 7, 14, 21, 28,
89 35, 42, 49, 56, 57, 50, 43, 36,
90 29, 22, 15, 23, 30, 37, 44, 51,
91 58, 59, 52, 45, 38, 31, 39, 46,
92 53, 60, 61, 54, 47, 55, 62, 63,
97 int factor = quant < 50 ? 5000 /
FFMAX(quant, 1) : 200 -
FFMIN(quant, 100) * 2;
99 for (
int i = 0;
i < 64;
i++) {
100 table[
i] = av_clip((quant_tab[
i] * factor + 0x32) / 100, 1, 0x7fff);
107 const unsigned t0 = blk[0 * step] + blk[4 * step];
108 const unsigned t1 = blk[0 * step] - blk[4 * step];
109 const unsigned t2 = blk[2 * step] + blk[6 * step];
110 const unsigned t3 = ((
int)((blk[2 * step] - blk[6 * step]) * 362
U) >> 8) -
t2;
111 const unsigned t4 = t0 +
t2;
112 const unsigned t5 = t0 -
t2;
113 const unsigned t6 = t1 +
t3;
114 const unsigned t7 = t1 -
t3;
115 const unsigned t8 = blk[5 * step] + blk[3 * step];
116 const unsigned t9 = blk[5 * step] - blk[3 * step];
117 const unsigned tA = blk[1 * step] + blk[7 * step];
118 const unsigned tB = blk[1 * step] - blk[7 * step];
119 const unsigned tC = t8 + tA;
120 const unsigned tD = (
int)((tB + t9) * 473
U) >> 8;
121 const unsigned tE = (((
int)(t9 * -669
U) >> 8) - tC) + tD;
122 const unsigned tF = ((
int)((tA - t8) * 362
U) >> 8) - tE;
123 const unsigned t10 = (((
int)(tB * 277
U) >> 8) - tD) + tF;
125 blk[0 * step] = t4 + tC;
126 blk[1 * step] = t6 + tE;
127 blk[2 * step] = t7 + tF;
128 blk[3 * step] = t5 -
t10;
129 blk[4 * step] = t5 +
t10;
130 blk[5 * step] = t7 - tF;
131 blk[6 * step] = t6 - tE;
132 blk[7 * step] = t4 - tC;
137 for (
int i = 0;
i < 8;
i++) {
138 if ((block[0x08 +
i] |
144 block[0x38 +
i]) == 0) {
145 block[0x08 +
i] = block[
i];
146 block[0x10 +
i] = block[
i];
147 block[0x18 +
i] = block[
i];
148 block[0x20 +
i] = block[
i];
149 block[0x28 +
i] = block[
i];
150 block[0x30 +
i] = block[
i];
151 block[0x38 +
i] = block[
i];
157 for (
int i = 0;
i < 8;
i++) {
159 for (
int j = 0; j < 8; j++)
160 dst[j] = av_clip_uint8((block[j] >> 5) + 128);
169 for (
int i = 0;
i < 8;
i++) {
170 if ((block[0x08 +
i] |
176 block[0x38 +
i]) == 0) {
177 block[0x08 +
i] = block[
i];
178 block[0x10 +
i] = block[
i];
179 block[0x18 +
i] = block[
i];
180 block[0x20 +
i] = block[
i];
181 block[0x28 +
i] = block[
i];
182 block[0x30 +
i] = block[
i];
183 block[0x38 +
i] = block[
i];
189 for (
int i = 0;
i < 8;
i++) {
191 for (
int j = 0; j < 8; j++)
192 dst[j] = av_clip_uint8((block[j] >> 5) + src[j]);
201 const unsigned int t0 = blk[0 * step];
202 const unsigned int t1 = blk[1 * step];
203 const unsigned int t2 = (
int)(t1 * 473
U) >> 8;
204 const unsigned int t3 = t2 -
t1;
205 const unsigned int t4 = ((
int)(t1 * 362U) >> 8) - t3;
206 const unsigned int t5 = (((
int)(t1 * 277U) >> 8) - t2) +
t4;
208 blk[0 * step] = t1 +
t0;
209 blk[1 * step] = t0 +
t3;
210 blk[2 * step] = t4 +
t0;
211 blk[3 * step] = t0 -
t5;
212 blk[4 * step] = t5 +
t0;
213 blk[5 * step] = t0 -
t4;
214 blk[6 * step] = t0 -
t3;
215 blk[7 * step] = t0 -
t1;
220 for (
int i = 0;
i < 2;
i++) {
221 if ((block[0x08 +
i]) == 0) {
222 block[0x08 +
i] = block[
i];
223 block[0x10 +
i] = block[
i];
224 block[0x18 +
i] = block[
i];
225 block[0x20 +
i] = block[
i];
226 block[0x28 +
i] = block[
i];
227 block[0x30 +
i] = block[
i];
228 block[0x38 +
i] = block[
i];
234 for (
int i = 0;
i < 8;
i++) {
236 for (
int j = 0; j < 8; j++)
237 dst[j] = av_clip_uint8((block[0] >> 5) + 128);
240 for (
int j = 0; j < 8; j++)
241 dst[j] = av_clip_uint8((block[j] >> 5) + 128);
252 for (
int i = 0;
i < 2;
i++) {
253 if ((block[0x08 +
i]) == 0) {
254 block[0x08 +
i] = block[
i];
255 block[0x10 +
i] = block[
i];
256 block[0x18 +
i] = block[
i];
257 block[0x20 +
i] = block[
i];
258 block[0x28 +
i] = block[
i];
259 block[0x30 +
i] = block[
i];
260 block[0x38 +
i] = block[
i];
266 for (
int i = 0;
i < 8;
i++) {
268 for (
int j = 0; j < 8; j++)
269 dst[j] = av_clip_uint8((block[0] >> 5) + src[j]);
272 for (
int j = 0; j < 8; j++)
273 dst[j] = av_clip_uint8((block[j] >> 5) + src[j]);
285 for (
int i = 0;
i < 8;
i++) {
286 for (
int j = 0; j < 8; j++)
287 dst[j] = av_clip_uint8(block + src[j]);
295 int *
block,
int *pfill,
308 block[0] = ((
int)((
unsigned)pfill[0] * qtab[0]) >> 5) + 128;
312 memset(block, 0,
sizeof(*block) * 64);
315 block[0] = (unsigned)pfill[0] * qtab[0];
324 block[0] = (unsigned)pfill[0] * qtab[0];
325 for (
int i = 1;
i < 64;
i++)
336 int *
block,
int *pfill,
349 block[0] = (
int)((
unsigned)pfill[0] * qtab[0]) >> 5;
353 memset(block, 0,
sizeof(*block) * 64);
356 block[0] = (unsigned)pfill[0] * qtab[0];
360 idct2_add(dst, linesize, src, in_linesize, block);
365 block[0] = (unsigned)pfill[0] * qtab[0];
366 for (
int i = 1;
i < 64;
i++)
368 idct_add(dst, linesize, src, in_linesize, block);
377 memset(coeffs, 0, nb_codes *
sizeof(*coeffs));
379 for (
int i = 0;
i < nb_codes;) {
388 if (x < (1 << value) / 2) {
389 x = (1 << (value - 1)) + (x & ((1 <<
value) - 1 >> 1));
391 x = -(1 << (value - 1)) - (x & ((1 <<
value) - 1 >> 1));
397 i +=
get_bits(gb, 3 + flag * 3) + 1 + flag * 8;
425 for (
int y = 0; y < avctx->
height; y += 16) {
427 int pfill[3][1] = { {0} };
439 for (
int x = 0; x < avctx->
width; x += 16) {
440 dst[0] = frame->
data[0] + linesize[0] * y + x;
441 dst[1] = frame->
data[0] + linesize[0] * y + x + 8;
442 dst[2] = frame->
data[0] + linesize[0] * (y + 8) + x;
443 dst[3] = frame->
data[0] + linesize[0] * (y + 8) + x + 8;
444 dst[4] = frame->
data[1] + linesize[4] * (y >> 1) + (x >> 1);
445 dst[5] = frame->
data[2] + linesize[5] * (y >> 1) + (x >> 1);
447 for (
int b = 0;
b < 6;
b++) {
452 pfill[(
b >= 4) + (
b >= 5)],
453 dst[
b], linesize[b]);
470 const int mask_size = ((avctx->
height >> 4) * (avctx->
width >> 4) * 2 + 7) / 8;
508 for (
int y = 0; y < avctx->
height; y += 16) {
510 int pfill[3][1] = { {0} };
531 for (
int x = 0; x < avctx->
width; x += 16) {
542 dst[0] = frame->
data[0] + linesize[0] * y + x;
543 dst[1] = frame->
data[0] + linesize[0] * y + x + 8;
544 dst[2] = frame->
data[0] + linesize[0] * (y + 8) + x;
545 dst[3] = frame->
data[0] + linesize[0] * (y + 8) + x + 8;
546 dst[4] = frame->
data[1] + linesize[4] * (y >> 1) + (x >> 1);
547 dst[5] = frame->
data[2] + linesize[5] * (y >> 1) + (x >> 1);
549 if ((flags >> (cnt)) & 1) {
560 src[0] = prev->
data[0] + in_linesize[0] * py + px;
561 src[1] = prev->
data[0] + in_linesize[0] * py + px + 8;
562 src[2] = prev->
data[0] + in_linesize[0] * (py + 8) + px;
563 src[3] = prev->
data[0] + in_linesize[0] * (py + 8) + px + 8;
564 src[4] = prev->
data[1] + in_linesize[4] * (py >> 1) + (px >> 1);
565 src[5] = prev->
data[2] + in_linesize[5] * (py >> 1) + (px >> 1);
567 if ((flags >> (cnt + 4)) & 1) {
568 for (
int b = 0;
b < 6;
b++)
569 copy_block8(dst[
b], src[b], linesize[b], in_linesize[b], 8);
571 for (
int b = 0;
b < 6;
b++) {
576 pfill[(
b >= 4) + (
b >= 5)],
578 src[b], in_linesize[b]);
584 for (
int b = 0;
b < 6;
b++) {
589 pfill[(
b >= 4) + (
b >= 5)],
590 dst[
b], linesize[b]);
658 0, 1, 4, 5, 6, 0xE, 0x1E, 0x3E, 0x7E, 0xFE, 0x1FE, 0x1FF,
662 2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9, 9,
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static const uint8_t cbp_bits[]
This structure describes decoded (raw) audio or video data.
static void flush(AVCodecContext *avctx)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static av_cold int init(AVCodecContext *avctx)
static const uint8_t zigzag[]
enum AVColorRange color_range
MPEG vs JPEG YUV range.
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
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...
static const uint16_t cbp_codes[]
static void idct_add(uint8_t *dst, int stride, const uint8_t *src, int in_linesize, int *block)
static void copy_block8(uint8_t *dst, const uint8_t *src, ptrdiff_t dstStride, ptrdiff_t srcStride, int h)
static int get_sbits(GetBitContext *s, int n)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static void idct_1d(unsigned *blk, int step)
int16_t interq_tab[2][64]
const uint16_t ff_aanscales[64]
bitstream reader API header.
static void idct2_add(uint8_t *dst, int stride, const uint8_t *src, int in_linesize, int *block)
static const uint16_t table[]
static int get_bits_left(GetBitContext *gb)
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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 bytestream2_get_ne16
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void idct_put(uint8_t *dst, int stride, int *block)
const char * name
Name of the codec implementation.
int16_t intraq_tab[2][64]
static int decode_coeffs(GetBitContext *gb, int16_t *coeffs, int nb_codes)
static av_cold int decode_init(AVCodecContext *avctx)
static void get_qtable(int16_t *table, int quant, const uint8_t *quant_tab)
unsigned int mvectors_size
int width
picture width / height.
static av_cold void init_static_data(void)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static const uint8_t chroma_tab[]
#define FF_ARRAY_ELEMS(a)
the normal 2^n-1 "JPEG" YUV ranges
static int decode_inter_block(AVCodecContext *avctx, int mode, GetByteContext *gbyte, int16_t *qtab, int *block, int *pfill, uint8_t *dst, int linesize, const uint8_t *src, int in_linesize)
static const int8_t mv[256][2]
#define INIT_VLC_SPARSE_STATIC(vlc, bits, a, b, c, d, e, f, g, h, i, j, static_size)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int decode_intra_block(AVCodecContext *avctx, int mode, GetByteContext *gbyte, int16_t *qtab, int *block, int *pfill, uint8_t *dst, int linesize)
static int decode_inter(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame, AVFrame *prev)
static const int factor[16]
static av_const int sign_extend(int val, unsigned bits)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define flags(name, subs,...)
static unsigned int get_bits_le(GetBitContext *s, int n)
AAN (Arai, Agui and Nakajima) (I)DCT tables.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void decode_flush(AVCodecContext *avctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void idct2_1d(int *blk, int step)
common internal api header.
static av_cold int decode_close(AVCodecContext *avctx)
static void update_inter_block(uint8_t *dst, int stride, const uint8_t *src, int in_linesize, int block)
static const uint8_t luma_tab[]
static void idct2_put(uint8_t *dst, int stride, int *block)
static int ff_thread_once(char *control, void(*routine)(void))
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static int decode_intra(AVCodecContext *avctx, GetBitContext *gb, AVFrame *frame)
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.
mode
Use these values in ebur128_init (or'ed).
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
op_fill_func fill_block_tab[2]