22 #include <dav1d/dav1d.h> 100 DAV1D_PICTURE_ALIGNMENT);
106 p->data[0] = data[0];
107 p->data[1] = data[1];
108 p->data[2] = data[2];
109 p->stride[0] = linesize[0];
110 p->stride[1] = linesize[1];
111 p->allocator_data = buf;
132 dav1d_default_settings(&s);
135 s.allocator.cookie = dav1d;
150 :
FFMIN(
floor(sqrt(threads)), DAV1D_MAX_TILE_THREADS);
153 :
FFMIN(
ceil(threads / s.n_tile_threads), DAV1D_MAX_FRAME_THREADS);
155 s.n_frame_threads, s.n_tile_threads);
157 res = dav1d_open(&dav1d->
c, &s);
168 dav1d_data_unref(&dav1d->
data);
169 dav1d_flush(dav1d->
c);
187 Dav1dPicture pic = { 0 }, *p = &pic;
204 data->m.timestamp = pkt.
pts;
205 data->m.offset = pkt.
pos;
213 if (!reordered_opaque) {
214 dav1d_data_unref(data);
219 res = dav1d_data_wrap_user_data(data, reordered_opaque,
223 dav1d_data_unref(data);
230 res = dav1d_send_data(dav1d->
c, data);
238 res = dav1d_get_picture(dav1d->
c, p);
252 if (!frame->
buf[0]) {
253 dav1d_picture_unref(p);
257 frame->
data[0] = p->data[0];
258 frame->
data[1] = p->data[1];
259 frame->
data[2] = p->data[2];
264 c->
profile = p->seq_hdr->profile;
265 c->
level = ((p->seq_hdr->operating_points[0].major_level - 2) << 2)
266 | p->seq_hdr->operating_points[0].minor_level;
267 frame->
width = p->p.w;
277 frame->
height * (int64_t)p->frame_hdr->render_width,
278 frame->
width * (int64_t)p->frame_hdr->render_height,
282 switch (p->seq_hdr->chr) {
283 case DAV1D_CHR_VERTICAL:
286 case DAV1D_CHR_COLOCATED:
295 if (p->p.layout == DAV1D_PIXEL_LAYOUT_I444 &&
296 p->seq_hdr->mtrx == DAV1D_MC_IDENTITY &&
297 p->seq_hdr->pri == DAV1D_COLOR_PRI_BT709 &&
298 p->seq_hdr->trc == DAV1D_TRC_SRGB)
303 if (p->m.user_data.data)
308 if (p->seq_hdr->num_units_in_tick && p->seq_hdr->time_scale) {
310 p->seq_hdr->num_units_in_tick, p->seq_hdr->time_scale, INT_MAX);
311 if (p->seq_hdr->equal_picture_interval)
316 frame->
pts = p->m.timestamp;
319 frame->
pkt_pts = p->m.timestamp;
322 frame->
pkt_dts = p->m.timestamp;
326 frame->
key_frame = p->frame_hdr->frame_type == DAV1D_FRAME_TYPE_KEY;
328 switch (p->frame_hdr->frame_type) {
329 case DAV1D_FRAME_TYPE_KEY:
330 case DAV1D_FRAME_TYPE_INTRA:
333 case DAV1D_FRAME_TYPE_INTER:
336 case DAV1D_FRAME_TYPE_SWITCH:
344 if (p->mastering_display) {
351 for (
int i = 0;
i < 3;
i++) {
364 if (p->content_light) {
370 light->
MaxCLL = p->content_light->max_content_light_level;
371 light->
MaxFALL = p->content_light->max_frame_average_light_level;
375 unsigned int user_identifier;
380 user_identifier = bytestream2_get_be32(&gb);
381 switch (user_identifier) {
382 case MKBETAG(
'G',
'A',
'9',
'4'): {
401 if (p->frame_hdr->film_grain.present && (!dav1d->
apply_grain ||
410 fgp->
seed = p->frame_hdr->film_grain.data.seed;
432 memcpy(&fgp->
codec.
aom.
uv_mult, &p->frame_hdr->film_grain.data.uv_mult,
442 dav1d_picture_unref(p);
453 dav1d_data_unref(&dav1d->
data);
454 dav1d_close(&dav1d->
c);
459 #define OFFSET(x) offsetof(Libdav1dContext, x) 460 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM 489 .priv_class = &libdav1d_class,
490 .wrapper_name =
"libdav1d",
The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
This structure describes decoded (raw) audio or video data.
unsigned MaxCLL
Max content light level (cd/m^2).
int ar_coeff_lag
Specifies the auto-regression lag.
ptrdiff_t const GLvoid * data
static void flush(AVCodecContext *avctx)
#define AV_OPT_FLAG_DEPRECATED
set if option is deprecated, users should refer to AVOption.help text for more information ...
int64_t pkt_pos
reordered pos from the last AVPacket that has been input into the decoder
int num_uv_points[2]
If chroma_scaling_from_luma is set to 0, signals the chroma scaling function parameters.
uint64_t seed
Seed to use for the synthesis process, if the codec allows for it.
This structure describes how to handle film grain synthesis in video for specific codecs...
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static av_cold int init(AVCodecContext *avctx)
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], const uint8_t *src, enum AVPixelFormat pix_fmt, int width, int height, int align)
Setup the data pointers and linesizes based on the specified image parameters and the provided array...
#define AV_PIX_FMT_GBRP10
const char * av_default_item_name(void *ptr)
Return the context name.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
#define AV_PIX_FMT_YUV420P12
static __device__ float ceil(float a)
static CopyRet receive_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
#define AV_CODEC_CAP_AUTO_THREADS
Codec supports avctx->thread_count == 0 (auto).
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 format(the sample packing is implied by the sample format) and sample rate.The lists are not just lists
AVColorTransferCharacteristic
Color Transfer Characteristic.
int grain_scale_shift
Signals the down shift applied to the generated gaussian numbers during synthesis.
#define AV_PIX_FMT_GRAY10
static __device__ float floor(float a)
static void libdav1d_picture_release(Dav1dPicture *p, void *cookie)
#define AV_PIX_FMT_GRAY12
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 limit_output_range
Signals to clip to limited color levels after film grain application.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame...
int scaling_shift
Specifies the shift applied to the chroma components.
AVColorSpace
YUV colorspace type.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt)
Called by decoders to get the next packet for decoding.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int ff_parse_a53_cc(AVBufferRef **pbuf, const uint8_t *data, int size)
Parse a data array for ATSC A53 Part 4 Closed Captions and store them in an AVBufferRef.
static enum AVPixelFormat pix_fmt_rgb[3]
static void libdav1d_flush(AVCodecContext *c)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define AVERROR_EOF
End of file.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_PIX_FMT_YUV422P12
AVColorPrimaries
Chromaticity coordinates of the source primaries.
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
int num_y_points
Number of points, and the scale and value for each point of the piecewise linear scaling function for...
static av_always_inline int bytestream2_get_bytes_left(GetByteContext *g)
int ar_coeff_shift
Specifies the range of the auto-regressive coefficients.
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters...
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
ATSC A53 Part 4 Closed Captions.
void av_vlog(void *avcl, int level, const char *fmt, va_list vl)
Send the specified message to the log if the level is less than or equal to the current av_log_level...
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
enum AVColorSpace colorspace
YUV colorspace type.
int chroma_scaling_from_luma
Signals whether to derive the chroma scaling function from the luma.
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
int64_t max_pixels
The number of pixels per image to maximally accept.
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
static av_cold int libdav1d_init(AVCodecContext *c)
AVFilmGrainParams * av_film_grain_params_create_side_data(AVFrame *frame)
Allocate a complete AVFilmGrainParams and add it to the frame.
enum AVPictureType pict_type
Picture type of the frame.
AVFrameSideData * av_frame_new_side_data_from_buf(AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
Add a new side data to a frame from an existing AVBufferRef.
int width
picture width / height.
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
static void libdav1d_user_data_free(const uint8_t *data, void *opaque)
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
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 uv_mult[2]
Specifies the luma/chroma multipliers for the index to the component scaling function.
int64_t reordered_opaque
opaque 64-bit number (generally a PTS) that will be reordered and output in AVFrame.reordered_opaque
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int overlap_flag
Signals whether to overlap film grain blocks.
static const AVOption libdav1d_options[]
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() ...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int8_t ar_coeffs_uv[2][25]
Chroma auto-regression coefficients.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown...
static void libdav1d_data_free(const uint8_t *data, void *opaque)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static AVRational av_make_q(int num, int den)
Create an AVRational.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * data
The data buffer.
static enum AVPixelFormat pix_fmt[][3]
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
#define AV_PIX_FMT_YUV420P10
int64_t reordered_opaque
reordered opaque 64 bits (generally an integer or a double precision float PTS but can be anything)...
Describe the class of an AVClass context structure.
#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
enum AVColorSpace colorspace
YUV colorspace type.
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
static const AVClass libdav1d_class
enum AVChromaLocation chroma_location
union AVFilmGrainParams::@294 codec
Additional fields may be added both here and in any structure included.
enum AVFilmGrainParamsType type
Specifies the codec for which this structure is valid.
#define AV_PIX_FMT_GBRP12
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define AV_PIX_FMT_YUV422P10
#define FF_CODEC_CAP_SETS_PKT_DTS
Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set AVFrame.pkt_dts manually.
#define AV_PIX_FMT_YUV444P12
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
attribute_deprecated int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
Narrow or limited range content.
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
static void libdav1d_log_callback(void *opaque, const char *fmt, va_list vl)
A reference to a data buffer.
static int libdav1d_picture_allocator(Dav1dPicture *p, void *cookie)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal api header.
AVBufferPool * av_buffer_pool_init(int size, AVBufferRef *(*alloc)(int size))
Allocate and initialize a buffer pool.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
static av_cold int libdav1d_close(AVCodecContext *c)
unsigned properties
Properties of the stream that gets decoded.
#define MKBETAG(a, b, c, d)
int uv_offset[2]
Offset used for component scaling function.
#define FF_ENABLE_DEPRECATION_WARNINGS
struct AVCodecInternal * internal
Private context used for internal data.
int8_t ar_coeffs_y[24]
Luma auto-regression coefficients.
int key_frame
1 -> keyframe, 0-> not
enum AVColorPrimaries color_primaries
enum AVColorTransferCharacteristic color_trc
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
uint8_t uv_points[2][10][2]
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
AVCodec ff_libdav1d_decoder
int pkt_size
size of the corresponding packet containing the compressed frame.
AVPixelFormat
Pixel format.
unsigned MaxFALL
Max average light level per frame (cd/m^2).
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)