FFmpeg
Macros | Functions | Variables
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 "libavutil/pixdesc.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 AVRational v4l2_get_timebase (V4L2Buffer *avbuf)
 
static void v4l2_set_pts (V4L2Buffer *out, int64_t pts)
 
static int64_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_increase_ref (V4L2Buffer *in)
 
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, int offset)
 
static int v4l2_buffer_buf_to_swframe (AVFrame *frame, V4L2Buffer *avbuf)
 
static int v4l2_buffer_swframe_to_buf (const AVFrame *frame, V4L2Buffer *out)
 
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...
 

Variables

static AVRational v4l2_timebase = { 1, USEC_PER_SEC }
 

Macro Definition Documentation

◆ USEC_PER_SEC

#define USEC_PER_SEC   1000000

Definition at line 37 of file v4l2_buffers.c.

Function Documentation

◆ buf_to_m2mctx()

static V4L2m2mContext* buf_to_m2mctx ( V4L2Buffer buf)
inlinestatic

◆ logger()

static AVCodecContext* logger ( V4L2Buffer buf)
inlinestatic

Definition at line 47 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe(), and ff_v4l2_buffer_buf_to_avpkt().

◆ v4l2_get_timebase()

static AVRational v4l2_get_timebase ( V4L2Buffer avbuf)
inlinestatic

Definition at line 52 of file v4l2_buffers.c.

Referenced by v4l2_get_pts(), and v4l2_set_pts().

◆ v4l2_set_pts()

static void v4l2_set_pts ( V4L2Buffer out,
int64_t  pts 
)
inlinestatic

Definition at line 61 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_avframe_to_buf(), and ff_v4l2_buffer_avpkt_to_buf().

◆ v4l2_get_pts()

static int64_t v4l2_get_pts ( V4L2Buffer avbuf)
inlinestatic

Definition at line 74 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe(), and ff_v4l2_buffer_buf_to_avpkt().

◆ v4l2_get_color_primaries()

static enum AVColorPrimaries v4l2_get_color_primaries ( V4L2Buffer buf)
static

Definition at line 85 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

◆ v4l2_get_color_range()

static enum AVColorRange v4l2_get_color_range ( V4L2Buffer buf)
static

Definition at line 119 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

◆ v4l2_get_color_space()

static enum AVColorSpace v4l2_get_color_space ( V4L2Buffer buf)
static

Definition at line 137 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

◆ v4l2_get_color_trc()

static enum AVColorTransferCharacteristic v4l2_get_color_trc ( V4L2Buffer buf)
static

Definition at line 169 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

◆ v4l2_free_buffer()

static void v4l2_free_buffer ( void *  opaque,
uint8_t *  unused 
)
static

Definition at line 213 of file v4l2_buffers.c.

Referenced by v4l2_buf_to_bufref().

◆ v4l2_buf_increase_ref()

static int v4l2_buf_increase_ref ( V4L2Buffer in)
static

Definition at line 237 of file v4l2_buffers.c.

Referenced by v4l2_buf_to_bufref().

◆ v4l2_buf_to_bufref()

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

Definition at line 257 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avpkt(), and v4l2_buffer_buf_to_swframe().

◆ v4l2_bufref_to_buf()

static int v4l2_bufref_to_buf ( V4L2Buffer out,
int  plane,
const uint8_t *  data,
int  size,
int  offset 
)
static

Definition at line 277 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_avpkt_to_buf(), and v4l2_buffer_swframe_to_buf().

◆ v4l2_buffer_buf_to_swframe()

static int v4l2_buffer_buf_to_swframe ( AVFrame frame,
V4L2Buffer avbuf 
)
static

Definition at line 300 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_buf_to_avframe().

◆ v4l2_buffer_swframe_to_buf()

static int v4l2_buffer_swframe_to_buf ( const AVFrame frame,
V4L2Buffer out 
)
static

Definition at line 341 of file v4l2_buffers.c.

Referenced by ff_v4l2_buffer_avframe_to_buf().

◆ ff_v4l2_buffer_avframe_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 412 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_enqueue_frame().

◆ ff_v4l2_buffer_buf_to_avframe()

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 419 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_dequeue_frame().

◆ ff_v4l2_buffer_buf_to_avpkt()

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 453 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_dequeue_packet().

◆ ff_v4l2_buffer_avpkt_to_buf()

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 478 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_enqueue_packet().

◆ ff_v4l2_buffer_initialize()

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 494 of file v4l2_buffers.c.

Referenced by ff_v4l2_context_init().

◆ ff_v4l2_buffer_enqueue()

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 561 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().

Variable Documentation

◆ v4l2_timebase

AVRational v4l2_timebase = { 1, USEC_PER_SEC }
static

Definition at line 38 of file v4l2_buffers.c.

Referenced by v4l2_get_pts(), and v4l2_set_pts().