[FFmpeg-cvslog] lavd/v4l2: simplify code

Giorgio Vazzana git at videolan.org
Sat Mar 9 17:15:08 CET 2013


ffmpeg | branch: master | Giorgio Vazzana <mywing81 at gmail.com> | Sat Mar  9 14:46:00 2013 +0100| [9222978aed8b186d61ef527ef4ca736aca7ac1dc] | committer: Michael Niedermayer

lavd/v4l2: simplify code

struct buff_data contains a pointer to struct video_data, so passing the
file descriptor again is redundant.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9222978aed8b186d61ef527ef4ca736aca7ac1dc
---

 libavdevice/v4l2.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index e12ca05..2a3f756 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -125,7 +125,6 @@ struct video_data {
 struct buff_data {
     struct video_data *s;
     int index;
-    int fd;
 };
 
 struct fmt_map {
@@ -483,17 +482,16 @@ static void dummy_release_buffer(AVPacket *pkt)
 static void mmap_release_buffer(void *opaque, uint8_t *data)
 {
     struct v4l2_buffer buf = { 0 };
-    int res, fd;
+    int res;
     struct buff_data *buf_descriptor = opaque;
     struct video_data *s = buf_descriptor->s;
 
     buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
     buf.memory = V4L2_MEMORY_MMAP;
     buf.index = buf_descriptor->index;
-    fd = buf_descriptor->fd;
     av_free(buf_descriptor);
 
-    if (v4l2_ioctl(fd, VIDIOC_QBUF, &buf) < 0) {
+    if (v4l2_ioctl(s->fd, VIDIOC_QBUF, &buf) < 0) {
         res = AVERROR(errno);
         av_log(NULL, AV_LOG_ERROR, "ioctl(VIDIOC_QBUF): %s\n",
                av_err2str(res));
@@ -643,7 +641,6 @@ static int mmap_read_frame(AVFormatContext *ctx, AVPacket *pkt)
 
             return AVERROR(ENOMEM);
         }
-        buf_descriptor->fd    = s->fd;
         buf_descriptor->index = buf.index;
         buf_descriptor->s     = s;
 



More information about the ffmpeg-cvslog mailing list