FFmpeg  4.0
Macros | Functions | Variables
snowenc.c File Reference
#include "libavutil/intmath.h"
#include "libavutil/libm.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "internal.h"
#include "snow_dwt.h"
#include "snow.h"
#include "rangecoder.h"
#include "mathops.h"
#include "mpegvideo.h"
#include "h263.h"

Go to the source code of this file.

Macros

#define P_LEFT   P[1]
 
#define P_TOP   P[2]
 
#define P_TOPRIGHT   P[3]
 
#define P_MEDIAN   P[4]
 
#define P_MV1   P[9]
 
#define FLAG_QPEL   1
 
#define OFFSET(x)   offsetof(SnowContext, x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static av_cold int encode_init (AVCodecContext *avctx)
 
static int pix_sum (uint8_t *pix, int line_size, int w, int h)
 
static int pix_norm1 (uint8_t *pix, int line_size, int w)
 
static int get_penalty_factor (int lambda, int lambda2, int type)
 
static int encode_q_branch (SnowContext *s, int level, int x, int y)
 
static void encode_q_branch2 (SnowContext *s, int level, int x, int y)
 
static int get_dc (SnowContext *s, int mb_x, int mb_y, int plane_index)
 
static int get_block_bits (SnowContext *s, int x, int y, int w)
 
static int get_block_rd (SnowContext *s, int mb_x, int mb_y, int plane_index, uint8_t(*obmc_edged)[MB_SIZE *2])
 
static int get_4block_rd (SnowContext *s, int mb_x, int mb_y, int plane_index)
 
static int encode_subband_c0run (SnowContext *s, SubBand *b, const IDWTELEM *src, const IDWTELEM *parent, int stride, int orientation)
 
static int encode_subband (SnowContext *s, SubBand *b, const IDWTELEM *src, const IDWTELEM *parent, int stride, int orientation)
 
static av_always_inline int check_block (SnowContext *s, int mb_x, int mb_y, int p[3], int intra, uint8_t(*obmc_edged)[MB_SIZE *2], int *best_rd)
 
static av_always_inline int check_block_inter (SnowContext *s, int mb_x, int mb_y, int p0, int p1, uint8_t(*obmc_edged)[MB_SIZE *2], int *best_rd)
 
static av_always_inline int check_4block_inter (SnowContext *s, int mb_x, int mb_y, int p0, int p1, int ref, int *best_rd)
 
static void iterative_me (SnowContext *s)
 
static void encode_blocks (SnowContext *s, int search)
 
static void quantize (SnowContext *s, SubBand *b, IDWTELEM *dst, DWTELEM *src, int stride, int bias)
 
static void dequantize (SnowContext *s, SubBand *b, IDWTELEM *src, int stride)
 
static void decorrelate (SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median)
 
static void correlate (SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median)
 
static void encode_qlogs (SnowContext *s)
 
static void encode_header (SnowContext *s)
 
static void update_last_header_values (SnowContext *s)
 
static int qscale2qlog (int qscale)
 
static int ratecontrol_1pass (SnowContext *s, AVFrame *pict)
 
static void calculate_visual_weight (SnowContext *s, Plane *p)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static av_cold int encode_end (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass snowenc_class
 
AVCodec ff_snow_encoder
 

Macro Definition Documentation

◆ P_LEFT

#define P_LEFT   P[1]

Definition at line 220 of file snowenc.c.

Referenced by encode_q_branch().

◆ P_TOP

#define P_TOP   P[2]

Definition at line 221 of file snowenc.c.

Referenced by encode_q_branch().

◆ P_TOPRIGHT

#define P_TOPRIGHT   P[3]

Definition at line 222 of file snowenc.c.

Referenced by encode_q_branch().

◆ P_MEDIAN

#define P_MEDIAN   P[4]

Definition at line 223 of file snowenc.c.

Referenced by encode_q_branch().

◆ P_MV1

#define P_MV1   P[9]

Definition at line 224 of file snowenc.c.

◆ FLAG_QPEL

#define FLAG_QPEL   1

Definition at line 225 of file snowenc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(SnowContext, x)

Definition at line 1922 of file snowenc.c.

◆ VE

Definition at line 1923 of file snowenc.c.

Function Documentation

◆ encode_init()

static av_cold int encode_init ( AVCodecContext avctx)
static

Definition at line 37 of file snowenc.c.

◆ pix_sum()

static int pix_sum ( uint8_t pix,
int  line_size,
int  w,
int  h 
)
static

Definition at line 163 of file snowenc.c.

Referenced by encode_q_branch().

◆ pix_norm1()

static int pix_norm1 ( uint8_t pix,
int  line_size,
int  w 
)
static

Definition at line 179 of file snowenc.c.

Referenced by encode_q_branch().

◆ get_penalty_factor()

static int get_penalty_factor ( int  lambda,
int  lambda2,
int  type 
)
inlinestatic

Definition at line 195 of file snowenc.c.

Referenced by encode_q_branch(), get_4block_rd(), and get_block_rd().

◆ encode_q_branch()

static int encode_q_branch ( SnowContext s,
int  level,
int  x,
int  y 
)
static

Definition at line 227 of file snowenc.c.

Referenced by encode_blocks(), and iterative_me().

◆ encode_q_branch2()

static void encode_q_branch2 ( SnowContext s,
int  level,
int  x,
int  y 
)
static

Definition at line 455 of file snowenc.c.

Referenced by encode_blocks().

◆ get_dc()

static int get_dc ( SnowContext s,
int  mb_x,
int  mb_y,
int  plane_index 
)
static

Definition at line 511 of file snowenc.c.

Referenced by iterative_me().

◆ get_block_bits()

static int get_block_bits ( SnowContext s,
int  x,
int  y,
int  w 
)
inlinestatic

Definition at line 569 of file snowenc.c.

Referenced by get_4block_rd(), and get_block_rd().

◆ get_block_rd()

static int get_block_rd ( SnowContext s,
int  mb_x,
int  mb_y,
int  plane_index,
uint8_t(*)  obmc_edged[MB_SIZE *2] 
)
static

Definition at line 607 of file snowenc.c.

Referenced by check_block().

◆ get_4block_rd()

static int get_4block_rd ( SnowContext s,
int  mb_x,
int  mb_y,
int  plane_index 
)
static

Definition at line 708 of file snowenc.c.

Referenced by check_4block_inter(), and iterative_me().

◆ encode_subband_c0run()

static int encode_subband_c0run ( SnowContext s,
SubBand b,
const IDWTELEM src,
const IDWTELEM parent,
int  stride,
int  orientation 
)
static

Definition at line 777 of file snowenc.c.

Referenced by encode_subband().

◆ encode_subband()

static int encode_subband ( SnowContext s,
SubBand b,
const IDWTELEM src,
const IDWTELEM parent,
int  stride,
int  orientation 
)
static

Definition at line 897 of file snowenc.c.

Referenced by encode_frame().

◆ check_block()

static av_always_inline int check_block ( SnowContext s,
int  mb_x,
int  mb_y,
int  p[3],
int  intra,
uint8_t(*)  obmc_edged[MB_SIZE *2],
int best_rd 
)
static

Definition at line 904 of file snowenc.c.

Referenced by check_block_inter(), and iterative_me().

◆ check_block_inter()

static av_always_inline int check_block_inter ( SnowContext s,
int  mb_x,
int  mb_y,
int  p0,
int  p1,
uint8_t(*)  obmc_edged[MB_SIZE *2],
int best_rd 
)
static

Definition at line 945 of file snowenc.c.

Referenced by iterative_me().

◆ check_4block_inter()

static av_always_inline int check_4block_inter ( SnowContext s,
int  mb_x,
int  mb_y,
int  p0,
int  p1,
int  ref,
int best_rd 
)
static

Definition at line 950 of file snowenc.c.

Referenced by iterative_me().

◆ iterative_me()

static void iterative_me ( SnowContext s)
static

Definition at line 996 of file snowenc.c.

Referenced by encode_blocks().

◆ encode_blocks()

static void encode_blocks ( SnowContext s,
int  search 
)
static

Definition at line 1223 of file snowenc.c.

Referenced by encode_frame().

◆ quantize()

static void quantize ( SnowContext s,
SubBand b,
IDWTELEM dst,
DWTELEM src,
int  stride,
int  bias 
)
static

Definition at line 1245 of file snowenc.c.

Referenced by encode_frame().

◆ dequantize()

static void dequantize ( SnowContext s,
SubBand b,
IDWTELEM src,
int  stride 
)
static

Definition at line 1306 of file snowenc.c.

Referenced by encode_frame().

◆ decorrelate()

static void decorrelate ( SnowContext s,
SubBand b,
IDWTELEM src,
int  stride,
int  inverse,
int  use_median 
)
static

Definition at line 1328 of file snowenc.c.

Referenced by encode_frame(), and ratecontrol_1pass().

◆ correlate()

static void correlate ( SnowContext s,
SubBand b,
IDWTELEM src,
int  stride,
int  inverse,
int  use_median 
)
static

Definition at line 1352 of file snowenc.c.

Referenced by encode_frame().

◆ encode_qlogs()

static void encode_qlogs ( SnowContext s)
static

Definition at line 1376 of file snowenc.c.

Referenced by encode_header().

◆ encode_header()

static void encode_header ( SnowContext s)
static

Definition at line 1389 of file snowenc.c.

Referenced by encode_frame().

◆ update_last_header_values()

static void update_last_header_values ( SnowContext s)
static

Definition at line 1462 of file snowenc.c.

Referenced by encode_frame().

◆ qscale2qlog()

static int qscale2qlog ( int  qscale)
static

< 64 > 60

Definition at line 1482 of file snowenc.c.

Referenced by encode_frame(), and ratecontrol_1pass().

◆ ratecontrol_1pass()

static int ratecontrol_1pass ( SnowContext s,
AVFrame pict 
)
static

Definition at line 1487 of file snowenc.c.

Referenced by encode_frame().

◆ calculate_visual_weight()

static void calculate_visual_weight ( SnowContext s,
Plane p 
)
static

Definition at line 1539 of file snowenc.c.

Referenced by encode_frame().

◆ encode_frame()

static int encode_frame ( AVCodecContext avctx,
AVPacket pkt,
const AVFrame pict,
int got_packet 
)
static

Definition at line 1565 of file snowenc.c.

◆ encode_end()

static av_cold int encode_end ( AVCodecContext avctx)
static

Definition at line 1910 of file snowenc.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{"motion_est", "motion estimation algorithm", OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_ITER, VE, "motion_est" },
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, VE, "motion_est" },
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, VE, "motion_est" },
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, VE, "motion_est" },
{ "iter", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ITER }, 0, 0, VE, "motion_est" },
{ "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "no_bitstream", "Skip final bitstream writeout.", OFFSET(no_bitstream), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
{ "intra_penalty", "Penalty for intra blocks in block decission", OFFSET(intra_penalty), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "iterative_dia_size", "Dia size for the iterative ME", OFFSET(iterative_dia_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
{ "sc_threshold", "Scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, VE },
{ "pred", "Spatial decomposition type", OFFSET(pred), AV_OPT_TYPE_INT, { .i64 = 0 }, DWT_97, DWT_53, VE, "pred" },
{ "dwt97", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, VE, "pred" },
{ "dwt53", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, VE, "pred" },
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define FF_ME_ZERO
Definition: motion_est.h:40
#define OFFSET(x)
Definition: snowenc.c:1922
#define DWT_97
Definition: snow_dwt.h:68
#define VE
Definition: snowenc.c:1923
static const float pred[4]
Definition: siprdata.h:259
#define FF_ME_XONE
Definition: motion_est.h:42
#define FF_ME_EPZS
Definition: motion_est.h:41
#define FF_ME_ITER
Definition: snow.h:38
#define DWT_53
Definition: snow_dwt.h:69

Definition at line 1924 of file snowenc.c.

◆ snowenc_class

const AVClass snowenc_class
static
Initial value:
= {
.class_name = "snow encoder",
.item_name = av_default_item_name,
.option = options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static const AVOption options[]
Definition: snowenc.c:1924

Definition at line 1941 of file snowenc.c.

◆ ff_snow_encoder

AVCodec ff_snow_encoder
Initial value:
= {
.name = "snow",
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
.priv_data_size = sizeof(SnowContext),
.encode2 = encode_frame,
.close = encode_end,
.pix_fmts = (const enum AVPixelFormat[]){
},
.priv_class = &snowenc_class,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE |
}
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
static const AVClass snowenc_class
Definition: snowenc.c:1941
static av_cold int encode_end(AVCodecContext *avctx)
Definition: snowenc.c:1910
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
Definition: snowenc.c:1565
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:68
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62
Y , 8bpp.
Definition: pixfmt.h:70
static av_cold int encode_init(AVCodecContext *avctx)
Definition: snowenc.c:37
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60

Definition at line 1948 of file snowenc.c.