47 kvz_config *cfg =
NULL;
48 kvz_encoder *enc =
NULL;
49 const kvz_api *
const api = kvz_api_get(8);
60 cfg = api->config_alloc();
67 if (!api->config_init(cfg)) {
73 cfg->width = avctx->
width;
74 cfg->height = avctx->
height;
77 cfg->target_bitrate = avctx->
bit_rate;
86 if (!api->config_parse(cfg, entry->
key, entry->
value)) {
88 "Invalid option: %s=%s.\n",
96 enc = api->encoder_open(cfg);
110 api->config_destroy(cfg);
111 api->encoder_close(enc);
119 if (!ctx->
api)
return 0;
140 kvz_picture *img_in =
NULL;
142 kvz_data_chunk *data_out =
NULL;
143 uint32_t len_out = 0;
144 kvz_picture *recon_pic =
NULL;
145 kvz_frame_info frame_info;
155 "Changing video dimensions during encoding is not supported. "
156 "(changed from %dx%d to %dx%d)\n",
165 "Changing pixel format during encoding is not supported. "
166 "(changed from %s to %s)\n",
183 int dst_linesizes[4] = {
194 img_in->pts = frame->
pts;
197 if (!ctx->
api->encoder_encode(ctx->
encoder, img_in,
207 kvz_data_chunk *chunk =
NULL;
208 uint64_t written = 0;
216 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
218 memcpy(avpkt->
data + written, chunk->data, chunk->len);
219 written += chunk->len;
223 ctx->
api->chunk_free(data_out);
226 avpkt->
pts = recon_pic->pts;
227 avpkt->
dts = recon_pic->dts;
232 if (frame_info.nal_unit_type >= KVZ_NAL_BLA_W_LP &&
233 frame_info.nal_unit_type <= KVZ_NAL_RSV_IRAP_VCL23) {
239 ctx->
api->picture_free(img_in);
240 ctx->
api->picture_free(recon_pic);
241 ctx->
api->chunk_free(data_out);
251 {
"kvazaar-params",
"Set kvazaar parameters as a comma-separated list of name=value pairs.",
270 .
name =
"libkvazaar",
277 .priv_class = &
class,
279 .defaults = defaults,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
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)
AVCodec ff_libkvazaar_encoder
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.
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.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int width
width and height of the video frame
#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. ...
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
Libavcodec external API header.
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[]
int bit_rate
the average bitrate
int width
picture width / height.
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.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
#define AV_OPT_FLAG_VIDEO_PARAM
main external API structure.
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.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
attribute_deprecated int ff_alloc_packet(AVPacket *avpkt, int size)
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.
#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...