45 kvz_config *cfg =
NULL;
46 kvz_encoder *enc =
NULL;
47 const kvz_api *
const api = kvz_api_get(8);
58 cfg = api->config_alloc();
65 if (!api->config_init(cfg)) {
71 cfg->width = avctx->
width;
72 cfg->height = avctx->
height;
76 cfg->target_bitrate = avctx->
bit_rate;
85 if (!api->config_parse(cfg, entry->
key, entry->
value)) {
87 "Invalid option: %s=%s.\n",
95 enc = api->encoder_open(cfg);
109 if (cfg) api->config_destroy(cfg);
110 if (enc) api->encoder_close(enc);
118 if (!ctx->
api)
return 0;
139 kvz_picture *img_in =
NULL;
140 kvz_data_chunk *data_out =
NULL;
141 uint32_t len_out = 0;
162 for (i = 0; i < 3; ++i) {
163 uint8_t *dst = img_in->data[i];
169 memcpy(dst, src, width);
176 if (!ctx->
api->encoder_encode(ctx->
encoder, img_in, &data_out, &len_out,
NULL)) {
183 kvz_data_chunk *chunk =
NULL;
184 uint64_t written = 0;
192 for (chunk = data_out; chunk !=
NULL; chunk = chunk->next) {
194 memcpy(avpkt->
data + written, chunk->data, chunk->len);
195 written += chunk->len;
199 ctx->
api->chunk_free(data_out);
204 if (img_in) ctx->
api->picture_free(img_in);
205 if (data_out) ctx->
api->chunk_free(data_out);
215 {
"kvazaar-params",
"Set kvazaar parameters as a comma-separated list of name=value pairs.",
234 .
name =
"libkvazaar",
241 .priv_class = &
class,
243 .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.
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
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.
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 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.
#define AV_OPT_FLAG_VIDEO_PARAM
main external API structure.
BYTE int const BYTE int int int height
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)
#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 AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.