FFmpeg
Loading...
Searching...
No Matches
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 "libavutil/avassert.h"
#include "libavutil/mem.h"
#include "libavutil/mem_internal.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "profiles.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 GET_SIGN(x)
 
#define MAKE_CODE(x)
 
#define OFFSET(x)
 
#define VE   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

static int int_from_list_or_default (void *ctx, const char *val_name, int val, const int *array_valid_values, int default_value)
 Check if a value is in the list.
 
static void encode_vlc_codeword (PutBitContext *pb, unsigned codebook, int val)
 
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, int *qmat, const uint8_t *scan)
 
static void get (const uint8_t *pixels, int stride, int16_t *block)
 
static void fdct_get (FDCTDSPContext *fdsp, const uint8_t *pixels, int stride, int16_t *block)
 
static void calc_plane_dct (FDCTDSPContext *fdsp, const 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, const uint8_t *scan)
 
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 put_alpha_diff (PutBitContext *pb, int cur, int prev)
 
static void put_alpha_run (PutBitContext *pb, int run)
 
static av_always_inline int encode_alpha_slice_data (AVCodecContext *avctx, int8_t *src_a, unsigned mb_count, uint8_t *buf, unsigned data_size, unsigned *a_data_size)
 
static void subimage_with_fill_template (const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_alpha_plane, int is_interlaced, int is_top_field)
 
static void subimage_with_fill (const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
 
static void subimage_alpha_with_fill (const uint16_t *src, unsigned x, unsigned y, unsigned stride, unsigned width, unsigned height, uint16_t *dst, unsigned dst_width, unsigned dst_height, int is_interlaced, int is_top_field)
 
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, int is_interlaced, int is_top_field)
 
static int prores_encode_picture (AVCodecContext *avctx, const AVFrame *pic, uint8_t *buf, const int buf_size, const int picture_index, const int is_top_field)
 
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 [] = { 8, 3, 2, 1, 1, 1}
 
static const int qp_end_table [] = { 13, 9, 6, 6, 5, 4}
 
static const int bitrate_table [] = { 1000, 2100, 3500, 5400, 7000, 10000}
 
static const int valid_primaries []
 
static const int valid_trc []
 
static const int valid_colorspace []
 
static const uint8_t QMAT_LUMA [6][64]
 
static const uint8_t QMAT_CHROMA [6][64]
 
static const AVOption options []
 
static const AVClass prores_enc_class
 
static enum AVPixelFormat pix_fmts []
 
const FFCodec ff_prores_aw_encoder
 
const FFCodec 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

◆ DEFAULT_SLICE_MB_WIDTH

#define DEFAULT_SLICE_MB_WIDTH   8

Definition at line 43 of file proresenc_anatoliy.c.

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

◆ GET_SIGN

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

Definition at line 260 of file proresenc_anatoliy.c.

Referenced by encode_acs(), and encode_dcs().

◆ MAKE_CODE

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

Definition at line 261 of file proresenc_anatoliy.c.

Referenced by encode_dcs().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 935 of file proresenc_anatoliy.c.

◆ VE

Definition at line 936 of file proresenc_anatoliy.c.

Function Documentation

◆ int_from_list_or_default()

static int int_from_list_or_default ( void * ctx,
const char * val_name,
int val,
const int * array_valid_values,
int default_value )
static

Check if a value is in the list.

If not, return the default value

Parameters
ctxContext for the log msg
val_nameName of the checked value, for log msg
array_valid_valuesArray of valid int, ended with INT_MAX
default_valueValue return if checked value is not in the array
Returns
Value or default_value.

Definition at line 211 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

◆ encode_vlc_codeword()

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

Definition at line 231 of file proresenc_anatoliy.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 263 of file proresenc_anatoliy.c.

Referenced by encode_slice_plane().

◆ encode_acs()

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

Definition at line 287 of file proresenc_anatoliy.c.

Referenced by encode_slice_plane().

◆ get()

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

◆ fdct_get()

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

Definition at line 330 of file proresenc_anatoliy.c.

Referenced by calc_plane_dct().

◆ calc_plane_dct()

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

Definition at line 336 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ encode_slice_plane()

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

Definition at line 373 of file proresenc_anatoliy.c.

Referenced by encode_slice_data().

◆ 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 389 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ put_alpha_diff()

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

Definition at line 410 of file proresenc_anatoliy.c.

Referenced by encode_alpha_slice_data().

◆ put_alpha_run()

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

Definition at line 430 of file proresenc_anatoliy.c.

Referenced by encode_alpha_slice_data().

◆ encode_alpha_slice_data()

static av_always_inline int encode_alpha_slice_data ( AVCodecContext * avctx,
int8_t * src_a,
unsigned mb_count,
uint8_t * buf,
unsigned data_size,
unsigned * a_data_size )
static

Definition at line 443 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ subimage_with_fill_template()

static void subimage_with_fill_template ( const uint16_t * src,
unsigned x,
unsigned y,
unsigned stride,
unsigned width,
unsigned height,
uint16_t * dst,
unsigned dst_width,
unsigned dst_height,
int is_alpha_plane,
int is_interlaced,
int is_top_field )
inlinestatic

Definition at line 483 of file proresenc_anatoliy.c.

Referenced by subimage_alpha_with_fill(), and subimage_with_fill().

◆ subimage_with_fill()

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

Definition at line 531 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ subimage_alpha_with_fill()

static void subimage_alpha_with_fill ( const uint16_t * src,
unsigned x,
unsigned y,
unsigned stride,
unsigned width,
unsigned height,
uint16_t * dst,
unsigned dst_width,
unsigned dst_height,
int is_interlaced,
int is_top_field )
static

Definition at line 539 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ 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,
int is_interlaced,
int is_top_field )
static

Definition at line 546 of file proresenc_anatoliy.c.

Referenced by prores_encode_picture().

◆ prores_encode_picture()

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

Definition at line 664 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

◆ prores_encode_frame()

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

Definition at line 728 of file proresenc_anatoliy.c.

◆ scale_mat()

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

Definition at line 808 of file proresenc_anatoliy.c.

Referenced by prores_encode_init().

◆ prores_encode_init()

static av_cold int prores_encode_init ( AVCodecContext * avctx)
static

Definition at line 815 of file proresenc_anatoliy.c.

◆ prores_encode_close()

static av_cold int prores_encode_close ( AVCodecContext * avctx)
static

Definition at line 926 of file proresenc_anatoliy.c.

Variable Documentation

◆ profiles

const AVProfile profiles[]
static
Initial value:
= {
}
#define AV_PROFILE_PRORES_STANDARD
Definition defs.h:183
#define AV_PROFILE_PRORES_4444
Definition defs.h:185
#define AV_PROFILE_PRORES_LT
Definition defs.h:182
#define AV_PROFILE_UNKNOWN
Definition defs.h:65
#define AV_PROFILE_PRORES_PROXY
Definition defs.h:181
#define AV_PROFILE_PRORES_XQ
Definition defs.h:186
#define AV_PROFILE_PRORES_HQ
Definition defs.h:184

Definition at line 45 of file proresenc_anatoliy.c.

◆ qp_start_table

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

Definition at line 55 of file proresenc_anatoliy.c.

Referenced by encode_slice(), and prores_encode_picture().

◆ qp_end_table

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

Definition at line 56 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ bitrate_table

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

Definition at line 57 of file proresenc_anatoliy.c.

Referenced by encode_slice().

◆ valid_primaries

const int valid_primaries[]
static
Initial value:
@ AVCOL_PRI_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
Definition pixfmt.h:649
@ AVCOL_PRI_SMPTE432
SMPTE ST 432-1 (2010) / P3 D65 / Display P3.
Definition pixfmt.h:657
@ AVCOL_PRI_BT709
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B
Definition pixfmt.h:644
@ AVCOL_PRI_UNSPECIFIED
Definition pixfmt.h:645
@ AVCOL_PRI_RESERVED0
Definition pixfmt.h:643
@ AVCOL_PRI_SMPTE431
SMPTE ST 431-2 (2011) / DCI P3.
Definition pixfmt.h:656
@ AVCOL_PRI_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition pixfmt.h:650
@ AVCOL_PRI_BT2020
ITU-R BT2020.
Definition pixfmt.h:653

Definition at line 59 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

◆ valid_trc

const int valid_trc[]
static
Initial value:
@ AVCOL_TRC_SMPTE2084
SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems.
Definition pixfmt.h:689
@ AVCOL_TRC_ARIB_STD_B67
ARIB STD-B67, known as "Hybrid log-gamma".
Definition pixfmt.h:693
@ AVCOL_TRC_UNSPECIFIED
Definition pixfmt.h:675
@ AVCOL_TRC_BT709
also ITU-R BT1361
Definition pixfmt.h:674
@ AVCOL_TRC_RESERVED0
Definition pixfmt.h:673

Definition at line 61 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

◆ valid_colorspace

const int valid_colorspace[]
static
Initial value:
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition pixfmt.h:708
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition pixfmt.h:717
@ AVCOL_SPC_UNSPECIFIED
Definition pixfmt.h:709
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition pixfmt.h:713

Definition at line 63 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame().

◆ QMAT_LUMA

const uint8_t QMAT_LUMA[6][64]
static

Definition at line 66 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame(), and prores_encode_init().

◆ QMAT_CHROMA

const uint8_t QMAT_CHROMA[6][64]
static

Definition at line 124 of file proresenc_anatoliy.c.

Referenced by prores_encode_frame(), and prores_encode_init().

◆ options

const AVOption options[]
static
Initial value:
= {
{ "vendor", "vendor ID", OFFSET(vendor), AV_OPT_TYPE_STRING, { .str = "fmpg" }, 0, 0, VE },
{ NULL }
}
#define VE
Definition amfenc_av1.c:30
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition opt.h:275

Definition at line 938 of file proresenc_anatoliy.c.

◆ prores_enc_class

const AVClass prores_enc_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 943 of file proresenc_anatoliy.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 950 of file proresenc_anatoliy.c.

◆ ff_prores_aw_encoder

const FFCodec ff_prores_aw_encoder
Initial value:
= {
.p.name = "prores_aw",
CODEC_LONG_NAME("Apple ProRes"),
.p.type = AVMEDIA_TYPE_VIDEO,
.color_ranges = AVCOL_RANGE_MPEG,
.priv_data_size = sizeof(ProresContext),
.p.priv_class = &prores_enc_class,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define CODEC_PIXFMTS_ARRAY(array)
#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...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#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_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#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
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition pixfmt.h:766
const AVProfile ff_prores_profiles[]
Definition profiles.c:175
static av_cold int prores_encode_init(AVCodecContext *avctx)
static int prores_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static const AVClass prores_enc_class
static av_cold int prores_encode_close(AVCodecContext *avctx)

Definition at line 955 of file proresenc_anatoliy.c.

◆ ff_prores_encoder

const FFCodec ff_prores_encoder
Initial value:

Definition at line 973 of file proresenc_anatoliy.c.