annotate libmpdemux/demux_nuv.c @ 27404:778fac8c186f

Add separate variables for CFLAGS that are specific to internal libraries and only add them to CFLAGS when compiling objects from those libraries.
author diego
date Thu, 07 Aug 2008 21:46:06 +0000
parents 4d56038ec730
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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"
22605
4d81dbdf46b9 Add explicit location for headers from the stream/ directory.
diego
parents: 18958
diff changeset
16 #include "stream/stream.h"
3801
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
25607
9d0b189ce1b2 Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents: 22605
diff changeset
28 typedef struct nuv_position_t nuv_position_t;
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
29
25607
9d0b189ce1b2 Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents: 22605
diff changeset
30 struct nuv_position_t
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
31 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
32 off_t offset;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
33 float time;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
34 int frame;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
35 nuv_position_t* next;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
36 };
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
37
25607
9d0b189ce1b2 Fix illegal identifiers: Names starting with __ or _ and uppercase are reserved
diego
parents: 22605
diff changeset
38 typedef struct nuv_info_t
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
39 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
40 int current_audio_frame;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
41 int current_video_frame;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
42 nuv_position_t *index_list;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
43 nuv_position_t *current_position;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
44 } nuv_priv_t;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
62
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
63 /**
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
64 * Seek to a position relative to the current position, indicated in time.
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
65 */
17636
b849a99cdc3c Second-try commit of this patch.
corey
parents: 17569
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
68 #define MAX_TIME 1000000
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
69 nuv_priv_t* priv = demuxer->priv;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
70 struct rtframeheader rtjpeg_frameheader;
7361
c3865710b53d fixed >2GB files demuxing
arpi
parents: 6660
diff changeset
71 off_t orig_pos;
c3865710b53d fixed >2GB files demuxing
arpi
parents: 6660
diff changeset
72 off_t curr_pos;
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
73 float current_time = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
74 float start_time = MAX_TIME;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
75 float target_time = start_time + rel_seek_secs * 1000; /* target_time, start_time are ms, rel_seek_secs s */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
76
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
77 orig_pos = stream_tell ( demuxer->stream );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
78
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
79 if ( rel_seek_secs > 0 )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
80 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
81 /* Seeking forward */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
82
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
83
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
84 while(current_time < target_time )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
85 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
86 if (stream_read ( demuxer->stream, (char*)& rtjpeg_frameheader, sizeof ( rtjpeg_frameheader ) ) < sizeof(rtjpeg_frameheader))
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
89
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
90 if ( rtjpeg_frameheader.frametype == 'V' )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
91 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
92 priv->current_position->next = (nuv_position_t*) malloc ( sizeof ( nuv_position_t ) );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
93 priv->current_position = priv->current_position->next;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
94 priv->current_position->frame = priv->current_video_frame++;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
95 priv->current_position->time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
96 priv->current_position->offset = orig_pos;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
97 priv->current_position->next = NULL;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
98
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
99 if ( start_time == MAX_TIME )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
100 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
101 start_time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
102 /* Recalculate target time with real start time */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
103 target_time = start_time + rel_seek_secs*1000;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
104 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
105
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
106 current_time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
107
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
108 curr_pos = stream_tell ( demuxer->stream );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
109 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
110
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
111 /* Adjust current sequence pointer */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
112 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
113 else if ( rtjpeg_frameheader.frametype == 'A' )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
114 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
115 if ( start_time == MAX_TIME )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
116 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
117 start_time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
118 /* Recalculate target time with real start time */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
119 target_time = start_time + rel_seek_secs * 1000;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
120 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
121 current_time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
122
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
123
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
124 curr_pos = stream_tell ( demuxer->stream );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
125 stream_seek ( demuxer->stream, curr_pos + rtjpeg_frameheader.packetlength );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
126 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
127 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
128 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
129 else
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
130 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
131 /* Seeking backward */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
132 nuv_position_t* p;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
133 start_time = priv->current_position->time;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
134
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
135 /* Recalculate target time with real start time */
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
136 target_time = start_time + rel_seek_secs * 1000;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
137
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
138
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
139 if(target_time < 0)
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
140 target_time = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
141
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
142 // Search the target time in the index list, get the offset
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
143 // and go to that offset.
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
144 p = priv->index_list;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
145 while ( ( p->next != NULL ) && ( p->time < target_time ) )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
146 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
147 p = p->next;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
148 }
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
149 stream_seek ( demuxer->stream, p->offset );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
150 priv->current_video_frame = p->frame;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
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
c3865710b53d fixed >2GB files demuxing
arpi
parents: 6660
diff changeset
158 off_t orig_pos;
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
c2792c5b4f6e audio is working
alex
parents: 3801
diff changeset
168 printf("NUV frame: frametype: %c, comptype: %c, packetlength: %d\n",
c2792c5b4f6e audio is working
alex
parents: 3801
diff changeset
169 rtjpeg_frameheader.frametype, rtjpeg_frameheader.comptype,
c2792c5b4f6e audio is working
alex
parents: 3801
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
190 if ( rtjpeg_frameheader.frametype == 'V' )
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
191 {
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
192 priv->current_video_frame++;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
193 priv->current_position->next = (nuv_position_t*) malloc(sizeof(nuv_position_t));
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
194 priv->current_position = priv->current_position->next;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
195 priv->current_position->frame = priv->current_video_frame;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
196 priv->current_position->time = rtjpeg_frameheader.timecode;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
197 priv->current_position->offset = orig_pos;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
198 priv->current_position->next = NULL;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
204
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
205
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
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
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
317 nuv_priv_t* priv = (nuv_priv_t*) malloc ( sizeof ( nuv_priv_t) );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
318 demuxer->priv = priv;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
319 priv->current_audio_frame = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
320 priv->current_video_frame = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
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
c2792c5b4f6e audio is working
alex
parents: 3801
diff changeset
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
f8d1c9ab777a aspect prescaling fix by magnus.pfeffer@epost.de
arpi
parents: 5810
diff changeset
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);
26299
4d56038ec730 Fix lots and lots of other demuxers broken by r26301
reimar
parents: 25707
diff changeset
372 demuxer->audio->id = 0;
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
373 demuxer->audio->sh = sh_audio;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
374 sh_audio->ds = demuxer->audio;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
375 sh_audio->format = 0x1;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
376 sh_audio->channels = 2;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
377 sh_audio->samplerate = 44100;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
378
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
379 sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
380 memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX));
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
381 sh_audio->wf->wFormatTag = sh_audio->format;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
382 sh_audio->wf->nChannels = sh_audio->channels;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
383 sh_audio->wf->wBitsPerSample = 16;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
384 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
385 sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels*
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
386 sh_audio->wf->wBitsPerSample*sh_audio->wf->nSamplesPerSec/8;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
387 sh_audio->wf->nBlockAlign = sh_audio->channels * 2;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
388 sh_audio->wf->cbSize = 0;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
389 }
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
390
16164
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
391 /* 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
392 if (!demux_xscan_nuv(demuxer, rtjpeg_fileheader.width,
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
393 rtjpeg_fileheader.height))
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
394 /* Otherwise assume defaults */
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
395 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
396
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
397
4065
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
398 priv->index_list = (nuv_position_t*) malloc(sizeof(nuv_position_t));
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
399 priv->index_list->frame = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
400 priv->index_list->time = 0;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
401 priv->index_list->offset = stream_tell ( demuxer->stream );
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
402 priv->index_list->next = NULL;
763a0e7e0521 seek patch by Panagoitis Issaris
alex
parents: 3960
diff changeset
403 priv->current_position = priv->index_list;
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
404
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
405 return demuxer;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
406 }
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
407
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
408 static int nuv_check_file ( demuxer_t* demuxer )
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
409 {
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
410 struct nuv_signature ns;
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
411
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
412 /* Store original position */
7361
c3865710b53d fixed >2GB files demuxing
arpi
parents: 6660
diff changeset
413 off_t orig_pos = stream_tell(demuxer->stream);
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
414
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
415 mp_msg ( MSGT_DEMUX, MSGL_V, "Checking for NuppelVideo\n" );
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
416
15817
faust3
parents: 14896
diff changeset
417 if(stream_read(demuxer->stream,(char*)&ns,sizeof(ns)) != sizeof(ns))
faust3
parents: 14896
diff changeset
418 return 0;
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
419
16164
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
420 if ( strncmp ( ns.finfo, "NuppelVideo", 12 ) &&
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
421 strncmp ( ns.finfo, "MythTVVideo", 12 ) )
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
422 return 0; /* Not a NuppelVideo file */
16164
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
423 if ( strncmp ( ns.version, "0.05", 5 ) &&
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
424 strncmp ( ns.version, "0.06", 5 ) &&
ec76d55a25f1 Support more MythTV nuv files, based on Gentoo portage patch
reimar
parents: 15817
diff changeset
425 strncmp ( ns.version, "0.07", 5 ) )
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
426 return 0; /* Wrong version NuppelVideo file */
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
427
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
428 /* Return to original position */
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
429 stream_seek ( demuxer->stream, orig_pos );
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
430 return DEMUXER_TYPE_NUV;
3801
3cea69dda1b3 added NuppelVideo demuxer, based on Panagiotis Issaris' patch
alex
parents:
diff changeset
431 }
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
432
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
433 static void demux_close_nuv(demuxer_t* demuxer) {
5810
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
434 nuv_priv_t* priv = demuxer->priv;
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
435 nuv_position_t* pos;
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
436 if(!priv)
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
437 return;
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
438 for(pos = priv->index_list ; pos != NULL ; ) {
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
439 nuv_position_t* p = pos;
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
440 pos = pos->next;
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
441 free(p);
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
442 }
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
443 free(priv);
8a357300d0ec Added demuxer uninit
albeu
parents: 5435
diff changeset
444 }
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
445
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
446
25707
d4fe6e23283e Make all demuxer_desc_t const, thus moving them to .rodata
reimar
parents: 25607
diff changeset
447 const demuxer_desc_t demuxer_desc_nuv = {
16175
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
448 "NuppelVideo demuxer",
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
449 "nuv",
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
450 "NuppelVideo",
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
451 "Panagiotis Issaris",
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
452 "",
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
453 DEMUXER_TYPE_NUV,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
454 1, // safe autodetect
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
455 nuv_check_file,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
456 demux_nuv_fill_buffer,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
457 demux_open_nuv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
458 demux_close_nuv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
459 demux_seek_nuv,
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
460 NULL
6b86089c2edd Demuxer modularization
rtognimp
parents: 16164
diff changeset
461 };