diff options
author | James Almer <jamrial@gmail.com> | 2018-11-27 21:25:43 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-11-27 21:29:02 +0300 |
commit | ae08430fba74624a971e7bf77ec1a31bbb26a034 (patch) | |
tree | c4876e7d63d88cacc760a5e94498d87290df5b2e /include/dav1d/dav1d.h | |
parent | 560dc6848ad6fa9e7037f8f795a2194a4242511e (diff) |
Add a simple API usage example to the doxy
Based on the implementation from tools/dav1d.c
Diffstat (limited to 'include/dav1d/dav1d.h')
-rw-r--r-- | include/dav1d/dav1d.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h index 2ea7a18..d13ad36 100644 --- a/include/dav1d/dav1d.h +++ b/include/dav1d/dav1d.h @@ -128,6 +128,39 @@ DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in); * * @note To drain buffered frames from the decoder (i.e. on end of stream), * call this function until it returns -EAGAIN. + * + * @code{.c} + * 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 != -EAGAIN) + * free_and_abort(); + * res = dav1d_get_picture(c, &p); + * if (res < 0) { + * if (res != -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 != -EAGAIN) + * free_and_abort(); + * } else + * output_and_unref_picture(&p); + * } while (res == 0); + * @endcode */ DAV1D_API int dav1d_get_picture(Dav1dContext *c, Dav1dPicture *out); |