Go to the documentation of this file.
45 #define MAX_BS_BUF (16*1024*1024)
50 #define XEVE_PARAM_BAD_NAME -100
51 #define XEVE_PARAM_BAD_VALUE -200
105 switch (av_pix_fmt) {
107 *xeve_col_fmt = XEVE_CF_YCBCR420;
110 *xeve_col_fmt = XEVE_CF_YCBCR420;
113 *xeve_col_fmt = XEVE_CF_UNKNOWN;
130 int cs = XEVE_CF_UNKNOWN;
132 switch (av_pix_fmt) {
134 cs = XEVE_CS_YCBCR420;
137 #if AV_HAVE_BIGENDIAN
138 cs = XEVE_CS_SET(XEVE_CF_YCBCR420, 10, 1);
140 cs = XEVE_CS_YCBCR420_10LE;
145 cs = XEVE_CF_UNKNOWN;
184 ret = xeve_param_default(&cdsc->param);
185 if (XEVE_FAILED(
ret)) {
191 if (avctx->
width > 0)
192 cdsc->param.w = avctx->
width;
195 cdsc->param.h = avctx->
height;
203 cdsc->param.keyint = avctx->
gop_size;
210 "Acceptable values for bf option (maximum number of B frames) are 0,1,3,7 or 15\n", avctx->
max_b_frames);
214 cdsc->param.level_idc = avctx->
level;
219 cdsc->param.rc_type = xectx->
rc_mode;
221 if (xectx->
rc_mode == XEVE_RC_CQP)
222 cdsc->param.qp = xectx->
qp;
223 else if (xectx->
rc_mode == XEVE_RC_ABR) {
225 av_log(avctx,
AV_LOG_ERROR,
"Not supported bitrate bit_rate and rc_max_rate > %d000\n", INT_MAX);
228 cdsc->param.bitrate = (
int)(avctx->
bit_rate / 1000);
229 }
else if (xectx->
rc_mode == XEVE_RC_CRF)
230 cdsc->param.crf = xectx->
crf;
240 cdsc->param.threads = XEVE_MAX_THREADS;
247 cdsc->param.cs = XEVE_CS_SET(xectx->
color_format, cdsc->param.codec_bit_depth, AV_HAVE_BIGENDIAN);
252 if (XEVE_FAILED(
ret)) {
284 ret = xeve_config(
id, XEVE_CFG_SET_SEI_CMD, &
ctx->sei_info, &
size);
285 if (XEVE_FAILED(
ret)) {
290 ret = xeve_config(
id, XEVE_CFG_SET_USE_PIC_SIGNATURE, &
ctx->hash, &
size);
291 if (XEVE_FAILED(
ret)) {
309 if (XEVE_FAILED(xeve_config(
id, XEVE_CFG_SET_FORCE_OUT, (
void *)(&
val), &
size)))
325 unsigned char *bs_buf =
NULL;
329 int width_chroma = 0;
330 int height_chroma = 0;
331 XEVE_IMGB *imgb =
NULL;
334 XEVE_CDSC *cdsc = &(xectx->
cdsc);
338 if (bs_buf ==
NULL) {
342 xectx->
bitb.addr = bs_buf;
351 if ((
ret = xeve_param_check(&cdsc->param)) != 0) {
359 if ((
ret = xeve_param_parse(&cdsc->param, en->
key, en->
value)) < 0) {
361 "Error parsing option '%s = %s'.\n",
368 xectx->
id = xeve_create(cdsc,
NULL);
399 for (
i = 0;
i < imgb->np;
i++)
400 imgb->x[
i] = imgb->y[
i] = 0;
402 imgb->w[0] = imgb->aw[0] = avctx->
width;
403 imgb->w[1] = imgb->w[2] = imgb->aw[1] = imgb->aw[2] = width_chroma;
404 imgb->h[0] = imgb->ah[0] = avctx->
height;
405 imgb->h[1] = imgb->h[2] = imgb->ah[1] = imgb->ah[2] = height_chroma;
442 XEVE_IMGB *imgb =
NULL;
446 for (
i = 0;
i < imgb->np;
i++) {
454 ret = xeve_push(xectx->
id, imgb);
455 if (XEVE_FAILED(
ret)) {
462 ret = xeve_encode(xectx->
id, &(xectx->
bitb), &(xectx->
stat));
463 if (XEVE_FAILED(
ret)) {
469 if (
ret == XEVE_OK_OUT_NOT_AVAILABLE) {
472 }
else if (
ret == XEVE_OK) {
475 if (xectx->
stat.write > 0) {
481 memcpy(avpkt->
data, xectx->
bitb.addr, xectx->
stat.write);
486 avpkt->
pts = xectx->
bitb.ts[XEVE_TS_PTS];
487 avpkt->
dts = xectx->
bitb.ts[XEVE_TS_DTS];
489 switch(xectx->
stat.stype) {
500 case XEVE_ST_UNKNOWN:
509 }
else if (
ret == XEVE_OK_NO_MORE_FRM) {
535 xeve_delete(xectx->
id);
544 #define OFFSET(x) offsetof(XeveContext, x)
545 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
556 {
"preset",
"Encoding preset for setting encoding speed",
OFFSET(preset_id),
AV_OPT_TYPE_INT, { .i64 = XEVE_PRESET_MEDIUM }, XEVE_PRESET_DEFAULT, XEVE_PRESET_PLACEBO,
VE, .unit =
"preset" },
557 {
"default",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_DEFAULT }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
559 {
"medium",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_MEDIUM }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
561 {
"placebo",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_PLACEBO }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
562 {
"tune",
"Tuning parameter for special purpose operation",
OFFSET(tune_id),
AV_OPT_TYPE_INT, { .i64 = XEVE_TUNE_NONE }, XEVE_TUNE_NONE, XEVE_TUNE_PSNR,
VE, .unit =
"tune"},
564 {
"zerolatency",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_TUNE_ZEROLATENCY }, INT_MIN, INT_MAX,
VE, .unit =
"tune" },
566 {
"profile",
"Encoding profile",
OFFSET(profile_id),
AV_OPT_TYPE_INT, { .i64 = XEVE_PROFILE_BASELINE }, XEVE_PROFILE_BASELINE, XEVE_PROFILE_MAIN,
VE, .unit =
"profile" },
567 {
"baseline",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PROFILE_BASELINE }, INT_MIN, INT_MAX,
VE, .unit =
"profile" },
573 {
"qp",
"Quantization parameter value for CQP rate control mode",
OFFSET(qp),
AV_OPT_TYPE_INT, { .i64 = 32 }, 0, 51,
VE },
574 {
"crf",
"Constant rate factor value for CRF rate control mode",
OFFSET(crf),
AV_OPT_TYPE_INT, { .i64 = 32 }, 10, 49,
VE },
575 {
"hash",
"Embed picture signature (HASH) for conformance checking in decoding",
OFFSET(
hash),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
576 {
"sei_info",
"Embed SEI messages identifying encoder parameters and command line arguments",
OFFSET(sei_info),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
577 {
"xeve-params",
"Override the xeve configuration using a :-separated list of key=value parameters",
OFFSET(xeve_params),
AV_OPT_TYPE_DICT, { 0 }, 0, 0,
VE },
613 .p.wrapper_name =
"libxeve",
static int libxeve_color_space(enum AVPixelFormat av_pix_fmt)
Convert FFmpeg pixel format (AVPixelFormat) into XEVE pre-defined color space.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static atomic_int cpu_count
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
static const AVClass libxeve_class
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AV_PIX_FMT_YUV420P10
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
static double val(void *priv, double ch)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define FF_CODEC_ENCODE_CB(func)
static int set_extra_config(AVCodecContext *avctx, XEVE id, XeveContext *ctx)
Set XEVE_CFG_SET_USE_PIC_SIGNATURE for encoder.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_CEIL_RSHIFT(a, b)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
const AVProfile ff_evc_profiles[]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int64_t rc_max_rate
maximum bitrate
int rc_buffer_size
decoder bitstream buffer size
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_PICTURE_TYPE_I
Intra.
static int libxeve_color_fmt(enum AVPixelFormat av_pix_fmt, int *xeve_col_fmt)
Convert FFmpeg pixel format (AVPixelFormat) to XEVE pre-defined color format.
int level
Encoding level descriptor.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
static const AVOption libxeve_options[]
static int libxeve_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet)
Encode raw data frame into EVC packet.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
The structure stores all the states associated with the instance of Xeve MPEG-5 EVC encoder.
#define AVERROR_EXTERNAL
Generic error in an external library.
int flags
A combination of AV_PKT_FLAG values.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVDictionary * xeve_params
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int get_conf(AVCodecContext *avctx, XEVE_CDSC *cdsc)
The function returns a pointer to the object of the XEVE_CDSC type.
static av_cold int libxeve_close(AVCodecContext *avctx)
Destroy the encoder and release all the allocated resources.
main external API structure.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static int setup_bumping(XEVE id)
Switch encoder to bumping mode.
static av_cold int libxeve_init(AVCodecContext *avctx)
Initialize eXtra-fast Essential Video Encoder codec Create an encoder instance and allocate all the n...
@ AV_PICTURE_TYPE_P
Predicted.
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat supported_pixel_formats[]
static const FFCodecDefault libxeve_defaults[]
libavcodec generic global options, which can be set on all the encoders and decoders
const FFCodec ff_libxeve_encoder
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
AVRational time_base
Time base of the packet's timestamps.