FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
v4l2_buffers.c File Reference
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>
#include "libavcodec/avcodec.h"
#include "libavcodec/internal.h"
#include "v4l2_context.h"
#include "v4l2_buffers.h"
#include "v4l2_m2m.h"

Go to the source code of this file.

Macros

#define USEC_PER_SEC   1000000
 

Functions

static V4L2m2mContextbuf_to_m2mctx (V4L2Buffer *buf)
 
static AVCodecContextlogger (V4L2Buffer *buf)
 
static void v4l2_set_pts (V4L2Buffer *out, int64_t pts)
 
static uint64_t v4l2_get_pts (V4L2Buffer *avbuf)
 
static enum AVColorPrimaries v4l2_get_color_primaries (V4L2Buffer *buf)
 
static enum AVColorRange v4l2_get_color_range (V4L2Buffer *buf)
 
static enum AVColorSpace v4l2_get_color_space (V4L2Buffer *buf)
 
static enum
AVColorTransferCharacteristic 
v4l2_get_color_trc (V4L2Buffer *buf)
 
static void v4l2_free_buffer (void *opaque, uint8_t *unused)
 
static int v4l2_buf_to_bufref (V4L2Buffer *in, int plane, AVBufferRef **buf)
 
static int v4l2_bufref_to_buf (V4L2Buffer *out, int plane, const uint8_t *data, int size, AVBufferRef *bref)
 
int ff_v4l2_buffer_avframe_to_buf (const AVFrame *frame, V4L2Buffer *out)
 Extracts the data from an AVFrame to a V4L2Buffer. More...
 
int ff_v4l2_buffer_buf_to_avframe (AVFrame *frame, V4L2Buffer *avbuf)
 Extracts the data from a V4L2Buffer to an AVFrame. More...
 
int ff_v4l2_buffer_buf_to_avpkt (AVPacket *pkt, V4L2Buffer *avbuf)
 Extracts the data from a V4L2Buffer to an AVPacket. More...
 
int ff_v4l2_buffer_avpkt_to_buf (const AVPacket *pkt, V4L2Buffer *out)
 Extracts the data from an AVPacket to a V4L2Buffer. More...
 
int ff_v4l2_buffer_initialize (V4L2Buffer *avbuf, int index)
 Initializes a V4L2Buffer. More...
 
int ff_v4l2_buffer_enqueue (V4L2Buffer *avbuf)
 Enqueues a V4L2Buffer. More...
 

Macro Definition Documentation

#define USEC_PER_SEC   1000000

Definition at line 36 of file v4l2_buffers.c.

Referenced by v4l2_get_pts(), and v4l2_set_pts().

Function Documentation

static V4L2m2mContext* buf_to_m2mctx ( V4L2Buffer buf)
inlinestatic
static AVCodecContext* logger ( V4L2Buffer buf)
inlinestatic

Definition at line 45 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe(), and ff_v4l2_buffer_buf_to_avpkt().

static void v4l2_set_pts ( V4L2Buffer out,
int64_t  pts 
)
inlinestatic

Definition at line 50 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_avframe_to_buf(), and ff_v4l2_buffer_avpkt_to_buf().

static uint64_t v4l2_get_pts ( V4L2Buffer avbuf)
inlinestatic

Definition at line 65 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe(), and ff_v4l2_buffer_buf_to_avpkt().

static enum AVColorPrimaries v4l2_get_color_primaries ( V4L2Buffer buf)
static

Definition at line 78 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

static enum AVColorRange v4l2_get_color_range ( V4L2Buffer buf)
static

Definition at line 112 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

static enum AVColorSpace v4l2_get_color_space ( V4L2Buffer buf)
static

Definition at line 130 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

static enum AVColorTransferCharacteristic v4l2_get_color_trc ( V4L2Buffer buf)
static

Definition at line 162 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

static void v4l2_free_buffer ( void opaque,
uint8_t unused 
)
static

Definition at line 206 of file v4l2_buffers.c.

Referenced by v4l2_buf_to_bufref().

static int v4l2_buf_to_bufref ( V4L2Buffer in,
int  plane,
AVBufferRef **  buf 
)
static

Definition at line 230 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe(), and ff_v4l2_buffer_buf_to_avpkt().

static int v4l2_bufref_to_buf ( V4L2Buffer out,
int  plane,
const uint8_t data,
int  size,
AVBufferRef bref 
)
static

Definition at line 260 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_avframe_to_buf(), and ff_v4l2_buffer_avpkt_to_buf().

int ff_v4l2_buffer_avframe_to_buf ( const AVFrame frame,
V4L2Buffer out 
)

Extracts the data from an AVFrame to a V4L2Buffer.

Parameters
[in]frameAVFrame to get the data from
[in]avbufV4L2Bfuffer to push the information to
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 289 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_enqueue_frame().

int ff_v4l2_buffer_buf_to_avframe ( AVFrame frame,
V4L2Buffer buf 
)

Extracts the data from a V4L2Buffer to an AVFrame.

Parameters
[in]frameThe AVFRame to push the information to
[in]bufThe 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 can't be created.

Definition at line 304 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_dequeue_frame().

int ff_v4l2_buffer_buf_to_avpkt ( AVPacket pkt,
V4L2Buffer buf 
)

Extracts the data from a V4L2Buffer to an AVPacket.

Parameters
[in]pktThe AVPacket to push the information to
[in]bufThe 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 can't be created.

Definition at line 355 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_dequeue_packet().

int ff_v4l2_buffer_avpkt_to_buf ( const AVPacket pkt,
V4L2Buffer out 
)

Extracts the data from an AVPacket to a V4L2Buffer.

Parameters
[in]frameAVPacket to get the data from
[in]avbufV4L2Bfuffer to push the information to
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 380 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_enqueue_packet().

int ff_v4l2_buffer_initialize ( V4L2Buffer avbuf,
int  index 
)

Initializes a V4L2Buffer.

Parameters
[in]avbufV4L2Bfuffer to initialize
[in]indexv4l2 buffer id
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 396 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_init().

int ff_v4l2_buffer_enqueue ( V4L2Buffer avbuf)

Enqueues a V4L2Buffer.

Parameters
[in]avbufV4L2Bfuffer to push to the driver
Returns
0 in case of success, a negative AVERROR code otherwise

Definition at line 465 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_initialize(), ff_v4l2_context_enqueue_frame(), ff_v4l2_context_enqueue_packet(), and v4l2_free_buffer().