dav1d
Data Structures | Macros | Typedefs | Enumerations | Functions
dav1d.h File Reference
#include <errno.h>
#include <stdarg.h>
#include "common.h"
#include "picture.h"
#include "data.h"
#include "version.h"
Include dependency graph for dav1d.h:

Go to the source code of this file.

Data Structures

struct  Dav1dLogger
 
struct  Dav1dSettings
 

Macros

#define DAV1D_MAX_FRAME_THREADS   256
 
#define DAV1D_MAX_TILE_THREADS   64
 
#define DAV1D_MAX_POSTFILTER_THREADS   256
 

Typedefs

typedef struct Dav1dContext Dav1dContext
 
typedef struct Dav1dRef Dav1dRef
 

Enumerations

enum  Dav1dEventFlags { DAV1D_EVENT_FLAG_NEW_SEQUENCE = 1 << 0 , DAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO = 1 << 1 }
 

Functions

DAV1D_API const char * dav1d_version (void)
 
DAV1D_API void dav1d_default_settings (Dav1dSettings *s)
 
DAV1D_API int dav1d_open (Dav1dContext **c_out, const Dav1dSettings *s)
 
DAV1D_API int dav1d_parse_sequence_header (Dav1dSequenceHeader *out, const uint8_t *buf, const size_t sz)
 
DAV1D_API int dav1d_send_data (Dav1dContext *c, Dav1dData *in)
 
DAV1D_API int dav1d_get_picture (Dav1dContext *c, Dav1dPicture *out)
 
DAV1D_API void dav1d_close (Dav1dContext **c_out)
 
DAV1D_API void dav1d_flush (Dav1dContext *c)
 
DAV1D_API int dav1d_get_event_flags (Dav1dContext *c, enum Dav1dEventFlags *flags)
 

Macro Definition Documentation

◆ DAV1D_MAX_FRAME_THREADS

#define DAV1D_MAX_FRAME_THREADS   256

◆ DAV1D_MAX_POSTFILTER_THREADS

#define DAV1D_MAX_POSTFILTER_THREADS   256

◆ DAV1D_MAX_TILE_THREADS

#define DAV1D_MAX_TILE_THREADS   64

Typedef Documentation

◆ Dav1dContext

typedef struct Dav1dContext Dav1dContext

◆ Dav1dRef

typedef struct Dav1dRef Dav1dRef

Enumeration Type Documentation

◆ Dav1dEventFlags

Enumerator
DAV1D_EVENT_FLAG_NEW_SEQUENCE 

The last returned picture contains a reference to a new Sequence Header, either because it's the start of a new coded sequence, or the decoder was flushed before it was generated.

DAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO 

The last returned picture contains a reference to a Sequence Header with new operating parameters information for the current coded sequence.

Function Documentation

◆ dav1d_close()

DAV1D_API void dav1d_close ( Dav1dContext **  c_out)

Close a decoder instance and free all associated memory.

Parameters
c_outThe decoder instance to close. *c_out will be set to NULL.

◆ dav1d_default_settings()

DAV1D_API void dav1d_default_settings ( Dav1dSettings s)

Initialize settings to default values.

Parameters
sInput settings context.

◆ dav1d_flush()

DAV1D_API void dav1d_flush ( Dav1dContext c)

Flush all delayed frames in decoder and clear internal decoder state, to be used when seeking.

Parameters
cInput decoder instance.
Note
Decoding will start only after a valid sequence header OBU is delivered to dav1d_send_data().

◆ dav1d_get_event_flags()

DAV1D_API int dav1d_get_event_flags ( Dav1dContext c,
enum Dav1dEventFlags flags 
)

Fetch a combination of DAV1D_EVENT_FLAG_* event flags generated by the decoding process.

Parameters
cInput decoder instance.
flagsWhere to write the flags.
Returns
0 on success, or < 0 (a negative DAV1D_ERR code) on error.
Note
Calling this function will clear all the event flags currently stored in the decoder.

◆ dav1d_get_picture()

DAV1D_API int dav1d_get_picture ( Dav1dContext c,
Dav1dPicture out 
)

Return a decoded picture.

Parameters
cInput decoder instance.
outOutput frame. The caller assumes ownership of the returned reference.
Returns
0: Success, and a frame is returned. DAV1D_ERR(EAGAIN): Not enough data to output a frame. dav1d_send_data() should be called with new input. other negative DAV1D_ERR codes: Error during decoding or because of invalid passed-in arguments.
Note
To drain buffered frames from the decoder (i.e. on end of stream), call this function until it returns DAV1D_ERR(EAGAIN).
Dav1dData data = { 0 };
Dav1dPicture p = { 0 };
int res;
read_data(&data);
do {
res = dav1d_send_data(c, &data);
// Keep going even if the function can't consume the current data
packet. It eventually will after one or more frames have been
returned in this loop.
if (res < 0 && res != DAV1D_ERR(EAGAIN))
free_and_abort();
res = dav1d_get_picture(c, &p);
if (res < 0) {
if (res != DAV1D_ERR(EAGAIN))
free_and_abort();
} else
output_and_unref_picture(&p);
// Stay in the loop as long as there's data to consume.
} while (data.sz || read_data(&data) == SUCCESS);
// Handle EOS by draining all buffered frames.
do {
res = dav1d_get_picture(c, &p);
if (res < 0) {
if (res != DAV1D_ERR(EAGAIN))
free_and_abort();
} else
output_and_unref_picture(&p);
} while (res == 0);
#define DAV1D_ERR(e)
Definition: common.h:54
DAV1D_API int dav1d_get_picture(Dav1dContext *c, Dav1dPicture *out)
DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in)
Definition: data.h:36
size_t sz
data size
Definition: data.h:38
Definition: picture.h:49

◆ dav1d_open()

DAV1D_API int dav1d_open ( Dav1dContext **  c_out,
const Dav1dSettings s 
)

Allocate and open a decoder instance.

Parameters
c_outThe decoder instance to open. *c_out will be set to the allocated context.
sInput settings context.
Note
The context must be freed using dav1d_close() when decoding is finished.
Returns
0 on success, or < 0 (a negative DAV1D_ERR code) on error.

◆ dav1d_parse_sequence_header()

DAV1D_API int dav1d_parse_sequence_header ( Dav1dSequenceHeader out,
const uint8_t *  buf,
const size_t  sz 
)

Parse a Sequence Header OBU from bitstream data.

Parameters
outOutput Sequence Header.
bufThe data to be parser.
szSize of the data.
Returns
0 on success, or < 0 (a negative DAV1D_ERR code) on error.
Note
It is safe to feed this function data containing other OBUs than a Sequence Header, as they will simply be ignored. If there is more than one Sequence Header OBU present, only the last will be returned.

◆ dav1d_send_data()

DAV1D_API int dav1d_send_data ( Dav1dContext c,
Dav1dData in 
)

Feed bitstream data to the decoder.

Parameters
cInput decoder instance.
inInput bitstream data. On success, ownership of the reference is passed to the library.
Returns
0: Success, and the data was consumed. DAV1D_ERR(EAGAIN): The data can't be consumed. dav1d_get_picture() should be called to get one or more frames before the function can consume new data. other negative DAV1D_ERR codes: Error during decoding or because of invalid passed-in arguments.

◆ dav1d_version()

DAV1D_API const char* dav1d_version ( void  )

Get library version.