33 #define NUM_DC_CODES 127
34 #define NUM_AC_CODES 103
37 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
38 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
39 0x10, 0x11, 0x12, 0x13, 0x13, 0x14, 0x07, 0x0B,
40 0x0C, 0x08, 0x08, 0x09, 0x04, 0x06, 0x07, 0x05,
41 0x04, 0x05, 0x04, 0x06, 0x05, 0x06, 0x07, 0x05,
42 0x06, 0x07, 0x06, 0x07, 0x08, 0x06, 0x07, 0x08,
43 0x09, 0x0A, 0x0B, 0x07, 0x08, 0x09, 0x07, 0x08,
44 0x06, 0x07, 0x08, 0x06, 0x04, 0x05, 0x02, 0x01,
45 0x03, 0x06, 0x07, 0x07, 0x09, 0x0A, 0x0B, 0x09,
46 0x0A, 0x0B, 0x0A, 0x0B, 0x0C, 0x0D, 0x0C, 0x09,
47 0x0D, 0x0A, 0x0B, 0x08, 0x09, 0x0A, 0x0B, 0x07,
48 0x08, 0x09, 0x0A, 0x0B, 0x06, 0x07, 0x06, 0x08,
49 0x07, 0x09, 0x0A, 0x0B, 0x09, 0x0A, 0x0B, 0x0C,
50 0x14, 0x0D, 0x0D, 0x0E, 0x0F, 0x15, 0x15, 0x16,
51 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E,
52 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
56 22, 22, 22, 22, 22, 22, 22, 22,
57 22, 22, 22, 22, 22, 22, 22, 22,
58 22, 22, 22, 21, 22, 22, 19, 20,
59 20, 19, 18, 18, 15, 17, 17, 16,
60 14, 15, 12, 13, 14, 14, 14, 12,
61 12, 12, 11, 11, 11, 10, 10, 10,
62 10, 10, 10, 9, 9, 9, 8, 8,
63 7, 7, 7, 6, 5, 5, 3, 1,
64 3, 5, 5, 6, 7, 7, 7, 8,
65 8, 8, 9, 9, 9, 9, 10, 11,
66 10, 11, 11, 12, 12, 12, 12, 13,
67 14, 14, 14, 14, 15, 15, 16, 17,
68 16, 17, 18, 18, 19, 19, 19, 19,
69 21, 19, 20, 19, 19, 21, 22, 22,
70 22, 22, 22, 22, 22, 22, 22, 22,
71 22, 22, 22, 22, 22, 22, 22,
75 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
76 0x0009, 0x000A, 0x000B, 0x000C, 0x0011, 0x0012, 0x0013, 0x0014,
77 0x0015, 0x0016, 0x0021, 0x0022, 0x0023, 0x0024, 0x0031, 0x0032,
78 0x0033, 0x0041, 0x0042, 0x0043, 0x0051, 0x0052, 0x0053, 0x0061,
79 0x0062, 0x0063, 0x0071, 0x0072, 0x0081, 0x0082, 0x0091, 0x0092,
80 0x00A1, 0x00A2, 0x00B1, 0x00C1, 0x00D1, 0x00E1, 0x00F1, 0x0101,
81 0x0111, 0x0121, 0x0131, 0x0141, 0x0151, 0x0161, 0x0171, 0x0181,
82 0x0191, 0x01A1, 0x1001, 0x1002, 0x1003, 0x1011, 0x1012, 0x1021,
83 0x1031, 0x1041, 0x1051, 0x1061, 0x1071, 0x1081, 0x1091, 0x10A1,
84 0x10B1, 0x10C1, 0x10D1, 0x10E1, 0x10F1, 0x1101, 0x1111, 0x1121,
85 0x1131, 0x1141, 0x1151, 0x1161, 0x1171, 0x1181, 0x1191, 0x11A1,
86 0x11B1, 0x11C1, 0x11D1, 0x11E1, 0x11F1, 0x1201, 0x1211, 0x1221,
87 0x1231, 0x1241, 0x1251, 0x1261, 0x1271, 0x1281, 0x1BFF,
91 0x02, 0x0F, 0x15, 0x17, 0x1F, 0x25, 0x24, 0x21,
92 0x20, 0x07, 0x06, 0x20, 0x06, 0x14, 0x1E, 0x0F,
93 0x21, 0x50, 0x0E, 0x1D, 0x0E, 0x51, 0x0D, 0x23,
94 0x0D, 0x0C, 0x22, 0x52, 0x0B, 0x0C, 0x53, 0x13,
95 0x0B, 0x54, 0x12, 0x0A, 0x11, 0x09, 0x10, 0x08,
96 0x16, 0x55, 0x15, 0x14, 0x1C, 0x1B, 0x21, 0x20,
97 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x22, 0x23,
98 0x56, 0x57, 0x07, 0x19, 0x05, 0x0F, 0x04, 0x0E,
99 0x0D, 0x0C, 0x13, 0x12, 0x11, 0x10, 0x1A, 0x19,
100 0x18, 0x17, 0x16, 0x15, 0x14, 0x13, 0x18, 0x17,
101 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x07, 0x06,
102 0x05, 0x04, 0x24, 0x25, 0x26, 0x27, 0x58, 0x59,
103 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x03,
107 2, 4, 6, 7, 8, 9, 9, 10,
108 10, 11, 11, 11, 3, 6, 8, 10,
109 11, 12, 4, 8, 10, 12, 5, 9,
110 10, 5, 9, 12, 5, 10, 12, 6,
111 10, 12, 6, 10, 6, 10, 6, 10,
112 7, 12, 7, 7, 8, 8, 9, 9,
113 9, 9, 9, 9, 9, 9, 11, 11,
114 12, 12, 4, 9, 11, 6, 11, 6,
115 6, 6, 7, 7, 7, 7, 8, 8,
116 8, 8, 8, 8, 8, 8, 9, 9,
117 9, 9, 9, 9, 9, 9, 10, 10,
118 10, 10, 11, 11, 11, 11, 12, 12,
119 12, 12, 12, 12, 12, 12, 7,
138 int idx = 1, last = 0,
val, skip;
140 memset(blk, 0,
sizeof(*blk) * 64);
149 while (idx < 64 && !last) {
155 skip = (
val >> 4) & 0xFF;
166 val = ac_quant * (2 * aval + 1);
178 return (idx <= 64 && last) ? 0 : -1;
181 #define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP) \
182 const int t0 = OP( 2841 * blk[1 * step] + 565 * blk[7 * step]); \
183 const int t1 = OP( 565 * blk[1 * step] - 2841 * blk[7 * step]); \
184 const int t2 = OP( 1609 * blk[5 * step] + 2408 * blk[3 * step]); \
185 const int t3 = OP( 2408 * blk[5 * step] - 1609 * blk[3 * step]); \
186 const int t4 = OP( 1108 * blk[2 * step] - 2676 * blk[6 * step]); \
187 const int t5 = OP( 2676 * blk[2 * step] + 1108 * blk[6 * step]); \
188 const int t6 = ((blk[0 * step] + blk[4 * step]) * (1 << dshift)) + bias; \
189 const int t7 = ((blk[0 * step] - blk[4 * step]) * (1 << dshift)) + bias; \
190 const int t8 = t0 + t2; \
191 const int t9 = t0 - t2; \
192 const int tA = (int)(181U * (t9 + (t1 - t3)) + 0x80) >> 8; \
193 const int tB = (int)(181U * (t9 - (t1 - t3)) + 0x80) >> 8; \
194 const int tC = t1 + t3; \
196 blk[0 * step] = (t6 + t5 + t8) >> shift; \
197 blk[1 * step] = (t7 + t4 + tA) >> shift; \
198 blk[2 * step] = (t7 - t4 + tB) >> shift; \
199 blk[3 * step] = (t6 - t5 + tC) >> shift; \
200 blk[4 * step] = (t6 - t5 - tC) >> shift; \
201 blk[5 * step] = (t7 - t4 - tB) >> shift; \
202 blk[6 * step] = (t7 + t4 - tA) >> shift; \
203 blk[7 * step] = (t6 + t5 - t8) >> shift; \
206 #define COP(x) (((x) + 4) >> 3)
214 for (i = 0; i < 8; i++) {
220 for (i = 0; i < 8; i++) {
232 for (i = 0; i < 6; i++)
236 for (i = 0; i < 4; i++) {
239 if (!x && !(i & 1)) {
255 for (i = 1; i < 3; i++) {
278 int buf_size = avpkt->
size;
288 int skip = bytestream2_get_byte(&gb);
292 frame_type = bytestream2_get_byte(&gb);
294 if (frame_type & 0x2) {
295 if (buf_size < c->mb_width * c->
mb_height) {
306 bytestream2_get_be32(&gb);
307 c->
ac_quant = bytestream2_get_byte(&gb);
315 for (i = 0; i < 3; i++)
317 for (i = 0; i < 4; i++)
335 return mb_ret < 0 ? mb_ret : buf_size;
387 .
name =
"clearvideo",
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static av_cold int clv_decode_init(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static av_cold int init(AVCodecContext *avctx)
static const uint8_t clv_ac_codes[NUM_AC_CODES]
int ff_init_vlc_sparse(VLC *vlc_arg, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
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)
static int get_sbits(GetBitContext *s, int n)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
static const uint8_t clv_dc_bits[NUM_DC_CODES]
static av_cold int clv_decode_end(AVCodecContext *avctx)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static int decode_mb(CLVContext *c, int x, int y)
static const uint8_t clv_dc_codes[NUM_DC_CODES]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
bitstream reader API header.
static void clv_dct(int16_t *block)
void(* put_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define init_vlc(vlc, nb_bits, nb_codes,bits, bits_wrap, bits_size,codes, codes_wrap, codes_size,flags)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
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. ...
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static int clv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
static int decode_block(CLVContext *ctx, int16_t *blk, int has_ac, int ac_quant)
static av_always_inline int bytestream2_tell(GetByteContext *g)
#define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP)
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.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static unsigned int get_bits1(GetBitContext *s)
const uint8_t ff_zigzag_direct[64]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
AVCodec ff_clearvideo_decoder
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
#define MKTAG(a, b, c, d)
static const uint16_t clv_ac_syms[NUM_AC_CODES]
This structure stores compressed data.
void ff_free_vlc(VLC *vlc)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const uint8_t clv_ac_bits[NUM_AC_CODES]