Go to the documentation of this file.
46 #define MAX_BS_BUF (16*1024*1024)
51 #define XEVE_PARAM_BAD_NAME -100
52 #define XEVE_PARAM_BAD_VALUE -200
106 switch (av_pix_fmt) {
108 *xeve_col_fmt = XEVE_CF_YCBCR420;
111 *xeve_col_fmt = XEVE_CF_YCBCR420;
114 *xeve_col_fmt = XEVE_CF_UNKNOWN;
131 int cs = XEVE_CF_UNKNOWN;
133 switch (av_pix_fmt) {
135 cs = XEVE_CS_YCBCR420;
138 #if AV_HAVE_BIGENDIAN
139 cs = XEVE_CS_SET(XEVE_CF_YCBCR420, 10, 1);
141 cs = XEVE_CS_YCBCR420_10LE;
146 cs = XEVE_CF_UNKNOWN;
185 ret = xeve_param_default(&cdsc->param);
186 if (XEVE_FAILED(
ret)) {
192 if (avctx->
width > 0)
193 cdsc->param.w = avctx->
width;
196 cdsc->param.h = avctx->
height;
205 cdsc->param.keyint = avctx->
gop_size;
212 "Acceptable values for bf option (maximum number of B frames) are 0,1,3,7 or 15\n", avctx->
max_b_frames);
216 cdsc->param.level_idc = avctx->
level;
221 cdsc->param.rc_type = xectx->
rc_mode;
223 if (xectx->
rc_mode == XEVE_RC_CQP)
224 cdsc->param.qp = xectx->
qp;
225 else if (xectx->
rc_mode == XEVE_RC_ABR) {
227 av_log(avctx,
AV_LOG_ERROR,
"Not supported bitrate bit_rate and rc_max_rate > %d000\n", INT_MAX);
230 cdsc->param.bitrate = (int)(avctx->
bit_rate / 1000);
231 }
else if (xectx->
rc_mode == XEVE_RC_CRF)
232 cdsc->param.crf = xectx->
crf;
242 cdsc->param.threads = XEVE_MAX_THREADS;
249 cdsc->param.cs = XEVE_CS_SET(xectx->
color_format, cdsc->param.codec_bit_depth, AV_HAVE_BIGENDIAN);
254 if (XEVE_FAILED(
ret)) {
286 ret = xeve_config(
id, XEVE_CFG_SET_SEI_CMD, &
ctx->sei_info, &
size);
287 if (XEVE_FAILED(
ret)) {
292 ret = xeve_config(
id, XEVE_CFG_SET_USE_PIC_SIGNATURE, &
ctx->hash, &
size);
293 if (XEVE_FAILED(
ret)) {
310 int size =
sizeof(int);
311 if (XEVE_FAILED(xeve_config(
id, XEVE_CFG_SET_FORCE_OUT, (
void *)(&
val), &
size)))
327 unsigned char *bs_buf =
NULL;
331 int width_chroma = 0;
332 int height_chroma = 0;
333 XEVE_IMGB *imgb =
NULL;
336 XEVE_CDSC *cdsc = &(xectx->
cdsc);
340 if (bs_buf ==
NULL) {
344 xectx->
bitb.addr = bs_buf;
353 if ((
ret = xeve_param_check(&cdsc->param)) != 0) {
361 if ((
ret = xeve_param_parse(&cdsc->param, en->
key, en->
value)) < 0) {
363 "Error parsing option '%s = %s'.\n",
370 xectx->
id = xeve_create(cdsc,
NULL);
401 for (
i = 0;
i < imgb->np;
i++)
402 imgb->x[
i] = imgb->y[
i] = 0;
404 imgb->w[0] = imgb->aw[0] = avctx->
width;
405 imgb->w[1] = imgb->w[2] = imgb->aw[1] = imgb->aw[2] = width_chroma;
406 imgb->h[0] = imgb->ah[0] = avctx->
height;
407 imgb->h[1] = imgb->h[2] = imgb->ah[1] = imgb->ah[2] = height_chroma;
444 XEVE_IMGB *imgb =
NULL;
448 for (
i = 0;
i < imgb->np;
i++) {
450 imgb->s[
i] =
frame->linesize[
i];
453 imgb->ts[XEVE_TS_PTS] =
frame->pts;
456 ret = xeve_push(xectx->
id, imgb);
457 if (XEVE_FAILED(
ret)) {
464 ret = xeve_encode(xectx->
id, &(xectx->
bitb), &(xectx->
stat));
465 if (XEVE_FAILED(
ret)) {
471 if (
ret == XEVE_OK_OUT_NOT_AVAILABLE) {
474 }
else if (
ret == XEVE_OK) {
477 if (xectx->
stat.write > 0) {
483 memcpy(avpkt->
data, xectx->
bitb.addr, xectx->
stat.write);
488 avpkt->
pts = xectx->
bitb.ts[XEVE_TS_PTS];
489 avpkt->
dts = xectx->
bitb.ts[XEVE_TS_DTS];
491 switch(xectx->
stat.stype) {
502 case XEVE_ST_UNKNOWN:
511 }
else if (
ret == XEVE_OK_NO_MORE_FRM) {
537 xeve_delete(xectx->
id);
546 #define OFFSET(x) offsetof(XeveContext, x)
547 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
558 {
"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" },
559 {
"default",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_DEFAULT }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
561 {
"medium",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_MEDIUM }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
563 {
"placebo",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PRESET_PLACEBO }, INT_MIN, INT_MAX,
VE, .unit =
"preset" },
564 {
"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"},
566 {
"zerolatency",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_TUNE_ZEROLATENCY }, INT_MIN, INT_MAX,
VE, .unit =
"tune" },
568 {
"profile",
"Encoding profile",
OFFSET(profile_id),
AV_OPT_TYPE_INT, { .i64 = XEVE_PROFILE_BASELINE }, XEVE_PROFILE_BASELINE, XEVE_PROFILE_MAIN,
VE, .unit =
"profile" },
569 {
"baseline",
NULL, 0,
AV_OPT_TYPE_CONST, { .i64 = XEVE_PROFILE_BASELINE }, INT_MIN, INT_MAX,
VE, .unit =
"profile" },
575 {
"qp",
"Quantization parameter value for CQP rate control mode",
OFFSET(qp),
AV_OPT_TYPE_INT, { .i64 = 32 }, 0, 51,
VE },
576 {
"crf",
"Constant rate factor value for CRF rate control mode",
OFFSET(crf),
AV_OPT_TYPE_INT, { .i64 = 32 }, 10, 49,
VE },
577 {
"hash",
"Embed picture signature (HASH) for conformance checking in decoding",
OFFSET(
hash),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
578 {
"sei_info",
"Embed SEI messages identifying encoder parameters and command line arguments",
OFFSET(sei_info),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
VE },
579 {
"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 },
615 .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
static const AVClass libxeve_class
This structure describes decoded (raw) audio or video data.
#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.
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)
#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
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
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.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
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.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
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
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
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.