55 const kvz_api *
const api = ctx->
api = kvz_api_get(8);
56 kvz_config *cfg =
NULL;
57 kvz_encoder *enc =
NULL;
62 "Video dimensions are not a multiple of 8 (%dx%d).\n",
67 ctx->
config = cfg = api->config_alloc();
70 "Could not allocate kvazaar config structure.\n");
74 if (!api->config_init(cfg)) {
76 "Could not initialize kvazaar config structure.\n");
80 cfg->width = avctx->
width;
81 cfg->height = avctx->
height;
89 "Could not set framerate for kvazaar: integer overflow\n");
95 cfg->target_bitrate = avctx->
bit_rate;
99 cfg->rc_algorithm = KVZ_LAMBDA;
107 if (!api->config_parse(cfg, entry->
key, entry->
value)) {
116 ctx->
encoder = enc = api->encoder_open(cfg);
123 kvz_data_chunk *data_out =
NULL;
124 kvz_data_chunk *chunk =
NULL;
128 if (!api->encoder_headers(enc, &data_out, &len_out))
133 ctx->
api->chunk_free(data_out);
139 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
140 memcpy(p, chunk->data, chunk->len);
144 ctx->
api->chunk_free(data_out);
171 kvz_picture *input_pic =
NULL;
172 kvz_picture *recon_pic =
NULL;
173 kvz_frame_info frame_info;
174 kvz_data_chunk *data_out =
NULL;
175 uint32_t len_out = 0;
185 "Changing video dimensions during encoding is not supported. " 186 "(changed from %dx%d to %dx%d)\n",
195 "Changing pixel format during encoding is not supported. " 196 "(changed from %s to %s)\n",
213 int dst_linesizes[4] = {
224 input_pic->pts = frame->
pts;
227 retval = ctx->
api->encoder_encode(ctx->
encoder,
240 kvz_data_chunk *chunk =
NULL;
241 uint64_t written = 0;
249 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
251 memcpy(avpkt->
data + written, chunk->data, chunk->len);
252 written += chunk->len;
255 avpkt->
pts = recon_pic->pts;
256 avpkt->
dts = recon_pic->dts;
260 if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
261 frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
265 switch (frame_info.slice_type) {
279 #if FF_API_CODED_FRAME 287 #if FF_API_CODED_FRAME 297 ctx->
api->picture_free(input_pic);
298 ctx->
api->picture_free(recon_pic);
299 ctx->
api->chunk_free(data_out);
308 #define OFFSET(x) offsetof(LibkvazaarContext, x) 309 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 311 {
"kvazaar-params",
"Set kvazaar parameters as a comma-separated list of key=value pairs.",
329 .
name =
"libkvazaar",
336 .priv_class = &
class,
338 .defaults = defaults,
347 .wrapper_name =
"libkvazaar",
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
int ff_side_data_set_encoder_stats(AVPacket *pkt, int quality, int64_t *error, int error_count, int pict_type)
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
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...
AVCodec ff_libkvazaar_encoder
#define AV_CODEC_CAP_OTHER_THREADS
Codec supports multithreading through a method other than slice- or frame-level multithreading.
Macro definitions for various function/variable attributes.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#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_*.
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
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.
int flags
A combination of AV_PKT_FLAG values.
static const AVOption options[]
common internal API header
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
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
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
static const AVCodecDefault defaults[]
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.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Describe the class of an AVClass context structure.
static int libkvazaar_encode(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static av_cold int libkvazaar_init(AVCodecContext *avctx)
static enum AVPixelFormat pix_fmts[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_ENABLE_DEPRECATION_WARNINGS
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
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.
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.
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
#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...