Commit 6af37afa authored by Ronald S. Bultje's avatar Ronald S. Bultje

Add API to match input images to specific output pictures

Fixes #59.
parent f8e1a621
......@@ -28,6 +28,9 @@
#ifndef __DAV1D_COMMON_H__
#define __DAV1D_COMMON_H__
#include <stddef.h>
#include <stdint.h>
#ifndef DAV1D_API
#if defined _WIN32
#define DAV1D_API __declspec(dllexport)
......@@ -40,4 +43,19 @@
#endif
#endif
/**
* Input packet metadata which are copied from the input data used to
* decode each image into the matching structure of the output image
* returned back to the user. Since these are metadata fields, they
* can be used for other purposes than the documented ones, they will
* still be passed from input data to output picture without being
* used internally.
*/
typedef struct Dav1dDataProps {
uint64_t timestamp; ///< container timestamp of input data, default -1
uint64_t duration; ///< container duration of input data, default -1
uint64_t offset; ///< stream offset of input data, default -1
size_t size; ///< packet size, default Dav1dData.sz
} Dav1dDataProps;
#endif // __DAV1D_COMMON_H__
......@@ -37,6 +37,7 @@ typedef struct Dav1dData {
const uint8_t *data; ///< data pointer
size_t sz; ///< data size
struct Dav1dRef *ref; ///< allocation origin
Dav1dDataProps m;
} Dav1dData;
/**
......
......@@ -165,6 +165,7 @@ typedef struct Dav1dPicture {
ptrdiff_t stride[2];
Dav1dPictureParameters p;
Dav1dDataProps m;
void *allocator_data; ///< pointer managed by the allocator
} Dav1dPicture;
......
......@@ -44,7 +44,8 @@ uint8_t * dav1d_data_create(Dav1dData *const buf, const size_t sz) {
buf->ref = dav1d_ref_create(sz);
if (!buf->ref) return NULL;
buf->data = buf->ref->const_data;
buf->sz = sz;
buf->sz = buf->m.size = sz;
buf->m.timestamp = buf->m.duration = buf->m.offset = ~0ULL;
return buf->ref->data;
}
......@@ -60,7 +61,8 @@ int dav1d_data_wrap(Dav1dData *const buf, const uint8_t *const ptr, const size_t
buf->ref = dav1d_ref_wrap(ptr, free_callback, user_data);
if (!buf->ref) return -ENOMEM;
buf->data = ptr;
buf->sz = sz;
buf->sz = buf->m.size = sz;
buf->m.timestamp = buf->m.duration = buf->m.offset = ~0ULL;
return 0;
}
......
......@@ -3110,6 +3110,7 @@ int dav1d_submit_frame(Dav1dContext *const c) {
f->sr_cur.p.p.mtrx = f->seq_hdr.mtrx;
f->sr_cur.p.p.chr = f->seq_hdr.chr;
f->sr_cur.p.p.fullrange = f->seq_hdr.color_range;
f->sr_cur.p.m = f->tile[0].data.m;
if (f->frame_hdr.super_res.enabled) {
res = dav1d_picture_alloc_copy(&f->cur, f->frame_hdr.width[0], &f->sr_cur.p);
......@@ -3186,7 +3187,6 @@ int dav1d_submit_frame(Dav1dContext *const c) {
// segmap
if (f->frame_hdr.segmentation.enabled) {
// By default, the previous segmentation map is not initialised.
f->prev_segmap_ref = NULL;
f->prev_segmap = NULL;
......
......@@ -1260,6 +1260,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
assert(pkt_bytelen >= (bit_pos >> 3));
dav1d_ref_inc(in->ref);
c->tile[c->n_tile_data].data.ref = in->ref;
c->tile[c->n_tile_data].data.m = in->m;
c->tile[c->n_tile_data].data.data = in->data + (bit_pos >> 3);
c->tile[c->n_tile_data].data.sz = pkt_bytelen - (bit_pos >> 3);
// ensure tile groups are in order and sane, see 6.10.1
......@@ -1303,6 +1304,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
if (c->n_fc == 1) {
dav1d_picture_ref(&c->out,
&c->refs[c->frame_hdr.existing_frame_idx].p.p);
c->out.m = in->m;
} else {
// need to append this to the frame output queue
const unsigned next = c->frame_thread.next++;
......@@ -1330,6 +1332,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
&c->refs[c->frame_hdr.existing_frame_idx].p);
out_delayed->visible = 1;
out_delayed->flushed = 0;
out_delayed->p.m = in->m;
pthread_mutex_unlock(&f->frame_thread.td.lock);
}
c->have_frame_hdr = 0;
......
......@@ -120,6 +120,7 @@ static int picture_alloc_with_edges(Dav1dPicture *const p,
p->p.trc = DAV1D_TRC_UNKNOWN;
p->p.mtrx = DAV1D_MC_UNKNOWN;
p->p.chr = DAV1D_CHR_UNKNOWN;
p->m.timestamp = p->m.duration = p->m.offset = ~0ULL;
p->p.layout = layout;
p->p.bpc = bpc;
p->p.film_grain = (Dav1dFilmGrainData) { 0 };
......@@ -178,6 +179,7 @@ int dav1d_picture_alloc_copy(Dav1dPicture *const dst, const int w,
if (!res) {
dst->poc = src->poc;
dst->p = src->p;
dst->m = src->m;
dst->p.w = w;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment