Go to the documentation of this file.
56 const kvz_api *
const api =
ctx->api = kvz_api_get(8);
57 kvz_config *cfg =
NULL;
58 kvz_encoder *enc =
NULL;
63 "Video dimensions are not a multiple of 8 (%dx%d).\n",
68 ctx->config = cfg = api->config_alloc();
71 "Could not allocate kvazaar config structure.\n");
75 if (!api->config_init(cfg)) {
77 "Could not initialize kvazaar config structure.\n");
81 cfg->width = avctx->
width;
82 cfg->height = avctx->
height;
90 "Could not set framerate for kvazaar: integer overflow\n");
96 cfg->target_bitrate = avctx->
bit_rate;
100 cfg->rc_algorithm = KVZ_LAMBDA;
103 if (
ctx->kvz_params) {
108 if (!api->config_parse(cfg, entry->
key, entry->
value)) {
117 ctx->encoder = enc = api->encoder_open(cfg);
124 kvz_data_chunk *data_out =
NULL;
125 kvz_data_chunk *chunk =
NULL;
129 if (!api->encoder_headers(enc, &data_out, &len_out))
134 ctx->api->chunk_free(data_out);
140 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
141 memcpy(p, chunk->data, chunk->len);
145 ctx->api->chunk_free(data_out);
156 ctx->api->encoder_close(
ctx->encoder);
157 ctx->api->config_destroy(
ctx->config);
169 kvz_picture *input_pic =
NULL;
170 kvz_picture *recon_pic =
NULL;
171 kvz_frame_info frame_info;
172 kvz_data_chunk *data_out =
NULL;
173 uint32_t len_out = 0;
180 if (
frame->width !=
ctx->config->width ||
181 frame->height !=
ctx->config->height) {
183 "Changing video dimensions during encoding is not supported. "
184 "(changed from %dx%d to %dx%d)\n",
185 ctx->config->width,
ctx->config->height,
193 "Changing pixel format during encoding is not supported. "
194 "(changed from %s to %s)\n",
202 input_pic =
ctx->api->picture_alloc(
frame->width,
frame->height);
217 int dst_linesizes[4] = {
224 (
const uint8_t **)
frame->data,
frame->linesize,
228 input_pic->pts =
frame->pts;
231 retval =
ctx->api->encoder_encode(
ctx->encoder,
244 kvz_data_chunk *chunk =
NULL;
245 uint64_t written = 0;
253 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
255 memcpy(avpkt->
data + written, chunk->data, chunk->len);
256 written += chunk->len;
259 avpkt->
pts = recon_pic->pts;
260 avpkt->
dts = recon_pic->dts;
264 if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
265 frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
269 switch (frame_info.slice_type) {
290 ctx->api->picture_free(input_pic);
291 ctx->api->picture_free(recon_pic);
292 ctx->api->chunk_free(data_out);
301 #define OFFSET(x) offsetof(LibkvazaarContext, x)
302 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
304 {
"kvazaar-params",
"Set kvazaar parameters as a comma-separated list of key=value pairs.",
322 .
name =
"libkvazaar",
330 .priv_class = &
class,
341 .wrapper_name =
"libkvazaar",
#define AV_LOG_WARNING
Something somehow does not look correct.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVPixelFormat
Pixel format.
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
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
const AVCodec ff_libkvazaar_encoder
static const AVOption options[]
This structure describes decoded (raw) audio or video data.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
static av_cold int libkvazaar_init(AVCodecContext *avctx)
int flags
AV_CODEC_FLAG_*.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static enum AVPixelFormat pix_fmts[]
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#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.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
#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.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
#define AVERROR_EXTERNAL
Generic error in an external library.
int flags
A combination of AV_PKT_FLAG values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static const AVCodecDefault defaults[]
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static av_cold int libkvazaar_close(AVCodecContext *avctx)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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...
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
#define AV_INPUT_BUFFER_PADDING_SIZE
main external API structure.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
@ 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.
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.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
@ AV_PICTURE_TYPE_P
Predicted.
This structure stores compressed data.
int width
picture width / height.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
static int libkvazaar_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.