aboutsummaryrefslogtreecommitdiff
path: root/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'video.c')
-rw-r--r--video.c105
1 files changed, 15 insertions, 90 deletions
diff --git a/video.c b/video.c
index e5a08c0..ae07eda 100644
--- a/video.c
+++ b/video.c
@@ -34,7 +34,6 @@
#include "common.h"
-/* mem2mem encoder/decoder */
#define V4L2_BUF_FLAG_LAST 0x00100000
static char *dbg_type[2] = {"OUTPUT", "CAPTURE"};
@@ -183,13 +182,17 @@ int video_set_control(struct instance *i)
if (ret)
err("set control - level (%s)", strerror(errno));
- memset(&cntrl, 0, sizeof(cntrl));
- cntrl.id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
- cntrl.value = 1;
- info("setting num b frames: %u", cntrl.value);
- ret = ioctl(i->video.fd, VIDIOC_S_CTRL, &cntrl);
- if (ret)
- err("set control - num b frames (%s)", strerror(errno));
+ if (i->num_bframes && i->num_bframes < 4) {
+ memset(&cntrl, 0, sizeof(cntrl));
+ cntrl.id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
+// cntrl.value = 1;
+ cntrl.value = i->num_bframes;
+ info("setting num b frames: %u", cntrl.value);
+ ret = ioctl(i->video.fd, VIDIOC_S_CTRL, &cntrl);
+ if (ret)
+ err("set control - num b frames (%s)",
+ strerror(errno));
+ }
}
#if 0
@@ -416,33 +419,6 @@ int video_dequeue_capture(struct instance *i, unsigned int *n,
return 0;
}
-int video_dequeue_capture_dmabuf(struct instance *i, unsigned int *n,
- unsigned int *finished,
- unsigned int *bytesused)
-{
- struct v4l2_buffer buf;
- struct v4l2_plane planes[CAP_PLANES];
-
- memzero(buf);
- buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- buf.memory = V4L2_MEMORY_DMABUF;
- buf.m.planes = planes;
- buf.length = CAP_PLANES;
-
- if (video_dequeue_buf(i, &buf))
- return -1;
-
- *finished = 0;
-
- if (buf.flags & V4L2_BUF_FLAG_LAST || buf.m.planes[0].bytesused == 0)
- *finished = 1;
-
- *bytesused = buf.m.planes[0].bytesused;
- *n = buf.index;
-
- return 0;
-}
-
int video_stream(struct instance *i, enum v4l2_buf_type type,
unsigned int status)
{
@@ -569,61 +545,6 @@ int video_setup_capture(struct instance *i, unsigned int count, unsigned int w,
return 0;
}
-int video_setup_capture_dmabuf(struct instance *i, unsigned int count,
- unsigned int w, unsigned int h)
-{
- struct video *vid = &i->video;
- struct v4l2_format fmt;
- struct v4l2_requestbuffers reqbuf;
- int ret;
-
- memzero(fmt);
- fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- fmt.fmt.pix_mp.height = h;
- fmt.fmt.pix_mp.width = w;
- fmt.fmt.pix_mp.pixelformat = V4L2_PIX_FMT_NV12;
- ret = ioctl(vid->fd, VIDIOC_S_FMT, &fmt);
- if (ret) {
- err("CAPTURE: S_FMT failed (%ux%u) (%s)", w, h, strerror(errno));
- return -1;
- }
-
- info("CAPTURE: Set format %ux%u, sizeimage %u, bpl %u",
- fmt.fmt.pix_mp.width, fmt.fmt.pix_mp.height,
- fmt.fmt.pix_mp.plane_fmt[0].sizeimage,
- fmt.fmt.pix_mp.plane_fmt[0].bytesperline);
-
- vid->cap_w = fmt.fmt.pix_mp.width;
- vid->cap_h = fmt.fmt.pix_mp.height;
-
- vid->cap_buf_size[0] = fmt.fmt.pix_mp.plane_fmt[0].sizeimage;
- vid->cap_buf_size[1] = fmt.fmt.pix_mp.plane_fmt[1].sizeimage;
-
- vid->cap_buf_cnt_min = 1;
- vid->cap_buf_queued = 0;
-
- memzero(reqbuf);
- reqbuf.count = count;
- reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- reqbuf.memory = V4L2_MEMORY_DMABUF;
-
- ret = ioctl(vid->fd, VIDIOC_REQBUFS, &reqbuf);
- if (ret) {
- err("CAPTURE: REQBUFS failed (%s)", strerror(errno));
- return -1;
- }
-
- vid->cap_buf_cnt = reqbuf.count;
-
- info("CAPTURE: Number of buffers %u (requested %u)",
- vid->cap_buf_cnt, count);
-
- info("CAPTURE: Succesfully requested %u dmabuf buffers",
- vid->cap_buf_cnt);
-
- return 0;
-}
-
int video_setup_output(struct instance *i, unsigned long codec,
unsigned int size, unsigned int count)
{
@@ -689,6 +610,10 @@ int video_setup_output(struct instance *i, unsigned long codec,
g_fmt.fmt.pix_mp.plane_fmt[0].sizeimage,
g_fmt.fmt.pix_mp.plane_fmt[0].bytesperline);
+ vid->out_w = g_fmt.fmt.pix_mp.width;
+ vid->out_h = g_fmt.fmt.pix_mp.height;
+ vid->out_bytesperline = g_fmt.fmt.pix_mp.plane_fmt[0].bytesperline;
+
memzero(reqbuf);
reqbuf.count = count;
reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;