Mercurial > mplayer.hg
annotate libmpdemux/demux_nuv.c @ 20400:f4518826ea84
Allow lowercase letters in AVI stream id, fixes bug #277
author | reimar |
---|---|
date | Mon, 23 Oct 2006 16:46:16 +0000 |
parents | a8e681ad7c90 |
children | 4d81dbdf46b9 |
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 | |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
46 /** |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
47 * \brief find best matching bitrate (in kbps) out of a table |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
48 * \param bitrate bitrate to find best match for |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
49 * \return best match from table |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
50 */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
51 static int nearestBitrate(int bitrate) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
52 const int rates[17] = {8000, 16000, 24000, 32000, 40000, 48000, 56000, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
53 64000, 80000, 96000, 112000, 128000, 160000, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
54 192000, 224000, 256000, 320000}; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
55 int i; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
56 for (i = 0; i < 16; i++) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
57 if ((rates[i] + rates[i + 1]) / 2 > bitrate) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
58 break; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
59 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
60 return rates[i]; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
61 } |
4065 | 62 |
63 /** | |
64 * Seek to a position relative to the current position, indicated in time. | |
65 */ | |
17636 | 66 static void demux_seek_nuv ( demuxer_t *demuxer, float rel_seek_secs, float audio_delay, int flags ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
67 { |
4065 | 68 #define MAX_TIME 1000000 |
69 nuv_priv_t* priv = demuxer->priv; | |
70 struct rtframeheader rtjpeg_frameheader; | |
7361 | 71 off_t orig_pos; |
72 off_t curr_pos; | |
4065 | 73 float current_time = 0; |
74 float start_time = MAX_TIME; | |
75 float target_time = start_time + rel_seek_secs * 1000; /* target_time, start_time are ms, rel_seek_secs s */ | |
76 | |
77 orig_pos = stream_tell ( demuxer->stream ); | |
78 | |
79 if ( rel_seek_secs > 0 ) | |
80 { | |
81 /* Seeking forward */ | |
82 | |
83 | |
84 while(current_time < target_time ) | |
85 { | |
86 if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader)) | |
87 return; /* EOF */ | |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
7566
diff
changeset
|
88 le2me_rtframeheader(&rtjpeg_frameheader); |
4065 | 89 |
90 if ( rtjpeg_frameheader.frametype == 'V' ) | |
91 { | |
92 priv->current_position->next = (nuv_position_t*) malloc ( sizeof ( nuv_position_t ) ); | |
93 priv->current_position = priv->current_position->next; | |
94 priv->current_position->frame = priv->current_video_frame++; | |
95 priv->current_position->time = rtjpeg_frameheader.timecode; | |
96 priv->current_position->offset = orig_pos; | |
97 priv->current_position->next = NULL; | |
98 | |
99 if ( start_time == MAX_TIME ) | |
100 { | |
101 start_time = rtjpeg_frameheader.timecode; | |
102 /* Recalculate target time with real start time */ | |
103 target_time = start_time + rel_seek_secs*1000; | |
104 } | |
105 | |
106 current_time = rtjpeg_frameheader.timecode; | |
107 | |
108 curr_pos = stream_tell ( demuxer->stream ); | |
109 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength ); | |
110 | |
111 /* Adjust current sequence pointer */ | |
112 } | |
113 else if ( rtjpeg_frameheader.frametype == 'A' ) | |
114 { | |
115 if ( start_time == MAX_TIME ) | |
116 { | |
117 start_time = rtjpeg_frameheader.timecode; | |
118 /* Recalculate target time with real start time */ | |
119 target_time = start_time + rel_seek_secs * 1000; | |
120 } | |
121 current_time = rtjpeg_frameheader.timecode; | |
122 | |
123 | |
124 curr_pos = stream_tell ( demuxer->stream ); | |
125 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength ); | |
126 } | |
127 } | |
128 } | |
129 else | |
130 { | |
131 /* Seeking backward */ | |
132 nuv_position_t* p; | |
133 start_time = priv->current_position->time; | |
134 | |
135 /* Recalculate target time with real start time */ | |
136 target_time = start_time + rel_seek_secs * 1000; | |
137 | |
138 | |
139 if(target_time < 0) | |
140 target_time = 0; | |
141 | |
142 // Search the target time in the index list, get the offset | |
143 // and go to that offset. | |
144 p = priv->index_list; | |
145 while ( ( p->next != NULL ) && ( p->time < target_time ) ) | |
146 { | |
147 p = p->next; | |
148 } | |
149 stream_seek ( demuxer->stream, p->offset ); | |
150 priv->current_video_frame = p->frame; | |
151 } | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
152 } |
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 |
16175 | 155 static int demux_nuv_fill_buffer ( demuxer_t *demuxer, demux_stream_t *ds ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
156 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
157 struct rtframeheader rtjpeg_frameheader; |
7361 | 158 off_t orig_pos; |
4065 | 159 nuv_priv_t* priv = demuxer->priv; |
7566
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
160 int want_audio = (demuxer->audio)&&(demuxer->audio->id!=-2); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
161 |
7566
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
162 demuxer->filepos = orig_pos = stream_tell ( demuxer->stream ); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
163 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
|
164 return 0; /* EOF */ |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
7566
diff
changeset
|
165 le2me_rtframeheader(&rtjpeg_frameheader); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
166 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
167 #if 0 |
3811 | 168 printf("NUV frame: frametype: %c, comptype: %c, packetlength: %d\n", |
169 rtjpeg_frameheader.frametype, rtjpeg_frameheader.comptype, | |
170 rtjpeg_frameheader.packetlength); | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
171 #endif |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
172 |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
173 /* Skip Seekpoint, Extended header and Sync for now */ |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
174 if ((rtjpeg_frameheader.frametype == 'R') || |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
175 (rtjpeg_frameheader.frametype == 'X') || |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
176 (rtjpeg_frameheader.frametype == 'S')) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
177 return 1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
178 |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
179 /* Skip seektable and text (these have a payload) */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
180 if ((rtjpeg_frameheader.frametype == 'Q') || |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
181 (rtjpeg_frameheader.frametype == 'T')) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
182 stream_skip(demuxer->stream, rtjpeg_frameheader.packetlength); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
183 return 1; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
184 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
185 |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
186 if (((rtjpeg_frameheader.frametype == 'D') && |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
187 (rtjpeg_frameheader.comptype == 'R')) || |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
188 (rtjpeg_frameheader.frametype == 'V')) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
189 { |
4065 | 190 if ( rtjpeg_frameheader.frametype == 'V' ) |
191 { | |
192 priv->current_video_frame++; | |
193 priv->current_position->next = (nuv_position_t*) malloc(sizeof(nuv_position_t)); | |
194 priv->current_position = priv->current_position->next; | |
195 priv->current_position->frame = priv->current_video_frame; | |
196 priv->current_position->time = rtjpeg_frameheader.timecode; | |
197 priv->current_position->offset = orig_pos; | |
198 priv->current_position->next = NULL; | |
199 } | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
200 /* put RTjpeg tables, Video info to video buffer */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
201 stream_seek ( demuxer->stream, orig_pos ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
202 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
|
203 rtjpeg_frameheader.timecode*0.001, orig_pos, 0 ); |
4065 | 204 |
205 | |
206 } else | |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
207 if (demuxer->audio && (rtjpeg_frameheader.frametype == 'A')) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
208 { |
4065 | 209 priv->current_audio_frame++; |
7566
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
210 if (want_audio) { |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
211 /* put Audio to audio buffer */ |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
212 ds_read_packet ( demuxer->audio, demuxer->stream, |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
213 rtjpeg_frameheader.packetlength, |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
214 rtjpeg_frameheader.timecode*0.001, |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
215 orig_pos + 12, 0 ); |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
216 } else { |
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
217 /* skip audio block */ |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
218 stream_skip ( demuxer->stream, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
219 rtjpeg_frameheader.packetlength ); |
7566
ab5984ab6af0
- demuxer->audio->id is set to -2 when using 'frameno.avi', so
arpi
parents:
7472
diff
changeset
|
220 } |
3801
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 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
223 return 1; |
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 |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
226 /* Scan for the extended data in MythTV nuv streams */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
227 static int demux_xscan_nuv(demuxer_t* demuxer, int width, int height) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
228 int i; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
229 off_t orig_pos = stream_tell(demuxer->stream); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
230 struct rtframeheader rtjpeg_frameheader; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
231 struct extendeddata ext; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
232 sh_video_t* sh_video = demuxer->video->sh; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
233 sh_audio_t* sh_audio = demuxer->audio->sh; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
234 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
235 for (i = 0; i < 2; ++i) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
236 if (stream_read(demuxer->stream, (char*)&rtjpeg_frameheader, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
237 sizeof(rtjpeg_frameheader)) < sizeof(rtjpeg_frameheader)) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
238 goto out; |
16859
d3b47567e629
big-endian fixes for "extended" (i.e. mythtv) files.
reimar
parents:
16175
diff
changeset
|
239 le2me_rtframeheader(&rtjpeg_frameheader); |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
240 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
241 if (rtjpeg_frameheader.frametype != 'X') |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
242 stream_skip(demuxer->stream, rtjpeg_frameheader.packetlength); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
243 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
244 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
245 if ( rtjpeg_frameheader.frametype != 'X' ) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
246 goto out; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
247 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
248 if (rtjpeg_frameheader.packetlength != sizeof(ext)) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
249 mp_msg(MSGT_DEMUXER, MSGL_WARN, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
250 "NUV extended frame does not have expected length, ignoring\n"); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
251 goto out; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
252 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
253 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
254 if (stream_read(demuxer->stream, (char*)&ext, sizeof(ext)) < sizeof(ext)) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
255 goto out; |
16859
d3b47567e629
big-endian fixes for "extended" (i.e. mythtv) files.
reimar
parents:
16175
diff
changeset
|
256 le2me_extendeddata(&ext); |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
257 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
258 if (ext.version != 1) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
259 mp_msg(MSGT_DEMUXER, MSGL_WARN, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
260 "NUV extended frame has unknown version number (%d), ignoring\n", |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
261 ext.version); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
262 goto out; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
263 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
264 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
265 mp_msg(MSGT_DEMUXER, MSGL_V, "Detected MythTV stream\n"); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
266 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
267 /* Video parameters */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
268 mp_msg(MSGT_DEMUXER, MSGL_V, "FOURCC: %c%c%c%c\n", |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
269 (ext.video_fourcc >> 24) & 0xff, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
270 (ext.video_fourcc >> 16) & 0xff, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
271 (ext.video_fourcc >> 8) & 0xff, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
272 (ext.video_fourcc) & 0xff); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
273 sh_video->format = ext.video_fourcc; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
274 sh_video->i_bps = ext.lavc_bitrate; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
275 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
276 /* Audio parameters */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
277 if (ext.audio_fourcc == mmioFOURCC('L', 'A', 'M', 'E')) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
278 sh_audio->format = 0x55; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
279 } else if (ext.audio_fourcc == mmioFOURCC('R', 'A', 'W', 'A')) { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
280 sh_audio->format = 0x1; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
281 } else { |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
282 mp_msg(MSGT_DEMUXER, MSGL_WARN, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
283 "Unknown audio format 0x%x\n", ext.audio_fourcc); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
284 } |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
285 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
286 sh_audio->channels = ext.audio_channels; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
287 sh_audio->samplerate = ext.audio_sample_rate; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
288 sh_audio->i_bps = sh_audio->channels * sh_audio->samplerate * |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
289 ext.audio_bits_per_sample; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
290 if (sh_audio->format != 0x1) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
291 sh_audio->i_bps = nearestBitrate(sh_audio->i_bps / |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
292 ext.audio_compression_ratio); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
293 sh_audio->wf->wFormatTag = sh_audio->format; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
294 sh_audio->wf->nChannels = sh_audio->channels; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
295 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
296 sh_audio->wf->nAvgBytesPerSec = sh_audio->i_bps / 8; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
297 sh_audio->wf->nBlockAlign = sh_audio->channels * 2; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
298 sh_audio->wf->wBitsPerSample = ext.audio_bits_per_sample; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
299 sh_audio->wf->cbSize = 0; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
300 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
301 mp_msg(MSGT_DEMUXER, MSGL_V, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
302 "channels=%d bitspersample=%d samplerate=%d compression_ratio=%d\n", |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
303 ext.audio_channels, ext.audio_bits_per_sample, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
304 ext.audio_sample_rate, ext.audio_compression_ratio); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
305 return 1; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
306 out: |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
307 stream_reset(demuxer->stream); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
308 stream_seek(demuxer->stream, orig_pos); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
309 return 0; |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
310 } |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
311 |
16175 | 312 static demuxer_t* demux_open_nuv ( demuxer_t* demuxer ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
313 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
314 sh_video_t *sh_video = NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
315 sh_audio_t *sh_audio = NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
316 struct rtfileheader rtjpeg_fileheader; |
4065 | 317 nuv_priv_t* priv = (nuv_priv_t*) malloc ( sizeof ( nuv_priv_t) ); |
318 demuxer->priv = priv; | |
319 priv->current_audio_frame = 0; | |
320 priv->current_video_frame = 0; | |
321 | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
322 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
323 /* Go to the start */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
324 stream_reset(demuxer->stream); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
325 stream_seek(demuxer->stream, 0); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
326 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
327 stream_read ( demuxer->stream, (char*)& rtjpeg_fileheader, sizeof(rtjpeg_fileheader) ); |
14896
9ddae5897422
Make nuv files work on bigendian (but old nuv files created with mencoder
reimar
parents:
7566
diff
changeset
|
328 le2me_rtfileheader(&rtjpeg_fileheader); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
329 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
330 /* no video */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
331 if (rtjpeg_fileheader.videoblocks == 0) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
332 { |
18176
f72bc5754209
Part3 of Otvos Attila's oattila AT chello-hu mp_msg changes, with lots of modifications as usual
reynaldo
parents:
17636
diff
changeset
|
333 mp_msg(MSGT_DEMUXER, MSGL_INFO, MSGTR_MPDEMUX_NUV_NoVideoBlocksInFile); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
334 return NULL; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
335 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
336 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
337 /* Create a new video stream header */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
338 sh_video = new_sh_video ( demuxer, 0 ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
339 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
340 /* Make sure the demuxer knows about the new video stream header |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
341 * (even though new_sh_video() ought to take care of it) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
342 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
343 demuxer->video->sh = sh_video; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
344 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
345 /* Make sure that the video demuxer stream header knows about its |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
346 * parent video demuxer stream (this is getting wacky), or else |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
347 * video_read_properties() will choke |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
348 */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
349 sh_video->ds = demuxer->video; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
350 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
351 /* Custom fourcc for internal MPlayer use */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
352 sh_video->format = mmioFOURCC('N', 'U', 'V', '1'); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
353 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
354 sh_video->disp_w = rtjpeg_fileheader.width; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
355 sh_video->disp_h = rtjpeg_fileheader.height; |
3811 | 356 |
3958
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
357 /* NuppelVideo uses pixel aspect ratio |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
358 here display aspect ratio is used. |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
359 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
|
360 1.33 == 4:3 aspect ratio. |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
361 */ |
5e61815deced
last minute aspect patch by Panagiotis Issaris <takis@lumumba.luc.ac.be>
arpi
parents:
3811
diff
changeset
|
362 if(rtjpeg_fileheader.aspect == 1.0) |
6660 | 363 sh_video->aspect = (float) 4.0f/3.0f; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
364 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
365 /* Get the FPS */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
366 sh_video->fps = rtjpeg_fileheader.fps; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
367 sh_video->frametime = 1 / sh_video->fps; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
368 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
369 if (rtjpeg_fileheader.audioblocks != 0) |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
370 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
371 sh_audio = new_sh_audio(demuxer, 0); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
372 demuxer->audio->sh = sh_audio; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
373 sh_audio->ds = demuxer->audio; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
374 sh_audio->format = 0x1; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
375 sh_audio->channels = 2; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
376 sh_audio->samplerate = 44100; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
377 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
378 sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
379 memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
380 sh_audio->wf->wFormatTag = sh_audio->format; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
381 sh_audio->wf->nChannels = sh_audio->channels; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
382 sh_audio->wf->wBitsPerSample = 16; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
383 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
384 sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels* |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
385 sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
386 sh_audio->wf->nBlockAlign = sh_audio->channels * 2; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
387 sh_audio->wf->cbSize = 0; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
388 } |
4065 | 389 |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
390 /* Check for extended data (X frame) and read settings from it */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
391 if (!demux_xscan_nuv(demuxer, rtjpeg_fileheader.width, |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
392 rtjpeg_fileheader.height)) |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
393 /* Otherwise assume defaults */ |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
394 mp_msg(MSGT_DEMUXER, MSGL_V, "No NUV extended frame, using defaults\n"); |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
395 |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
396 |
4065 | 397 priv->index_list = (nuv_position_t*) malloc(sizeof(nuv_position_t)); |
398 priv->index_list->frame = 0; | |
399 priv->index_list->time = 0; | |
400 priv->index_list->offset = stream_tell ( demuxer->stream ); | |
401 priv->index_list->next = NULL; | |
402 priv->current_position = priv->index_list; | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
403 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
404 return demuxer; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
405 } |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
406 |
16175 | 407 static int nuv_check_file ( demuxer_t* demuxer ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
408 { |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
409 struct nuv_signature ns; |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
410 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
411 /* Store original position */ |
7361 | 412 off_t orig_pos = stream_tell(demuxer->stream); |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
413 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
414 mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for NuppelVideo\n" ); |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
415 |
15817 | 416 if(stream_read(demuxer->stream,(char*)&ns,sizeof(ns)) != sizeof(ns)) |
417 return 0; | |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
418 |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
419 if ( strncmp ( ns.finfo, "NuppelVideo", 12 ) && |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
420 strncmp ( ns.finfo, "MythTVVideo", 12 ) ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
421 return 0; /* Not a NuppelVideo file */ |
16164
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
422 if ( strncmp ( ns.version, "0.05", 5 ) && |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
423 strncmp ( ns.version, "0.06", 5 ) && |
ec76d55a25f1
Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents:
15817
diff
changeset
|
424 strncmp ( ns.version, "0.07", 5 ) ) |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
425 return 0; /* Wrong version NuppelVideo file */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
426 |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
427 /* Return to original position */ |
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
428 stream_seek ( demuxer->stream, orig_pos ); |
16175 | 429 return DEMUXER_TYPE_NUV; |
3801
3cea69dda1b3
added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff
changeset
|
430 } |
5810 | 431 |
16175 | 432 static void demux_close_nuv(demuxer_t* demuxer) { |
5810 | 433 nuv_priv_t* priv = demuxer->priv; |
434 nuv_position_t* pos; | |
435 if(!priv) | |
436 return; | |
437 for(pos = priv->index_list ; pos != NULL ; ) { | |
438 nuv_position_t* p = pos; | |
439 pos = pos->next; | |
440 free(p); | |
441 } | |
442 free(priv); | |
443 } | |
16175 | 444 |
445 | |
446 demuxer_desc_t demuxer_desc_nuv = { | |
447 "NuppelVideo demuxer", | |
448 "nuv", | |
449 "NuppelVideo", | |
450 "Panagiotis Issaris", | |
451 "", | |
452 DEMUXER_TYPE_NUV, | |
453 1, // safe autodetect | |
454 nuv_check_file, | |
455 demux_nuv_fill_buffer, | |
456 demux_open_nuv, | |
457 demux_close_nuv, | |
458 demux_seek_nuv, | |
459 NULL | |
460 }; |