59 return RA_PIXEL_RANGE_FULL;
64 return RA_PIXEL_RANGE_FULL;
67 return RA_PIXEL_RANGE_LIMITED;
78 return RA_CHROMA_SAMPLING_CS420;
83 return RA_CHROMA_SAMPLING_CS422;
88 return RA_CHROMA_SAMPLING_CS444;
98 return RA_CHROMA_SAMPLE_POSITION_VERTICAL;
100 return RA_CHROMA_SAMPLE_POSITION_COLOCATED;
102 return RA_CHROMA_SAMPLE_POSITION_UNKNOWN;
109 RaData* buf = rav1e_twopass_out(ctx->
ctx);
117 rav1e_data_unref(buf);
127 memcpy(ctx->
pass_data, buf->data, buf->len);
131 rav1e_data_unref(buf);
140 rav1e_data_unref(buf);
165 rav1e_context_unref(ctx->
ctx);
179 RaConfig *cfg =
NULL;
183 cfg = rav1e_config_default();
195 rav1e_config_set_time_base(cfg, (RaRational) {
199 rav1e_config_set_time_base(cfg, (RaRational) {
240 "not found. This is a bug, please report it.\n");
267 int parse_ret = rav1e_config_parse(cfg, en->
key, en->
value);
273 rret = rav1e_config_parse_int(cfg,
"width", avctx->
width);
280 rret = rav1e_config_parse_int(cfg,
"height", avctx->
height);
287 rret = rav1e_config_parse_int(cfg,
"threads", avctx->
thread_count);
291 if (ctx->
speed >= 0) {
292 rret = rav1e_config_parse_int(cfg,
"speed", ctx->
speed);
301 if (ctx->
tiles > 0) {
302 rret = rav1e_config_parse_int(cfg,
"tiles", ctx->
tiles);
310 rret = rav1e_config_parse_int(cfg,
"tile_rows", ctx->
tile_rows);
318 rret = rav1e_config_parse_int(cfg,
"tile_cols", ctx->
tile_cols);
327 rret = rav1e_config_parse_int(cfg,
"key_frame_interval", avctx->
gop_size);
336 rret = rav1e_config_parse_int(cfg,
"min_key_frame_interval", avctx->
keyint_min);
345 int max_quantizer = avctx->
qmax >= 0 ? avctx->
qmax : 255;
347 rret = rav1e_config_parse_int(cfg,
"quantizer", max_quantizer);
354 if (avctx->
qmin >= 0) {
355 rret = rav1e_config_parse_int(cfg,
"min_quantizer", avctx->
qmin);
363 rret = rav1e_config_parse_int(cfg,
"bitrate", avctx->
bit_rate);
373 rret = rav1e_config_parse_int(cfg,
"quantizer", ctx->
quantizer);
381 rret = rav1e_config_set_pixel_format(cfg, desc->
comp[0].
depth,
392 rret = rav1e_config_set_color_description(cfg, (RaMatrixCoefficients) avctx->
colorspace,
394 (RaTransferCharacteristics) avctx->
color_trc);
403 ctx->
ctx = rav1e_context_new(cfg);
414 rav1e_config_unref(cfg);
422 RaFrame *rframe =
NULL;
428 rframe = rav1e_frame_new(ctx->
ctx);
436 int bytes = desc->
comp[0].
depth == 8 ? 1 : 2;
437 rav1e_frame_fill_plane(rframe,
i, frame->
data[
i],
443 ret = rav1e_send_frame(ctx->
ctx, rframe);
445 rav1e_frame_unref(rframe);
448 case RA_ENCODER_STATUS_SUCCESS:
450 case RA_ENCODER_STATUS_ENOUGH_DATA:
452 case RA_ENCODER_STATUS_FAILURE:
456 av_log(avctx,
AV_LOG_ERROR,
"Unknown return code %d from rav1e_send_frame: %s\n", ret, rav1e_status_to_str(ret));
466 RaPacket *rpkt =
NULL;
481 ret = rav1e_receive_packet(ctx->
ctx, &rpkt);
483 case RA_ENCODER_STATUS_SUCCESS:
485 case RA_ENCODER_STATUS_LIMIT_REACHED:
492 case RA_ENCODER_STATUS_ENCODED:
496 case RA_ENCODER_STATUS_NEED_MORE_DATA:
502 case RA_ENCODER_STATUS_FAILURE:
503 av_log(avctx,
AV_LOG_ERROR,
"Could not encode frame: %s\n", rav1e_status_to_str(ret));
506 av_log(avctx,
AV_LOG_ERROR,
"Unknown return code %d from rav1e_receive_packet: %s\n", ret, rav1e_status_to_str(ret));
513 rav1e_packet_unref(rpkt);
517 memcpy(pkt->
data, rpkt->data, rpkt->len);
519 if (rpkt->frame_type == RA_FRAME_TYPE_KEY)
523 rav1e_packet_unref(rpkt);
544 #define OFFSET(x) offsetof(librav1eContext, x) 545 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 560 {
"keyint_min",
"0" },
599 .priv_class = &
class,
604 .wrapper_name =
"librav1e",
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
This structure describes decoded (raw) audio or video data.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
AVCodec ff_librav1e_encoder
static RaChromaSamplePosition chroma_loc_map(enum AVChromaLocation chroma_loc)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
The bitstream filter state.
const char * av_default_item_name(void *ptr)
Return the context name.
AVDictionary * rav1e_opts
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
#define AV_PIX_FMT_YUV420P12
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
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.
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static int librav1e_send_frame(AVCodecContext *avctx, const AVFrame *frame)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
static av_cold int librav1e_encode_init(AVCodecContext *avctx)
static av_cold int end(AVCodecContext *avctx)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AVERROR_EOF
End of file.
AVColorRange
MPEG vs JPEG YUV range.
#define AV_PIX_FMT_YUV422P12
char * stats_out
pass1 encoding statistics output buffer
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int get_stats(AVCodecContext *avctx, int eos)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
int qmax
maximum quantizer
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
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.
#define AV_PIX_FMT_YUV444P10
static const AVCodecDefault defaults[]
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
int flags
A combination of AV_PKT_FLAG values.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
common internal API header
uint8_t nb_components
The number of components each pixel has, (1-4)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
static const AVCodecDefault librav1e_defaults[]
static av_cold int librav1e_encode_close(AVCodecContext *avctx)
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int width
picture width / height.
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
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.
#define AV_EF_EXPLODE
abort decoding on minor error detection
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
static RaChromaSampling pix_fmt_map(enum AVPixelFormat pix_fmt)
int draining
checks API usage: after codec draining, flush is required to resume operation
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
the normal 2^n-1 "JPEG" YUV ranges
enum AVPixelFormat librav1e_pix_fmts[]
static int set_stats(AVCodecContext *avctx)
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
int qmin
minimum quantizer
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_PIX_FMT_YUV420P10
static RaPixelRange range_map(enum AVPixelFormat pix_fmt, enum AVColorRange range)
Describe the class of an AVClass context structure.
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
static int librav1e_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
static enum AVPixelFormat pix_fmts[]
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV444P12
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.
the normal 219*2^(n-8) "MPEG" YUV ranges
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
common internal and external API header
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
struct AVCodecInternal * internal
Private context used for internal data.
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
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.
AVChromaLocation
Location of chroma samples.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
int depth
Number of bits in the component.
static const AVOption options[]
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.
AVCodecParameters * par_in
Parameters of the input stream.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int keyint_min
minimum GOP size