29 #define xavs2_opt_set2(name, format, ...) do{ \
30 char opt_str[16] = {0}; \
32 av_strlcatf(opt_str, sizeof(opt_str), format, __VA_ARGS__); \
33 err = cae->api->opt_set2(cae->param, name, opt_str); \
35 av_log(avctx, AV_LOG_WARNING, "Invalid value for %s: %s\n", name, opt_str);\
56 const xavs2_api_t *
api;
133 for (plane = 0; plane < 3; plane++) {
134 p_plane = (uint16_t *)pic->img.img_planes[plane];
136 for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
137 memset(p_plane, 0, pic->img.i_stride[plane]);
138 for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) {
139 p_plane[wIdx] = p_buffer[wIdx] << shift_in;
141 p_plane += pic->img.i_stride[plane];
155 for (plane = 0; plane < 3; plane++) {
156 p_plane = pic->img.img_planes[plane];
158 stride = pic->img.i_width[plane] * pic->img.in_sample_size;
159 for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) {
160 memcpy(p_plane, p_buffer,
stride);
161 p_plane += pic->img.i_stride[plane];
176 if (cae->
api->encoder_get_buffer(cae->
encoder, &pic) < 0) {
183 if (pic.img.in_sample_size == pic.img.enc_sample_size) {
186 const int shift_in = atoi(cae->
api->opt_get(cae->
param,
"SampleShift"));
191 if (pic.img.in_sample_size == pic.img.enc_sample_size) {
203 pic.i_type = XAVS2_TYPE_AUTO;
216 if ((cae->
packet.len) && (cae->
packet.state != XAVS2_STATE_FLUSH_END)) {
226 if (cae->
packet.type == XAVS2_TYPE_IDR ||
227 cae->
packet.type == XAVS2_TYPE_I ||
228 cae->
packet.type == XAVS2_TYPE_KEYFRAME) {
259 #define OFFSET(x) offsetof(XAVS2EContext, x)
260 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
263 {
"lcu_row_threads" ,
"number of parallel threads for rows" ,
OFFSET(lcu_row_threads) ,
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX,
VE },
264 {
"initial_qp" ,
"Quantization initial parameter" ,
OFFSET(initial_qp) ,
AV_OPT_TYPE_INT, {.i64 = 34 }, 1, 63,
VE },
268 {
"speed_level" ,
"Speed level, higher is better but slower",
OFFSET(preset_level) ,
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 9,
VE },
269 {
"log_level" ,
"log level: -1: none, 0: error, 1: warning, 2: info, 3: debug",
OFFSET(log_level) ,
AV_OPT_TYPE_INT, {.i64 = 0 }, -1, 3,
VE },
270 {
"xavs2-params" ,
"set the xavs2 configuration using a :-separated list of key=value parameters",
OFFSET(xavs2_opts),
AV_OPT_TYPE_DICT, { 0 }, 0, 0,
VE },
303 .wrapper_name =
"libxavs2",
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
static av_cold int init(AVCodecContext *avctx)
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_FLAG_CLOSED_GOP
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AVERROR_EXTERNAL
Generic error in an external library.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static enum AVPixelFormat pix_fmts[]
static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
AVCodec ff_libxavs2_encoder
static const AVOption options[]
static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame *frame, const int shift_in)
static av_cold int xavs2_init(AVCodecContext *avctx)
#define xavs2_opt_set2(name, format,...)
static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static av_cold int xavs2_close(AVCodecContext *avctx)
static const AVCodecDefault xavs2_defaults[]
static const AVClass libxavs2
void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard)
#define AV_PIX_FMT_YUV420P10
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
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...
int qmin
minimum quantizer
int64_t bit_rate
the average bitrate
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int qmax
maximum quantizer
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
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).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
AVDictionary * xavs2_opts