Fix vf_tcdump's compilation
[mplayer/kovensky.git] / stream / tvi_def.h
blob43de8c64239a3a42fcd7aebd19a1148e3d049b2d
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_TVI_DEF_H
20 #define MPLAYER_TVI_DEF_H
22 #include <stdlib.h> /* malloc */
23 #include <string.h> /* memset */
24 #include "libmpcodecs/img_format.h"
25 #include "tv.h"
27 static int init(priv_t *priv);
28 static int uninit(priv_t *priv);
29 static int control(priv_t *priv, int cmd, void *arg);
30 static int start(priv_t *priv);
31 static double grab_video_frame(priv_t *priv, char *buffer, int len);
32 static int get_video_framesize(priv_t *priv);
33 static double grab_audio_frame(priv_t *priv, char *buffer, int len);
34 static int get_audio_framesize(priv_t *priv);
36 static const tvi_functions_t functions =
38 init,
39 uninit,
40 control,
41 start,
42 grab_video_frame,
43 get_video_framesize,
44 grab_audio_frame,
45 get_audio_framesize
48 static tvi_handle_t *new_handle(void)
50 tvi_handle_t *h = malloc(sizeof(tvi_handle_t));
52 if (!h)
53 return NULL;
54 h->priv = malloc(sizeof(priv_t));
55 if (!h->priv)
57 free(h);
58 return NULL;
60 memset(h->priv, 0, sizeof(priv_t));
61 h->functions = &functions;
62 h->seq = 0;
63 h->chanlist = -1;
64 h->chanlist_s = NULL;
65 h->norm = -1;
66 h->channel = -1;
67 h->scan = NULL;
68 return h;
71 static void free_handle(tvi_handle_t *h)
73 if (h) {
74 if (h->priv)
75 free(h->priv);
76 if (h->scan)
77 free(h->scan);
78 free(h);
82 /**
83 Fills video frame in given buffer with blue color for yv12,i420,uyvy,yuy2.
84 Other formats will be filled with 0xC0
86 static inline void fill_blank_frame(char* buffer,int len,int fmt){
87 int i;
88 // RGB(0,0,255) <-> YVU(41,110,240)
90 switch(fmt){
91 case IMGFMT_YV12:
92 memset(buffer, 41,4*len/6); //Y
93 memset(buffer+4*len/6, 110,len/6);//V
94 memset(buffer+5*len/6, 240,len/6);//U
95 break;
96 case IMGFMT_I420:
97 memset(buffer, 41,4*len/6); //Y
98 memset(buffer+4*len/6, 240,len/6);//U
99 memset(buffer+5*len/6, 110,len/6);//V
100 break;
101 case IMGFMT_UYVY:
102 for(i=0;i<len;i+=4){
103 buffer[i]=0xFF;
104 buffer[i+1]=0;
105 buffer[i+2]=0;
106 buffer[i+3]=0;
108 break;
109 case IMGFMT_YUY2:
110 for(i=0;i<len;i+=4){
111 buffer[i]=0;
112 buffer[i+1]=0xFF;
113 buffer[i+2]=0;
114 buffer[i+3]=0;
116 break;
117 case IMGFMT_MJPEG:
119 This is compressed format. I don't know yet how to fill such frame with blue color.
120 Keeping frame unchanged.
122 break;
123 default:
124 memset(buffer,0xC0,len);
128 #endif /* MPLAYER_TVI_DEF_H */