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 "libavcodec/internal.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/opt.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 AVCodecDefault v4l2_m2m_defaults []
 

Macro Definition Documentation

#define MPEG_CID (   x)    V4L2_CID_MPEG_VIDEO_##x
#define MPEG_VIDEO (   x)    V4L2_MPEG_VIDEO_##x
#define OFFSET (   x)    offsetof(V4L2m2mPriv, x)

Definition at line 385 of file v4l2_m2m_enc.c.

Definition at line 386 of file v4l2_m2m_enc.c.

#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 }
#define FLAGS
Definition: v4l2_m2m_enc.c:386
#define OFFSET(x)
Definition: v4l2_m2m_enc.c:385
#define V4L_M2M_DEFAULT_OPTS
Definition: v4l2_m2m.h:39

Definition at line 388 of file v4l2_m2m_enc.c.

#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, \
};
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
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:72
Describe the class of an AVClass context structure.
Definition: log.h:67

Definition at line 410 of file v4l2_m2m_enc.c.

#define M2MENC (   NAME,
  LONGNAME,
  OPTIONS_NAME,
  CODEC 
)
Value:
M2MENC_CLASS(NAME, OPTIONS_NAME) \
AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \
.name = #NAME "_v4l2m2m" , \
.long_name = NULL_IF_CONFIG_SMALL("V4L2 mem2mem " LONGNAME " encoder wrapper"), \
.type = AVMEDIA_TYPE_VIDEO, \
.id = CODEC , \
.priv_data_size = sizeof(V4L2m2mPriv), \
.priv_class = &v4l2_m2m_ ## NAME ##_enc_class, \
.receive_packet = v4l2_receive_packet, \
.close = v4l2_encode_close, \
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \
.wrapper_name = "v4l2m2m", \
}
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
static const AVCodecDefault v4l2_m2m_defaults[]
Definition: v4l2_m2m_enc.c:404
#define M2MENC_CLASS(NAME, OPTIONS_NAME)
Definition: v4l2_m2m_enc.c:410
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:150
static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Definition: v4l2_m2m_enc.c:287
static av_cold int v4l2_encode_init(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:330
#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:75
static av_cold int v4l2_encode_close(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:380
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361

Definition at line 418 of file v4l2_m2m_enc.c.

Function Documentation

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

static void v4l2_set_ext_ctrl ( V4L2m2mContext s,
unsigned int  id,
signed int  value,
const char *  name,
int  log_warning 
)
inlinestatic
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().

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

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

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

static void v4l2_subscribe_eos_event ( V4L2m2mContext s)
inlinestatic

Definition at line 163 of file v4l2_m2m_enc.c.

Referenced by 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().

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

static int v4l2_receive_packet ( AVCodecContext avctx,
AVPacket avpkt 
)
static

Definition at line 287 of file v4l2_m2m_enc.c.

static av_cold int v4l2_encode_init ( AVCodecContext avctx)
static

Definition at line 330 of file v4l2_m2m_enc.c.

static av_cold int v4l2_encode_close ( AVCodecContext avctx)
static

Definition at line 380 of file v4l2_m2m_enc.c.

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   
)

Variable Documentation

const AVOption mpeg4_options[]
static
Initial value:
= {
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define FF_MPEG4_PROFILE_OPTS
Definition: profiles.h:40
#define V4L_M2M_CAPTURE_OPTS
Definition: v4l2_m2m_enc.c:388

Definition at line 393 of file v4l2_m2m_enc.c.

const AVOption options[]
static
Initial value:
= {
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define V4L_M2M_CAPTURE_OPTS
Definition: v4l2_m2m_enc.c:388

Definition at line 399 of file v4l2_m2m_enc.c.

const AVCodecDefault v4l2_m2m_defaults[]
static
Initial value:
= {
{ "qmin", "-1" },
{ "qmax", "-1" },
{ NULL },
}
#define NULL
Definition: coverity.c:32

Definition at line 404 of file v4l2_m2m_enc.c.