Introduce ADD_ALL_DIRS function to factorize clean and distclean target commands
[mplayer/glamo.git] / stream / tvi_def.h
blob967c15ee1545ff9b0742ae583b90a83214b5c41f
1 #ifndef MPLAYER_TVI_DEF_H
2 #define MPLAYER_TVI_DEF_H
4 #include <stdlib.h> /* malloc */
5 #include <string.h> /* memset */
6 #include "libmpcodecs/img_format.h"
7 #include "tv.h"
9 static int init(priv_t *priv);
10 static int uninit(priv_t *priv);
11 static int control(priv_t *priv, int cmd, void *arg);
12 static int start(priv_t *priv);
13 static double grab_video_frame(priv_t *priv, char *buffer, int len);
14 static int get_video_framesize(priv_t *priv);
15 static double grab_audio_frame(priv_t *priv, char *buffer, int len);
16 static int get_audio_framesize(priv_t *priv);
18 int teletext_control(void* p, int cmd, void *arg);
20 static const tvi_functions_t functions =
22 init,
23 uninit,
24 control,
25 start,
26 grab_video_frame,
27 get_video_framesize,
28 grab_audio_frame,
29 get_audio_framesize
32 static tvi_handle_t *new_handle(void)
34 tvi_handle_t *h = (tvi_handle_t *)malloc(sizeof(tvi_handle_t));
36 if (!h)
37 return NULL;
38 h->priv = (priv_t *)malloc(sizeof(priv_t));
39 if (!h->priv)
41 free(h);
42 return NULL;
44 memset(h->priv, 0, sizeof(priv_t));
45 h->functions = &functions;
46 h->seq = 0;
47 h->chanlist = -1;
48 h->chanlist_s = NULL;
49 h->norm = -1;
50 h->channel = -1;
51 h->scan = NULL;
52 return h;
55 static void free_handle(tvi_handle_t *h)
57 if (h) {
58 if (h->priv)
59 free(h->priv);
60 if (h->scan)
61 free(h->scan);
62 free(h);
66 /**
67 Fills video frame in given buffer with blue color for yv12,i420,uyvy,yuy2.
68 Other formats will be filled with 0xC0
70 static inline void fill_blank_frame(char* buffer,int len,int fmt){
71 int i;
72 // RGB(0,0,255) <-> YVU(41,110,240)
74 switch(fmt){
75 case IMGFMT_YV12:
76 memset(buffer, 41,4*len/6); //Y
77 memset(buffer+4*len/6, 110,len/6);//V
78 memset(buffer+5*len/6, 240,len/6);//U
79 break;
80 case IMGFMT_I420:
81 memset(buffer, 41,4*len/6); //Y
82 memset(buffer+4*len/6, 240,len/6);//U
83 memset(buffer+5*len/6, 110,len/6);//V
84 break;
85 case IMGFMT_UYVY:
86 for(i=0;i<len;i+=4){
87 buffer[i]=0xFF;
88 buffer[i+1]=0;
89 buffer[i+2]=0;
90 buffer[i+3]=0;
92 break;
93 case IMGFMT_YUY2:
94 for(i=0;i<len;i+=4){
95 buffer[i]=0;
96 buffer[i+1]=0xFF;
97 buffer[i+2]=0;
98 buffer[i+3]=0;
100 break;
101 case IMGFMT_MJPEG:
103 This is compressed format. I don't know yet how to fill such frame with blue color.
104 Keeping frame unchanged.
106 break;
107 default:
108 memset(buffer,0xC0,len);
112 #endif /* MPLAYER_TVI_DEF_H */