#ifndef AVCODEC_V4L2_BUFFERS_H
#define AVCODEC_V4L2_BUFFERS_H
+#include <stdatomic.h>
#include <linux/videodev2.h>
#include "avcodec.h"
/* each buffer needs to have a reference to its context */
struct V4L2Context *context;
+ /* This object is refcounted per-plane, so we need to keep track
+ * of how many context-refs we are holding. */
+ AVBufferRef *context_ref;
+ atomic_uint context_refcount;
+
/* keep track of the mmap address and mmap length */
struct V4L2Plane_info {
int bytesperline;
* @param[in] buf The V4L2Buffer to get the information from
*
* @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
- * AVERROR(ENOMEM) if the AVBufferRef cant be created.
+ * AVERROR(ENOMEM) if the AVBufferRef can't be created.
*/
int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *buf);
* @param[in] buf The V4L2Buffer to get the information from
*
* @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
- * AVERROR(ENOMEM) if the AVBufferRef cant be created.
+ * AVERROR(ENOMEM) if the AVBufferRef can't be created.
*
*/
int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *buf);