Mercurial > mplayer.hg
annotate libmpdemux/demux_pva.c @ 15493:3d17af80dca8
Consistency fixes
author | gpoirier |
---|---|
date | Mon, 16 May 2005 21:13:20 +0000 |
parents | 772d6d27fd66 |
children | 6b86089c2edd |
rev | line source |
---|---|
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
1 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
2 * demuxer for PVA files, such as the ones produced by software to manage DVB boards |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
3 * like the Hauppauge WinTV DVBs, for MPlayer. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
4 * |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
5 * Uses info from the PVA file specifications found at |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
6 * |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
7 * http://www.technotrend.de/download/av_format_v1.pdf |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
8 * |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
9 * WARNING: Quite a hack was required in order to get files by MultiDec played back correctly. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
10 * If it breaks anything else, just comment out the "#define DEMUX_PVA_MULTIDEC_HACK" below |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
11 * and it will not be compiled in. |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
12 * |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
13 * Feedback is appreciated. |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
14 * |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
15 * written by Matteo Giani |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
16 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
17 |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
18 #define DEMUX_PVA_MULTIDEC_HACK |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
19 #define PVA_NEW_PREBYTES_CODE |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
20 |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
21 #include <stdio.h> |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
22 #include <stdlib.h> |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
23 #include <string.h> |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
24 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
25 #include "config.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
26 #include "mp_msg.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
27 #include "help_mp.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
28 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
29 #include "stream.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
30 #include "demuxer.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
31 #include "stheader.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
32 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
33 #include "bswap.h" |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
34 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
35 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
36 * #defines below taken from PVA spec (see URL above) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
37 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
38 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
39 #define PVA_MAX_VIDEO_PACK_LEN 6*1024 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
40 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
41 #define VIDEOSTREAM 0x01 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
42 #define MAINAUDIOSTREAM 0x02 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
43 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
44 typedef struct { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
45 off_t offset; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
46 long size; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
47 uint8_t type; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
48 uint8_t is_packet_start; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
49 float pts; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
50 } pva_payload_t; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
51 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
52 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
53 typedef struct { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
54 float last_audio_pts; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
55 float last_video_pts; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
56 #ifdef PVA_NEW_PREBYTES_CODE |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
57 float video_pts_after_prebytes; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
58 long video_size_after_prebytes; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
59 uint8_t prebytes_delivered; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
60 #endif |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
61 uint8_t just_synced; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
62 uint8_t synced_stream_id; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
63 } pva_priv_t; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
64 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
65 |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
66 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
67 int pva_sync(demuxer_t * demuxer) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
68 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
69 uint8_t buffer[5]={0,0,0,0,0}; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
70 int count; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
71 pva_priv_t * priv = (pva_priv_t *) demuxer->priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
72 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
73 |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
74 /* This function is used to find the next nearest PVA packet start after a seek, since a PVA file |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
75 * is not indexed. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
76 * The just_synced field is in the priv structure so that pva_get_payload knows pva_sync |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
77 * has already read (part of) the PVA header. This way we can avoid to seek back and (hopefully) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
78 * be able to read from pipes and such. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
79 */ |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
80 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
81 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
82 for(count=0 ; count<PVA_MAX_VIDEO_PACK_LEN && !demuxer->stream->eof && !priv->just_synced ; count++) |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
83 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
84 buffer[0]=buffer[1]; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
85 buffer[1]=buffer[2]; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
86 buffer[2]=buffer[3]; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
87 buffer[3]=buffer[4]; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
88 buffer[4]=stream_read_char(demuxer->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
89 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
90 * Check for a PVA packet beginning sequence: we check both the "AV" word at the |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
91 * very beginning and the "0x55" reserved byte (which is unused and set to 0x55 by spec) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
92 */ |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
93 if(buffer[0]=='A' && buffer[1] == 'V' && buffer[4] == 0x55) priv->just_synced=1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
94 //printf("demux_pva: pva_sync(): current offset= %ld\n",stream_tell(demuxer->stream)); |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
95 } |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
96 if(priv->just_synced) |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
97 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
98 if(priv!=NULL) priv->synced_stream_id=buffer[2]; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
99 return 1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
100 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
101 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
102 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
103 return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
104 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
105 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
106 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
107 int pva_check_file(demuxer_t * demuxer) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
108 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
109 uint8_t buffer[5]={0,0,0,0,0}; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
110 mp_msg(MSGT_DEMUX, MSGL_V, "Checking for PVA\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
111 stream_read(demuxer->stream,buffer,5); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
112 if(buffer[0]=='A' && buffer[1] == 'V' && buffer[4] == 0x55) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
113 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
114 mp_msg(MSGT_DEMUX,MSGL_DBG2, "Success: PVA\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
115 return 1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
116 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
117 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
118 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
119 mp_msg(MSGT_DEMUX,MSGL_DBG2, "Failed: PVA\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
120 return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
121 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
122 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
123 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
124 demuxer_t * demux_open_pva (demuxer_t * demuxer) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
125 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
126 sh_video_t *sh_video = new_sh_video(demuxer,0); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
127 sh_audio_t *sh_audio = new_sh_audio(demuxer,0); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
128 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
129 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
130 pva_priv_t * priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
131 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
132 stream_reset(demuxer->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
133 stream_seek(demuxer->stream,0); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
134 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
135 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
136 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
137 priv=malloc(sizeof(pva_priv_t)); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
138 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
139 if(demuxer->stream->type!=STREAMTYPE_FILE) demuxer->seekable=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
140 else demuxer->seekable=1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
141 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
142 demuxer->priv=priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
143 memset(demuxer->priv,0,sizeof(pva_priv_t)); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
144 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
145 if(!pva_sync(demuxer)) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
146 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
147 mp_msg(MSGT_DEMUX,MSGL_ERR,"Not a PVA file.\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
148 return NULL; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
149 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
150 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
151 //printf("priv->just_synced %s after initial sync!\n",priv->just_synced?"set":"UNSET"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
152 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
153 demuxer->video->sh=sh_video; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
154 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
155 //printf("demuxer->stream->end_pos= %d\n",demuxer->stream->end_pos); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
156 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
157 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
158 mp_msg(MSGT_DEMUXER,MSGL_INFO,"Opened PVA demuxer...\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
159 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
160 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
161 * Audio and Video codecs: |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
162 * the PVA spec only allows MPEG2 video and MPEG layer II audio. No need to check the formats then. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
163 * Moreover, there would be no way to do that since the PVA stream format has no fields to describe |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
164 * the used codecs. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
165 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
166 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
167 sh_video->format=0x10000002; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
168 sh_video->ds=demuxer->video; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
169 |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
170 /* |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
171 printf("demuxer->video->id==%d\n",demuxer->video->id); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
172 printf("demuxer->audio->id==%d\n",demuxer->audio->id); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
173 */ |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
174 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
175 demuxer->audio->sh=sh_audio; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
176 sh_audio->format=0x50; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
177 sh_audio->ds=demuxer->audio; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
178 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
179 demuxer->movi_start=0; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
180 demuxer->movi_end=demuxer->stream->end_pos; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
181 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
182 priv->last_video_pts=-1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
183 priv->last_audio_pts=-1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
184 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
185 return demuxer; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
186 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
187 |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
188 int pva_get_payload(demuxer_t * d,pva_payload_t * payload); |
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
189 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
190 // 0 = EOF or no stream found |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
191 // 1 = successfully read a packet |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
192 int demux_pva_fill_buffer (demuxer_t * demux) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
193 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
194 uint8_t done=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
195 demux_packet_t * dp; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
196 pva_priv_t * priv=demux->priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
197 pva_payload_t current_payload; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
198 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
199 while(!done) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
200 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
201 if(!pva_get_payload(demux,¤t_payload)) return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
202 switch(current_payload.type) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
203 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
204 case VIDEOSTREAM: |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
205 if(demux->video->id==-1) demux->video->id=0; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
206 if(!current_payload.is_packet_start && priv->last_video_pts==-1) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
207 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
208 /* We should only be here at the beginning of a stream, when we have |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
209 * not yet encountered a valid Video PTS, or after a seek. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
210 * So, skip these starting packets in order not to deliver the |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
211 * player a bogus PTS. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
212 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
213 done=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
214 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
215 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
216 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
217 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
218 * In every other condition, we are delivering the payload. Set this |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
219 * so that the following code knows whether to skip it or read it. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
220 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
221 done=1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
222 } |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
223 if(demux->video->id!=0) done=0; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
224 if(current_payload.is_packet_start) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
225 { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
226 priv->last_video_pts=current_payload.pts; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
227 //mp_msg(MSGT_DEMUXER,MSGL_DBG2,"demux_pva: Video PTS=%llu , delivered %f\n",current_payload.pts,priv->last_video_pts); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
228 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
229 if(done) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
230 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
231 dp=new_demux_packet(current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
232 dp->pts=priv->last_video_pts; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
233 stream_read(demux->stream,dp->buffer,current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
234 ds_add_packet(demux->video,dp); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
235 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
236 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
237 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
238 //printf("Skipping %u video bytes\n",current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
239 stream_skip(demux->stream,current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
240 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
241 break; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
242 case MAINAUDIOSTREAM: |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
243 if(demux->audio->id==-1) demux->audio->id=0; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
244 if(!current_payload.is_packet_start && priv->last_audio_pts==-1) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
245 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
246 /* Same as above for invalid video PTS, just for audio. */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
247 done=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
248 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
249 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
250 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
251 done=1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
252 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
253 if(current_payload.is_packet_start) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
254 { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
255 priv->last_audio_pts=current_payload.pts; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
256 } |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
257 if(demux->audio->id!=0) done=0; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
258 if(done) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
259 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
260 dp=new_demux_packet(current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
261 dp->pts=priv->last_audio_pts; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
262 if(current_payload.offset != stream_tell(demux->stream)) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
263 stream_seek(demux->stream,current_payload.offset); |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
264 stream_read(demux->stream,dp->buffer,current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
265 ds_add_packet(demux->audio,dp); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
266 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
267 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
268 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
269 stream_skip(demux->stream,current_payload.size); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
270 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
271 break; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
272 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
273 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
274 return 1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
275 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
276 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
277 int pva_get_payload(demuxer_t * d,pva_payload_t * payload) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
278 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
279 uint8_t flags,pes_head_len; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
280 uint16_t pack_size; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
281 off_t next_offset,pva_payload_start; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
282 unsigned char buffer[256]; |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
7663
diff
changeset
|
283 #ifndef PVA_NEW_PREBYTES_CODE |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
284 demux_packet_t * dp; //hack to deliver the preBytes (see PVA doc) |
8254
772d6d27fd66
warning patch by (Dominik Mierzejewski <dominik at rangers dot eu dot org>)
michael
parents:
7663
diff
changeset
|
285 #endif |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
286 pva_priv_t * priv=(pva_priv_t *) d->priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
287 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
288 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
289 if(d==NULL) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
290 { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
291 mp_msg(MSGT_DEMUX,MSGL_ERR,"demux_pva: pva_get_payload got passed a NULL pointer!\n"); |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
292 return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
293 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
294 |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
295 d->filepos=stream_tell(d->stream); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
296 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
297 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
298 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
299 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
300 if(d->stream->eof) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
301 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
302 mp_msg(MSGT_DEMUX,MSGL_V,"demux_pva: pva_get_payload() detected stream->eof!!!\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
303 return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
304 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
305 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
306 //printf("priv->just_synced %s\n",priv->just_synced?"SET":"UNSET"); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
307 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
308 #ifdef PVA_NEW_PREBYTES_CODE |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
309 if(priv->prebytes_delivered) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
310 /* The previous call to this fn has delivered the preBytes. Then we are already inside |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
311 * the payload. Let's just deliver the video along with its right PTS, the one we stored |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
312 * in the priv structure and was in the PVA header before the PreBytes. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
313 */ |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
314 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
315 //printf("prebytes_delivered=1. Resetting.\n"); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
316 payload->size = priv->video_size_after_prebytes; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
317 payload->pts = priv->video_pts_after_prebytes; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
318 payload->is_packet_start = 1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
319 payload->offset = stream_tell(d->stream); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
320 payload->type = VIDEOSTREAM; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
321 priv->prebytes_delivered = 0; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
322 return 1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
323 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
324 #endif |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
325 if(!priv->just_synced) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
326 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
327 if(stream_read_word(d->stream) != (('A'<<8)|'V')) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
328 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
329 mp_msg(MSGT_DEMUX,MSGL_V,"demux_pva: pva_get_payload() missed a SyncWord at %ld!! Trying to sync...\n",stream_tell(d->stream)); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
330 if(!pva_sync(d)) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
331 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
332 if (!d->stream->eof) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
333 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
334 mp_msg(MSGT_DEMUX,MSGL_ERR,"demux_pva: couldn't sync! (broken file?)"); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
335 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
336 return 0; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
337 } |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
338 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
339 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
340 if(priv->just_synced) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
341 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
342 payload->type=priv->synced_stream_id; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
343 priv->just_synced=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
344 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
345 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
346 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
347 payload->type=stream_read_char(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
348 stream_skip(d->stream,2); //counter and reserved |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
349 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
350 flags=stream_read_char(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
351 payload->is_packet_start=flags & 0x10; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
352 pack_size=le2me_16(stream_read_word(d->stream)); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
353 mp_msg(MSGT_DEMUX,MSGL_DBG2,"demux_pva::pva_get_payload(): pack_size=%u field read at offset %lu\n",pack_size,stream_tell(d->stream)-2); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
354 pva_payload_start=stream_tell(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
355 next_offset=pva_payload_start+pack_size; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
356 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
357 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
358 /* |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
359 * The code in the #ifdef directive below is a hack needed to get badly formatted PVA files |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
360 * such as the ones written by MultiDec played back correctly. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
361 * Basically, it works like this: if the PVA packet does not signal a PES header, but the |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
362 * payload looks like one, let's assume it IS one. It has worked for me up to now. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
363 * It can be disabled since it's quite an ugly hack and could potentially break things up |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
364 * if the PVA audio payload happens to start with 0x000001 even without being a non signalled |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
365 * PES header start. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
366 * Though it's quite unlikely, it potentially could (AFAIK). |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
367 */ |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
368 #ifdef DEMUX_PVA_MULTIDEC_HACK |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
369 if(payload->type==MAINAUDIOSTREAM) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
370 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
371 stream_read(d->stream,buffer,3); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
372 if(buffer[0]==0x00 && buffer[1]==0x00 && buffer[2]==0x01 && !payload->is_packet_start) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
373 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
374 mp_msg(MSGT_DEMUX,MSGL_V,"demux_pva: suspecting non signaled audio PES packet start. Maybe file by MultiDec?\n"); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
375 payload->is_packet_start=1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
376 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
377 stream_seek(d->stream,stream_tell(d->stream)-3); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
378 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
379 #endif |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
380 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
381 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
382 if(!payload->is_packet_start) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
383 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
384 payload->offset=stream_tell(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
385 payload->size=pack_size; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
386 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
387 else |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
388 { //here comes the good part... |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
389 switch(payload->type) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
390 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
391 case VIDEOSTREAM: |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
392 payload->pts=(float)(le2me_32(stream_read_dword(d->stream)))/90000; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
393 //printf("Video PTS: %f\n",payload->pts); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
394 if((flags&0x03) |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
395 #ifdef PVA_NEW_PREBYTES_CODE |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
396 && !priv->prebytes_delivered |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
397 #endif |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
398 ) |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
399 { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
400 #ifndef PVA_NEW_PREBYTES_CODE |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
401 dp=new_demux_packet(flags&0x03); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
402 stream_read(d->stream,dp->buffer,flags & 0x03); //read PreBytes |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
403 ds_add_packet(d->video,dp); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
404 #else |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
405 //printf("Delivering prebytes. Setting prebytes_delivered."); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
406 payload->offset=stream_tell(d->stream); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
407 payload->size = flags & 0x03; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
408 priv->video_pts_after_prebytes = payload->pts; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
409 priv->video_size_after_prebytes = pack_size - 4 - (flags & 0x03); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
410 payload->pts=priv->last_video_pts; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
411 payload->is_packet_start=0; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
412 priv->prebytes_delivered=1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
413 return 1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
414 #endif |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
415 } |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
416 |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
417 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
418 //now we are at real beginning of payload. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
419 payload->offset=stream_tell(d->stream); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
420 //size is pack_size minus PTS size minus PreBytes size. |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
421 payload->size=pack_size - 4 - (flags & 0x03); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
422 break; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
423 case MAINAUDIOSTREAM: |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
424 stream_skip(d->stream,3); //FIXME properly parse PES header. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
425 //printf("StreamID in audio PES header: 0x%2X\n",stream_read_char(d->stream)); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
426 stream_skip(d->stream,4); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
427 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
428 buffer[255]=stream_read_char(d->stream); |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
429 pes_head_len=stream_read_char(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
430 stream_read(d->stream,buffer,pes_head_len); |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
431 if(!buffer[255]&0x80) //PES header does not contain PTS. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
432 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
433 mp_msg(MSGT_DEMUX,MSGL_V,"Audio PES packet does not contain PTS. (pes_head_len=%d)\n",pes_head_len); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
434 payload->pts=priv->last_audio_pts; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
435 break; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
436 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
437 else //PES header DOES contain PTS |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
438 { |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
439 if((buffer[0] & 0xf0)!=0x20) // PTS badly formatted |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
440 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
441 mp_msg(MSGT_DEMUX,MSGL_V,"demux_pva: expected audio PTS but badly formatted... (read 0x%02X). Falling back to previous PTS (hack).\n",buffer[0]); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
442 payload->pts=priv->last_audio_pts; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
443 // return 0; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
444 } |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
445 else |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
446 { |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
447 uint64_t temp_pts; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
448 |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
449 temp_pts=0LL; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
450 temp_pts|=((uint64_t)(buffer[0] & 0x0e) << 29); |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
451 temp_pts|=buffer[1]<<22; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
452 temp_pts|=(buffer[2] & 0xfe) << 14; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
453 temp_pts|=buffer[3]<<7; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
454 temp_pts|=(buffer[4] & 0xfe) >> 1; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
455 /* |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
456 * PTS parsing is hopefully finished. |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
457 */ |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
458 payload->pts=(float)le2me_64(temp_pts)/90000; |
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
459 } |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
460 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
461 payload->offset=stream_tell(d->stream); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
462 payload->size=pack_size-stream_tell(d->stream)+pva_payload_start; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
463 break; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
464 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
465 } |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7364
diff
changeset
|
466 return 1; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
467 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
468 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
469 int demux_seek_pva(demuxer_t * demuxer,float rel_seek_secs,int flags) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
470 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
471 int total_bitrate=0; |
7663
eb3afb162aa4
* Fix for the broken MultiDec files I had originally posted with the
arpi
parents:
7472
diff
changeset
|
472 off_t dest_offset; |
7364
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
473 pva_priv_t * priv=demuxer->priv; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
474 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
475 total_bitrate=((sh_audio_t *)demuxer->audio->sh)->i_bps + ((sh_video_t *)demuxer->video->sh)->i_bps; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
476 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
477 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
478 * Compute absolute offset inside the stream. Approximate total bitrate with sum of bitrates |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
479 * reported by the audio and video codecs. The seek is not accurate because, just like |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
480 * with MPEG streams, the bitrate is not constant. Moreover, we do not take into account |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
481 * the overhead caused by PVA and PES headers. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
482 * If the calculated absolute offset is negative, seek to the beginning of the file. |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
483 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
484 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
485 dest_offset=stream_tell(demuxer->stream)+rel_seek_secs*total_bitrate; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
486 if(dest_offset<0) dest_offset=0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
487 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
488 stream_seek(demuxer->stream,dest_offset); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
489 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
490 if(!pva_sync(demuxer)) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
491 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
492 mp_msg(MSGT_DEMUX,MSGL_V,"demux_pva: Couldn't seek!\n"); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
493 return 0; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
494 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
495 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
496 /* |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
497 * Reset the PTS info inside the pva_priv_t structure. This way we don't deliver |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
498 * data with the wrong PTSs (the ones we had before seeking). |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
499 * |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
500 */ |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
501 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
502 priv->last_video_pts=-1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
503 priv->last_audio_pts=-1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
504 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
505 return 1; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
506 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
507 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
508 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
509 |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
510 void demux_close_pva(demuxer_t * demuxer) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
511 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
512 if(demuxer->priv) |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
513 { |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
514 free(demuxer->priv); |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
515 demuxer->priv=NULL; |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
516 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
517 } |
b2445802532c
.PVA (mpeg-like fileformat used by MultiDec && WinTV) demuxer
arpi
parents:
diff
changeset
|
518 |