FFmpeg  4.3.9
v4l2_m2m_enc.c
Go to the documentation of this file.
1 /*
2  * V4L2 mem2mem encoders
3  *
4  * Copyright (C) 2017 Alexis Ballier <aballier@gentoo.org>
5  * Copyright (C) 2017 Jorge Ramirez <jorge.ramirez-ortiz@linaro.org>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include <linux/videodev2.h>
25 #include <sys/ioctl.h>
26 #include <search.h>
27 #include "libavcodec/avcodec.h"
28 #include "libavcodec/internal.h"
29 #include "libavutil/pixdesc.h"
30 #include "libavutil/pixfmt.h"
31 #include "libavutil/opt.h"
32 #include "profiles.h"
33 #include "v4l2_context.h"
34 #include "v4l2_m2m.h"
35 #include "v4l2_fmt.h"
36 
37 #define MPEG_CID(x) V4L2_CID_MPEG_VIDEO_##x
38 #define MPEG_VIDEO(x) V4L2_MPEG_VIDEO_##x
39 
40 static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, unsigned int den)
41 {
42  struct v4l2_streamparm parm = { 0 };
43 
44  parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT;
45  parm.parm.output.timeperframe.denominator = den;
46  parm.parm.output.timeperframe.numerator = num;
47 
48  if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0)
49  av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe");
50 }
51 
52 static inline void v4l2_set_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int value, const char *name, int log_warning)
53 {
54  struct v4l2_ext_controls ctrls = { { 0 } };
55  struct v4l2_ext_control ctrl = { 0 };
56 
57  /* set ctrls */
58  ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
59  ctrls.controls = &ctrl;
60  ctrls.count = 1;
61 
62  /* set ctrl*/
63  ctrl.value = value;
64  ctrl.id = id;
65 
66  if (ioctl(s->fd, VIDIOC_S_EXT_CTRLS, &ctrls) < 0)
67  av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG,
68  "Failed to set %s: %s\n", name, strerror(errno));
69  else
70  av_log(s->avctx, AV_LOG_DEBUG, "Encoder: %s = %d\n", name, value);
71 }
72 
73 static inline int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning)
74 {
75  struct v4l2_ext_controls ctrls = { { 0 } };
76  struct v4l2_ext_control ctrl = { 0 };
77  int ret;
78 
79  /* set ctrls */
80  ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
81  ctrls.controls = &ctrl;
82  ctrls.count = 1;
83 
84  /* set ctrl*/
85  ctrl.id = id ;
86 
87  ret = ioctl(s->fd, VIDIOC_G_EXT_CTRLS, &ctrls);
88  if (ret < 0) {
89  av_log(s->avctx, log_warning || errno != EINVAL ? AV_LOG_WARNING : AV_LOG_DEBUG,
90  "Failed to get %s\n", name);
91  return ret;
92  }
93 
94  *value = ctrl.value;
95 
96  return 0;
97 }
98 
99 static inline unsigned int v4l2_h264_profile_from_ff(int p)
100 {
101  static const struct h264_profile {
102  unsigned int ffmpeg_val;
103  unsigned int v4l2_val;
104  } profile[] = {
105  { FF_PROFILE_H264_CONSTRAINED_BASELINE, MPEG_VIDEO(H264_PROFILE_CONSTRAINED_BASELINE) },
106  { FF_PROFILE_H264_HIGH_444_PREDICTIVE, MPEG_VIDEO(H264_PROFILE_HIGH_444_PREDICTIVE) },
107  { FF_PROFILE_H264_HIGH_422_INTRA, MPEG_VIDEO(H264_PROFILE_HIGH_422_INTRA) },
108  { FF_PROFILE_H264_HIGH_444_INTRA, MPEG_VIDEO(H264_PROFILE_HIGH_444_INTRA) },
109  { FF_PROFILE_H264_HIGH_10_INTRA, MPEG_VIDEO(H264_PROFILE_HIGH_10_INTRA) },
110  { FF_PROFILE_H264_HIGH_422, MPEG_VIDEO(H264_PROFILE_HIGH_422) },
111  { FF_PROFILE_H264_BASELINE, MPEG_VIDEO(H264_PROFILE_BASELINE) },
112  { FF_PROFILE_H264_EXTENDED, MPEG_VIDEO(H264_PROFILE_EXTENDED) },
113  { FF_PROFILE_H264_HIGH_10, MPEG_VIDEO(H264_PROFILE_HIGH_10) },
114  { FF_PROFILE_H264_MAIN, MPEG_VIDEO(H264_PROFILE_MAIN) },
115  { FF_PROFILE_H264_HIGH, MPEG_VIDEO(H264_PROFILE_HIGH) },
116  };
117  int i;
118 
119  for (i = 0; i < FF_ARRAY_ELEMS(profile); i++) {
120  if (profile[i].ffmpeg_val == p)
121  return profile[i].v4l2_val;
122  }
123  return AVERROR(ENOENT);
124 }
125 
126 static inline int v4l2_mpeg4_profile_from_ff(int p)
127 {
128  static const struct mpeg4_profile {
129  unsigned int ffmpeg_val;
130  unsigned int v4l2_val;
131  } profile[] = {
132  { FF_PROFILE_MPEG4_ADVANCED_CODING, MPEG_VIDEO(MPEG4_PROFILE_ADVANCED_CODING_EFFICIENCY) },
133  { FF_PROFILE_MPEG4_ADVANCED_SIMPLE, MPEG_VIDEO(MPEG4_PROFILE_ADVANCED_SIMPLE) },
134  { FF_PROFILE_MPEG4_SIMPLE_SCALABLE, MPEG_VIDEO(MPEG4_PROFILE_SIMPLE_SCALABLE) },
135  { FF_PROFILE_MPEG4_SIMPLE, MPEG_VIDEO(MPEG4_PROFILE_SIMPLE) },
136  { FF_PROFILE_MPEG4_CORE, MPEG_VIDEO(MPEG4_PROFILE_CORE) },
137  };
138  int i;
139 
140  for (i = 0; i < FF_ARRAY_ELEMS(profile); i++) {
141  if (profile[i].ffmpeg_val == p)
142  return profile[i].v4l2_val;
143  }
144  return AVERROR(ENOENT);
145 }
146 
148 {
149  if (s->avctx->max_b_frames)
150  av_log(s->avctx, AV_LOG_WARNING, "Encoder does not support b-frames yet\n");
151 
152  v4l2_set_ext_ctrl(s, MPEG_CID(B_FRAMES), 0, "number of B-frames", 0);
153  v4l2_get_ext_ctrl(s, MPEG_CID(B_FRAMES), &s->avctx->max_b_frames, "number of B-frames", 0);
154  if (s->avctx->max_b_frames == 0)
155  return 0;
156 
157  avpriv_report_missing_feature(s->avctx, "DTS/PTS calculation for V4L2 encoding");
158 
159  return AVERROR_PATCHWELCOME;
160 }
161 
163 {
164  struct v4l2_event_subscription sub;
165 
166  memset(&sub, 0, sizeof(sub));
167  sub.type = V4L2_EVENT_EOS;
168  if (ioctl(s->fd, VIDIOC_SUBSCRIBE_EVENT, &sub) < 0)
170  "the v4l2 driver does not support end of stream VIDIOC_SUBSCRIBE_EVENT\n");
171 }
172 
174 {
175  AVCodecContext *avctx = s->avctx;
176  int qmin_cid, qmax_cid, qmin, qmax;
177  int ret, val;
178 
179  /**
180  * requirements
181  */
183 
185  if (ret)
186  return ret;
187 
188  /**
189  * settingss
190  */
191  if (avctx->framerate.num || avctx->framerate.den)
192  v4l2_set_timeperframe(s, avctx->framerate.den, avctx->framerate.num);
193 
194  /* set ext ctrls */
195  v4l2_set_ext_ctrl(s, MPEG_CID(HEADER_MODE), MPEG_VIDEO(HEADER_MODE_SEPARATE), "header mode", 0);
196  v4l2_set_ext_ctrl(s, MPEG_CID(BITRATE) , avctx->bit_rate, "bit rate", 1);
197  v4l2_set_ext_ctrl(s, MPEG_CID(FRAME_RC_ENABLE), 1, "frame level rate control", 0);
198  v4l2_set_ext_ctrl(s, MPEG_CID(GOP_SIZE), avctx->gop_size,"gop size", 1);
199 
200  av_log(avctx, AV_LOG_DEBUG,
201  "Encoder Context: id (%d), profile (%d), frame rate(%d/%d), number b-frames (%d), "
202  "gop size (%d), bit rate (%"PRId64"), qmin (%d), qmax (%d)\n",
203  avctx->codec_id, avctx->profile, avctx->framerate.num, avctx->framerate.den,
204  avctx->max_b_frames, avctx->gop_size, avctx->bit_rate, avctx->qmin, avctx->qmax);
205 
206  switch (avctx->codec_id) {
207  case AV_CODEC_ID_H264:
208  if (avctx->profile != FF_PROFILE_UNKNOWN) {
209  val = v4l2_h264_profile_from_ff(avctx->profile);
210  if (val < 0)
211  av_log(avctx, AV_LOG_WARNING, "h264 profile not found\n");
212  else
213  v4l2_set_ext_ctrl(s, MPEG_CID(H264_PROFILE), val, "h264 profile", 1);
214  }
215  qmin_cid = MPEG_CID(H264_MIN_QP);
216  qmax_cid = MPEG_CID(H264_MAX_QP);
217  qmin = 0;
218  qmax = 51;
219  break;
220  case AV_CODEC_ID_MPEG4:
221  if (avctx->profile != FF_PROFILE_UNKNOWN) {
222  val = v4l2_mpeg4_profile_from_ff(avctx->profile);
223  if (val < 0)
224  av_log(avctx, AV_LOG_WARNING, "mpeg4 profile not found\n");
225  else
226  v4l2_set_ext_ctrl(s, MPEG_CID(MPEG4_PROFILE), val, "mpeg4 profile", 1);
227  }
228  qmin_cid = MPEG_CID(MPEG4_MIN_QP);
229  qmax_cid = MPEG_CID(MPEG4_MAX_QP);
230  if (avctx->flags & AV_CODEC_FLAG_QPEL)
231  v4l2_set_ext_ctrl(s, MPEG_CID(MPEG4_QPEL), 1, "qpel", 1);
232  qmin = 1;
233  qmax = 31;
234  break;
235  case AV_CODEC_ID_H263:
236  qmin_cid = MPEG_CID(H263_MIN_QP);
237  qmax_cid = MPEG_CID(H263_MAX_QP);
238  qmin = 1;
239  qmax = 31;
240  break;
241  case AV_CODEC_ID_VP8:
242  qmin_cid = MPEG_CID(VPX_MIN_QP);
243  qmax_cid = MPEG_CID(VPX_MAX_QP);
244  qmin = 0;
245  qmax = 127;
246  break;
247  case AV_CODEC_ID_VP9:
248  qmin_cid = MPEG_CID(VPX_MIN_QP);
249  qmax_cid = MPEG_CID(VPX_MAX_QP);
250  qmin = 0;
251  qmax = 255;
252  break;
253  default:
254  return 0;
255  }
256 
257  if (avctx->qmin >= 0 && avctx->qmax >= 0 && avctx->qmin > avctx->qmax) {
258  av_log(avctx, AV_LOG_WARNING, "Invalid qmin:%d qmax:%d. qmin should not "
259  "exceed qmax\n", avctx->qmin, avctx->qmax);
260  } else {
261  qmin = avctx->qmin >= 0 ? avctx->qmin : qmin;
262  qmax = avctx->qmax >= 0 ? avctx->qmax : qmax;
263  }
264 
265  v4l2_set_ext_ctrl(s, qmin_cid, qmin, "minimum video quantizer scale",
266  avctx->qmin >= 0);
267  v4l2_set_ext_ctrl(s, qmax_cid, qmax, "maximum video quantizer scale",
268  avctx->qmax >= 0);
269 
270  return 0;
271 }
272 
273 static int v4l2_send_frame(AVCodecContext *avctx, const AVFrame *frame)
274 {
275  V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
276  V4L2Context *const output = &s->output;
277 
278 #ifdef V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME
279  if (frame && frame->pict_type == AV_PICTURE_TYPE_I)
280  v4l2_set_ext_ctrl(s, MPEG_CID(FORCE_KEY_FRAME), 0, "force key frame", 1);
281 #endif
282 
283  return ff_v4l2_context_enqueue_frame(output, frame);
284 }
285 
286 static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
287 {
288  V4L2m2mContext *s = ((V4L2m2mPriv*)avctx->priv_data)->context;
289  V4L2Context *const capture = &s->capture;
290  V4L2Context *const output = &s->output;
291  int ret;
292 
293  if (s->draining)
294  goto dequeue;
295 
296  if (!output->streamon) {
297  ret = ff_v4l2_context_set_status(output, VIDIOC_STREAMON);
298  if (ret) {
299  av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMON failed on output context\n");
300  return ret;
301  }
302  }
303 
304  if (!capture->streamon) {
305  ret = ff_v4l2_context_set_status(capture, VIDIOC_STREAMON);
306  if (ret) {
307  av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMON failed on capture context\n");
308  return ret;
309  }
310  }
311 
312 dequeue:
313  return ff_v4l2_context_dequeue_packet(capture, avpkt);
314 }
315 
317 {
318  V4L2Context *capture, *output;
319  V4L2m2mContext *s;
320  V4L2m2mPriv *priv = avctx->priv_data;
321  enum AVPixelFormat pix_fmt_output;
322  uint32_t v4l2_fmt_output;
323  int ret;
324 
325  ret = ff_v4l2_m2m_create_context(priv, &s);
326  if (ret < 0)
327  return ret;
328 
329  capture = &s->capture;
330  output = &s->output;
331 
332  /* common settings output/capture */
333  output->height = capture->height = avctx->height;
334  output->width = capture->width = avctx->width;
335 
336  /* output context */
338  output->av_pix_fmt = avctx->pix_fmt;
339 
340  /* capture context */
341  capture->av_codec_id = avctx->codec_id;
342  capture->av_pix_fmt = AV_PIX_FMT_NONE;
343 
344  s->avctx = avctx;
345  ret = ff_v4l2_m2m_codec_init(priv);
346  if (ret) {
347  av_log(avctx, AV_LOG_ERROR, "can't configure encoder\n");
348  return ret;
349  }
350 
351  if (V4L2_TYPE_IS_MULTIPLANAR(output->type))
352  v4l2_fmt_output = output->format.fmt.pix_mp.pixelformat;
353  else
354  v4l2_fmt_output = output->format.fmt.pix.pixelformat;
355 
356  pix_fmt_output = ff_v4l2_format_v4l2_to_avfmt(v4l2_fmt_output, AV_CODEC_ID_RAWVIDEO);
357  if (pix_fmt_output != avctx->pix_fmt) {
358  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt_output);
359  av_log(avctx, AV_LOG_ERROR, "Encoder requires %s pixel format.\n", desc->name);
360  return AVERROR(EINVAL);
361  }
362 
363  return v4l2_prepare_encoder(s);
364 }
365 
367 {
368  return ff_v4l2_m2m_codec_end(avctx->priv_data);
369 }
370 
371 #define OFFSET(x) offsetof(V4L2m2mPriv, x)
372 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
373 
374 #define V4L_M2M_CAPTURE_OPTS \
375  V4L_M2M_DEFAULT_OPTS,\
376  { "num_capture_buffers", "Number of buffers in the capture context", \
377  OFFSET(num_capture_buffers), AV_OPT_TYPE_INT, {.i64 = 4 }, 4, INT_MAX, FLAGS }
378 
379 static const AVOption mpeg4_options[] = {
382  { NULL },
383 };
384 
385 static const AVOption options[] = {
387  { NULL },
388 };
389 
391  { "qmin", "-1" },
392  { "qmax", "-1" },
393  { NULL },
394 };
395 
396 #define M2MENC_CLASS(NAME, OPTIONS_NAME) \
397  static const AVClass v4l2_m2m_ ## NAME ## _enc_class = { \
398  .class_name = #NAME "_v4l2m2m_encoder", \
399  .item_name = av_default_item_name, \
400  .option = OPTIONS_NAME, \
401  .version = LIBAVUTIL_VERSION_INT, \
402  };
403 
404 #define M2MENC(NAME, LONGNAME, OPTIONS_NAME, CODEC) \
405  M2MENC_CLASS(NAME, OPTIONS_NAME) \
406  AVCodec ff_ ## NAME ## _v4l2m2m_encoder = { \
407  .name = #NAME "_v4l2m2m" , \
408  .long_name = NULL_IF_CONFIG_SMALL("V4L2 mem2mem " LONGNAME " encoder wrapper"), \
409  .type = AVMEDIA_TYPE_VIDEO, \
410  .id = CODEC , \
411  .priv_data_size = sizeof(V4L2m2mPriv), \
412  .priv_class = &v4l2_m2m_ ## NAME ##_enc_class, \
413  .init = v4l2_encode_init, \
414  .send_frame = v4l2_send_frame, \
415  .receive_packet = v4l2_receive_packet, \
416  .close = v4l2_encode_close, \
417  .defaults = v4l2_m2m_defaults, \
418  .capabilities = AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_DELAY, \
419  .wrapper_name = "v4l2m2m", \
420  }
421 
422 M2MENC(mpeg4,"MPEG4", mpeg4_options, AV_CODEC_ID_MPEG4);
423 M2MENC(h263, "H.263", options, AV_CODEC_ID_H263);
424 M2MENC(h264, "H.264", options, AV_CODEC_ID_H264);
425 M2MENC(hevc, "HEVC", options, AV_CODEC_ID_HEVC);
426 M2MENC(vp8, "VP8", options, AV_CODEC_ID_VP8);
#define FF_PROFILE_H264_MAIN
Definition: avcodec.h:1904
enum AVPixelFormat ff_v4l2_format_v4l2_to_avfmt(uint32_t v4l2_fmt, enum AVCodecID avcodec)
Definition: v4l2_fmt.c:132
#define FF_PROFILE_MPEG4_SIMPLE
Definition: avcodec.h:1923
#define NULL
Definition: coverity.c:32
AVRational framerate
Definition: avcodec.h:2073
static const AVOption options[]
Definition: v4l2_m2m_enc.c:385
static const AVCodecDefault v4l2_m2m_defaults[]
Definition: v4l2_m2m_enc.c:390
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2549
This structure describes decoded (raw) audio or video data.
Definition: frame.h:300
static int v4l2_get_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int *value, const char *name, int log_warning)
Definition: v4l2_m2m_enc.c:73
static const AVOption mpeg4_options[]
Definition: v4l2_m2m_enc.c:379
AVOption.
Definition: opt.h:246
AVCodecContext * avctx
Definition: v4l2_m2m.h:52
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
int64_t bit_rate
the average bitrate
Definition: avcodec.h:576
const char * desc
Definition: nvenc.c:79
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
Definition: avcodec.h:786
static int v4l2_mpeg4_profile_from_ff(int p)
Definition: v4l2_m2m_enc.c:126
int num
Numerator.
Definition: rational.h:59
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:736
static void v4l2_set_ext_ctrl(V4L2m2mContext *s, unsigned int id, signed int value, const char *name, int log_warning)
Definition: v4l2_m2m_enc.c:52
int width
Width and height of the frames it produces (in case of a capture context, e.g.
Definition: v4l2_context.h:71
#define MPEG_VIDEO(x)
Definition: v4l2_m2m_enc.c:38
#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE
Definition: avcodec.h:1924
int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
Releases all the codec resources if all AVBufferRefs have been returned to the ctx.
Definition: v4l2_m2m.c:336
int ff_v4l2_context_dequeue_packet(V4L2Context *ctx, AVPacket *pkt)
Dequeues a buffer from a V4L2Context to an AVPacket.
Definition: v4l2_context.c:656
int profile
profile
Definition: avcodec.h:1863
static int v4l2_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Definition: v4l2_m2m_enc.c:286
static av_cold int v4l2_encode_init(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:316
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE
Definition: avcodec.h:1914
int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
Probes the video nodes looking for the required codec capabilities.
Definition: v4l2_m2m.c:357
enum AVCodecID av_codec_id
AVCodecID corresponding to this buffer context.
Definition: v4l2_context.h:59
#define FF_PROFILE_H264_BASELINE
Definition: avcodec.h:1902
int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
Allocate a new context and references for a V4L2 M2M instance.
Definition: v4l2_m2m.c:395
#define av_cold
Definition: attributes.h:88
#define FF_PROFILE_MPEG4_CORE
Definition: avcodec.h:1925
AVOptions.
static AVFrame * frame
static int v4l2_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Definition: v4l2_m2m_enc.c:273
static void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, unsigned int den)
Definition: v4l2_m2m_enc.c:40
#define FF_PROFILE_H264_EXTENDED
Definition: avcodec.h:1905
#define av_log(a,...)
const char * name
Definition: pixdesc.h:82
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
#define AVERROR(e)
Definition: error.h:43
static av_cold int v4l2_encode_close(AVCodecContext *avctx)
Definition: v4l2_m2m_enc.c:366
int qmax
maximum quantizer
Definition: avcodec.h:1379
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
#define FF_PROFILE_H264_HIGH_422
Definition: avcodec.h:1910
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:606
#define FF_PROFILE_H264_HIGH
Definition: avcodec.h:1906
enum AVPixelFormat av_pix_fmt
AVPixelFormat corresponding to this buffer context.
Definition: v4l2_context.h:53
int streamon
Whether the stream has been started (VIDIOC_STREAMON has been sent).
Definition: v4l2_context.h:87
const char * name
Definition: qsvenc.c:46
enum AVPictureType pict_type
Picture type of the frame.
Definition: frame.h:383
static int v4l2_check_b_frame_support(V4L2m2mContext *s)
Definition: v4l2_m2m_enc.c:147
int width
picture width / height.
Definition: avcodec.h:699
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1864
#define s(width, name)
Definition: cbs_vp9.c:257
#define FF_MPEG4_PROFILE_OPTS
Definition: profiles.h:40
#define FF_ARRAY_ELEMS(a)
struct v4l2_format format
Format returned by the driver after initializing the buffer context.
Definition: v4l2_context.h:65
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:62
int ff_v4l2_context_set_status(V4L2Context *ctx, uint32_t cmd)
Sets the status of a V4L2Context.
Definition: v4l2_context.c:572
V4L2Context capture
Definition: v4l2_m2m.h:48
Libavcodec external API header.
static void v4l2_subscribe_eos_event(V4L2m2mContext *s)
Definition: v4l2_m2m_enc.c:162
#define FF_PROFILE_H264_HIGH_422_INTRA
Definition: avcodec.h:1911
enum AVCodecID codec_id
Definition: avcodec.h:536
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
main external API structure.
Definition: avcodec.h:526
#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE
Definition: avcodec.h:1938
int qmin
minimum quantizer
Definition: avcodec.h:1372
#define V4L_M2M_CAPTURE_OPTS
Definition: v4l2_m2m_enc.c:374
#define FF_PROFILE_H264_HIGH_10_INTRA
Definition: avcodec.h:1908
double value
Definition: eval.c:98
#define FF_PROFILE_MPEG4_ADVANCED_CODING
Definition: avcodec.h:1934
mfxU16 profile
Definition: qsvenc.c:45
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
V4L2Context output
Definition: v4l2_m2m.h:49
#define AV_CODEC_FLAG_QPEL
Use qpel MC.
Definition: avcodec.h:287
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:721
int ff_v4l2_context_enqueue_frame(V4L2Context *ctx, const AVFrame *frame)
Enqueues a buffer to a V4L2Context from an AVFrame.
Definition: v4l2_context.c:586
common internal api header.
#define M2MENC(NAME, LONGNAME, OPTIONS_NAME, CODEC)
Definition: v4l2_m2m_enc.c:404
int den
Denominator.
Definition: rational.h:60
#define MPEG_CID(x)
Definition: v4l2_m2m_enc.c:37
static int v4l2_prepare_encoder(V4L2m2mContext *s)
Definition: v4l2_m2m_enc.c:173
void * priv_data
Definition: avcodec.h:553
pixel format definitions
static unsigned int v4l2_h264_profile_from_ff(int p)
Definition: v4l2_m2m_enc.c:99
#define FF_PROFILE_H264_HIGH_444_INTRA
Definition: avcodec.h:1915
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
Definition: avcodec.h:1903
#define FF_PROFILE_H264_HIGH_10
Definition: avcodec.h:1907
enum AVCodecID id
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
static double val(void *priv, double ch)
Definition: aeval.c:76
This structure stores compressed data.
Definition: packet.h:332
enum v4l2_buf_type type
Type of this buffer context.
Definition: v4l2_context.h:47