Mercurial > mplayer.hg
annotate libmpdemux/demux_nuv.c @ 6646:6cfc8fd31299
Added the bandwidth option
author | bertrand |
---|---|
date | Fri, 05 Jul 2002 02:51:19 +0000 |
parents | 8a357300d0ec |
children | f8d1c9ab777a |
rev | line source |
---|---|
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
1 /* |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
2 * NuppelVideo 0.05 file parser |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
3 * for MPlayer |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
4 * by Panagiotis Issaris <takis@lumumba.luc.ac.be> |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
5 * |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
6 * Reworked by alex |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
7 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
8 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
9 #include <stdio.h> |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
10 #include <stdlib.h> |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
11 #include <unistd.h> |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
12 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
13 #include "config.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
14 #include "mp_msg.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
15 #include "help_mp.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
16 #include "stream.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
17 #include "demuxer.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
18 #include "stheader.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
19 #include "nuppelvideo.h" |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
20 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
21 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
22 struct nuv_signature |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
23 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
24 char finfo[12]; /* "NuppelVideo" + \0 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
25 char version[5]; /* "0.05" + \0 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
26 }; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
27 |
4065 | 28 typedef struct _nuv_position_t nuv_position_t; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
29 |
4065 | 30 struct _nuv_position_t |
31 { | |
32 off_t offset; | |
33 float time; | |
34 int frame; | |
35 nuv_position_t* next; | |
36 }; | |
37 | |
38 typedef struct _nuv_info_t | |
39 { | |
40 int current_audio_frame; | |
41 int current_video_frame; | |
42 nuv_position_t *index_list; | |
43 nuv_position_t *current_position; | |
44 } nuv_priv_t; | |
45 | |
46 | |
47 /** | |
48 * Seek to a position relative to the current position, indicated in time. | |
49 */ | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
50 void demux_seek_nuv ( demuxer_t *demuxer, float rel_seek_secs, int flags ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
51 { |
4065 | 52 #define MAX_TIME 1000000 |
53 nuv_priv_t* priv = demuxer->priv; | |
54 struct rtframeheader rtjpeg_frameheader; | |
55 int orig_pos; | |
56 int curr_pos; | |
57 float current_time = 0; | |
58 float start_time = MAX_TIME; | |
59 float target_time = start_time + rel_seek_secs * 1000; /* target_time, start_time are ms, rel_seek_secs s */ | |
60 | |
61 orig_pos = stream_tell ( demuxer->stream ); | |
62 | |
63 if ( rel_seek_secs > 0 ) | |
64 { | |
65 /* Seeking forward */ | |
66 | |
67 | |
68 while(current_time < target_time ) | |
69 { | |
70 if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader)) | |
71 return; /* EOF */ | |
72 | |
73 if ( rtjpeg_frameheader.frametype == 'V' ) | |
74 { | |
75 priv->current_position->next = (nuv_position_t*) malloc ( sizeof ( nuv_position_t ) ); | |
76 priv->current_position = priv->current_position->next; | |
77 priv->current_position->frame = priv->current_video_frame++; | |
78 priv->current_position->time = rtjpeg_frameheader.timecode; | |
79 priv->current_position->offset = orig_pos; | |
80 priv->current_position->next = NULL; | |
81 | |
82 if ( start_time == MAX_TIME ) | |
83 { | |
84 start_time = rtjpeg_frameheader.timecode; | |
85 /* Recalculate target time with real start time */ | |
86 target_time = start_time + rel_seek_secs*1000; | |
87 } | |
88 | |
89 current_time = rtjpeg_frameheader.timecode; | |
90 | |
91 curr_pos = stream_tell ( demuxer->stream ); | |
92 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength ); | |
93 | |
94 /* Adjust current sequence pointer */ | |
95 } | |
96 else if ( rtjpeg_frameheader.frametype == 'A' ) | |
97 { | |
98 if ( start_time == MAX_TIME ) | |
99 { | |
100 start_time = rtjpeg_frameheader.timecode; | |
101 /* Recalculate target time with real start time */ | |
102 target_time = start_time + rel_seek_secs * 1000; | |
103 } | |
104 current_time = rtjpeg_frameheader.timecode; | |
105 | |
106 | |
107 curr_pos = stream_tell ( demuxer->stream ); | |
108 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength ); | |
109 } | |
110 } | |
111 } | |
112 else | |
113 { | |
114 /* Seeking backward */ | |
115 nuv_position_t* p; | |
116 start_time = priv->current_position->time; | |
117 | |
118 /* Recalculate target time with real start time */ | |
119 target_time = start_time + rel_seek_secs * 1000; | |
120 | |
121 | |
122 if(target_time < 0) | |
123 target_time = 0; | |
124 | |
125 // Search the target time in the index list, get the offset | |
126 // and go to that offset. | |
127 p = priv->index_list; | |
128 while ( ( p->next != NULL ) && ( p->time < target_time ) ) | |
129 { | |
130 p = p->next; | |
131 } | |
132 stream_seek ( demuxer->stream, p->offset ); | |
133 priv->current_video_frame = p->frame; | |
134 } | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
135 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
136 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
137 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
138 int demux_nuv_fill_buffer ( demuxer_t *demuxer ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
139 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
140 struct rtframeheader rtjpeg_frameheader; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
141 int orig_pos; |
4065 | 142 nuv_priv_t* priv = demuxer->priv; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
143 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
144 orig_pos = stream_tell ( demuxer->stream ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
145 if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader)) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
146 return 0; /* EOF */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
147 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
148 #if 0 |
3811 | 149 printf("NUV frame: frametype: %c, comptype: %c, packetlength: %d\n", |
150 rtjpeg_frameheader.frametype, rtjpeg_frameheader.comptype, | |
151 rtjpeg_frameheader.packetlength); | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
152 #endif |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
153 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
154 /* Skip Seekpoint, Text and Sync for now */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
155 if ((rtjpeg_frameheader.frametype == 'R') || |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
156 (rtjpeg_frameheader.frametype == 'T') || |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
157 (rtjpeg_frameheader.frametype == 'S')) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
158 return 1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
159 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
160 if (((rtjpeg_frameheader.frametype == 'D') && |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
161 (rtjpeg_frameheader.comptype == 'R')) || |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
162 (rtjpeg_frameheader.frametype == 'V')) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
163 { |
4065 | 164 if ( rtjpeg_frameheader.frametype == 'V' ) |
165 { | |
166 priv->current_video_frame++; | |
167 priv->current_position->next = (nuv_position_t*) malloc(sizeof(nuv_position_t)); | |
168 priv->current_position = priv->current_position->next; | |
169 priv->current_position->frame = priv->current_video_frame; | |
170 priv->current_position->time = rtjpeg_frameheader.timecode; | |
171 priv->current_position->offset = orig_pos; | |
172 priv->current_position->next = NULL; | |
173 } | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
174 /* put RTjpeg tables, Video info to video buffer */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
175 stream_seek ( demuxer->stream, orig_pos ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
176 ds_read_packet ( demuxer->video, demuxer->stream, rtjpeg_frameheader.packetlength + 12, |
5435
508a4e7df349
10l... int/1000 will be int while we want float, so let's do int*0.001
arpi
parents:
4065
diff
changeset
|
177 rtjpeg_frameheader.timecode*0.001, orig_pos, 0 ); |
4065 | 178 |
179 | |
180 } else | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
181 /* copy PCM only */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
182 if (demuxer->audio && (rtjpeg_frameheader.frametype == 'A') && |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
183 (rtjpeg_frameheader.comptype == '0')) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
184 { |
4065 | 185 priv->current_audio_frame++; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
186 /* put Audio to audio buffer */ |
3960
79e1c3c0e634
last minute audio demuxer patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3958
diff
changeset
|
187 ds_read_packet ( demuxer->audio, demuxer->stream, rtjpeg_frameheader.packetlength, |
5435
508a4e7df349
10l... int/1000 will be int while we want float, so let's do int*0.001
arpi
parents:
4065
diff
changeset
|
188 rtjpeg_frameheader.timecode*0.001, orig_pos + 12, 0 ); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
189 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
190 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
191 return 1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
192 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
193 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
194 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
195 demuxer_t* demux_open_nuv ( demuxer_t* demuxer ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
196 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
197 sh_video_t *sh_video = NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
198 sh_audio_t *sh_audio = NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
199 struct rtfileheader rtjpeg_fileheader; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
200 struct rtframeheader rtjpeg_frameheader; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
201 unsigned long int tbls[128]; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
202 int bytes_read; |
4065 | 203 nuv_priv_t* priv = (nuv_priv_t*) malloc ( sizeof ( nuv_priv_t) ); |
204 demuxer->priv = priv; | |
205 priv->current_audio_frame = 0; | |
206 priv->current_video_frame = 0; | |
207 | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
208 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
209 /* Go to the start */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
210 stream_reset(demuxer->stream); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
211 stream_seek(demuxer->stream, 0); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
212 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
213 stream_read ( demuxer->stream, (char*)& rtjpeg_fileheader, sizeof(rtjpeg_fileheader) ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
214 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
215 /* no video */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
216 if (rtjpeg_fileheader.videoblocks == 0) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
217 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
218 printf("No video blocks in file\n"); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
219 return NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
220 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
221 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
222 /* Create a new video stream header */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
223 sh_video = new_sh_video ( demuxer, 0 ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
224 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
225 /* Make sure the demuxer knows about the new video stream header |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
226 * (even though new_sh_video() ought to take care of it) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
227 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
228 demuxer->video->sh = sh_video; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
229 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
230 /* Make sure that the video demuxer stream header knows about its |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
231 * parent video demuxer stream (this is getting wacky), or else |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
232 * video_read_properties() will choke |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
233 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
234 sh_video->ds = demuxer->video; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
235 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
236 /* Custom fourcc for internal MPlayer use */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
237 sh_video->format = mmioFOURCC('N', 'U', 'V', '1'); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
238 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
239 sh_video->disp_w = rtjpeg_fileheader.width; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
240 sh_video->disp_h = rtjpeg_fileheader.height; |
3811 | 241 |
3958
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
242 /* NuppelVideo uses pixel aspect ratio |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
243 here display aspect ratio is used. |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
244 For the moment NuppelVideo only supports 1.0 thus |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
245 1.33 == 4:3 aspect ratio. |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
246 */ |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
247 if(rtjpeg_fileheader.aspect == 1.0) |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
248 sh_video->aspect = (float) 1.33; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
249 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
250 /* Get the FPS */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
251 sh_video->fps = rtjpeg_fileheader.fps; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
252 sh_video->frametime = 1 / sh_video->fps; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
253 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
254 if (rtjpeg_fileheader.audioblocks != 0) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
255 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
256 sh_audio = new_sh_audio(demuxer, 0); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
257 demuxer->audio->sh = sh_audio; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
258 sh_audio->ds = demuxer->audio; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
259 sh_audio->format = 0x1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
260 sh_audio->channels = 2; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
261 sh_audio->samplerate = 44100; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
262 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
263 sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
264 memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
265 sh_audio->wf->wFormatTag = sh_audio->format; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
266 sh_audio->wf->nChannels = sh_audio->channels; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
267 sh_audio->wf->wBitsPerSample = 16; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
268 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
269 sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels* |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
270 sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
271 sh_audio->wf->nBlockAlign = sh_audio->channels * 2; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
272 sh_audio->wf->cbSize = 0; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
273 } |
4065 | 274 |
275 priv->index_list = (nuv_position_t*) malloc(sizeof(nuv_position_t)); | |
276 priv->index_list->frame = 0; | |
277 priv->index_list->time = 0; | |
278 priv->index_list->offset = stream_tell ( demuxer->stream ); | |
279 priv->index_list->next = NULL; | |
280 priv->current_position = priv->index_list; | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
281 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
282 return demuxer; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
283 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
284 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
285 int nuv_check_file ( demuxer_t* demuxer ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
286 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
287 struct nuv_signature ns; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
288 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
289 /* Store original position */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
290 int orig_pos = stream_tell(demuxer->stream); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
291 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
292 mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for NuppelVideo\n" ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
293 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
294 stream_read(demuxer->stream,(char*)&ns,sizeof(ns)); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
295 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
296 if ( strncmp ( ns.finfo, "NuppelVideo", 12 ) ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
297 return 0; /* Not a NuppelVideo file */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
298 if ( strncmp ( ns.version, "0.05", 5 ) ) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
299 return 0; /* Wrong version NuppelVideo file */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
300 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
301 /* Return to original position */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
302 stream_seek ( demuxer->stream, orig_pos ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
303 return 1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
304 } |
5810 | 305 |
306 void demux_close_nuv(demuxer_t* demuxer) { | |
307 nuv_priv_t* priv = demuxer->priv; | |
308 nuv_position_t* pos; | |
309 if(!priv) | |
310 return; | |
311 for(pos = priv->index_list ; pos != NULL ; ) { | |
312 nuv_position_t* p = pos; | |
313 pos = pos->next; | |
314 free(p); | |
315 } | |
316 free(priv); | |
317 } |