annotate stream/tvi_def.h @ 30811:50e0f6942e43

Implement Win32 mutexes. Implement Win32 mutexes; they used to just be mapped on top of events, which is not the same thing at all. The implementation is pretty much the obvious one, similar to the current critical section implementation and the semaphore implementation; a single lock count protected by a pthread mutex, and an event lockers can sleep on to know when the mutex is available. Also make CreateMutexA and ReleaseMutex available even if QuickTime codecs support is not configured.
author sesse
date Sat, 06 Mar 2010 10:13:37 +0000
parents 9fc9d1e788aa
children 535ebcd085e4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30426
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
1 /*
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
2 * This file is part of MPlayer.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
3 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
5 * it under the terms of the GNU General Public License as published by
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
7 * (at your option) any later version.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
8 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
12 * GNU General Public License for more details.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
13 *
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
14 * You should have received a copy of the GNU General Public License along
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
17 */
ce0122361a39 Add license header to all files missing it in the stream subdirectory.
diego
parents: 29759
diff changeset
18
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 26012
diff changeset
19 #ifndef MPLAYER_TVI_DEF_H
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 26012
diff changeset
20 #define MPLAYER_TVI_DEF_H
26012
04f59a060070 Add missing multiple inclusion guards.
diego
parents: 25684
diff changeset
21
3815
622a9ade4517 updated
alex
parents: 3611
diff changeset
22 #include <stdlib.h> /* malloc */
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 5572
diff changeset
23 #include <string.h> /* memset */
26184
7ee4ae1648e6 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
24 #include "libmpcodecs/img_format.h"
7ee4ae1648e6 Add missing header #includes to fix 'make checkheaders'.
diego
parents: 26029
diff changeset
25 #include "tv.h"
3815
622a9ade4517 updated
alex
parents: 3611
diff changeset
26
622a9ade4517 updated
alex
parents: 3611
diff changeset
27 static int init(priv_t *priv);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
28 static int uninit(priv_t *priv);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
29 static int control(priv_t *priv, int cmd, void *arg);
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
30 static int start(priv_t *priv);
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 3815
diff changeset
31 static double grab_video_frame(priv_t *priv, char *buffer, int len);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
32 static int get_video_framesize(priv_t *priv);
5572
8cd761968f35 BSD-BT848 TV update patch by Charles Henrich <henrich@sigbus.com>
arpi
parents: 3815
diff changeset
33 static double grab_audio_frame(priv_t *priv, char *buffer, int len);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
34 static int get_audio_framesize(priv_t *priv);
98769cea155c added tv subsystem
alex
parents:
diff changeset
35
25684
c6c7a09bf439 tvi_functions_t should be const
reimar
parents: 24105
diff changeset
36 static const tvi_functions_t functions =
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
37 {
98769cea155c added tv subsystem
alex
parents:
diff changeset
38 init,
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
39 uninit,
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
40 control,
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
41 start,
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
42 grab_video_frame,
98769cea155c added tv subsystem
alex
parents:
diff changeset
43 get_video_framesize,
98769cea155c added tv subsystem
alex
parents:
diff changeset
44 grab_audio_frame,
98769cea155c added tv subsystem
alex
parents:
diff changeset
45 get_audio_framesize
98769cea155c added tv subsystem
alex
parents:
diff changeset
46 };
98769cea155c added tv subsystem
alex
parents:
diff changeset
47
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 8123
diff changeset
48 static tvi_handle_t *new_handle(void)
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
49 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30426
diff changeset
50 tvi_handle_t *h = malloc(sizeof(tvi_handle_t));
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
51
98769cea155c added tv subsystem
alex
parents:
diff changeset
52 if (!h)
26756
c43ce7268677 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26184
diff changeset
53 return NULL;
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30426
diff changeset
54 h->priv = malloc(sizeof(priv_t));
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
55 if (!h->priv)
98769cea155c added tv subsystem
alex
parents:
diff changeset
56 {
98769cea155c added tv subsystem
alex
parents:
diff changeset
57 free(h);
26756
c43ce7268677 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26184
diff changeset
58 return NULL;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
59 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
60 memset(h->priv, 0, sizeof(priv_t));
98769cea155c added tv subsystem
alex
parents:
diff changeset
61 h->functions = &functions;
2802
09d5c9834580 tv update
alex
parents: 2790
diff changeset
62 h->seq = 0;
2941
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2819
diff changeset
63 h->chanlist = -1;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2819
diff changeset
64 h->chanlist_s = NULL;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2819
diff changeset
65 h->norm = -1;
60c1b7c0ea21 added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents: 2819
diff changeset
66 h->channel = -1;
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 24104
diff changeset
67 h->scan = NULL;
26756
c43ce7268677 cosmetics: Remove useless parentheses from return statements.
diego
parents: 26184
diff changeset
68 return h;
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
69 }
98769cea155c added tv subsystem
alex
parents:
diff changeset
70
98769cea155c added tv subsystem
alex
parents:
diff changeset
71 static void free_handle(tvi_handle_t *h)
98769cea155c added tv subsystem
alex
parents:
diff changeset
72 {
3611
178c562948ff checkings for malloc results (potential memleaks)
pl
parents: 2941
diff changeset
73 if (h) {
178c562948ff checkings for malloc results (potential memleaks)
pl
parents: 2941
diff changeset
74 if (h->priv)
178c562948ff checkings for malloc results (potential memleaks)
pl
parents: 2941
diff changeset
75 free(h->priv);
24105
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 24104
diff changeset
76 if (h->scan)
9e71e0345c35 Automatic TV channels scanning ability for MPlayer.
voroshil
parents: 24104
diff changeset
77 free(h->scan);
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
78 free(h);
3611
178c562948ff checkings for malloc results (potential memleaks)
pl
parents: 2941
diff changeset
79 }
2790
98769cea155c added tv subsystem
alex
parents:
diff changeset
80 }
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
81
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
82 /**
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
83 Fills video frame in given buffer with blue color for yv12,i420,uyvy,yuy2.
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
84 Other formats will be filled with 0xC0
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
85 */
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
86 static inline void fill_blank_frame(char* buffer,int len,int fmt){
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
87 int i;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 26756
diff changeset
88 // RGB(0,0,255) <-> YVU(41,110,240)
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
89
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
90 switch(fmt){
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
91 case IMGFMT_YV12:
24104
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
92 memset(buffer, 41,4*len/6); //Y
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
93 memset(buffer+4*len/6, 110,len/6);//V
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
94 memset(buffer+5*len/6, 240,len/6);//U
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
95 break;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
96 case IMGFMT_I420:
24104
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
97 memset(buffer, 41,4*len/6); //Y
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
98 memset(buffer+4*len/6, 240,len/6);//U
b0a47d3bf2f3 Fix blue color for yv12 and i420 image formats in "automute" screen
voroshil
parents: 24017
diff changeset
99 memset(buffer+5*len/6, 110,len/6);//V
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
100 break;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
101 case IMGFMT_UYVY:
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
102 for(i=0;i<len;i+=4){
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
103 buffer[i]=0xFF;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
104 buffer[i+1]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
105 buffer[i+2]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
106 buffer[i+3]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
107 }
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
108 break;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
109 case IMGFMT_YUY2:
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
110 for(i=0;i<len;i+=4){
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
111 buffer[i]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
112 buffer[i+1]=0xFF;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
113 buffer[i+2]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
114 buffer[i+3]=0;
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
115 }
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
116 break;
23423
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
117 case IMGFMT_MJPEG:
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
118 /*
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
119 This is compressed format. I don't know yet how to fill such frame with blue color.
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
120 Keeping frame unchanged.
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
121 */
6b18c979dd45 mjpeg support for v4l2 tv:// driver
voroshil
parents: 23422
diff changeset
122 break;
23422
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
123 default:
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
124 memset(buffer,0xC0,len);
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
125 }
e7b4c913dc31 New "automute" tv:// option.
voroshil
parents: 23362
diff changeset
126 }
26012
04f59a060070 Add missing multiple inclusion guards.
diego
parents: 25684
diff changeset
127
26029
4129c8cfa742 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 26012
diff changeset
128 #endif /* MPLAYER_TVI_DEF_H */