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;
68 cae->
api = xavs2_api_get(bit_depth);
136 for (k = 0; k < 3; k++) {
137 int i_stride = pic->img.i_stride[k];
138 for (j = 0; j < pic->img.i_lines[k]; j++) {
139 uint16_t *p_plane = (uint16_t *)&pic->img.img_planes[k][j * i_stride];
142 memset(p_plane, 0, i_stride);
143 for (
i = 0;
i < pic->img.i_width[k];
i++) {
144 p_plane[
i] = p_buffer[
i] << shift_in;
153 for (k = 0; k < 3; k++) {
154 for (j = 0; j < pic->img.i_lines[k]; j++) {
155 memcpy( pic->img.img_planes[k] + pic->img.i_stride[k] * j,
157 pic->img.i_width[k] * pic->img.in_sample_size);
171 if (cae->
api->encoder_get_buffer(cae->
encoder, &pic) < 0) {
178 if (pic.img.in_sample_size == pic.img.enc_sample_size) {
181 const int shift_in = atoi(cae->
api->opt_get(cae->
param,
"SampleShift"));
186 if (pic.img.in_sample_size == pic.img.enc_sample_size) {
197 pic.i_pts = frame->
pts;
198 pic.i_type = XAVS2_TYPE_AUTO;
211 if ((cae->
packet.len) && (cae->
packet.state != XAVS2_STATE_FLUSH_END)){
249 #define OFFSET(x) offsetof(XAVS2EContext, x) 250 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 259 {
"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 },
292 .wrapper_name =
"libxavs2",
This structure describes decoded (raw) audio or video data.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
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...
const char * av_default_item_name(void *ptr)
Return the context name.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
static int xavs2_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet)
static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
AVCodec ff_libxavs2_encoder
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const AVOption options[]
int qmax
maximum quantizer
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
void ff_mpeg12_find_best_frame_rate(AVRational frame_rate, int *code, int *ext_n, int *ext_d, int nonstandard)
static av_cold int xavs2_close(AVCodecContext *avctx)
int width
picture width / height.
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_dict_parse_string(AVDictionary **pm, const char *str, const char *key_val_sep, const char *pairs_sep, int flags)
Parse the key/value pairs list and add the parsed entries to a dictionary.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int qmin
minimum quantizer
#define AV_PIX_FMT_YUV420P10
Describe the class of an AVClass context structure.
static const AVCodecDefault xavs2_defaults[]
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int xavs2_init(AVCodecContext *avctx)
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static const AVClass libxavs2
#define xavs2_opt_set2(name, format,...)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
#define AV_CODEC_FLAG_CLOSED_GOP
static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame *frame, const int shift_in)
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...