Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-05-08 06:45:15 +0300
committerJames Almer <jamrial@gmail.com>2019-05-09 01:27:20 +0300
commitf713e25030bbe8deaf6266246f78b4e5d3a05bf7 (patch)
tree2e6e9ddf40e8ffebd6b644098915e31e169d2a2d /include/dav1d
parent11da4086e59f81393255a1c1786a990f9fa565b9 (diff)
Add a DAV1D_ERR define to negate errno values when needed
Diffstat (limited to 'include/dav1d')
-rw-r--r--include/dav1d/common.h7
-rw-r--r--include/dav1d/data.h4
-rw-r--r--include/dav1d/dav1d.h22
-rw-r--r--include/dav1d/picture.h2
4 files changed, 21 insertions, 14 deletions
diff --git a/include/dav1d/common.h b/include/dav1d/common.h
index b1f79a4..b55e939 100644
--- a/include/dav1d/common.h
+++ b/include/dav1d/common.h
@@ -28,6 +28,7 @@
#ifndef DAV1D_COMMON_H
#define DAV1D_COMMON_H
+#include <errno.h>
#include <stddef.h>
#include <stdint.h>
@@ -47,6 +48,12 @@
#endif
#endif
+#if EPERM > 0
+#define DAV1D_ERR(e) (-(e)) ///< Negate POSIX error code.
+#else
+#define DAV1D_ERR(e) (e)
+#endif
+
/**
* A reference-counted object wrapper for a user-configurable pointer.
*/
diff --git a/include/dav1d/data.h b/include/dav1d/data.h
index 09a03a1..f945a04 100644
--- a/include/dav1d/data.h
+++ b/include/dav1d/data.h
@@ -62,7 +62,7 @@ DAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);
* be the $cookie input argument to this function.
* @param cookie Opaque parameter passed to free_callback().
*
- * @return 0 on success. A negative errno value on error.
+ * @return 0 on success. A negative DAV1D_ERR value on error.
*/
DAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,
void (*free_callback)(const uint8_t *buf, void *cookie),
@@ -87,7 +87,7 @@ DAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,
* function.
* @param cookie Opaque parameter passed to $free_callback.
*
- * @return 0 on success. A negative errno value on error.
+ * @return 0 on success. A negative DAV1D_ERR value on error.
*/
DAV1D_API int dav1d_data_wrap_user_data(Dav1dData *data,
const uint8_t *user_data,
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h
index 5f7db46..f56cd15 100644
--- a/include/dav1d/dav1d.h
+++ b/include/dav1d/dav1d.h
@@ -90,7 +90,7 @@ DAV1D_API void dav1d_default_settings(Dav1dSettings *s);
* @note The context must be freed using dav1d_close() when decoding is
* finished.
*
- * @return 0 on success, or < 0 (a negative errno code) on error.
+ * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.
*/
DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
@@ -101,7 +101,7 @@ DAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);
* @param buf The data to be parser.
* @param sz Size of the data.
*
- * @return 0 on success, or < 0 (a negative errno code) on error.
+ * @return 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
@@ -119,11 +119,11 @@ DAV1D_API int dav1d_parse_sequence_header(Dav1dSequenceHeader *out,
*
* @return
* 0: Success, and the data was consumed.
- * -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 errno codes: Error during decoding or because of invalid
- * passed-in arguments.
+ * 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_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);
@@ -136,10 +136,10 @@ DAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);
*
* @return
* 0: Success, and a frame is returned.
- * -EAGAIN: Not enough data to output a frame. dav1d_send_data() should be
- * called with new input.
- * other negative errno codes: Error during decoding or because of invalid
- * passed-in arguments.
+ * 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 -EAGAIN.
diff --git a/include/dav1d/picture.h b/include/dav1d/picture.h
index fee0ec8..477eda3 100644
--- a/include/dav1d/picture.h
+++ b/include/dav1d/picture.h
@@ -109,7 +109,7 @@ typedef struct Dav1dPicAllocator {
*
* @note No fields other than data, stride and allocator_data must be filled
* by this callback.
- * @return 0 on success. A negative errno value on error.
+ * @return 0 on success. A negative DAV1D_ERR value on error.
*/
int (*alloc_picture_callback)(Dav1dPicture *pic, void *cookie);
/**