diff options
author | Ronald S. Bultje <rsbultje@gmail.com> | 2018-11-22 16:51:08 +0300 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2018-11-23 17:10:38 +0300 |
commit | 6af37afa94abac4f002c80bb1bdb794f21cf21ff (patch) | |
tree | 4c5bb47c1dc3864a52f57af2289aadfe3555118f | |
parent | f8e1a621f9b68ac60115773874b0ce646e79c02d (diff) |
Add API to match input images to specific output pictures
Fixes #59.
-rw-r--r-- | include/dav1d/common.h | 18 | ||||
-rw-r--r-- | include/dav1d/data.h | 1 | ||||
-rw-r--r-- | include/dav1d/picture.h | 1 | ||||
-rw-r--r-- | src/data.c | 6 | ||||
-rw-r--r-- | src/decode.c | 2 | ||||
-rw-r--r-- | src/obu.c | 3 | ||||
-rw-r--r-- | src/picture.c | 2 |
7 files changed, 30 insertions, 3 deletions
diff --git a/include/dav1d/common.h b/include/dav1d/common.h index a4e3021..9da18ac 100644 --- a/include/dav1d/common.h +++ b/include/dav1d/common.h @@ -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__ diff --git a/include/dav1d/data.h b/include/dav1d/data.h index c68a29b..a78dc4a 100644 --- a/include/dav1d/data.h +++ b/include/dav1d/data.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; /** diff --git a/include/dav1d/picture.h b/include/dav1d/picture.h index f8e1025..9dbdaf9 100644 --- a/include/dav1d/picture.h +++ b/include/dav1d/picture.h @@ -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; } diff --git a/src/decode.c b/src/decode.c index 92ce9e2..6389552 100644 --- a/src/decode.c +++ b/src/decode.c @@ -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; diff --git a/src/picture.c b/src/picture.c index 57935e2..39be558 100644 --- a/src/picture.c +++ b/src/picture.c @@ -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; } |