FFmpeg
Macros | Functions | Variables
v4l2_m2m_enc.c File Reference
#include <linux/videodev2.h>
#include <sys/ioctl.h>
#include <search.h>
#include "encode.h"
#include "libavcodec/avcodec.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/opt.h"
#include "codec_internal.h"
#include "profiles.h"
#include "v4l2_context.h"
#include "v4l2_m2m.h"
#include "v4l2_fmt.h"

Go to the source code of this file.

Macros

#define MPEG_CID(x)   V4L2_CID_MPEG_VIDEO_##x
 
#define MPEG_VIDEO(x)   V4L2_MPEG_VIDEO_##x
 
#define OFFSET(x)   offsetof(V4L2m2mPriv, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 
#define V4L_M2M_CAPTURE_OPTS
 
#define M2MENC_CLASS(NAME, OPTIONS_NAME)
 
#define M2MENC(NAME, LONGNAME, OPTIONS_NAME, CODEC)
 

Functions

static void v4l2_set_timeperframe (V4L2m2mContext *s, unsigned int num, unsigned int den)
 
static void v4l2_set_ext_ctrl (V4L2m2mContext *s, unsigned int id, signed int value, const char *name, int log_warning)
 
static int v4l2_get_ext_ctrl (V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning)
 
static unsigned int v4l2_h264_profile_from_ff (int p)
 
static int v4l2_mpeg4_profile_from_ff (int p)
 
static int v4l2_check_b_frame_support (V4L2m2mContext *s)
 
static void v4l2_subscribe_eos_event (V4L2m2mContext *s)
 
static int v4l2_prepare_encoder (V4L2m2mContext *s)
 
static int v4l2_send_frame (AVCodecContext *avctx, const AVFrame *frame)
 
static int v4l2_receive_packet (AVCodecContext *avctx, AVPacket *avpkt)
 
static av_cold int v4l2_encode_init (AVCodecContext *avctx)
 
static av_cold int v4l2_encode_close (AVCodecContext *avctx)
 
 M2MENC (mpeg4,"MPEG4", mpeg4_options, AV_CODEC_ID_MPEG4)
 
 M2MENC (h263, "H.263", options, AV_CODEC_ID_H263)
 
 M2MENC (h264, "H.264", options, AV_CODEC_ID_H264)
 
 M2MENC (hevc, "HEVC", options, AV_CODEC_ID_HEVC)
 
 M2MENC (vp8, "VP8", options, AV_CODEC_ID_VP8)
 

Variables

static const AVOption mpeg4_options []
 
static const AVOption options []
 
static const FFCodecDefault v4l2_m2m_defaults []
 

Macro Definition Documentation

◆ MPEG_CID

#define MPEG_CID (   x)    V4L2_CID_MPEG_VIDEO_##x

Definition at line 38 of file v4l2_m2m_enc.c.

◆ MPEG_VIDEO

#define MPEG_VIDEO (   x)    V4L2_MPEG_VIDEO_##x

Definition at line 39 of file v4l2_m2m_enc.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(V4L2m2mPriv, x)

Definition at line 389 of file v4l2_m2m_enc.c.

◆ FLAGS

Definition at line 390 of file v4l2_m2m_enc.c.

◆ V4L_M2M_CAPTURE_OPTS

#define V4L_M2M_CAPTURE_OPTS
Value:
{ "num_capture_buffers", "Number of buffers in the capture context", \
OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 4 }, 4, INT_MAX, FLAGS }

Definition at line 392 of file v4l2_m2m_enc.c.

◆ M2MENC_CLASS

#define M2MENC_CLASS (   NAME,
  OPTIONS_NAME 
)
Value:
static const AVClass v4l2_m2m_ ## NAME ## _enc_class = { \
.class_name = #NAME "_v4l2m2m_encoder", \
.item_name = av_default_item_name, \
.option = OPTIONS_NAME, \
.version = LIBAVUTIL_VERSION_INT, \
};

Definition at line 414 of file v4l2_m2m_enc.c.

◆ M2MENC

#define M2MENC (   NAME,
  LONGNAME,
  OPTIONS_NAME,
  CODEC 
)
Value:
M2MENC_CLASS(NAME, OPTIONS_NAME) \
const FFCodec ff_ ## NAME ## _v4l2m2m_encoder = { \
.p.name = #NAME "_v4l2m2m" , \
CODEC_LONG_NAME("V4L2 mem2mem " LONGNAME " encoder wrapper"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = CODEC , \
.priv_data_size = sizeof(V4L2m2mPriv), \
.p.priv_class = &v4l2_m2m_ ## NAME ##_enc_class, \
.init = v4l2_encode_init, \
.close = v4l2_encode_close, \
.defaults = v4l2_m2m_defaults, \
.color_ranges = AVCOL_RANGE_MPEG, \
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_INIT_CLEANUP, \
.p.wrapper_name = "v4l2m2m", \
}

Definition at line 422 of file v4l2_m2m_enc.c.

Function Documentation

◆ v4l2_set_timeperframe()

static void v4l2_set_timeperframe ( V4L2m2mContext s,
unsigned int  num,
unsigned int  den 
)
inlinestatic

Definition at line 41 of file v4l2_m2m_enc.c.

Referenced by v4l2_prepare_encoder().

◆ v4l2_set_ext_ctrl()

static void v4l2_set_ext_ctrl ( V4L2m2mContext s,
unsigned int  id,
signed int  value,
const char *  name,
int  log_warning 
)
inlinestatic

◆ v4l2_get_ext_ctrl()

static int v4l2_get_ext_ctrl ( V4L2m2mContext s,
unsigned int  id,
signed int *  value,
const char *  name,
int  log_warning 
)
inlinestatic

Definition at line 74 of file v4l2_m2m_enc.c.

Referenced by v4l2_check_b_frame_support().

◆ v4l2_h264_profile_from_ff()

static unsigned int v4l2_h264_profile_from_ff ( int  p)
inlinestatic

Definition at line 100 of file v4l2_m2m_enc.c.

Referenced by v4l2_prepare_encoder().

◆ v4l2_mpeg4_profile_from_ff()

static int v4l2_mpeg4_profile_from_ff ( int  p)
inlinestatic

Definition at line 127 of file v4l2_m2m_enc.c.

Referenced by v4l2_prepare_encoder().

◆ v4l2_check_b_frame_support()

static int v4l2_check_b_frame_support ( V4L2m2mContext s)
static

Definition at line 148 of file v4l2_m2m_enc.c.

Referenced by v4l2_prepare_encoder().

◆ v4l2_subscribe_eos_event()

static void v4l2_subscribe_eos_event ( V4L2m2mContext s)
inlinestatic

Definition at line 163 of file v4l2_m2m_enc.c.

Referenced by v4l2_prepare_encoder().

◆ v4l2_prepare_encoder()

static int v4l2_prepare_encoder ( V4L2m2mContext s)
static

requirements

settingss

Definition at line 174 of file v4l2_m2m_enc.c.

Referenced by v4l2_encode_init().

◆ v4l2_send_frame()

static int v4l2_send_frame ( AVCodecContext avctx,
const AVFrame frame 
)
static

Definition at line 274 of file v4l2_m2m_enc.c.

Referenced by v4l2_receive_packet().

◆ v4l2_receive_packet()

static int v4l2_receive_packet ( AVCodecContext avctx,
AVPacket avpkt 
)
static

Definition at line 287 of file v4l2_m2m_enc.c.

◆ v4l2_encode_init()

static av_cold int v4l2_encode_init ( AVCodecContext avctx)
static

Definition at line 334 of file v4l2_m2m_enc.c.

◆ v4l2_encode_close()

static av_cold int v4l2_encode_close ( AVCodecContext avctx)
static

Definition at line 384 of file v4l2_m2m_enc.c.

◆ M2MENC() [1/5]

M2MENC ( mpeg4  ,
"MPEG4"  ,
mpeg4_options  ,
AV_CODEC_ID_MPEG4   
)

◆ M2MENC() [2/5]

M2MENC ( h263  ,
"H.263"  ,
options  ,
AV_CODEC_ID_H263   
)

◆ M2MENC() [3/5]

M2MENC ( h264  ,
"H.264"  ,
options  ,
AV_CODEC_ID_H264   
)

◆ M2MENC() [4/5]

M2MENC ( hevc  ,
"HEVC"  ,
options  ,
AV_CODEC_ID_HEVC   
)

◆ M2MENC() [5/5]

M2MENC ( vp8  ,
"VP8"  ,
options  ,
AV_CODEC_ID_VP8   
)

Variable Documentation

◆ mpeg4_options

const AVOption mpeg4_options[]
static
Initial value:

Definition at line 397 of file v4l2_m2m_enc.c.

◆ options

const AVOption options[]
static
Initial value:

Definition at line 403 of file v4l2_m2m_enc.c.

◆ v4l2_m2m_defaults

const FFCodecDefault v4l2_m2m_defaults[]
static
Initial value:
= {
{ "qmin", "-1" },
{ "qmax", "-1" },
{ NULL },
}

Definition at line 408 of file v4l2_m2m_enc.c.

v4l2_m2m_defaults
static const FFCodecDefault v4l2_m2m_defaults[]
Definition: v4l2_m2m_enc.c:408
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
v4l2_encode_close
static av_cold int v4l2_encode_close(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:384
v4l2_encode_init
static av_cold int v4l2_encode_init(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:334
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:35
FFCodec
Definition: codec_internal.h:127
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
V4L_M2M_DEFAULT_OPTS
#define V4L_M2M_DEFAULT_OPTS
Definition: v4l2_m2m.h:39
M2MENC_CLASS
#define M2MENC_CLASS(NAME, OPTIONS_NAME)
Definition: v4l2_m2m_enc.c:414
v4l2_receive_packet
static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Definition: v4l2_m2m_enc.c:287
FLAGS
#define FLAGS
Definition: v4l2_m2m_enc.c:390
FF_MPEG4_PROFILE_OPTS
#define FF_MPEG4_PROFILE_OPTS
Definition: profiles.h:42
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
V4L2m2mPriv
Definition: v4l2_m2m.h:71
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
V4L_M2M_CAPTURE_OPTS
#define V4L_M2M_CAPTURE_OPTS
Definition: v4l2_m2m_enc.c:392