Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / stream / tvi_def.h
blobc47b0dfe36ae6deacf85a24f373bcdf725fdcfc7
1 #include <stdlib.h> /* malloc */
2 #include <string.h> /* memset */
4 static int init(priv_t *priv);
5 static int uninit(priv_t *priv);
6 static int control(priv_t *priv, int cmd, void *arg);
7 static int start(priv_t *priv);
8 static double grab_video_frame(priv_t *priv, char *buffer, int len);
9 static int get_video_framesize(priv_t *priv);
10 static double grab_audio_frame(priv_t *priv, char *buffer, int len);
11 static int get_audio_framesize(priv_t *priv);
13 int teletext_control(void* p, int cmd, void *arg);
15 static tvi_functions_t functions =
17 init,
18 uninit,
19 control,
20 start,
21 grab_video_frame,
22 get_video_framesize,
23 grab_audio_frame,
24 get_audio_framesize
27 static tvi_handle_t *new_handle(void)
29 tvi_handle_t *h = (tvi_handle_t *)malloc(sizeof(tvi_handle_t));
31 if (!h)
32 return(NULL);
33 h->priv = (priv_t *)malloc(sizeof(priv_t));
34 if (!h->priv)
36 free(h);
37 return(NULL);
39 memset(h->priv, 0, sizeof(priv_t));
40 h->functions = &functions;
41 h->seq = 0;
42 h->chanlist = -1;
43 h->chanlist_s = NULL;
44 h->norm = -1;
45 h->channel = -1;
46 h->scan = NULL;
47 return(h);
50 static void free_handle(tvi_handle_t *h)
52 if (h) {
53 if (h->priv)
54 free(h->priv);
55 if (h->scan)
56 free(h->scan);
57 free(h);
61 /**
62 Fills video frame in given buffer with blue color for yv12,i420,uyvy,yuy2.
63 Other formats will be filled with 0xC0
65 static inline void fill_blank_frame(char* buffer,int len,int fmt){
66 int i;
67 // RGB(0,0,255) <-> YVU(41,110,240)
69 switch(fmt){
70 case IMGFMT_YV12:
71 memset(buffer, 41,4*len/6); //Y
72 memset(buffer+4*len/6, 110,len/6);//V
73 memset(buffer+5*len/6, 240,len/6);//U
74 break;
75 case IMGFMT_I420:
76 memset(buffer, 41,4*len/6); //Y
77 memset(buffer+4*len/6, 240,len/6);//U
78 memset(buffer+5*len/6, 110,len/6);//V
79 break;
80 case IMGFMT_UYVY:
81 for(i=0;i<len;i+=4){
82 buffer[i]=0xFF;
83 buffer[i+1]=0;
84 buffer[i+2]=0;
85 buffer[i+3]=0;
87 break;
88 case IMGFMT_YUY2:
89 for(i=0;i<len;i+=4){
90 buffer[i]=0;
91 buffer[i+1]=0xFF;
92 buffer[i+2]=0;
93 buffer[i+3]=0;
95 break;
96 case IMGFMT_MJPEG:
98 This is compressed format. I don't know yet how to fill such frame with blue color.
99 Keeping frame unchanged.
101 break;
102 default:
103 memset(buffer,0xC0,len);