FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
v4l2_buffers.h
Go to the documentation of this file.
1 /*
2  * V4L2 buffer helper functions.
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 #ifndef AVCODEC_V4L2_BUFFERS_H
25 #define AVCODEC_V4L2_BUFFERS_H
26 
27 #include <linux/videodev2.h>
28 
29 #include "avcodec.h"
30 
35 };
36 
37 /**
38  * V4L2Buffer (wrapper for v4l2_buffer management)
39  */
40 typedef struct V4L2Buffer {
41  /* each buffer needs to have a reference to its context */
43 
44  /* keep track of the mmap address and mmap length */
45  struct V4L2Plane_info {
47  void * mm_addr;
48  size_t length;
49  } plane_info[VIDEO_MAX_PLANES];
50 
52 
53  /* the v4l2_buffer buf.m.planes pointer uses the planes[] mem */
54  struct v4l2_buffer buf;
55  struct v4l2_plane planes[VIDEO_MAX_PLANES];
56 
57  int flags;
59 
60 } V4L2Buffer;
61 
62 /**
63  * Extracts the data from a V4L2Buffer to an AVFrame
64  *
65  * @param[in] frame The AVFRame to push the information to
66  * @param[in] buf The V4L2Buffer to get the information from
67  *
68  * @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
69  * AVERROR(ENOMEM) if the AVBufferRef cant be created.
70  */
72 
73 /**
74  * Extracts the data from a V4L2Buffer to an AVPacket
75  *
76  * @param[in] pkt The AVPacket to push the information to
77  * @param[in] buf The V4L2Buffer to get the information from
78  *
79  * @returns 0 in case of success, AVERROR(EINVAL) if the number of planes is incorrect,
80  * AVERROR(ENOMEM) if the AVBufferRef cant be created.
81  *
82  */
84 
85 /**
86  * Extracts the data from an AVPacket to a V4L2Buffer
87  *
88  * @param[in] frame AVPacket to get the data from
89  * @param[in] avbuf V4L2Bfuffer to push the information to
90  *
91  * @returns 0 in case of success, a negative AVERROR code otherwise
92  */
94 
95 /**
96  * Extracts the data from an AVFrame to a V4L2Buffer
97  *
98  * @param[in] frame AVFrame to get the data from
99  * @param[in] avbuf V4L2Bfuffer to push the information to
100  *
101  * @returns 0 in case of success, a negative AVERROR code otherwise
102  */
104 
105 /**
106  * Initializes a V4L2Buffer
107  *
108  * @param[in] avbuf V4L2Bfuffer to initialize
109  * @param[in] index v4l2 buffer id
110  *
111  * @returns 0 in case of success, a negative AVERROR code otherwise
112  */
114 
115 /**
116  * Enqueues a V4L2Buffer
117  *
118  * @param[in] avbuf V4L2Bfuffer to push to the driver
119  *
120  * @returns 0 in case of success, a negative AVERROR code otherwise
121  */
123 
124 
125 #endif // AVCODEC_V4L2_BUFFERS_H
int ff_v4l2_buffer_avframe_to_buf(const AVFrame *frame, V4L2Buffer *out)
Extracts the data from an AVFrame to a V4L2Buffer.
Definition: v4l2_buffers.c:274
V4L2Buffer_status
Definition: v4l2_buffers.h:31
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
int ff_v4l2_buffer_buf_to_avframe(AVFrame *frame, V4L2Buffer *buf)
Extracts the data from a V4L2Buffer to an AVFrame.
Definition: v4l2_buffers.c:289
int ff_v4l2_buffer_enqueue(V4L2Buffer *avbuf)
Enqueues a V4L2Buffer.
Definition: v4l2_buffers.c:450
static AVPacket pkt
enum V4L2Buffer_status status
Definition: v4l2_buffers.h:58
int ff_v4l2_buffer_initialize(V4L2Buffer *avbuf, int index)
Initializes a V4L2Buffer.
Definition: v4l2_buffers.c:381
static AVFrame * frame
struct V4L2Context * context
Definition: v4l2_buffers.h:42
int ff_v4l2_buffer_buf_to_avpkt(AVPacket *pkt, V4L2Buffer *buf)
Extracts the data from a V4L2Buffer to an AVPacket.
Definition: v4l2_buffers.c:340
struct v4l2_buffer buf
Definition: v4l2_buffers.h:54
struct v4l2_plane planes[VIDEO_MAX_PLANES]
Definition: v4l2_buffers.h:55
Libavcodec external API header.
V4L2Buffer (wrapper for v4l2_buffer management)
Definition: v4l2_buffers.h:40
void * buf
Definition: avisynth_c.h:690
int index
Definition: gxfenc.c:89
int num_planes
Definition: v4l2_buffers.h:51
int ff_v4l2_buffer_avpkt_to_buf(const AVPacket *pkt, V4L2Buffer *out)
Extracts the data from an AVPacket to a V4L2Buffer.
Definition: v4l2_buffers.c:365
FILE * out
Definition: movenc.c:54
This structure stores compressed data.
Definition: avcodec.h:1656