87 int idx = 1, last = 0,
val, skip;
89 memset(blk, 0,
sizeof(*blk) * 64);
98 while (idx < 64 && !last) {
104 skip = (
val >> 4) & 0xFF;
115 val = ac_quant * (2 * aval + 1);
127 return (idx <= 64 && last) ? 0 : -1;
130 #define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP) \
131 const int t0 = OP(2841 * blk[1 * step] + 565 * blk[7 * step]); \
132 const int t1 = OP( 565 * blk[1 * step] - 2841 * blk[7 * step]); \
133 const int t2 = OP(1609 * blk[5 * step] + 2408 * blk[3 * step]); \
134 const int t3 = OP(2408 * blk[5 * step] - 1609 * blk[3 * step]); \
135 const int t4 = OP(1108 * blk[2 * step] - 2676 * blk[6 * step]); \
136 const int t5 = OP(2676 * blk[2 * step] + 1108 * blk[6 * step]); \
137 const int t6 = ((blk[0 * step] + blk[4 * step]) * (1 << dshift)) + bias; \
138 const int t7 = ((blk[0 * step] - blk[4 * step]) * (1 << dshift)) + bias; \
139 const int t8 = t0 + t2; \
140 const int t9 = t0 - t2; \
141 const int tA = (int)(181U * (t9 + (t1 - t3)) + 0x80) >> 8; \
142 const int tB = (int)(181U * (t9 - (t1 - t3)) + 0x80) >> 8; \
143 const int tC = t1 + t3; \
145 blk[0 * step] = (t6 + t5 + t8) >> shift; \
146 blk[1 * step] = (t7 + t4 + tA) >> shift; \
147 blk[2 * step] = (t7 - t4 + tB) >> shift; \
148 blk[3 * step] = (t6 - t5 + tC) >> shift; \
149 blk[4 * step] = (t6 - t5 - tC) >> shift; \
150 blk[5 * step] = (t7 - t4 - tB) >> shift; \
151 blk[6 * step] = (t7 + t4 - tA) >> shift; \
152 blk[7 * step] = (t6 + t5 - t8) >> shift; \
155 #define COP(x) (((x) + 4) >> 3)
163 for (i = 0; i < 8; i++) {
169 for (i = 0; i < 8; i++) {
177 int i, has_ac[6], off;
179 for (i = 0; i < 6; i++)
183 for (i = 0; i < 4; i++) {
186 if (!x && !(i & 1)) {
198 c->
pic->
data[0] + off + (i & 1) * 8,
203 for (i = 1; i < 3; i++) {
223 int plane,
int x,
int y,
int dx,
int dy,
int size)
225 int shift = plane > 0;
228 int sstride, dstride, soff, doff;
232 if (x < 0 || sx < 0 || y < 0 || sy < 0 ||
241 soff = sx + sy * sstride;
243 doff = x + y * dstride;
246 for (i = 0; i <
size; i++) {
250 memcpy(dptr, sptr, size);
259 int plane,
int x,
int y,
int dx,
int dy,
int size,
int bias)
261 int shift = plane > 0;
266 int soff = sx + sy * sstride;
268 int doff = x + y * dstride;
272 if (x < 0 || sx < 0 || y < 0 || sy < 0 ||
279 for (j = 0; j <
size; j++) {
283 for (i = 0; i <
size; i++) {
284 int val = sptr[i] + bias;
286 dptr[i] = av_clip_uint8(val);
299 int left_mv, right_mv, top_mv, bot_mv;
307 }
else if ((mb_x == 0) || (mb_x == mvi->
mb_w - 1)) {
308 pred_mv = mvi->
mv[mb_x];
311 MV B = mvi->
mv[ mb_x ];
312 MV C = mvi->
mv[ mb_x + 1];
319 left_mv = -((mb_x * mvi->
mb_size));
320 right_mv = ((mvi->
mb_w - mb_x - 1) * mvi->
mb_size);
321 if (res.
x < left_mv) {
324 if (res.
x > right_mv) {
327 top_mv = -((mb_y * mvi->
mb_size));
329 if (res.
y < top_mv) {
332 if (res.
y > bot_mv) {
369 if (lc[level].flags_cb.table) {
373 if (lc[level].mv_cb.table) {
376 if (mv_code != lc[level].mv_esc) {
377 mv.
x = (int8_t)(mv_code & 0xff);
378 mv.
y = (int8_t)(mv_code >> 8);
385 if (lc[level].bias_cb.table) {
388 if (bias_val != lc[level].bias_esc) {
389 bias = (int16_t)(bias_val);
404 for (i = 0; i < 4; i++) {
405 if (ti->
flags & (1 << i)) {
407 ti->
child[i] = subti;
416 int plane,
int x,
int y,
int dx,
int dy,
int size,
int bias)
421 ret =
copy_block(avctx, dst, src, plane, x, y, dx, dy, size);
423 ret =
copyadd_block(avctx, dst, src, plane, x, y, dx, dy, size, bias);
436 mv.
x = root_mv.
x + tile->
mv.
x;
437 mv.
y = root_mv.
y + tile->
mv.
y;
442 int i, hsize = size >> 1;
444 for (i = 0; i < 4; i++) {
445 int xoff = (i & 2) == 0 ? 0 : hsize;
446 int yoff = (i & 1) == 0 ? 0 : hsize;
448 if (tile->
child[i]) {
449 ret =
restore_tree(avctx, dst, src, plane, x + xoff, y + yoff, hsize, tile->
child[i], root_mv);
452 ret =
tile_do_block(avctx, dst, src, plane, x + xoff, y + yoff, mv.
x, mv.
y, hsize, tile->
bias);
464 for (comp = 0; comp < 3; comp++) {
465 int shift = comp > 0;
468 int size = comp == 0 ? tile_size : tile_size >> 1;
472 int right = size - (w & (size - 1));
473 int bottom = size - (h & (size - 1));
475 if ((right == size) && (bottom == size)) {
480 for (j = 0; j <
h; j++) {
481 for (i = 0; i < right; i++) {
482 framebuf[off + i] = 0x80;
487 if (bottom != size) {
489 for (j = 0; j < bottom; j++) {
490 for (i = 0; i <
stride; i++) {
491 framebuf[off + i] = 0x80;
503 int buf_size = avpkt->
size;
512 int skip = bytestream2_get_byte(&gb);
516 frame_type = bytestream2_get_byte(&gb);
518 if ((frame_type & 0x7f) == 0x30) {
524 }
else if (frame_type & 0x2) {
525 if (buf_size < c->mb_width * c->
mb_height) {
536 bytestream2_get_be32(&gb);
537 c->
ac_quant = bytestream2_get_byte(&gb);
545 for (i = 0; i < 3; i++)
547 for (i = 0; i < 4; i++)
579 for (plane = 0; plane < 3; plane++) {
583 int16_t mx = plane == 0 ? mv.
x : mv.
x / 2;
584 int16_t my = plane == 0 ? mv.
y : mv.
y / 2;
607 cmv.
x = mv.
x + tile->
mv.
x;
608 cmv.
y = mv.
y + tile->
mv.
y;
643 return mb_ret < 0 ? mb_ret : buf_size;
884 for (i = 0; i < 4; i++) {
889 for (i = 0; i < 3; i++) {
902 .
name =
"clearvideo",
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void mvi_reset(MVInfo *mvi, int mb_w, int mb_h, int mb_size)
static int shift(int a, int b)
static av_cold int clv_decode_init(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static const uint16_t clv_mvu_2_syms[]
static const uint16_t clv_biasy_2_syms[]
static const uint16_t clv_biasv_2_syms[]
int coded_width
Bitstream width / height, may be different from width/height e.g.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static const uint16_t clv_biasv_1_codes[]
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_cold int init(AVCodecContext *avctx)
static const uint8_t clv_flagsy_1_bits[]
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)
static const uint8_t clv_mvy_3_bits[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const uint16_t clv_ac_syms[NUM_AC_CODES]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static const uint16_t clv_biasu_1_syms[]
static const uint8_t clv_mvv_2_bits[]
static const uint8_t clv_flagsy_2_bits[]
static const uint16_t clv_mvv_2_syms[]
static const uint8_t clv_flagsy_0_bits[]
static void mvi_update_row(MVInfo *mvi)
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_ac_bits[NUM_AC_CODES]
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static void extend_edges(AVFrame *buf, int tile_size)
static const uint8_t clv_flagsu_0_bits[]
static av_cold int clv_decode_end(AVCodecContext *avctx)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static const uint8_t clv_flagsu_1_bits[]
static const uint8_t clv_dc_bits[NUM_DC_CODES]
static const uint16_t clv_biasu_2_codes[]
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 uint16_t clv_mvu_2_codes[]
static const uint16_t clv_biasy_3_syms[]
static const uint16_t clv_flagsu_0_codes[]
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
static const uint16_t clv_biasy_1_codes[]
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
static const uint16_t clv_flagsy_2_codes[]
static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int dx, int dy, int size, int bias)
bitstream reader API header.
static void clv_dct(int16_t *block)
static const uint16_t clv_mvy_1_codes[]
static int restore_tree(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int size, TileInfo *tile, MV root_mv)
void(* put_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
struct TileInfo * child[4]
static const uint8_t clv_biasy_3_bits[]
static const uint8_t clv_ac_codes[NUM_AC_CODES]
static const uint8_t clv_biasy_2_bits[]
static const uint8_t clv_mvu_2_bits[]
#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. ...
static void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
static const uint8_t clv_biasy_1_bits[]
const char * name
Name of the codec implementation.
static const uint8_t clv_biasv_2_bits[]
static const uint16_t clv_mvy_0_codes[]
static const uint16_t clv_biasy_1_syms[]
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static const uint8_t clv_mvy_1_bits[]
static const uint16_t clv_mvy_2_codes[]
enum AVPictureType pict_type
Picture type of the frame.
static const uint8_t clv_biasv_1_bits[]
int width
picture width / height.
static int clv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static const uint16_t clv_mvv_2_codes[]
#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 const uint16_t clv_mvy_2_syms[]
static const uint16_t clv_biasu_1_codes[]
static int decode_block(CLVContext *ctx, int16_t *blk, int has_ac, int ac_quant)
#define FF_ARRAY_ELEMS(a)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
static const uint8_t clv_flagsv_0_bits[]
static const int8_t mv[256][2]
static av_always_inline int bytestream2_tell(GetByteContext *g)
#define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP)
static const uint16_t clv_flagsy_0_codes[]
static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff)
static const uint16_t clv_mvy_0_syms[]
Libavcodec external API header.
static const uint8_t clv_dc_codes[NUM_DC_CODES]
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.
static const uint16_t clv_biasy_3_codes[]
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static const uint8_t clv_mvu_1_bits[]
static const uint16_t clv_flagsv_1_codes[]
static const uint8_t clv_biasu_1_bits[]
static unsigned int get_bits1(GetBitContext *s)
static const uint16_t clv_flagsy_1_codes[]
static const uint16_t clv_flagsu_1_codes[]
static int copy_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int dx, int dy, int size)
static const uint8_t clv_mvv_1_bits[]
static const uint16_t clv_biasu_2_syms[]
const uint8_t ff_zigzag_direct[64]
static TileInfo * decode_tile_info(GetBitContext *gb, LevelCodes *lc, int level)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static const uint16_t clv_mvu_1_syms[]
common internal api header.
AVCodec ff_clearvideo_decoder
static const uint16_t clv_biasv_1_syms[]
static const uint8_t clv_biasu_2_bits[]
static const uint16_t clv_mvy_3_syms[]
static const uint16_t clv_biasv_2_codes[]
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const uint16_t clv_biasy_2_codes[]
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
VLC_TYPE(* table)[2]
code, bits
int key_frame
1 -> keyframe, 0-> not
static const uint16_t clv_mvu_1_codes[]
static const uint16_t clv_mvy_1_syms[]
static const uint8_t clv_mvy_2_bits[]
static const uint16_t clv_flagsv_0_codes[]
static const uint16_t clv_mvv_1_syms[]
static const uint16_t clv_mvy_3_codes[]
#define FFSWAP(type, a, b)
static const uint8_t clv_flagsv_1_bits[]
static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int dx, int dy, int size, int bias)
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
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 uint16_t clv_mvv_1_codes[]
static const uint8_t clv_mvy_0_bits[]