]> git.sesse.net Git - vlc/blob - modules/access/v4l/videodev_mjpeg.h
5d8f32d17d2cd3201ae5d646a424ab5ee8289db6
[vlc] / modules / access / v4l / videodev_mjpeg.h
1 /*****************************************************************************
2  * Copyright (C) lavrec (see http://mjpeg.sourceforge.net)
3  * ( XXX This file was get from the driver-zoran package and it is under GPL)
4  *
5  * $Id$
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
20  *****************************************************************************/
21
22 /* These are the MJPEG API extensions for the Video4Linux API,
23    first introduced by the Iomega Buz driver by Rainer Johanni
24    <rainer@johanni.de>
25 */
26
27 /* This is identical with the mgavideo internal params struct,
28    please tell me if you change this struct here ! <gz@lysator.liu.se) */
29 struct mjpeg_params
30 {
31
32    /* The following parameters can only be queried */
33
34    int major_version;            /* Major version number of driver */
35    int minor_version;            /* Minor version number of driver */
36
37    /* Main control parameters */
38
39    int input;                    /* Input channel: 0 = Composite, 1 = S-VHS */
40    int norm;                     /* Norm: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
41    int decimation;               /* decimation of captured video,
42                                     enlargement of video played back.
43                                     Valid values are 1, 2, 4 or 0.
44                                     0 is a special value where the user
45                                     has full control over video scaling */
46
47    /* The following parameters only have to be set if decimation==0,
48       for other values of decimation they provide the data how the image is captured */
49
50    int HorDcm;                    /* Horizontal decimation: 1, 2 or 4 */
51    int VerDcm;                    /* Vertical decimation: 1 or 2 */
52    int TmpDcm;                    /* Temporal decimation: 1 or 2,
53                                      if TmpDcm==2 in capture every second frame is dropped,
54                                      in playback every frame is played twice */
55    int field_per_buff;            /* Number of fields per buffer: 1 or 2 */
56    int img_x;                     /* start of image in x direction */
57    int img_y;                     /* start of image in y direction */
58    int img_width;                 /* image width BEFORE decimation,
59                                      must be a multiple of HorDcm*16 */
60    int img_height;                /* image height BEFORE decimation,
61                                      must be a multiple of VerDcm*8 */
62
63    /* --- End of parameters for decimation==0 only --- */
64
65    /* JPEG control parameters */
66
67    int  quality;                  /* Measure for quality of compressed images.
68                                      Scales linearly with the size of the compressed images.
69                                      Must be beetween 0 and 100, 100 is a compression
70                                      ratio of 1:4 */
71
72    int  odd_even;                 /* Which field should come first ???
73                                      This is more aptly named "top_first",
74                                      i.e. (odd_even==1) --> top-field-first */
75
76    int  APPn;                     /* Number of APP segment to be written, must be 0..15 */
77    int  APP_len;                  /* Length of data in JPEG APPn segment */
78    char APP_data[60];             /* Data in the JPEG APPn segment. */
79
80    int  COM_len;                  /* Length of data in JPEG COM segment */
81    char COM_data[60];             /* Data in JPEG COM segment */
82
83    unsigned long jpeg_markers;    /* Which markers should go into the JPEG output.
84                                      Unless you exactly know what you do, leave them untouched.
85                                      Inluding less markers will make the resulting code
86                                      smaller, but there will be fewer aplications
87                                      which can read it.
88                                      The presence of the APP and COM marker is
89                                      influenced by APP0_len and COM_len ONLY! */
90 #define JPEG_MARKER_DHT (1<<3)    /* Define Huffman Tables */
91 #define JPEG_MARKER_DQT (1<<4)    /* Define Quantization Tables */
92 #define JPEG_MARKER_DRI (1<<5)    /* Define Restart Interval */
93 #define JPEG_MARKER_COM (1<<6)    /* Comment segment */
94 #define JPEG_MARKER_APP (1<<7)    /* App segment, driver will allways use APP0 */
95
96    int  VFIFO_FB;        /* Flag for enabling Video Fifo Feedback.
97                             If this flag is turned on and JPEG decompressing
98                             is going to the screen, the decompress process
99                             is stopped every time the Video Fifo is full.
100                             This enables a smooth decompress to the screen
101                             but the video output signal will get scrambled */
102
103    /* Misc */
104
105     char reserved[312];  /* Makes 512 bytes for this structure */
106 };
107
108 struct mjpeg_requestbuffers
109 {
110    unsigned long count;      /* Number of buffers for MJPEG grabbing */
111    unsigned long size;       /* Size PER BUFFER in bytes */
112 };
113
114 struct mjpeg_sync
115 {
116    unsigned long frame;      /* Frame (0 - n) for double buffer */
117    unsigned long length;     /* number of code bytes in buffer (capture only) */
118    unsigned long seq;        /* frame sequence number */
119    struct timeval timestamp; /* timestamp */
120 };
121
122 struct mjpeg_status
123 {
124    int input;                /* Input channel, has to be set prior to BUZIOC_G_STATUS */
125    int signal;               /* Returned: 1 if valid video signal detected */
126    int norm;                 /* Returned: VIDEO_MODE_PAL or VIDEO_MODE_NTSC */
127    int color;                /* Returned: 1 if color signal detected */
128 };
129
130 /*
131 Private IOCTL to set up for displaying MJPEG
132 */
133 #define MJPIOC_G_PARAMS       _IOR ('v', BASE_VIDIOCPRIVATE+0,  struct mjpeg_params)
134 #define MJPIOC_S_PARAMS       _IOWR('v', BASE_VIDIOCPRIVATE+1,  struct mjpeg_params)
135 #define MJPIOC_REQBUFS        _IOWR('v', BASE_VIDIOCPRIVATE+2,  struct mjpeg_requestbuffers)
136 #define MJPIOC_QBUF_CAPT      _IOW ('v', BASE_VIDIOCPRIVATE+3,  int)
137 #define MJPIOC_QBUF_PLAY      _IOW ('v', BASE_VIDIOCPRIVATE+4,  int)
138 #define MJPIOC_SYNC           _IOR ('v', BASE_VIDIOCPRIVATE+5,  struct mjpeg_sync)
139 #define MJPIOC_G_STATUS       _IOWR('v', BASE_VIDIOCPRIVATE+6,  struct mjpeg_status)