Go to the documentation of this file.
64 return RA_PIXEL_RANGE_FULL;
69 return RA_PIXEL_RANGE_FULL;
72 return RA_PIXEL_RANGE_LIMITED;
83 return RA_CHROMA_SAMPLING_CS420;
88 return RA_CHROMA_SAMPLING_CS422;
93 return RA_CHROMA_SAMPLING_CS444;
101 switch (chroma_loc) {
103 return RA_CHROMA_SAMPLE_POSITION_VERTICAL;
105 return RA_CHROMA_SAMPLE_POSITION_COLOCATED;
107 return RA_CHROMA_SAMPLE_POSITION_UNKNOWN;
114 RaData* buf = rav1e_twopass_out(
ctx->ctx);
120 ctx->pass_pos + buf->len);
122 rav1e_data_unref(buf);
127 memcpy(
ctx->pass_data +
ctx->pass_pos, buf->data, buf->len);
128 ctx->pass_pos += buf->len;
132 memcpy(
ctx->pass_data, buf->data, buf->len);
136 rav1e_data_unref(buf);
145 rav1e_data_unref(buf);
155 while (
ret > 0 &&
ctx->pass_size -
ctx->pass_pos > 0) {
156 ret = rav1e_twopass_in(
ctx->ctx,
ctx->pass_data +
ctx->pass_pos,
ctx->pass_size);
170 rav1e_context_unref(
ctx->ctx);
174 rav1e_frame_unref(
ctx->rframe);
189 RaConfig *cfg =
NULL;
197 cfg = rav1e_config_default();
209 rav1e_config_set_time_base(cfg, (RaRational) {
213 rav1e_config_set_time_base(cfg, (RaRational) {
232 ctx->pass_size = (strlen(avctx->
stats_in) * 3) / 4;
234 if (!
ctx->pass_data) {
241 if (
ctx->pass_size < 0) {
254 "not found. This is a bug, please report it.\n");
281 int parse_ret = rav1e_config_parse(cfg, en->
key, en->
value);
287 rret = rav1e_config_parse_int(cfg,
"width", avctx->
width);
294 rret = rav1e_config_parse_int(cfg,
"height", avctx->
height);
301 rret = rav1e_config_parse_int(cfg,
"threads", avctx->
thread_count);
305 if (
ctx->speed >= 0) {
306 rret = rav1e_config_parse_int(cfg,
"speed",
ctx->speed);
315 if (
ctx->tiles > 0) {
316 rret = rav1e_config_parse_int(cfg,
"tiles",
ctx->tiles);
323 if (
ctx->tile_rows > 0) {
324 rret = rav1e_config_parse_int(cfg,
"tile_rows",
ctx->tile_rows);
331 if (
ctx->tile_cols > 0) {
332 rret = rav1e_config_parse_int(cfg,
"tile_cols",
ctx->tile_cols);
341 rret = rav1e_config_parse_int(cfg,
"key_frame_interval", avctx->
gop_size);
350 rret = rav1e_config_parse_int(cfg,
"min_key_frame_interval", avctx->
keyint_min);
359 int max_quantizer = avctx->
qmax >= 0 ? avctx->
qmax : 255;
361 rret = rav1e_config_parse_int(cfg,
"quantizer", max_quantizer);
368 if (avctx->
qmin >= 0) {
369 rret = rav1e_config_parse_int(cfg,
"min_quantizer", avctx->
qmin);
377 rret = rav1e_config_parse_int(cfg,
"bitrate", avctx->
bit_rate);
383 }
else if (
ctx->quantizer >= 0) {
387 rret = rav1e_config_parse_int(cfg,
"quantizer",
ctx->quantizer);
395 rret = rav1e_config_set_pixel_format(cfg,
desc->comp[0].depth,
406 rret = rav1e_config_set_color_description(cfg, (RaMatrixCoefficients) avctx->
colorspace,
408 (RaTransferCharacteristics) avctx->
color_trc);
417 ctx->ctx = rav1e_context_new(cfg);
428 rav1e_config_unref(cfg);
436 RaFrame *rframe =
ctx->rframe;
437 RaPacket *rpkt =
NULL;
457 rframe = rav1e_frame_new(
ctx->ctx);
465 for (
int i = 0;
i <
desc->nb_components;
i++) {
467 int bytes =
desc->comp[0].depth == 8 ? 1 : 2;
468 rav1e_frame_fill_plane(rframe,
i,
frame->data[
i],
470 frame->linesize[
i], bytes);
477 ret = rav1e_send_frame(
ctx->ctx, rframe);
479 if (
ret == RA_ENCODER_STATUS_ENOUGH_DATA) {
480 ctx->rframe = rframe;
482 rav1e_frame_unref(rframe);
487 case RA_ENCODER_STATUS_SUCCESS:
488 case RA_ENCODER_STATUS_ENOUGH_DATA:
490 case RA_ENCODER_STATUS_FAILURE:
510 ret = rav1e_receive_packet(
ctx->ctx, &rpkt);
512 case RA_ENCODER_STATUS_SUCCESS:
514 case RA_ENCODER_STATUS_LIMIT_REACHED:
521 case RA_ENCODER_STATUS_ENCODED:
523 case RA_ENCODER_STATUS_NEED_MORE_DATA:
529 case RA_ENCODER_STATUS_FAILURE:
533 av_log(avctx,
AV_LOG_ERROR,
"Unknown return code %d from rav1e_receive_packet: %s\n",
ret, rav1e_status_to_str(
ret));
540 rav1e_packet_unref(rpkt);
544 memcpy(
pkt->
data, rpkt->data, rpkt->len);
546 if (rpkt->frame_type == RA_FRAME_TYPE_KEY)
551 rav1e_packet_unref(rpkt);
572 #define OFFSET(x) offsetof(librav1eContext, x)
573 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
581 {
"rav1e-params",
"set the rav1e configuration using a :-separated list of key=value parameters",
OFFSET(rav1e_opts),
AV_OPT_TYPE_DICT, { 0 }, 0, 0,
VE },
588 {
"keyint_min",
"0" },
618 .
p.
name =
"librav1e",
626 .p.priv_class = &
class,
632 .p.wrapper_name =
"librav1e",
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
AVPixelFormat
Pixel format.
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int keyint_min
minimum GOP size
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
enum AVColorSpace colorspace
YUV colorspace type.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
@ AVCOL_RANGE_JPEG
Full range content.
static int set_stats(AVCodecContext *avctx)
#define AV_PIX_FMT_YUV420P10
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int qmax
maximum quantizer
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
const FFCodec ff_librav1e_encoder
The bitstream filter state.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
AVCodec p
The public AVCodec.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
int flags
AV_CODEC_FLAG_*.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_PIX_FMT_YUV444P10
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
#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.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
static av_cold int librav1e_encode_init(AVCodecContext *avctx)
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_fmt
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define LIBAVUTIL_VERSION_INT
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Describe the class of an AVClass context structure.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
AVDictionary * rav1e_opts
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
struct AVCodecInternal * internal
Private context used for internal data.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
#define FF_CODEC_RECEIVE_PACKET_CB(func)
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
#define AV_PIX_FMT_YUV422P10
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
#define AV_EF_EXPLODE
abort decoding on minor error detection
static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
char * stats_out
pass1 encoding statistics output buffer
#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.
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV444P12
static RaPixelRange range_map(enum AVPixelFormat pix_fmt, enum AVColorRange range)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static RaChromaSampling pix_fmt_map(enum AVPixelFormat pix_fmt)
#define AVERROR_EXTERNAL
Generic error in an external library.
int flags
A combination of AV_PKT_FLAG values.
AVChromaLocation
Location of chroma samples.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
const char * name
Name of the codec implementation.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
static const AVOption options[]
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_PIX_FMT_YUV420P12
main external API structure.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
int qmin
minimum quantizer
static const FFCodecDefault librav1e_defaults[]
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
static RaChromaSamplePosition chroma_loc_map(enum AVChromaLocation chroma_loc)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int draining
checks API usage: after codec draining, flush is required to resume operation
static int shift(int a, int b)
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
#define FF_CODEC_CAP_AUTO_THREADS
Codec handles avctx->thread_count == 0 (auto) internally.
enum AVPixelFormat librav1e_pix_fmts[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
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.
AVColorRange
Visual content value range.
static av_cold int librav1e_encode_close(AVCodecContext *avctx)
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
static int get_stats(AVCodecContext *avctx, int eos)
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)