FFmpeg
Loading...
Searching...
No Matches
proresenc_kostya.c File Reference
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "fdctdsp.h"
#include "put_bits.h"
#include "profiles.h"
#include "bytestream.h"
#include "proresdata.h"
#include "proresenc_kostya_common.h"

Go to the source code of this file.

Data Structures

struct  TrellisNode
 
struct  ProresThreadData
 

Macros

#define TRELLIS_WIDTH   16
 
#define SCORE_LIMIT   INT_MAX / 2
 
#define GET_SIGN(x)
 
#define MAKE_CODE(x)
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static void get_slice_data (ProresContext *ctx, const uint16_t *src, ptrdiff_t linesize, int x, int y, int w, int h, int16_t *blocks, uint16_t *emu_buf, int mbs_per_slice, int blocks_per_mb, int is_chroma)
 
static void get_alpha_data (ProresContext *ctx, const uint16_t *src, ptrdiff_t linesize, int x, int y, int w, int h, uint16_t *blocks, int mbs_per_slice, int abits)
 
static void encode_vlc_codeword (PutBitContext *pb, unsigned codebook, int val)
 Write an unsigned rice/exp golomb codeword.
 
static void encode_dcs (PutBitContext *pb, int16_t *blocks, int blocks_per_slice, int scale)
 
static void encode_acs (PutBitContext *pb, int16_t *blocks, int blocks_per_slice, const uint8_t *scan, const int16_t *qmat)
 
static void encode_slice_plane (ProresContext *ctx, PutBitContext *pb, const uint16_t *src, ptrdiff_t linesize, int mbs_per_slice, int16_t *blocks, int blocks_per_mb, const int16_t *qmat)
 
static void put_alpha_diff (PutBitContext *pb, int cur, int prev, int abits)
 
static void put_alpha_run (PutBitContext *pb, int run)
 
static void encode_alpha_plane (ProresContext *ctx, PutBitContext *pb, int mbs_per_slice, uint16_t *blocks, int quant)
 
static int encode_slice (AVCodecContext *avctx, const AVFrame *pic, PutBitContext *pb, int sizes[4], int x, int y, int quant, int mbs_per_slice)
 
static int estimate_vlc (unsigned codebook, int val)
 
static int estimate_dcs (int *error, int16_t *blocks, int blocks_per_slice, int scale)
 
static int estimate_acs (int *error, int16_t *blocks, int blocks_per_slice, const uint8_t *scan, const int16_t *qmat)
 
static int estimate_slice_plane (ProresContext *ctx, int *error, int plane, const uint16_t *src, ptrdiff_t linesize, int mbs_per_slice, int blocks_per_mb, const int16_t *qmat, ProresThreadData *td)
 
static int est_alpha_diff (int cur, int prev, int abits)
 
static int estimate_alpha_plane (ProresContext *ctx, const uint16_t *src, ptrdiff_t linesize, int mbs_per_slice, int16_t *blocks)
 
static int find_slice_quant (AVCodecContext *avctx, int trellis_node, int x, int y, int mbs_per_slice, ProresThreadData *td)
 
static int find_quant_thread (AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 
static int encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic, int *got_packet)
 
static av_cold int encode_close (AVCodecContext *avctx)
 
static void prores_fdct (FDCTDSPContext *fdsp, const uint16_t *src, ptrdiff_t linesize, int16_t *block)
 
static av_cold int encode_init (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVClass proresenc_class
 
const FFCodec ff_prores_ks_encoder
 

Macro Definition Documentation

◆ TRELLIS_WIDTH

#define TRELLIS_WIDTH   16

Definition at line 38 of file proresenc_kostya.c.

Referenced by encode_init(), find_quant_thread(), and find_slice_quant().

◆ SCORE_LIMIT

#define SCORE_LIMIT   INT_MAX / 2

Definition at line 39 of file proresenc_kostya.c.

Referenced by find_slice_quant().

◆ GET_SIGN

#define GET_SIGN ( x)
Value:
((x) >> 31)

Definition at line 187 of file proresenc_kostya.c.

Referenced by encode_acs(), encode_dcs(), and estimate_dcs().

◆ MAKE_CODE

#define MAKE_CODE ( x)
Value:
(((x) * 2) ^ GET_SIGN(x))
#define GET_SIGN(x)

Definition at line 188 of file proresenc_kostya.c.

Referenced by encode_dcs(), and estimate_dcs().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 969 of file proresenc_kostya.c.

◆ VE

Definition at line 970 of file proresenc_kostya.c.

Function Documentation

◆ get_slice_data()

static void get_slice_data ( ProresContext * ctx,
const uint16_t * src,
ptrdiff_t linesize,
int x,
int y,
int w,
int h,
int16_t * blocks,
uint16_t * emu_buf,
int mbs_per_slice,
int blocks_per_mb,
int is_chroma )
static

Definition at line 56 of file proresenc_kostya.c.

Referenced by encode_slice(), and find_slice_quant().

◆ get_alpha_data()

static void get_alpha_data ( ProresContext * ctx,
const uint16_t * src,
ptrdiff_t linesize,
int x,
int y,
int w,
int h,
uint16_t * blocks,
int mbs_per_slice,
int abits )
static

Definition at line 127 of file proresenc_kostya.c.

Referenced by encode_slice(), and find_slice_quant().

◆ encode_vlc_codeword()

static void encode_vlc_codeword ( PutBitContext * pb,
unsigned codebook,
int val )
inlinestatic

Write an unsigned rice/exp golomb codeword.

Definition at line 158 of file proresenc_kostya.c.

Referenced by encode_acs(), and encode_dcs().

◆ encode_dcs()

static void encode_dcs ( PutBitContext * pb,
int16_t * blocks,
int blocks_per_slice,
int scale )
static

Definition at line 190 of file proresenc_kostya.c.

Referenced by encode_slice_plane().

◆ encode_acs()

static void encode_acs ( PutBitContext * pb,
int16_t * blocks,
int blocks_per_slice,
const uint8_t * scan,
const int16_t * qmat )
static

Definition at line 214 of file proresenc_kostya.c.

Referenced by encode_slice_plane().

◆ encode_slice_plane()

static void encode_slice_plane ( ProresContext * ctx,
PutBitContext * pb,
const uint16_t * src,
ptrdiff_t linesize,
int mbs_per_slice,
int16_t * blocks,
int blocks_per_mb,
const int16_t * qmat )
static

Definition at line 244 of file proresenc_kostya.c.

Referenced by encode_slice().

◆ put_alpha_diff()

static void put_alpha_diff ( PutBitContext * pb,
int cur,
int prev,
int abits )
static

Definition at line 256 of file proresenc_kostya.c.

Referenced by encode_alpha_plane().

◆ put_alpha_run()

static void put_alpha_run ( PutBitContext * pb,
int run )
static

Definition at line 275 of file proresenc_kostya.c.

Referenced by encode_alpha_plane().

◆ encode_alpha_plane()

static void encode_alpha_plane ( ProresContext * ctx,
PutBitContext * pb,
int mbs_per_slice,
uint16_t * blocks,
int quant )
static

Definition at line 289 of file proresenc_kostya.c.

Referenced by encode_slice().

◆ encode_slice()

static int encode_slice ( AVCodecContext * avctx,
const AVFrame * pic,
PutBitContext * pb,
int sizes[4],
int x,
int y,
int quant,
int mbs_per_slice )
static

Definition at line 317 of file proresenc_kostya.c.

Referenced by encode_frame().

◆ estimate_vlc()

static int estimate_vlc ( unsigned codebook,
int val )
inlinestatic

Definition at line 397 of file proresenc_kostya.c.

Referenced by estimate_acs(), and estimate_dcs().

◆ estimate_dcs()

static int estimate_dcs ( int * error,
int16_t * blocks,
int blocks_per_slice,
int scale )
static

Definition at line 419 of file proresenc_kostya.c.

Referenced by estimate_slice_plane().

◆ estimate_acs()

static int estimate_acs ( int * error,
int16_t * blocks,
int blocks_per_slice,
const uint8_t * scan,
const int16_t * qmat )
static

Definition at line 448 of file proresenc_kostya.c.

Referenced by estimate_slice_plane().

◆ estimate_slice_plane()

static int estimate_slice_plane ( ProresContext * ctx,
int * error,
int plane,
const uint16_t * src,
ptrdiff_t linesize,
int mbs_per_slice,
int blocks_per_mb,
const int16_t * qmat,
ProresThreadData * td )
static

Definition at line 482 of file proresenc_kostya.c.

Referenced by find_slice_quant().

◆ est_alpha_diff()

static int est_alpha_diff ( int cur,
int prev,
int abits )
static

Definition at line 499 of file proresenc_kostya.c.

Referenced by estimate_alpha_plane().

◆ estimate_alpha_plane()

static int estimate_alpha_plane ( ProresContext * ctx,
const uint16_t * src,
ptrdiff_t linesize,
int mbs_per_slice,
int16_t * blocks )
static

Definition at line 514 of file proresenc_kostya.c.

Referenced by find_slice_quant().

◆ find_slice_quant()

static int find_slice_quant ( AVCodecContext * avctx,
int trellis_node,
int x,
int y,
int mbs_per_slice,
ProresThreadData * td )
static

Definition at line 556 of file proresenc_kostya.c.

Referenced by find_quant_thread().

◆ find_quant_thread()

static int find_quant_thread ( AVCodecContext * avctx,
void * arg,
int jobnr,
int threadnr )
static

Definition at line 720 of file proresenc_kostya.c.

Referenced by encode_frame().

◆ encode_frame()

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

Definition at line 744 of file proresenc_kostya.c.

◆ encode_close()

static av_cold int encode_close ( AVCodecContext * avctx)
static

Definition at line 899 of file proresenc_kostya.c.

◆ prores_fdct()

static void prores_fdct ( FDCTDSPContext * fdsp,
const uint16_t * src,
ptrdiff_t linesize,
int16_t * block )
static

Definition at line 914 of file proresenc_kostya.c.

Referenced by encode_init().

◆ encode_init()

static av_cold int encode_init ( AVCodecContext * avctx)
static

Definition at line 928 of file proresenc_kostya.c.

Variable Documentation

◆ options

const AVOption options[]
static

Definition at line 972 of file proresenc_kostya.c.

◆ proresenc_class

const AVClass proresenc_class
static
Initial value:
= {
.class_name = "ProRes encoder",
.item_name = av_default_item_name,
.option = options,
}
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:241
#define LIBAVUTIL_VERSION_INT
Definition version.h:85

Definition at line 1015 of file proresenc_kostya.c.

◆ ff_prores_ks_encoder

const FFCodec ff_prores_ks_encoder
Initial value:
= {
.p.name = "prores_ks",
CODEC_LONG_NAME("Apple ProRes (iCodec Pro)"),
.p.type = AVMEDIA_TYPE_VIDEO,
.priv_data_size = sizeof(ProresContext),
.color_ranges = AVCOL_RANGE_MPEG,
.p.priv_class = &proresenc_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
static av_cold int encode_init(AVCodecContext *avctx)
Definition asvenc.c:373
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static av_cold int encode_close(AVCodecContext *avctx)
Definition dcaenc.c:354
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static int encode_frame(OutputFile *of, OutputStream *ost, AVFrame *frame, AVPacket *pkt)
Definition ffmpeg_enc.c:694
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition codec.h:102
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition codec.h:98
@ AV_CODEC_ID_PRORES
Definition codec_id.h:198
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548
const AVProfile ff_prores_profiles[]
Definition profiles.c:175
static const AVClass proresenc_class

Definition at line 1022 of file proresenc_kostya.c.