diff options
author | James Almer <jamrial@gmail.com> | 2022-03-08 21:52:10 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-08 22:43:22 +0300 |
commit | 493ffb12f77df791f7dcde991b92d64bf873fefd (patch) | |
tree | 301bc8f75479432a01f229f941699e277c1eb8cc | |
parent | 3d3c51a07cc3dd1e3687da40fdb6fbb857cbced1 (diff) |
lib: add a public function to return the props from the last frame that failed to decode
-rw-r--r-- | include/dav1d/dav1d.h | 13 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/decode.c | 4 | ||||
-rw-r--r-- | src/internal.h | 1 | ||||
-rw-r--r-- | src/lib.c | 16 | ||||
-rw-r--r-- | src/obu.c | 2 |
6 files changed, 36 insertions, 2 deletions
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h index 0938156..fd3b622 100644 --- a/include/dav1d/dav1d.h +++ b/include/dav1d/dav1d.h @@ -274,6 +274,19 @@ enum Dav1dEventFlags { */ DAV1D_API int dav1d_get_event_flags(Dav1dContext *c, enum Dav1dEventFlags *flags); +/** + * Retrieve the user-provided metadata associated with the input data packet + * for the last decoding error reported to the user, i.e. a negative return + * value (not EAGAIN) from dav1d_send_data() or dav1d_get_picture(). + * + * @param c Input decoder instance. + * @param out Output Dav1dDataProps. On success, the caller assumes ownership of + * the returned reference. + * + * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error. + */ +DAV1D_API int dav1d_get_decode_error_data_props(Dav1dContext *c, Dav1dDataProps *out); + # ifdef __cplusplus } # endif diff --git a/meson.build b/meson.build index f1258c4..5efb88c 100644 --- a/meson.build +++ b/meson.build @@ -30,7 +30,7 @@ project('dav1d', ['c'], 'b_ndebug=if-release'], meson_version: '>= 0.49.0') -dav1d_soname_version = '6.5.0' +dav1d_soname_version = '6.6.0' dav1d_api_version_array = dav1d_soname_version.split('.') dav1d_api_version_major = dav1d_api_version_array[0] dav1d_api_version_minor = dav1d_api_version_array[1] diff --git a/src/decode.c b/src/decode.c index dff59c2..bd13014 100644 --- a/src/decode.c +++ b/src/decode.c @@ -3501,6 +3501,7 @@ int dav1d_submit_frame(Dav1dContext *const c) { if (error) { f->task_thread.retval = 0; c->cached_error = error; + dav1d_data_props_copy(&c->cached_error_props, &out_delayed->p.m); dav1d_thread_picture_unref(out_delayed); } else if (out_delayed->p.data[0]) { const unsigned progress = atomic_load_explicit(&out_delayed->progress[1], @@ -3844,7 +3845,7 @@ int dav1d_submit_frame(Dav1dContext *const c) { dav1d_ref_dec(&c->refs[i].refmvs); } } - return res; + goto error; } } else { dav1d_task_frame_init(f); @@ -3871,6 +3872,7 @@ error: dav1d_ref_dec(&f->mvs_ref); dav1d_ref_dec(&f->seq_hdr_ref); dav1d_ref_dec(&f->frame_hdr_ref); + dav1d_data_props_copy(&c->cached_error_props, &c->in.m); for (int i = 0; i < f->n_tile_data; i++) dav1d_data_unref_internal(&f->tile[i].data); diff --git a/src/internal.h b/src/internal.h index b8fba1d..eceda98 100644 --- a/src/internal.h +++ b/src/internal.h @@ -197,6 +197,7 @@ struct Dav1dContext { int drain; enum PictureFlags frame_flags; enum Dav1dEventFlags event_flags; + Dav1dDataProps cached_error_props; int cached_error; Dav1dLogger logger; @@ -134,6 +134,8 @@ COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) { c->output_invisible_frames = s->output_invisible_frames; c->inloop_filters = s->inloop_filters; + dav1d_data_props_set_defaults(&c->cached_error_props); + if (dav1d_mem_pool_init(&c->seq_hdr_pool) || dav1d_mem_pool_init(&c->frame_hdr_pool) || dav1d_mem_pool_init(&c->segmap_pool) || @@ -385,6 +387,7 @@ static int drain_picture(Dav1dContext *const c, Dav1dPicture *const out) { const int error = f->task_thread.retval; if (error) { f->task_thread.retval = 0; + dav1d_data_props_copy(&c->cached_error_props, &out_delayed->p.m); dav1d_thread_picture_unref(out_delayed); return error; } @@ -552,6 +555,8 @@ void dav1d_flush(Dav1dContext *const c) { dav1d_ref_dec(&c->content_light_ref); dav1d_ref_dec(&c->itut_t35_ref); + dav1d_data_props_unref_internal(&c->cached_error_props); + if (c->n_fc == 1 && c->n_tc == 1) return; atomic_store(c->flush, 1); @@ -702,6 +707,17 @@ int dav1d_get_event_flags(Dav1dContext *const c, enum Dav1dEventFlags *const fla return 0; } +int dav1d_get_decode_error_data_props(Dav1dContext *const c, Dav1dDataProps *const out) { + validate_input_or_ret(c != NULL, DAV1D_ERR(EINVAL)); + validate_input_or_ret(out != NULL, DAV1D_ERR(EINVAL)); + + dav1d_data_props_unref_internal(out); + *out = c->cached_error_props; + dav1d_data_props_set_defaults(&c->cached_error_props); + + return 0; +} + void dav1d_picture_unref(Dav1dPicture *const p) { dav1d_picture_unref_internal(p); } @@ -1581,6 +1581,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, const int globa if (error) { c->cached_error = error; f->task_thread.retval = 0; + dav1d_data_props_copy(&c->cached_error_props, &out_delayed->p.m); dav1d_thread_picture_unref(out_delayed); } else if (out_delayed->p.data[0]) { const unsigned progress = atomic_load_explicit(&out_delayed->progress[1], @@ -1633,6 +1634,7 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in, const int globa return len + init_byte_pos; error: + dav1d_data_props_copy(&c->cached_error_props, &in->m); dav1d_log(c, "Error parsing OBU data\n"); return DAV1D_ERR(EINVAL); } |