FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
proresenc_anatoliy.c File Reference

Apple ProRes encoder (Anatoliy Wasserman version) Known FOURCCs: 'ap4h' (444), 'apch' (HQ), 'apcn' (422), 'apcs' (LT), 'acpo' (Proxy) More...

#include "avcodec.h"
#include "dct.h"
#include "internal.h"
#include "proresdata.h"
#include "put_bits.h"
#include "bytestream.h"
#include "fdctdsp.h"

Go to the source code of this file.

Data Structures

struct  ProresContext
 

Macros

#define DEFAULT_SLICE_MB_WIDTH   8
 
#define FF_PROFILE_PRORES_PROXY   0
 
#define FF_PROFILE_PRORES_LT   1
 
#define FF_PROFILE_PRORES_STANDARD   2
 
#define FF_PROFILE_PRORES_HQ   3
 
#define FF_PROFILE_PRORES_444   4
 
#define QSCALE(qmat, ind, val)   ((val) / ((qmat)[ind]))
 
#define TO_GOLOMB(val)   (((val) << 1) ^ ((val) >> 31))
 
#define DIFF_SIGN(val, sign)   (((val) >> 31) ^ (sign))
 
#define IS_NEGATIVE(val)   ((((val) >> 31) ^ -1) + 1)
 
#define TO_GOLOMB2(val, sign)   ((val)==0 ? 0 : ((val) << 1) + (sign))
 
#define FIRST_DC_CB   0xB8
 

Functions

static void encode_codeword (PutBitContext *pb, int val, int codebook)
 
static av_always_inline int get_level (int val)
 
static void encode_dc_coeffs (PutBitContext *pb, int16_t *in, int blocks_per_slice, int *qmat)
 
static void encode_ac_coeffs (PutBitContext *pb, int16_t *in, int blocks_per_slice, int *qmat)
 
static void get (uint8_t *pixels, int stride, int16_t *block)
 
static void fdct_get (FDCTDSPContext *fdsp, uint8_t *pixels, int stride, int16_t *block)
 
static void calc_plane_dct (FDCTDSPContext *fdsp, uint8_t *src, int16_t *blocks, int src_stride, int mb_count, int chroma, int is_422)
 
static int encode_slice_plane (int16_t *blocks, int mb_count, uint8_t *buf, unsigned buf_size, int *qmat, int sub_sample_chroma)
 
static av_always_inline unsigned encode_slice_data (AVCodecContext *avctx, int16_t *blocks_y, int16_t *blocks_u, int16_t *blocks_v, unsigned mb_count, uint8_t *buf, unsigned data_size, unsigned *y_data_size, unsigned *u_data_size, unsigned *v_data_size, int qp)
 
static void subimage_with_fill (uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height)
 
static int encode_slice (AVCodecContext *avctx, const AVFrame *pic, int mb_x, int mb_y, unsigned mb_count, uint8_t *buf, unsigned data_size, int unsafe, int *qp)
 
static int prores_encode_picture (AVCodecContext *avctx, const AVFrame *pic, uint8_t *buf, const int buf_size)
 
static int prores_encode_frame (AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
 
static void scale_mat (const uint8_t *src, int *dst, int scale)
 
static av_cold int prores_encode_init (AVCodecContext *avctx)
 
static av_cold int prores_encode_close (AVCodecContext *avctx)
 

Variables

static const AVProfile profiles []
 
static const int qp_start_table [5] = { 8, 3, 2, 1, 1}
 
static const int qp_end_table [5] = { 13, 9, 6, 6, 5}
 
static const int bitrate_table [5] = { 1000, 2100, 3500, 5400, 7000}
 
static const uint8_t QMAT_LUMA [5][64]
 
static const uint8_t QMAT_CHROMA [5][64]
 
static const uint8_t dc_codebook [7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}
 
static const uint8_t run_to_cb [16]
 
static const uint8_t lev_to_cb [10]
 
AVCodec ff_prores_aw_encoder
 
AVCodec ff_prores_encoder
 

Detailed Description

Apple ProRes encoder (Anatoliy Wasserman version) Known FOURCCs: 'ap4h' (444), 'apch' (HQ), 'apcn' (422), 'apcs' (LT), 'acpo' (Proxy)

Definition in file proresenc_anatoliy.c.

Macro Definition Documentation

#define DEFAULT_SLICE_MB_WIDTH   8

Definition at line 38 of file proresenc_anatoliy.c.

Referenced by encode_slice(), prores_encode_init(), and prores_encode_picture().

#define FF_PROFILE_PRORES_PROXY   0

Definition at line 40 of file proresenc_anatoliy.c.

Referenced by prores_encode_init().

#define FF_PROFILE_PRORES_LT   1

Definition at line 41 of file proresenc_anatoliy.c.

#define FF_PROFILE_PRORES_STANDARD   2

Definition at line 42 of file proresenc_anatoliy.c.

Referenced by prores_encode_init().

#define FF_PROFILE_PRORES_HQ   3

Definition at line 43 of file proresenc_anatoliy.c.

Referenced by prores_encode_init().

#define FF_PROFILE_PRORES_444   4

Definition at line 44 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame(), and prores_encode_init().

#define QSCALE (   qmat,
  ind,
  val 
)    ((val) / ((qmat)[ind]))

Definition at line 198 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs(), and encode_dc_coeffs().

#define TO_GOLOMB (   val)    (((val) << 1) ^ ((val) >> 31))

Definition at line 199 of file proresenc_anatoliy.c.

Referenced by encode_dc_coeffs().

#define DIFF_SIGN (   val,
  sign 
)    (((val) >> 31) ^ (sign))

Definition at line 200 of file proresenc_anatoliy.c.

Referenced by encode_dc_coeffs().

#define IS_NEGATIVE (   val)    ((((val) >> 31) ^ -1) + 1)

Definition at line 201 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs().

#define TO_GOLOMB2 (   val,
  sign 
)    ((val)==0 ? 0 : ((val) << 1) + (sign))

Definition at line 202 of file proresenc_anatoliy.c.

Referenced by encode_dc_coeffs().

#define FIRST_DC_CB   0xB8

Definition at line 210 of file proresenc_anatoliy.c.

Referenced by encode_dc_coeffs().

Function Documentation

static void encode_codeword ( PutBitContext pb,
int  val,
int  codebook 
)
static

Definition at line 170 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs(), and encode_dc_coeffs().

static av_always_inline int get_level ( int  val)
static

Definition at line 204 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs(), and encode_dc_coeffs().

static void encode_dc_coeffs ( PutBitContext pb,
int16_t *  in,
int  blocks_per_slice,
int qmat 
)
static

Definition at line 214 of file proresenc_anatoliy.c.

Referenced by encode_slice_plane().

static void encode_ac_coeffs ( PutBitContext pb,
int16_t *  in,
int  blocks_per_slice,
int qmat 
)
static

Definition at line 245 of file proresenc_anatoliy.c.

Referenced by encode_slice_plane().

static void get ( uint8_t pixels,
int  stride,
int16_t *  block 
)
static

Definition at line 276 of file proresenc_anatoliy.c.

static void fdct_get ( FDCTDSPContext fdsp,
uint8_t pixels,
int  stride,
int16_t *  block 
)
static

Definition at line 288 of file proresenc_anatoliy.c.

Referenced by calc_plane_dct().

static void calc_plane_dct ( FDCTDSPContext fdsp,
uint8_t src,
int16_t *  blocks,
int  src_stride,
int  mb_count,
int  chroma,
int  is_422 
)
static

Definition at line 294 of file proresenc_anatoliy.c.

Referenced by encode_slice().

static int encode_slice_plane ( int16_t *  blocks,
int  mb_count,
uint8_t buf,
unsigned  buf_size,
int qmat,
int  sub_sample_chroma 
)
static

Definition at line 331 of file proresenc_anatoliy.c.

Referenced by encode_slice_data().

static av_always_inline unsigned encode_slice_data ( AVCodecContext avctx,
int16_t *  blocks_y,
int16_t *  blocks_u,
int16_t *  blocks_v,
unsigned  mb_count,
uint8_t buf,
unsigned  data_size,
unsigned *  y_data_size,
unsigned *  u_data_size,
unsigned *  v_data_size,
int  qp 
)
static

Definition at line 346 of file proresenc_anatoliy.c.

Referenced by encode_slice().

static void subimage_with_fill ( uint16_t *  src,
unsigned  x,
unsigned  y,
unsigned  stride,
unsigned  width,
unsigned  height,
uint16_t *  dst,
unsigned  dst_width,
unsigned  dst_height 
)
static

Definition at line 369 of file proresenc_anatoliy.c.

Referenced by encode_slice().

static int encode_slice ( AVCodecContext avctx,
const AVFrame pic,
int  mb_x,
int  mb_y,
unsigned  mb_count,
uint8_t buf,
unsigned  data_size,
int  unsafe,
int qp 
)
static

Definition at line 399 of file proresenc_anatoliy.c.

Referenced by prores_encode_picture().

static int prores_encode_picture ( AVCodecContext avctx,
const AVFrame pic,
uint8_t buf,
const int  buf_size 
)
static

Definition at line 481 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

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

Definition at line 529 of file proresenc_anatoliy.c.

static void scale_mat ( const uint8_t src,
int dst,
int  scale 
)
static

Definition at line 576 of file proresenc_anatoliy.c.

Referenced by prores_encode_init().

static av_cold int prores_encode_init ( AVCodecContext avctx)
static

Definition at line 583 of file proresenc_anatoliy.c.

static av_cold int prores_encode_close ( AVCodecContext avctx)
static

Definition at line 663 of file proresenc_anatoliy.c.

Variable Documentation

const AVProfile profiles[]
static
Initial value:
= {
}
#define FF_PROFILE_PRORES_PROXY
#define FF_PROFILE_PRORES_444
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:2860
#define FF_PROFILE_PRORES_STANDARD
#define FF_PROFILE_PRORES_HQ
#define FF_PROFILE_PRORES_LT

Definition at line 46 of file proresenc_anatoliy.c.

const int qp_start_table[5] = { 8, 3, 2, 1, 1}
static

Definition at line 55 of file proresenc_anatoliy.c.

Referenced by encode_slice(), and prores_encode_picture().

const int qp_end_table[5] = { 13, 9, 6, 6, 5}
static

Definition at line 56 of file proresenc_anatoliy.c.

Referenced by encode_slice().

const int bitrate_table[5] = { 1000, 2100, 3500, 5400, 7000}
static

Definition at line 57 of file proresenc_anatoliy.c.

Referenced by encode_slice().

const uint8_t QMAT_LUMA[5][64]
static

Definition at line 59 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame(), and prores_encode_init().

const uint8_t QMAT_CHROMA[5][64]
static

Definition at line 108 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame(), and prores_encode_init().

const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}
static

Definition at line 212 of file proresenc_anatoliy.c.

Referenced by encode_dc_coeffs().

const uint8_t run_to_cb[16]
static
Initial value:
= { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }

Definition at line 240 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs().

const uint8_t lev_to_cb[10]
static
Initial value:
= { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
0x28, 0x28, 0x28, 0x4C }

Definition at line 242 of file proresenc_anatoliy.c.

Referenced by encode_ac_coeffs().

AVCodec ff_prores_aw_encoder
Initial value:
= {
.name = "prores_aw",
.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"),
.priv_data_size = sizeof(ProresContext),
.encode2 = prores_encode_frame,
.profiles = profiles
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int prores_encode_init(AVCodecContext *avctx)
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1054
static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int prores_encode_close(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1024
static const AVProfile profiles[]
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64

Definition at line 671 of file proresenc_anatoliy.c.

AVCodec ff_prores_encoder
Initial value:
= {
.name = "prores",
.long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"),
.priv_data_size = sizeof(ProresContext),
.encode2 = prores_encode_frame,
.profiles = profiles
}
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static av_cold int prores_encode_init(AVCodecContext *avctx)
#define AV_CODEC_CAP_INTRA_ONLY
Codec is intra only.
Definition: avcodec.h:1054
static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int prores_encode_close(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:1024
static const AVProfile profiles[]
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64

Definition at line 685 of file proresenc_anatoliy.c.