本文整理汇总了C++中V4L2_TYPE_IS_MULTIPLANAR函数的典型用法代码示例。如果您正苦于以下问题:C++ V4L2_TYPE_IS_MULTIPLANAR函数的具体用法?C++ V4L2_TYPE_IS_MULTIPLANAR怎么用?C++ V4L2_TYPE_IS_MULTIPLANAR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了V4L2_TYPE_IS_MULTIPLANAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ff_v4l2_context_init
int ff_v4l2_context_init(V4L2Context* ctx)
{
V4L2m2mContext *s = ctx_to_m2mctx(ctx);
struct v4l2_requestbuffers req;
int ret, i;
if (!v4l2_type_supported(ctx)) {
av_log(logger(ctx), AV_LOG_ERROR, "type %i not supported\n", ctx->type);
return AVERROR_PATCHWELCOME;
}
ret = ioctl(s->fd, VIDIOC_G_FMT, &ctx->format);
if (ret)
av_log(logger(ctx), AV_LOG_ERROR, "%s VIDIOC_G_FMT failed\n", ctx->name);
memset(&req, 0, sizeof(req));
req.count = ctx->num_buffers;
req.memory = V4L2_MEMORY_MMAP;
req.type = ctx->type;
ret = ioctl(s->fd, VIDIOC_REQBUFS, &req);
if (ret < 0)
return AVERROR(errno);
ctx->num_buffers = req.count;
ctx->buffers = av_mallocz(ctx->num_buffers * sizeof(V4L2Buffer));
if (!ctx->buffers) {
av_log(logger(ctx), AV_LOG_ERROR, "%s malloc enomem\n", ctx->name);
return AVERROR(ENOMEM);
}
for (i = 0; i < req.count; i++) {
ctx->buffers[i].context = ctx;
ret = ff_v4l2_buffer_initialize(&ctx->buffers[i], i);
if (ret < 0) {
av_log(logger(ctx), AV_LOG_ERROR, "%s buffer initialization (%s)\n", ctx->name, av_err2str(ret));
av_free(ctx->buffers);
return ret;
}
}
av_log(logger(ctx), AV_LOG_DEBUG, "%s: %s %02d buffers initialized: %04ux%04u, sizeimage %08u, bytesperline %08u\n", ctx->name,
V4L2_TYPE_IS_MULTIPLANAR(ctx->type) ? av_fourcc2str(ctx->format.fmt.pix_mp.pixelformat) : av_fourcc2str(ctx->format.fmt.pix.pixelformat),
req.count,
v4l2_get_width(&ctx->format),
v4l2_get_height(&ctx->format),
V4L2_TYPE_IS_MULTIPLANAR(ctx->type) ? ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage : ctx->format.fmt.pix.sizeimage,
V4L2_TYPE_IS_MULTIPLANAR(ctx->type) ? ctx->format.fmt.pix_mp.plane_fmt[0].bytesperline : ctx->format.fmt.pix.bytesperline);
return 0;
}
示例2: __verify_length
/**
* __verify_length() - Verify that the bytesused value for each plane fits in
* the plane length and that the data offset doesn't exceed the bytesused value.
*/
static int __verify_length(struct vb2_buffer *vb, const struct v4l2_buffer *b)
{
unsigned int length;
unsigned int bytesused;
unsigned int plane;
if (!V4L2_TYPE_IS_OUTPUT(b->type))
return 0;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
for (plane = 0; plane < vb->num_planes; ++plane) {
length = (b->memory == VB2_MEMORY_USERPTR ||
b->memory == VB2_MEMORY_DMABUF)
? b->m.planes[plane].length
: vb->planes[plane].length;
bytesused = b->m.planes[plane].bytesused
? b->m.planes[plane].bytesused : length;
if (b->m.planes[plane].bytesused > length)
return -EINVAL;
if (b->m.planes[plane].data_offset > 0 &&
b->m.planes[plane].data_offset >= bytesused)
return -EINVAL;
}
} else {
length = (b->memory == VB2_MEMORY_USERPTR)
? b->length : vb->planes[0].length;
if (b->bytesused > length)
return -EINVAL;
}
return 0;
}
示例3: vb2_queue_init
/**
* vb2_queue_init() - initialize a videobuf2 queue
* @q: videobuf2 queue; this structure should be allocated in driver
*
* The vb2_queue structure should be allocated by the driver. The driver is
* responsible of clearing it's content and setting initial values for some
* required entries before calling this function.
* q->ops, q->mem_ops, q->type and q->io_modes are mandatory. Please refer
* to the struct vb2_queue description in include/media/videobuf2-core.h
* for more information.
*/
int vb2_queue_init(struct vb2_queue *q)
{
/*
* Sanity check
*/
if (WARN_ON(!q) ||
WARN_ON(q->timestamp_flags &
~(V4L2_BUF_FLAG_TIMESTAMP_MASK |
V4L2_BUF_FLAG_TSTAMP_SRC_MASK)))
return -EINVAL;
/* Warn that the driver should choose an appropriate timestamp type */
WARN_ON((q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK) ==
V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN);
/* Warn that vb2_memory should match with v4l2_memory */
if (WARN_ON(VB2_MEMORY_MMAP != (int)V4L2_MEMORY_MMAP)
|| WARN_ON(VB2_MEMORY_USERPTR != (int)V4L2_MEMORY_USERPTR)
|| WARN_ON(VB2_MEMORY_DMABUF != (int)V4L2_MEMORY_DMABUF))
return -EINVAL;
if (q->buf_struct_size == 0)
q->buf_struct_size = sizeof(struct vb2_v4l2_buffer);
q->buf_ops = &v4l2_buf_ops;
q->is_multiplanar = V4L2_TYPE_IS_MULTIPLANAR(q->type);
q->is_output = V4L2_TYPE_IS_OUTPUT(q->type);
q->copy_timestamp = (q->timestamp_flags & V4L2_BUF_FLAG_TIMESTAMP_MASK)
== V4L2_BUF_FLAG_TIMESTAMP_COPY;
return vb2_core_queue_init(q);
}
示例4: gst_v4l2_allocator_reset_size
static void
gst_v4l2_allocator_reset_size (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group)
{
gsize size;
gboolean imported = FALSE;
switch (allocator->memory) {
case V4L2_MEMORY_USERPTR:
case V4L2_MEMORY_DMABUF:
imported = TRUE;
break;
}
if (V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
gint i;
for (i = 0; i < group->n_mem; i++) {
size = allocator->format.fmt.pix_mp.plane_fmt[i].sizeimage;
if (imported)
group->mem[i]->maxsize = size;
gst_memory_resize (group->mem[i], 0, size);
}
} else {
size = allocator->format.fmt.pix.sizeimage;
if (imported)
group->mem[0]->maxsize = size;
gst_memory_resize (group->mem[0], 0, size);
}
}
示例5: v4l2_save_to_context
static inline void v4l2_save_to_context(V4L2Context* ctx, struct v4l2_format_update *fmt)
{
ctx->format.type = ctx->type;
if (fmt->update_avfmt)
ctx->av_pix_fmt = fmt->av_fmt;
if (V4L2_TYPE_IS_MULTIPLANAR(ctx->type)) {
/* update the sizes to handle the reconfiguration of the capture stream at runtime */
ctx->format.fmt.pix_mp.height = ctx->height;
ctx->format.fmt.pix_mp.width = ctx->width;
if (fmt->update_v4l2) {
ctx->format.fmt.pix_mp.pixelformat = fmt->v4l2_fmt;
/* s5p-mfc requires the user to specify a buffer size */
ctx->format.fmt.pix_mp.plane_fmt[0].sizeimage =
v4l2_get_framesize_compressed(ctx, ctx->width, ctx->height);
}
} else {
ctx->format.fmt.pix.height = ctx->height;
ctx->format.fmt.pix.width = ctx->width;
if (fmt->update_v4l2) {
ctx->format.fmt.pix.pixelformat = fmt->v4l2_fmt;
/* s5p-mfc requires the user to specify a buffer size */
ctx->format.fmt.pix.sizeimage =
v4l2_get_framesize_compressed(ctx, ctx->width, ctx->height);
}
}
}
示例6: gst_v4l2_allocator_clear_userptr
static void
gst_v4l2_allocator_clear_userptr (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group)
{
GstV4l2Memory *mem;
gint i;
g_return_if_fail (allocator->memory == V4L2_MEMORY_USERPTR);
for (i = 0; i < group->n_mem; i++) {
mem = (GstV4l2Memory *) group->mem[i];
GST_LOG_OBJECT (allocator, "clearing USERPTR %p plane %d size %"
G_GSIZE_FORMAT, mem->data, i, mem->mem.size);
mem->mem.maxsize = 0;
mem->mem.size = 0;
mem->data = NULL;
group->planes[i].length = 0;
group->planes[i].bytesused = 0;
group->planes[i].m.userptr = 0;
}
if (!V4L2_TYPE_IS_MULTIPLANAR (allocator->type)) {
group->buffer.bytesused = 0;
group->buffer.length = 0;
group->buffer.m.userptr = 0;
}
}
示例7: __fill_v4l2_buffer
/**
* __fill_v4l2_buffer() - fill in a struct v4l2_buffer with information to be
* returned to userspace
*/
static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
{
struct vb2_queue *q = vb->vb2_queue;
int ret = 0;
/* Copy back data such as timestamp, flags, input, etc. */
memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m));
b->input = vb->v4l2_buf.input;
b->reserved = vb->v4l2_buf.reserved;
if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) {
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
/*
* Fill in plane-related data if userspace provided an array
* for it. The memory and size is verified above.
*/
memcpy(b->m.planes, vb->v4l2_planes,
b->length * sizeof(struct v4l2_plane));
} else {
/*
* We use length and offset in v4l2_planes array even for
* single-planar buffers, but userspace does not.
*/
b->length = vb->v4l2_planes[0].length;
b->bytesused = vb->v4l2_planes[0].bytesused;
if (q->memory == V4L2_MEMORY_MMAP)
b->m.offset = vb->v4l2_planes[0].m.mem_offset;
else if (q->memory == V4L2_MEMORY_USERPTR)
b->m.userptr = vb->v4l2_planes[0].m.userptr;
}
/*
* Clear any buffer state related flags.
*/
b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
switch (vb->state) {
case VB2_BUF_STATE_QUEUED:
case VB2_BUF_STATE_ACTIVE:
b->flags |= V4L2_BUF_FLAG_QUEUED;
break;
case VB2_BUF_STATE_ERROR:
b->flags |= V4L2_BUF_FLAG_ERROR;
/* fall through */
case VB2_BUF_STATE_DONE:
b->flags |= V4L2_BUF_FLAG_DONE;
break;
case VB2_BUF_STATE_DEQUEUED:
/* nothing */
break;
}
if (vb->num_planes_mapped == vb->num_planes)
b->flags |= V4L2_BUF_FLAG_MAPPED;
return ret;
}
示例8: __fill_vb2_buffer
/**
* __fill_vb2_buffer() - fill a vb2_buffer with information provided in
* a v4l2_buffer by the userspace
*/
static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
struct v4l2_plane *v4l2_planes)
{
unsigned int plane;
int ret;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
/*
* Verify that the userspace gave us a valid array for
* plane information.
*/
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
/* Fill in driver-provided information for OUTPUT types */
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
/*
* Will have to go up to b->length when API starts
* accepting variable number of planes.
*/
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].bytesused =
b->m.planes[plane].bytesused;
v4l2_planes[plane].data_offset =
b->m.planes[plane].data_offset;
}
}
if (b->memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].m.userptr =
b->m.planes[plane].m.userptr;
v4l2_planes[plane].length =
b->m.planes[plane].length;
}
}
} else {
/*
* Single-planar buffers do not use planes array,
* so fill in relevant v4l2_buffer struct fields instead.
* In videobuf we use our internal V4l2_planes struct for
* single-planar buffers as well, for simplicity.
*/
if (V4L2_TYPE_IS_OUTPUT(b->type))
v4l2_planes[0].bytesused = b->bytesused;
if (b->memory == V4L2_MEMORY_USERPTR) {
v4l2_planes[0].m.userptr = b->m.userptr;
v4l2_planes[0].length = b->length;
}
}
vb->v4l2_buf.field = b->field;
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.input = b->input;
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
return 0;
}
示例9: __vb2_queue_alloc
static int __vb2_queue_alloc(struct vb2_queue *q, enum v4l2_memory memory,
unsigned int num_buffers, unsigned int num_planes,
unsigned long plane_sizes[])
{
unsigned int buffer;
struct vb2_buffer *vb;
int ret;
for (buffer = 0; buffer < num_buffers; ++buffer) {
vb = kzalloc(q->buf_struct_size, GFP_KERNEL);
if (!vb) {
dprintk(1, "Memory alloc for buffer struct failed\n");
break;
}
if (V4L2_TYPE_IS_MULTIPLANAR(q->type))
vb->v4l2_buf.length = num_planes;
vb->state = VB2_BUF_STATE_DEQUEUED;
vb->vb2_queue = q;
vb->num_planes = num_planes;
vb->v4l2_buf.index = buffer;
vb->v4l2_buf.type = q->type;
vb->v4l2_buf.memory = memory;
if (memory == V4L2_MEMORY_MMAP) {
ret = __vb2_buf_mem_alloc(vb, plane_sizes);
if (ret) {
dprintk(1, "Failed allocating memory for "
"buffer %d\n", buffer);
kfree(vb);
break;
}
ret = call_qop(q, buf_init, vb);
if (ret) {
dprintk(1, "Buffer %d %p initialization"
" failed\n", buffer, vb);
__vb2_buf_mem_free(vb);
kfree(vb);
break;
}
}
q->bufs[buffer] = vb;
}
q->num_buffers = buffer;
__setup_offsets(q);
dprintk(1, "Allocated %d buffers, %d plane(s) each\n",
q->num_buffers, num_planes);
return buffer;
}
示例10: ioctl
bool v4l2::s_fmt(v4l2_format &fmt)
{
if (V4L2_TYPE_IS_MULTIPLANAR(fmt.type)) {
fmt.fmt.pix_mp.plane_fmt[0].bytesperline = 0;
fmt.fmt.pix_mp.plane_fmt[1].bytesperline = 0;
} else {
fmt.fmt.pix.bytesperline = 0;
}
return ioctl("Set Capture Format", VIDIOC_S_FMT, &fmt);
}
示例11: v4l2_set_timeperframe
static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, unsigned int den)
{
struct v4l2_streamparm parm = { 0 };
parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT;
parm.parm.output.timeperframe.denominator = den;
parm.parm.output.timeperframe.numerator = num;
if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0)
av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe");
}
示例12: gst_v4l2_allocator_qbuf
gboolean
gst_v4l2_allocator_qbuf (GstV4l2Allocator * allocator,
GstV4l2MemoryGroup * group)
{
GstV4l2Object *obj = allocator->obj;
gboolean ret = TRUE;
gint i;
g_return_val_if_fail (g_atomic_int_get (&allocator->active), FALSE);
/* update sizes */
if (V4L2_TYPE_IS_MULTIPLANAR (obj->type)) {
for (i = 0; i < group->n_mem; i++)
group->planes[i].bytesused =
gst_memory_get_sizes (group->mem[i], NULL, NULL);
} else {
group->buffer.bytesused = gst_memory_get_sizes (group->mem[0], NULL, NULL);
}
/* Ensure the memory will stay around and is RO */
for (i = 0; i < group->n_mem; i++)
gst_memory_ref (group->mem[i]);
if (obj->ioctl (obj->video_fd, VIDIOC_QBUF, &group->buffer) < 0) {
GST_ERROR_OBJECT (allocator, "failed queueing buffer %i: %s",
group->buffer.index, g_strerror (errno));
/* Release the memory, possibly making it RW again */
for (i = 0; i < group->n_mem; i++)
gst_memory_unref (group->mem[i]);
ret = FALSE;
if (IS_QUEUED (group->buffer)) {
GST_DEBUG_OBJECT (allocator,
"driver pretends buffer is queued even if queue failed");
UNSET_QUEUED (group->buffer);
}
goto done;
}
GST_LOG_OBJECT (allocator, "queued buffer %i (flags 0x%X)",
group->buffer.index, group->buffer.flags);
if (!IS_QUEUED (group->buffer)) {
GST_DEBUG_OBJECT (allocator,
"driver pretends buffer is not queued even if queue succeeded");
SET_QUEUED (group->buffer);
}
done:
return ret;
}
示例13: __fill_v4l2_buffer
static int __fill_v4l2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b)
{
struct vb2_queue *q = vb->vb2_queue;
int ret = 0;
memcpy(b, &vb->v4l2_buf, offsetof(struct v4l2_buffer, m));
b->input = vb->v4l2_buf.input;
b->reserved = vb->v4l2_buf.reserved;
if (V4L2_TYPE_IS_MULTIPLANAR(q->type)) {
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
memcpy(b->m.planes, vb->v4l2_planes,
b->length * sizeof(struct v4l2_plane));
} else {
b->length = vb->v4l2_planes[0].length;
b->bytesused = vb->v4l2_planes[0].bytesused;
if (q->memory == V4L2_MEMORY_MMAP)
b->m.offset = vb->v4l2_planes[0].m.mem_offset;
else if (q->memory == V4L2_MEMORY_USERPTR)
b->m.userptr = vb->v4l2_planes[0].m.userptr;
}
b->flags &= ~V4L2_BUFFER_STATE_FLAGS;
switch (vb->state) {
case VB2_BUF_STATE_QUEUED:
case VB2_BUF_STATE_ACTIVE:
b->flags |= V4L2_BUF_FLAG_QUEUED;
break;
case VB2_BUF_STATE_ERROR:
b->flags |= V4L2_BUF_FLAG_ERROR;
case VB2_BUF_STATE_DONE:
b->flags |= V4L2_BUF_FLAG_DONE;
break;
case VB2_BUF_STATE_DEQUEUED:
break;
}
if (vb->num_planes_mapped == vb->num_planes)
b->flags |= V4L2_BUF_FLAG_MAPPED;
return ret;
}
示例14: __fill_vb2_buffer
static int __fill_vb2_buffer(struct vb2_buffer *vb, struct v4l2_buffer *b,
struct v4l2_plane *v4l2_planes)
{
unsigned int plane;
int ret;
if (V4L2_TYPE_IS_MULTIPLANAR(b->type)) {
ret = __verify_planes_array(vb, b);
if (ret)
return ret;
if (V4L2_TYPE_IS_OUTPUT(b->type)) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].bytesused =
b->m.planes[plane].bytesused;
v4l2_planes[plane].data_offset =
b->m.planes[plane].data_offset;
}
}
if (b->memory == V4L2_MEMORY_USERPTR) {
for (plane = 0; plane < vb->num_planes; ++plane) {
v4l2_planes[plane].m.userptr =
b->m.planes[plane].m.userptr;
v4l2_planes[plane].length =
b->m.planes[plane].length;
}
}
} else {
if (V4L2_TYPE_IS_OUTPUT(b->type))
v4l2_planes[0].bytesused = b->bytesused;
if (b->memory == V4L2_MEMORY_USERPTR) {
v4l2_planes[0].m.userptr = b->m.userptr;
v4l2_planes[0].length = b->length;
}
}
vb->v4l2_buf.field = b->field;
vb->v4l2_buf.timestamp = b->timestamp;
vb->v4l2_buf.input = b->input;
vb->v4l2_buf.flags = b->flags & ~V4L2_BUFFER_STATE_FLAGS;
return 0;
}
示例15: v4l2_resolution_changed
static inline unsigned int v4l2_resolution_changed(V4L2Context *ctx, struct v4l2_format *fmt2)
{
struct v4l2_format *fmt1 = &ctx->format;
int ret = V4L2_TYPE_IS_MULTIPLANAR(ctx->type) ?
fmt1->fmt.pix_mp.width != fmt2->fmt.pix_mp.width ||
fmt1->fmt.pix_mp.height != fmt2->fmt.pix_mp.height
:
fmt1->fmt.pix.width != fmt2->fmt.pix.width ||
fmt1->fmt.pix.height != fmt2->fmt.pix.height;
if (ret)
av_log(logger(ctx), AV_LOG_DEBUG, "%s changed (%dx%d) -> (%dx%d)\n",
ctx->name,
v4l2_get_width(fmt1), v4l2_get_height(fmt1),
v4l2_get_width(fmt2), v4l2_get_height(fmt2));
return ret;
}