FFmpeg: libavdevice/kmsgrab.c Source File

FFmpeg
kmsgrab.c
Go to the documentation of this file.
1 /*
2  * KMS/DRM input device
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <fcntl.h>
22 #include <unistd.h>
23 
24 #include <drm.h>
25 #include <drm_fourcc.h>
26 #include <drm_mode.h>
27 #include <xf86drm.h>
28 #include <xf86drmMode.h>
29 
30 #include "libavutil/hwcontext.h"
31 #include "libavutil/hwcontext_drm.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/mathematics.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixfmt.h"
36 #include "libavutil/pixdesc.h"
37 #include "libavutil/time.h"
38 
39 #include "libavformat/avformat.h"
40 #include "libavformat/internal.h"
41 
42  typedef struct KMSGrabContext {
43   const AVClass *class;
44 
45   AVBufferRef *device_ref;
46   AVHWDeviceContext *device;
47   AVDRMDeviceContext *hwctx;
48 
49   AVBufferRef *frames_ref;
50   AVHWFramesContext *frames;
51 
52   uint32_t plane_id;
53   uint32_t drm_format;
54   unsigned int width;
55   unsigned int height;
56 
57   int64_t frame_delay;
58   int64_t frame_last;
59 
60   const char *device_path;
61   enum AVPixelFormat format;
62   int64_t drm_format_modifier;
63   int64_t source_plane;
64   int64_t source_crtc;
65   AVRational framerate;
66 } KMSGrabContext;
67 
68  static void kmsgrab_free_desc(void *opaque, uint8_t *data)
69 {
70  AVDRMFrameDescriptor *desc = (AVDRMFrameDescriptor*)data;
71 
72  close(desc->objects[0].fd);
73 
74  av_free(desc);
75 }
76 
77  static void kmsgrab_free_frame(void *opaque, uint8_t *data)
78 {
79  AVFrame *frame = (AVFrame*)data;
80 
81  av_frame_free(&frame);
82 }
83 
84  static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
85 {
86  KMSGrabContext *ctx = avctx->priv_data;
87  drmModePlane *plane;
88  drmModeFB *fb;
89  AVDRMFrameDescriptor *desc;
90  AVFrame *frame;
91  int64_t now;
92  int err, fd;
93 
94  now = av_gettime();
95  if (ctx->frame_last) {
96  int64_t delay;
97  while (1) {
98  delay = ctx->frame_last + ctx->frame_delay - now;
99  if (delay <= 0)
100  break;
101  av_usleep(delay);
102  now = av_gettime();
103  }
104  }
105  ctx->frame_last = now;
106 
107  plane = drmModeGetPlane(ctx->hwctx->fd, ctx->plane_id);
108  if (!plane) {
109  av_log(avctx, AV_LOG_ERROR, "Failed to get plane "
110  "%"PRIu32".\n", ctx->plane_id);
111  return AVERROR(EIO);
112  }
113  if (!plane->fb_id) {
114  av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" no longer has "
115  "an associated framebuffer.\n", ctx->plane_id);
116  return AVERROR(EIO);
117  }
118 
119  fb = drmModeGetFB(ctx->hwctx->fd, plane->fb_id);
120  if (!fb) {
121  av_log(avctx, AV_LOG_ERROR, "Failed to get framebuffer "
122  "%"PRIu32".\n", plane->fb_id);
123  return AVERROR(EIO);
124  }
125  if (fb->width != ctx->width || fb->height != ctx->height) {
126  av_log(avctx, AV_LOG_ERROR, "Plane %"PRIu32" framebuffer "
127  "dimensions changed: now %"PRIu32"x%"PRIu32".\n",
128  ctx->plane_id, fb->width, fb->height);
129  return AVERROR(EIO);
130  }
131  if (!fb->handle) {
132  av_log(avctx, AV_LOG_ERROR, "No handle set on framebuffer.\n");
133  return AVERROR(EIO);
134  }
135 
136  err = drmPrimeHandleToFD(ctx->hwctx->fd, fb->handle, O_RDONLY, &fd);
137  if (err < 0) {
138  err = errno;
139  av_log(avctx, AV_LOG_ERROR, "Failed to get PRIME fd from "
140  "framebuffer handle: %s.\n", strerror(errno));
141  return AVERROR(err);
142  }
143 
144  desc = av_mallocz(sizeof(*desc));
145  if (!desc)
146  return AVERROR(ENOMEM);
147 
148  *desc = (AVDRMFrameDescriptor) {
149  .nb_objects = 1,
150  .objects[0] = {
151  .fd = fd,
152  .size = fb->height * fb->pitch,
153  .format_modifier = ctx->drm_format_modifier,
154  },
155  .nb_layers = 1,
156  .layers[0] = {
157  .format = ctx->drm_format,
158  .nb_planes = 1,
159  .planes[0] = {
160  .object_index = 0,
161  .offset = 0,
162  .pitch = fb->pitch,
163  },
164  },
165  };
166 
167  frame = av_frame_alloc();
168  if (!frame)
169  return AVERROR(ENOMEM);
170 
171  frame->hw_frames_ctx = av_buffer_ref(ctx->frames_ref);
172  if (!frame->hw_frames_ctx)
173  return AVERROR(ENOMEM);
174 
175  frame->buf[0] = av_buffer_create((uint8_t*)desc, sizeof(*desc),
176  &kmsgrab_free_desc, avctx, 0);
177  if (!frame->buf[0])
178  return AVERROR(ENOMEM);
179 
180  frame->data[0] = (uint8_t*)desc;
181  frame->format = AV_PIX_FMT_DRM_PRIME;
182  frame->width = fb->width;
183  frame->height = fb->height;
184 
185  drmModeFreeFB(fb);
186  drmModeFreePlane(plane);
187 
188  pkt->buf = av_buffer_create((uint8_t*)frame, sizeof(*frame),
189  &kmsgrab_free_frame, avctx, 0);
190  if (!pkt->buf)
191  return AVERROR(ENOMEM);
192 
193  pkt->data = (uint8_t*)frame;
194  pkt->size = sizeof(*frame);
195  pkt->pts = now;
196  pkt->flags |= AV_PKT_FLAG_TRUSTED;
197 
198  return 0;
199 }
200 
201 static const struct {
202   enum AVPixelFormat pixfmt;
203   uint32_t drm_format;
204 } kmsgrab_formats[] = {
205 #ifdef DRM_FORMAT_R8
206  { AV_PIX_FMT_GRAY8, DRM_FORMAT_R8 },
207 #endif
208 #ifdef DRM_FORMAT_R16
209  { AV_PIX_FMT_GRAY16LE, DRM_FORMAT_R16 },
210  { AV_PIX_FMT_GRAY16BE, DRM_FORMAT_R16 | DRM_FORMAT_BIG_ENDIAN },
211 #endif
212  { AV_PIX_FMT_BGR8, DRM_FORMAT_BGR233 },
213  { AV_PIX_FMT_RGB555LE, DRM_FORMAT_XRGB1555 },
214  { AV_PIX_FMT_RGB555BE, DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN },
215  { AV_PIX_FMT_BGR555LE, DRM_FORMAT_XBGR1555 },
216  { AV_PIX_FMT_BGR555BE, DRM_FORMAT_XBGR1555 | DRM_FORMAT_BIG_ENDIAN },
217  { AV_PIX_FMT_RGB565LE, DRM_FORMAT_RGB565 },
218  { AV_PIX_FMT_RGB565BE, DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN },
219  { AV_PIX_FMT_BGR565LE, DRM_FORMAT_BGR565 },
220  { AV_PIX_FMT_BGR565BE, DRM_FORMAT_BGR565 | DRM_FORMAT_BIG_ENDIAN },
221  { AV_PIX_FMT_RGB24, DRM_FORMAT_RGB888 },
222  { AV_PIX_FMT_BGR24, DRM_FORMAT_BGR888 },
223  { AV_PIX_FMT_0RGB, DRM_FORMAT_BGRX8888 },
224  { AV_PIX_FMT_0BGR, DRM_FORMAT_RGBX8888 },
225  { AV_PIX_FMT_RGB0, DRM_FORMAT_XBGR8888 },
226  { AV_PIX_FMT_BGR0, DRM_FORMAT_XRGB8888 },
227  { AV_PIX_FMT_ARGB, DRM_FORMAT_BGRA8888 },
228  { AV_PIX_FMT_ABGR, DRM_FORMAT_RGBA8888 },
229  { AV_PIX_FMT_RGBA, DRM_FORMAT_ABGR8888 },
230  { AV_PIX_FMT_BGRA, DRM_FORMAT_ARGB8888 },
231  { AV_PIX_FMT_YUYV422, DRM_FORMAT_YUYV },
232  { AV_PIX_FMT_YVYU422, DRM_FORMAT_YVYU },
233  { AV_PIX_FMT_UYVY422, DRM_FORMAT_UYVY },
234 };
235 
236  static av_cold int kmsgrab_read_header(AVFormatContext *avctx)
237 {
238  KMSGrabContext *ctx = avctx->priv_data;
239  drmModePlaneRes *plane_res = NULL;
240  drmModePlane *plane = NULL;
241  drmModeFB *fb = NULL;
242  AVStream *stream;
243  int err, i;
244 
245  for (i = 0; i < FF_ARRAY_ELEMS(kmsgrab_formats); i++) {
246  if (kmsgrab_formats[i].pixfmt == ctx->format) {
247  ctx->drm_format = kmsgrab_formats[i].drm_format;
248  break;
249  }
250  }
251  if (i >= FF_ARRAY_ELEMS(kmsgrab_formats)) {
252  av_log(avctx, AV_LOG_ERROR, "Unsupported format %s.\n",
253  av_get_pix_fmt_name(ctx->format));
254  return AVERROR(EINVAL);
255  }
256 
257  err = av_hwdevice_ctx_create(&ctx->device_ref, AV_HWDEVICE_TYPE_DRM,
258  ctx->device_path, NULL, 0);
259  if (err < 0) {
260  av_log(avctx, AV_LOG_ERROR, "Failed to open DRM device.\n");
261  return err;
262  }
263  ctx->device = (AVHWDeviceContext*) ctx->device_ref->data;
264  ctx->hwctx = (AVDRMDeviceContext*)ctx->device->hwctx;
265 
266  err = drmSetClientCap(ctx->hwctx->fd,
267  DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
268  if (err < 0) {
269  av_log(avctx, AV_LOG_WARNING, "Failed to set universal planes "
270  "capability: primary planes will not be usable.\n");
271  }
272 
273  if (ctx->source_plane > 0) {
274  plane = drmModeGetPlane(ctx->hwctx->fd, ctx->source_plane);
275  if (!plane) {
276  err = errno;
277  av_log(avctx, AV_LOG_ERROR, "Failed to get plane %"PRId64": "
278  "%s.\n", ctx->source_plane, strerror(err));
279  err = AVERROR(err);
280  goto fail;
281  }
282 
283  if (plane->fb_id == 0) {
284  av_log(avctx, AV_LOG_ERROR, "Plane %"PRId64" does not have "
285  "an attached framebuffer.\n", ctx->source_plane);
286  err = AVERROR(EINVAL);
287  goto fail;
288  }
289  } else {
290  plane_res = drmModeGetPlaneResources(ctx->hwctx->fd);
291  if (!plane_res) {
292  av_log(avctx, AV_LOG_ERROR, "Failed to get plane "
293  "resources: %s.\n", strerror(errno));
294  err = AVERROR(EINVAL);
295  goto fail;
296  }
297 
298  for (i = 0; i < plane_res->count_planes; i++) {
299  plane = drmModeGetPlane(ctx->hwctx->fd,
300  plane_res->planes[i]);
301  if (!plane) {
302  err = errno;
303  av_log(avctx, AV_LOG_VERBOSE, "Failed to get "
304  "plane %"PRIu32": %s.\n",
305  plane_res->planes[i], strerror(err));
306  continue;
307  }
308 
309  av_log(avctx, AV_LOG_DEBUG, "Plane %"PRIu32": "
310  "CRTC %"PRIu32" FB %"PRIu32".\n",
311  plane->plane_id, plane->crtc_id, plane->fb_id);
312 
313  if ((ctx->source_crtc > 0 &&
314  plane->crtc_id != ctx->source_crtc) ||
315  plane->fb_id == 0) {
316  // Either not connected to the target source CRTC
317  // or not active.
318  drmModeFreePlane(plane);
319  plane = NULL;
320  continue;
321  }
322 
323  break;
324  }
325 
326  if (i == plane_res->count_planes) {
327  if (ctx->source_crtc > 0) {
328  av_log(avctx, AV_LOG_ERROR, "No usable planes found on "
329  "CRTC %"PRId64".\n", ctx->source_crtc);
330  } else {
331  av_log(avctx, AV_LOG_ERROR, "No usable planes found.\n");
332  }
333  err = AVERROR(EINVAL);
334  goto fail;
335  }
336 
337  av_log(avctx, AV_LOG_INFO, "Using plane %"PRIu32" to "
338  "locate framebuffers.\n", plane->plane_id);
339  }
340 
341  ctx->plane_id = plane->plane_id;
342 
343  fb = drmModeGetFB(ctx->hwctx->fd, plane->fb_id);
344  if (!fb) {
345  err = errno;
346  av_log(avctx, AV_LOG_ERROR, "Failed to get "
347  "framebuffer %"PRIu32": %s.\n",
348  plane->fb_id, strerror(err));
349  err = AVERROR(err);
350  goto fail;
351  }
352 
353  av_log(avctx, AV_LOG_INFO, "Template framebuffer is %"PRIu32": "
354  "%"PRIu32"x%"PRIu32" %"PRIu32"bpp %"PRIu32"b depth.\n",
355  fb->fb_id, fb->width, fb->height, fb->bpp, fb->depth);
356 
357  ctx->width = fb->width;
358  ctx->height = fb->height;
359 
360  if (!fb->handle) {
361  av_log(avctx, AV_LOG_ERROR, "No handle set on framebuffer: "
362  "maybe you need some additional capabilities?\n");
363  err = AVERROR(EINVAL);
364  goto fail;
365  }
366 
367  stream = avformat_new_stream(avctx, NULL);
368  if (!stream) {
369  err = AVERROR(ENOMEM);
370  goto fail;
371  }
372 
373  stream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
374  stream->codecpar->codec_id = AV_CODEC_ID_WRAPPED_AVFRAME;
375  stream->codecpar->width = fb->width;
376  stream->codecpar->height = fb->height;
377  stream->codecpar->format = AV_PIX_FMT_DRM_PRIME;
378 
379  avpriv_set_pts_info(stream, 64, 1, 1000000);
380 
381  ctx->frames_ref = av_hwframe_ctx_alloc(ctx->device_ref);
382  if (!ctx->frames_ref) {
383  err = AVERROR(ENOMEM);
384  goto fail;
385  }
386  ctx->frames = (AVHWFramesContext*)ctx->frames_ref->data;
387 
388  ctx->frames->format = AV_PIX_FMT_DRM_PRIME;
389  ctx->frames->sw_format = ctx->format,
390  ctx->frames->width = fb->width;
391  ctx->frames->height = fb->height;
392 
393  err = av_hwframe_ctx_init(ctx->frames_ref);
394  if (err < 0) {
395  av_log(avctx, AV_LOG_ERROR, "Failed to initialise "
396  "hardware frames context: %d.\n", err);
397  goto fail;
398  }
399 
400  ctx->frame_delay = av_rescale_q(1, (AVRational) { ctx->framerate.den,
401  ctx->framerate.num }, AV_TIME_BASE_Q);
402 
403  err = 0;
404 fail:
405  if (plane_res)
406  drmModeFreePlaneResources(plane_res);
407  if (plane)
408  drmModeFreePlane(plane);
409  if (fb)
410  drmModeFreeFB(fb);
411 
412  return err;
413 }
414 
415  static av_cold int kmsgrab_read_close(AVFormatContext *avctx)
416 {
417  KMSGrabContext *ctx = avctx->priv_data;
418 
419  av_buffer_unref(&ctx->frames_ref);
420  av_buffer_unref(&ctx->device_ref);
421 
422  return 0;
423 }
424 
425  #define OFFSET(x) offsetof(KMSGrabContext, x)
426  #define FLAGS AV_OPT_FLAG_DECODING_PARAM
427  static const AVOption options[] = {
428  { "device", "DRM device path",
429  OFFSET(device_path), AV_OPT_TYPE_STRING,
430  { .str = "/dev/dri/card0" }, 0, 0, FLAGS },
431  { "format", "Pixel format for framebuffer",
432  OFFSET(format), AV_OPT_TYPE_PIXEL_FMT,
433  { .i64 = AV_PIX_FMT_BGR0 }, 0, UINT32_MAX, FLAGS },
434  { "format_modifier", "DRM format modifier for framebuffer",
435  OFFSET(drm_format_modifier), AV_OPT_TYPE_INT64,
436  { .i64 = DRM_FORMAT_MOD_NONE }, 0, INT64_MAX, FLAGS },
437  { "crtc_id", "CRTC ID to define capture source",
438  OFFSET(source_crtc), AV_OPT_TYPE_INT64,
439  { .i64 = 0 }, 0, UINT32_MAX, FLAGS },
440  { "plane_id", "Plane ID to define capture source",
441  OFFSET(source_plane), AV_OPT_TYPE_INT64,
442  { .i64 = 0 }, 0, UINT32_MAX, FLAGS },
443  { "framerate", "Framerate to capture at",
444  OFFSET(framerate), AV_OPT_TYPE_RATIONAL,
445  { .dbl = 30.0 }, 0, 1000, FLAGS },
446  { NULL },
447 };
448 
449  static const AVClass kmsgrab_class = {
450  .class_name = "kmsgrab indev",
451  .item_name = av_default_item_name,
452  .option = options,
453  .version = LIBAVUTIL_VERSION_INT,
454  .category = AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT,
455 };
456 
457  AVInputFormat ff_kmsgrab_demuxer = {
458  .name = "kmsgrab",
459  .long_name = NULL_IF_CONFIG_SMALL("KMS screen capture"),
460  .priv_data_size = sizeof(KMSGrabContext),
461  .read_header = &kmsgrab_read_header,
462  .read_packet = &kmsgrab_read_packet,
463  .read_close = &kmsgrab_read_close,
464  .flags = AVFMT_NOFILE,
465  .priv_class = &kmsgrab_class,
466 };
kmsgrab_class
static const AVClass kmsgrab_class
Definition: kmsgrab.c:449
AVHWDeviceContext
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
Definition: hwcontext.h:60
plane
int plane
Definition: avisynth_c.h:422
AV_PIX_FMT_UYVY422
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
Definition: pixfmt.h:77
KMSGrabContext::source_crtc
int64_t source_crtc
Definition: kmsgrab.c:64
NULL
#define NULL
Definition: coverity.c:32
options
static const AVOption options[]
Definition: kmsgrab.c:427
KMSGrabContext::frame_delay
int64_t frame_delay
Definition: kmsgrab.c:57
kmsgrab_formats
static const struct @168 kmsgrab_formats[]
format
static const char * format[]
Definition: af_aiir.c:311
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:125
kmsgrab_free_desc
static void kmsgrab_free_desc(void *opaque, uint8_t *data)
Definition: kmsgrab.c:68
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
AVOption
AVOption.
Definition: opt.h:246
data
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:64
avpriv_set_pts_info
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4820
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:410
desc
const char * desc
Definition: nvenc.c:65
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: avcodec.h:3884
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV_PIX_FMT_RGB555LE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:104
KMSGrabContext::format
enum AVPixelFormat format
Definition: kmsgrab.c:61
AVPacket::size
int size
Definition: avcodec.h:1431
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:228
AV_PIX_FMT_BGR565LE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
Definition: pixfmt.h:107
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:208
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:236
av_usleep
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:84
AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:235
pkt
static AVPacket pkt
Definition: demuxing_decoding.c:54
AVDRMFrameDescriptor::nb_objects
int nb_objects
Number of DRM objects making up this frame.
Definition: hwcontext_drm.h:137
KMSGrabContext::device_path
const char * device_path
Definition: kmsgrab.c:60
AV_PIX_FMT_RGB565LE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
Definition: pixfmt.h:102
AVFrame::hw_frames_ctx
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
Definition: frame.h:556
AVFormatContext
Format I/O context.
Definition: avformat.h:1342
AVDRMFrameDescriptor
DRM frame descriptor.
Definition: hwcontext_drm.h:133
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:72
uint8_t
uint8_t
Definition: audio_convert.c:194
av_cold
#define av_cold
Definition: attributes.h:82
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:189
AVCodecParameters::width
int width
Video only.
Definition: avcodec.h:3950
AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:234
opt.h
AVOptions.
KMSGrabContext::plane_id
uint32_t plane_id
Definition: kmsgrab.c:52
avformat_new_stream
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
Definition: utils.c:4450
AV_PIX_FMT_RGB565BE
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
Definition: pixfmt.h:101
AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:90
frame
static AVFrame * frame
Definition: demuxing_decoding.c:53
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:91
av_hwdevice_ctx_create
int av_hwdevice_ctx_create(AVBufferRef **pdevice_ref, enum AVHWDeviceType type, const char *device, AVDictionary *opts, int flags)
Open a device of the specified type and create an AVHWDeviceContext for it.
Definition: hwcontext.c:571
AVPacket::data
uint8_t * data
Definition: avcodec.h:1430
kmsgrab_read_packet
static int kmsgrab_read_packet(AVFormatContext *avctx, AVPacket *pkt)
Definition: kmsgrab.c:84
flags
static int flags
Definition: log.c:55
read_close
static av_cold int read_close(AVFormatContext *ctx)
Definition: libcdio.c:145
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
AVDRMObjectDescriptor::fd
int fd
DRM PRIME fd for the object.
Definition: hwcontext_drm.h:52
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
kmsgrab_read_close
static av_cold int kmsgrab_read_close(AVFormatContext *avctx)
Definition: kmsgrab.c:415
AVFrame::width
int width
Definition: frame.h:276
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AVERROR
#define AVERROR(e)
Definition: error.h:43
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:91
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: avcodec.h:3880
AVPacket::buf
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1413
OFFSET
#define OFFSET(x)
Definition: kmsgrab.c:425
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:28
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:329
AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:88
fail
#define fail()
Definition: checkasm.h:116
AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:89
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1436
internal.h
common internal API header
KMSGrabContext::drm_format
uint32_t drm_format
Definition: kmsgrab.c:53
KMSGrabContext::framerate
AVRational framerate
Definition: kmsgrab.c:65
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_YVYU422
packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
Definition: pixfmt.h:206
AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:65
AVDRMFrameDescriptor::objects
AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]
Array of objects making up the frame.
Definition: hwcontext_drm.h:141
AV_CODEC_ID_WRAPPED_AVFRAME
Passthrough codec, AVFrames wrapped in AVPacket.
Definition: avcodec.h:691
KMSGrabContext::device
AVHWDeviceContext * device
Definition: kmsgrab.c:46
AV_PIX_FMT_BGR565BE
packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
Definition: pixfmt.h:106
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen_template.c:36
read_header
static int read_header(FFV1Context *f)
Definition: ffv1dec.c:530
av_gettime
int64_t av_gettime(void)
Get the current time in microseconds.
Definition: time.c:39
AVStream
Stream structure.
Definition: avformat.h:873
read_packet
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Definition: avio_reading.c:42
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:291
AV_PIX_FMT_BGR8
packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
Definition: pixfmt.h:79
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:187
KMSGrabContext::source_plane
int64_t source_plane
Definition: kmsgrab.c:63
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
KMSGrabContext::width
unsigned int width
Definition: kmsgrab.c:54
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:89
AV_PIX_FMT_YUYV422
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
Definition: pixfmt.h:63
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
Definition: pixfmt.h:93
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AV_PIX_FMT_DRM_PRIME
DRM-managed buffers exposed through PRIME buffer sharing.
Definition: pixfmt.h:324
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:123
AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:236
AV_PIX_FMT_BGR555LE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined ...
Definition: pixfmt.h:109
KMSGrabContext::hwctx
AVDRMDeviceContext * hwctx
Definition: kmsgrab.c:47
hwcontext_drm.h
API-specific header for AV_HWDEVICE_TYPE_DRM.
AV_PKT_FLAG_TRUSTED
#define AV_PKT_FLAG_TRUSTED
The packet comes from a trusted source.
Definition: avcodec.h:1476
AV_PIX_FMT_RGB555BE
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:103
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:232
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:81
avformat.h
Main libavformat public API header.
AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:70
AVFMT_NOFILE
#define AVFMT_NOFILE
Demuxer will use avio_open, no opened file should be provided by the caller.
Definition: avformat.h:465
AVDRMDeviceContext::fd
int fd
File descriptor of DRM device.
Definition: hwcontext_drm.h:166
kmsgrab_free_frame
static void kmsgrab_free_frame(void *opaque, uint8_t *data)
Definition: kmsgrab.c:77
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:243
FLAGS
#define FLAGS
Definition: kmsgrab.c:426
av_buffer_ref
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:93
KMSGrabContext::height
unsigned int height
Definition: kmsgrab.c:55
drm_format
uint32_t drm_format
Definition: kmsgrab.c:203
AVRational::den
int den
Denominator.
Definition: rational.h:60
kmsgrab_read_header
static av_cold int kmsgrab_read_header(AVFormatContext *avctx)
Definition: kmsgrab.c:236
pixfmt.h
pixel format definitions
av_free
#define av_free(p)
Definition: tableprint_vlc.h:34
KMSGrabContext::frames
AVHWFramesContext * frames
Definition: kmsgrab.c:50
KMSGrabContext::drm_format_modifier
int64_t drm_format_modifier
Definition: kmsgrab.c:62
AVFormatContext::priv_data
void * priv_data
Format private data.
Definition: avformat.h:1370
AV_PIX_FMT_GRAY16LE
Y , 16bpp, little-endian.
Definition: pixfmt.h:94
ff_kmsgrab_demuxer
AVInputFormat ff_kmsgrab_demuxer
Definition: kmsgrab.c:457
pixfmt
enum AVPixelFormat pixfmt
Definition: kmsgrab.c:202
KMSGrabContext::device_ref
AVBufferRef * device_ref
Definition: kmsgrab.c:45
AV_PIX_FMT_BGR555BE
packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
Definition: pixfmt.h:108
AVFrame::height
int height
Definition: frame.h:276
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:647
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:1020
av_get_pix_fmt_name
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
Definition: pixdesc.c:2279
AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:233
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:221
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
AVPacket
This structure stores compressed data.
Definition: avcodec.h:1407
KMSGrabContext::frames_ref
AVBufferRef * frames_ref
Definition: kmsgrab.c:49
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1423
AVDRMDeviceContext
DRM device.
Definition: hwcontext_drm.h:157
KMSGrabContext::frame_last
int64_t frame_last
Definition: kmsgrab.c:58

Generated on Sun May 13 2018 02:03:59 for FFmpeg by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /