Go to the documentation of this file.
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++)
182 off = x * 16 + y * 16 *
c->pic->linesize[0];
183 for (
i = 0;
i < 4;
i++) {
186 if (!x && !(
i & 1)) {
187 c->block[0] +=
c->top_dc[0];
188 c->top_dc[0] =
c->block[0];
190 c->block[0] +=
c->left_dc[(
i & 2) >> 1];
192 c->left_dc[(
i & 2) >> 1] =
c->block[0];
193 c->block[0] *=
c->luma_dc_quant;
196 off +=
c->pic->linesize[0] * 8;
197 c->idsp.put_pixels_clamped(
c->block,
198 c->pic->data[0] + off + (
i & 1) * 8,
199 c->pic->linesize[0]);
202 off = x * 8 + y * 8 *
c->pic->linesize[1];
203 for (
i = 1;
i < 3;
i++) {
207 c->block[0] +=
c->top_dc[
i];
208 c->top_dc[
i] =
c->block[0];
210 c->block[0] +=
c->left_dc[
i + 1];
212 c->left_dc[
i + 1] =
c->block[0];
213 c->block[0] *=
c->chroma_dc_quant;
215 c->idsp.put_pixels_clamped(
c->block,
c->pic->data[
i] + off,
216 c->pic->linesize[
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 ||
239 sstride =
src->linesize[plane];
241 soff = sx + sy * sstride;
242 sbuf =
src->data[plane];
243 doff = x + y * dstride;
244 dbuf = dst->
data[plane];
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;
264 int sstride =
src->linesize[plane];
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++) {
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)) {
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)) {
416 int plane,
int x,
int y,
int dx,
int dy,
int size,
int bias)
430 int plane,
int x,
int y,
int size,
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;
468 int size =
comp == 0 ? tile_size : tile_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++) {
491 framebuf[off +
i] = 0x80;
503 int buf_size = avpkt->
size;
512 int skip = bytestream2_get_byte(&gb);
522 if (buf_size < c->mb_width *
c->mb_height) {
530 c->pic->key_frame = 1;
533 bytestream2_get_be32(&gb);
534 c->ac_quant = bytestream2_get_byte(&gb);
535 c->luma_dc_quant = 32;
536 c->chroma_dc_quant = 32;
542 for (
i = 0;
i < 3;
i++)
547 for (j = 0; j <
c->mb_height; j++) {
548 for (
i = 0;
i <
c->mb_width;
i++) {
572 mvi_reset(&
c->mvi,
c->pmb_width,
c->pmb_height, 1 <<
c->tile_shift);
574 for (j = 0; j <
c->pmb_height; j++) {
575 for (
i = 0;
i <
c->pmb_width;
i++) {
581 for (plane = 0; plane < 3; plane++) {
582 int16_t x = plane == 0 ?
i <<
c->tile_shift :
i << (
c->tile_shift - 1);
583 int16_t y = plane == 0 ? j <<
c->tile_shift : j << (
c->tile_shift - 1);
584 int16_t
size = plane == 0 ? 1 <<
c->tile_shift : 1 << (
c->tile_shift - 1);
585 int16_t mx = plane == 0 ?
mv.x :
mv.x / 2;
586 int16_t my = plane == 0 ?
mv.y :
mv.y / 2;
593 int x =
i <<
c->tile_shift;
594 int y = j <<
c->tile_shift;
595 int size = 1 <<
c->tile_shift;
606 x =
i << (
c->tile_shift - 1);
607 y = j << (
c->tile_shift - 1);
608 size = 1 << (
c->tile_shift - 1);
609 cmv.
x =
mv.x + tile->
mv.
x;
610 cmv.
y =
mv.y + tile->
mv.
y;
634 c->pic->key_frame = 0;
648 return mb_ret < 0 ? mb_ret : buf_size;
668 if (1
U <<
c->tile_shift !=
c->tile_size ||
c->tile_shift < 1 ||
c->tile_shift > 30) {
669 av_log(avctx,
AV_LOG_ERROR,
"Tile size: %d, is not power of 2 > 1 and < 2^31\n",
c->tile_size);
685 c->pmb_width = (
w +
c->tile_size - 1) >>
c->tile_shift;
686 c->pmb_height = (
h +
c->tile_size - 1) >>
c->tile_shift;
689 c->mvi.mv =
av_calloc(
c->pmb_width * 2,
sizeof(*
c->mvi.mv));
690 if (!
c->pic || !
c->prev || !
c->mvi.mv)
857 c->ylev[0].mv_esc = 0x0909;
858 c->ylev[1].mv_esc = 0x0A0A;
859 c->ylev[2].mv_esc = 0x1010;
860 c->ylev[3].mv_esc = 0x1313;
861 c->ulev[1].mv_esc = 0x0808;
862 c->ulev[2].mv_esc = 0x0B0B;
863 c->vlev[1].mv_esc = 0x0808;
864 c->vlev[2].mv_esc = 0x0B0B;
866 c->ylev[1].bias_esc = 0x100;
867 c->ylev[2].bias_esc = 0x100;
868 c->ylev[3].bias_esc = 0x100;
869 c->ulev[1].bias_esc = 0x100;
870 c->ulev[2].bias_esc = 0x100;
871 c->vlev[1].bias_esc = 0x100;
872 c->vlev[2].bias_esc = 0x100;
889 for (
i = 0;
i < 4;
i++) {
894 for (
i = 0;
i < 3;
i++) {
907 .
name =
"clearvideo",
static const uint16_t clv_mvy_0_codes[]
#define AV_LOG_WARNING
Something somehow does not look correct.
#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 uint16_t clv_biasy_2_codes[]
static const uint8_t clv_dc_bits[NUM_DC_CODES]
static av_cold int init(AVCodecContext *avctx)
static const uint8_t clv_flagsv_0_bits[]
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 clv_biasu_1_codes[]
static const uint16_t clv_mvy_2_codes[]
AVCodec ff_clearvideo_decoder
static const uint16_t clv_mvu_1_codes[]
#define FFSWAP(type, a, b)
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
static const uint16_t clv_flagsv_0_codes[]
#define MKTAG(a, b, c, d)
static const uint16_t clv_biasy_1_codes[]
static const int8_t mv[256][2]
static const uint16_t clv_mvu_2_codes[]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int dx, int dy, int size, int bias)
This structure describes decoded (raw) audio or video data.
#define init_vlc(vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static const uint16_t clv_biasy_3_codes[]
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 clv_mvu_1_bits[]
static const uint16_t clv_flagsu_1_codes[]
static const uint16_t clv_flagsy_0_codes[]
static av_cold int clv_decode_init(AVCodecContext *avctx)
static const uint16_t clv_flagsv_1_codes[]
static const uint8_t clv_ac_codes[NUM_AC_CODES]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static const uint16_t clv_biasy_2_syms[]
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static const uint8_t clv_mvv_1_bits[]
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static void extend_edges(AVFrame *buf, int tile_size)
static int decode_mb(CLVContext *c, int x, int y)
static const uint8_t clv_mvy_1_bits[]
static const uint16_t clv_mvu_2_syms[]
static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff)
static const uint16_t clv_biasv_2_syms[]
static double val(void *priv, double ch)
static const uint16_t clv_mvu_1_syms[]
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
#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 clv_mvv_2_codes[]
struct TileInfo * child[4]
static const uint16_t clv_biasv_1_syms[]
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static void clv_dct(int16_t *block)
static const uint16_t clv_mvy_3_syms[]
static const uint8_t clv_flagsu_0_bits[]
static int get_sbits(GetBitContext *s, int n)
static const uint16_t clv_mvy_1_syms[]
void ff_free_vlc(VLC *vlc)
static const uint16_t clv_mvv_1_syms[]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static const uint8_t clv_mvy_0_bits[]
static const uint16_t clv_biasv_2_codes[]
static const uint8_t clv_flagsu_1_bits[]
static const uint16_t clv_mvy_3_codes[]
static const uint16_t clv_biasu_2_codes[]
static const uint16_t clv_mvv_1_codes[]
static const uint8_t clv_biasu_1_bits[]
@ AV_PICTURE_TYPE_I
Intra.
static unsigned int get_bits1(GetBitContext *s)
static const uint8_t clv_mvy_2_bits[]
static const uint16_t clv_flagsy_1_codes[]
static av_cold int clv_decode_end(AVCodecContext *avctx)
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 void mvi_update_row(MVInfo *mvi)
static const uint8_t clv_flagsv_1_bits[]
static const uint8_t clv_mvu_2_bits[]
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static av_always_inline int bytestream2_tell(GetByteContext *g)
static int clv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const uint16_t clv_biasu_2_syms[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
static int restore_tree(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int size, TileInfo *tile, MV root_mv)
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_syms[]
static const uint8_t clv_biasy_1_bits[]
static int copy_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src, int plane, int x, int y, int dx, int dy, int size)
static const uint16_t clv_mvv_2_syms[]
static const uint8_t clv_flagsy_0_bits[]
#define DECLARE_ALIGNED(n, t, v)
static const uint8_t clv_biasv_1_bits[]
static const uint8_t clv_flagsy_2_bits[]
#define i(width, name, range_min, range_max)
static void pred_mv(DiracBlock *block, int stride, int x, int y, int ref)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static const uint8_t clv_mvy_3_bits[]
static const uint8_t clv_biasu_2_bits[]
static const uint16_t clv_flagsu_0_codes[]
static const uint8_t clv_ac_bits[NUM_AC_CODES]
static const uint8_t clv_mvv_2_bits[]
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
const char * name
Name of the codec implementation.
static const uint16_t clv_flagsy_2_codes[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static const uint16_t clv_biasy_3_syms[]
const uint8_t ff_zigzag_direct[64]
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.
static const uint16_t clv_mvy_2_syms[]
#define FF_ARRAY_ELEMS(a)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
static int decode_block(CLVContext *ctx, int16_t *blk, int has_ac, int ac_quant)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static const uint16_t clv_mvy_1_codes[]
#define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP)
static const uint16_t clv_mvy_0_syms[]
static const uint8_t clv_dc_codes[NUM_DC_CODES]
static const uint8_t clv_biasy_2_bits[]
static int shift(int a, int b)
int coded_width
Bitstream width / height, may be different from width/height e.g.
@ AV_PICTURE_TYPE_P
Predicted.
static const uint16_t clv_biasv_1_codes[]
static const uint8_t clv_biasy_3_bits[]
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 void mvi_reset(MVInfo *mvi, int mb_w, int mb_h, int mb_size)
static TileInfo * decode_tile_info(GetBitContext *gb, LevelCodes *lc, int level)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
This structure stores compressed data.
int width
picture width / height.
static const uint8_t clv_biasv_2_bits[]
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define flags(name, subs,...)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
The exact code depends on how similar the blocks are and how related they are to the block
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const uint8_t clv_flagsy_1_bits[]
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)
static const uint16_t clv_ac_syms[NUM_AC_CODES]
static const uint16_t clv_biasu_1_syms[]