FFmpeg
Data Structures | Macros | Functions | Variables
clearvideo.c File Reference
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "idctdsp.h"
#include "mathops.h"
#include "clearvideodata.h"

Go to the source code of this file.

Data Structures

struct  LevelCodes
 
struct  MV
 
struct  MVInfo
 
struct  CLVContext
 

Macros

#define CLV_VLC_BITS   9
 
#define DCT_TEMPLATE(blk, step, bias, shift, dshift, OP)
 
#define ROP(x)   x
 
#define COP(x)   (((x) + 4) >> 3)
 

Functions

static int decode_block (CLVContext *ctx, int16_t *blk, int has_ac, int ac_quant)
 
static void clv_dct (int16_t *block)
 
static int decode_mb (CLVContext *c, int x, int y)
 
static int copy_block (AVCodecContext *avctx, AVFrame *dst, const AVFrame *src, int plane, int x, int y, int dx, int dy, int size)
 
static int copyadd_block (AVCodecContext *avctx, AVFrame *dst, const AVFrame *src, int plane, int x, int y, int dx, int dy, int size, int bias)
 
static MVmvi_predict (MVInfo *mvi, int mb_x, int mb_y)
 
static void mvi_update_prediction (MV *mv, MV diff)
 
static void mvi_reset (MVInfo *mvi, int mb_w, int mb_h, int mb_size)
 
static void mvi_update_row (MVInfo *mvi)
 
static int tile_do_block (AVCodecContext *avctx, AVFrame *dst, const AVFrame *src, int plane, int x, int y, int dx, int dy, int size, int bias)
 
static int decode_tile (AVCodecContext *avctx, GetBitContext *gb, const LevelCodes *lc, AVFrame *dst, const AVFrame *src, int plane, int x, int y, int size, MV root_mv, MV *pred)
 
static void extend_edges (AVFrame *buf, int tile_size)
 
static int clv_decode_frame (AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
 
static av_cold void build_vlc (VLC *vlc, const uint8_t counts[16], const uint16_t **syms, unsigned *offset)
 
static av_cold void clv_init_static (void)
 
static av_cold int clv_decode_init (AVCodecContext *avctx)
 
static av_cold int clv_decode_end (AVCodecContext *avctx)
 

Variables

static const MV zero_mv = { 0 }
 
static VLC dc_vlc
 
static VLC ac_vlc
 
static LevelCodes lev [4+3+3]
 
static VLCElem vlc_buf [16716]
 
const FFCodec ff_clearvideo_decoder
 

Detailed Description

ClearVideo decoder

Definition in file clearvideo.c.

Macro Definition Documentation

◆ CLV_VLC_BITS

#define CLV_VLC_BITS   9

Definition at line 39 of file clearvideo.c.

◆ DCT_TEMPLATE

#define DCT_TEMPLATE (   blk,
  step,
  bias,
  shift,
  dshift,
  OP 
)
Value:
const int t0 = OP(2841 * blk[1 * step] + 565 * blk[7 * step]); \
const int t1 = OP( 565 * blk[1 * step] - 2841 * blk[7 * step]); \
const int t2 = OP(1609 * blk[5 * step] + 2408 * blk[3 * step]); \
const int t3 = OP(2408 * blk[5 * step] - 1609 * blk[3 * step]); \
const int t4 = OP(1108 * blk[2 * step] - 2676 * blk[6 * step]); \
const int t5 = OP(2676 * blk[2 * step] + 1108 * blk[6 * step]); \
const int t6 = ((blk[0 * step] + blk[4 * step]) * (1 << dshift)) + bias; \
const int t7 = ((blk[0 * step] - blk[4 * step]) * (1 << dshift)) + bias; \
const int t8 = t0 + t2; \
const int t9 = t0 - t2; \
const int tA = (int)(181U * (t9 + (t1 - t3)) + 0x80) >> 8; \
const int tB = (int)(181U * (t9 - (t1 - t3)) + 0x80) >> 8; \
const int tC = t1 + t3; \
\
blk[0 * step] = (t6 + t5 + t8) >> shift; \
blk[1 * step] = (t7 + t4 + tA) >> shift; \
blk[2 * step] = (t7 - t4 + tB) >> shift; \
blk[3 * step] = (t6 - t5 + tC) >> shift; \
blk[4 * step] = (t6 - t5 - tC) >> shift; \
blk[5 * step] = (t7 - t4 - tB) >> shift; \
blk[6 * step] = (t7 + t4 - tA) >> shift; \
blk[7 * step] = (t6 + t5 - t8) >> shift; \

Definition at line 126 of file clearvideo.c.

◆ ROP

#define ROP (   x)    x

Definition at line 150 of file clearvideo.c.

◆ COP

#define COP (   x)    (((x) + 4) >> 3)

Definition at line 151 of file clearvideo.c.

Function Documentation

◆ decode_block()

static int decode_block ( CLVContext ctx,
int16_t *  blk,
int  has_ac,
int  ac_quant 
)
inlinestatic

Definition at line 82 of file clearvideo.c.

Referenced by decode_mb().

◆ clv_dct()

static void clv_dct ( int16_t *  block)
static

Definition at line 153 of file clearvideo.c.

Referenced by decode_mb().

◆ decode_mb()

static int decode_mb ( CLVContext c,
int  x,
int  y 
)
static

Definition at line 171 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ copy_block()

static int copy_block ( AVCodecContext avctx,
AVFrame dst,
const AVFrame src,
int  plane,
int  x,
int  y,
int  dx,
int  dy,
int  size 
)
static

Definition at line 218 of file clearvideo.c.

Referenced by clv_decode_frame(), and tile_do_block().

◆ copyadd_block()

static int copyadd_block ( AVCodecContext avctx,
AVFrame dst,
const AVFrame src,
int  plane,
int  x,
int  y,
int  dx,
int  dy,
int  size,
int  bias 
)
static

Definition at line 255 of file clearvideo.c.

Referenced by tile_do_block().

◆ mvi_predict()

static MV* mvi_predict ( MVInfo mvi,
int  mb_x,
int  mb_y 
)
static

Definition at line 293 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ mvi_update_prediction()

static void mvi_update_prediction ( MV mv,
MV  diff 
)
static

Definition at line 339 of file clearvideo.c.

Referenced by decode_tile().

◆ mvi_reset()

static void mvi_reset ( MVInfo mvi,
int  mb_w,
int  mb_h,
int  mb_size 
)
static

Definition at line 345 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ mvi_update_row()

static void mvi_update_row ( MVInfo mvi)
static

Definition at line 355 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ tile_do_block()

static int tile_do_block ( AVCodecContext avctx,
AVFrame dst,
const AVFrame src,
int  plane,
int  x,
int  y,
int  dx,
int  dy,
int  size,
int  bias 
)
static

Definition at line 365 of file clearvideo.c.

Referenced by decode_tile().

◆ decode_tile()

static int decode_tile ( AVCodecContext avctx,
GetBitContext gb,
const LevelCodes lc,
AVFrame dst,
const AVFrame src,
int  plane,
int  x,
int  y,
int  size,
MV  root_mv,
MV pred 
)
static

Definition at line 379 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ extend_edges()

static void extend_edges ( AVFrame buf,
int  tile_size 
)
static

Definition at line 444 of file clearvideo.c.

Referenced by clv_decode_frame().

◆ clv_decode_frame()

static int clv_decode_frame ( AVCodecContext avctx,
AVFrame rframe,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 483 of file clearvideo.c.

◆ build_vlc()

static av_cold void build_vlc ( VLC vlc,
const uint8_t  counts[16],
const uint16_t **  syms,
unsigned *  offset 
)
static

Definition at line 625 of file clearvideo.c.

Referenced by clv_init_static().

◆ clv_init_static()

static av_cold void clv_init_static ( void  )
static

Definition at line 646 of file clearvideo.c.

Referenced by clv_decode_init().

◆ clv_decode_init()

static av_cold int clv_decode_init ( AVCodecContext avctx)
static

Definition at line 679 of file clearvideo.c.

◆ clv_decode_end()

static av_cold int clv_decode_end ( AVCodecContext avctx)
static

Definition at line 729 of file clearvideo.c.

Variable Documentation

◆ zero_mv

const MV zero_mv = { 0 }
static

Definition at line 51 of file clearvideo.c.

Referenced by mvi_predict().

◆ dc_vlc

VLC dc_vlc
static

Definition at line 78 of file clearvideo.c.

Referenced by clv_init_static(), and decode_block().

◆ ac_vlc

VLC ac_vlc
static

Definition at line 78 of file clearvideo.c.

Referenced by clv_init_static(), and decode_block().

◆ lev

LevelCodes lev[4+3+3]
static

◆ vlc_buf

VLCElem vlc_buf[16716]
static

◆ ff_clearvideo_decoder

const FFCodec ff_clearvideo_decoder
Initial value:
= {
.p.name = "clearvideo",
CODEC_LONG_NAME("Iterated Systems ClearVideo"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(CLVContext),
.close = clv_decode_end,
.p.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}

Definition at line 741 of file clearvideo.c.

FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
t0
#define t0
Definition: regdef.h:28
clv_decode_frame
static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
Definition: clearvideo.c:483
t1
#define t1
Definition: regdef.h:29
clv_decode_init
static av_cold int clv_decode_init(AVCodecContext *avctx)
Definition: clearvideo.c:679
OP
#define OP(LOAD, STORE)
Definition: hpeldsp_alpha.c:55
FF_CODEC_DECODE_CB
#define FF_CODEC_DECODE_CB(func)
Definition: codec_internal.h:306
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
t7
#define t7
Definition: regdef.h:35
blk
#define blk(i)
Definition: sha.c:186
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:272
bias
static int bias(int x, int c)
Definition: vqcdec.c:113
t5
#define t5
Definition: regdef.h:33
t6
#define t6
Definition: regdef.h:34
clv_decode_end
static av_cold int clv_decode_end(AVCodecContext *avctx)
Definition: clearvideo.c:729
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
shift
static int shift(int a, int b)
Definition: bonk.c:257
t8
#define t8
Definition: regdef.h:53
t4
#define t4
Definition: regdef.h:32
t3
#define t3
Definition: regdef.h:31
U
#define U(x)
Definition: vpx_arith.h:37
t2
#define t2
Definition: regdef.h:30
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
t9
#define t9
Definition: regdef.h:54
CLVContext
Definition: clearvideo.c:62
AV_CODEC_ID_CLEARVIDEO
@ AV_CODEC_ID_CLEARVIDEO
Definition: codec_id.h:281
int
int
Definition: ffmpeg_filter.c:156