Mercurial > mplayer.hg
annotate libmpdemux/muxer_mpeg.c @ 32880:96cbdbf90c42
Cosmetic: Adjust indent.
author | ib |
---|---|
date | Thu, 24 Feb 2011 23:51:27 +0000 |
parents | de37221dff02 |
children | 6d00f9ad294c |
rev | line source |
---|---|
29238
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
1 /* |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
2 * This file is part of MPlayer. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
3 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
7 * (at your option) any later version. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
8 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
12 * GNU General Public License for more details. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
13 * |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
d643e4643313
Add standard license header to all files in libmpdemux.
diego
parents:
29222
diff
changeset
|
17 */ |
8585 | 18 |
19 #include <stdio.h> | |
20 #include <stdlib.h> | |
23637 | 21 #include <inttypes.h> |
8585 | 22 #include <string.h> |
23 #include <sys/types.h> | |
24 | |
25 #include "config.h" | |
17012 | 26 #include "mp_msg.h" |
17065
cf6bfdf41143
Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents:
17023
diff
changeset
|
27 #include "help_mp.h" |
8585 | 28 |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
29 #include "libavutil/intreadwrite.h" |
12341
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
30 #include "aviheader.h" |
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
31 #include "ms_hdr.h" |
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
32 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22333
diff
changeset
|
33 #include "stream/stream.h" |
8585 | 34 #include "muxer.h" |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
35 #include "demuxer.h" |
30576
24a5dc9d1466
Add separate header for mp_a52_framesize(); avoids forward declarations.
diego
parents:
30574
diff
changeset
|
36 #include "demux_ts.h" |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
37 #include "stheader.h" |
17012 | 38 #include "m_option.h" |
30574
928359c13d93
Add separate header for aac_parse_frame(); avoids forward declarations.
diego
parents:
29263
diff
changeset
|
39 #include "aac_hdr.h" |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
40 #include "mpeg_hdr.h" |
17091 | 41 #include "mp3_hdr.h" |
31864
d277ede2b207
Add missing header for mp_a52_framesize, fixes the warning:
diego
parents:
31799
diff
changeset
|
42 #include "parse_es.h" |
31089
459227551819
Use the system liba52 headers when internal liba52 is disabled, fixes:
diego
parents:
30958
diff
changeset
|
43 |
8585 | 44 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
45 #define PACK_HEADER_START_CODE 0x01ba |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
46 #define SYSTEM_HEADER_START_CODE 0x01bb |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
47 #define PSM_START_CODE 0x01bc |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
48 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
49 #define PES_PRIVATE1 0x01bd |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
50 #define PES_PRIVATE2 0x01bf |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
51 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
52 #define MUX_MPEG1 1 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
53 #define MUX_MPEG2 2 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
54 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
55 #define VIDEO_MPEG1 0x10000001 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
56 #define VIDEO_MPEG2 0x10000002 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
57 #define AUDIO_MP2 0x50 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
58 #define AUDIO_MP3 0x55 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
59 #define AUDIO_A52 0x2000 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
60 #define AUDIO_LPCM 0x10001 /* only a placeholder at the moment */ |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
61 #define AUDIO_AAC1 0x706D |
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
62 //#define AUDIO_AAC2 (short) mmioFOURCC('m','p','4','a') |
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
63 #define AUDIO_AAC2 0x504D |
32618
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
64 #define AUDIO_AAC3 0xFF |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
65 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
66 #define ASPECT_1_1 1 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
67 #define ASPECT_4_3 2 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
68 #define ASPECT_16_9 3 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
69 #define ASPECT_2_21_1 4 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
70 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
71 #define FRAMERATE_23976 1 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
72 #define FRAMERATE_24 2 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
73 #define FRAMERATE_25 3 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
74 #define FRAMERATE_2997 4 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
75 #define FRAMERATE_30 5 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
76 #define FRAMERATE_50 6 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
77 #define FRAMERATE_5994 7 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
78 #define FRAMERATE_60 8 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
79 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
80 static char ftypes[] = {'?', 'I', 'P', 'B'}; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
81 #define FTYPE(x) (ftypes[(x)]) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
82 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
83 static const char *framerates[] = { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
84 "unchanged", "23.976", "24", "25", "29.97", "30", "50", "59.94", "60" |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
85 }; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
86 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
87 static const char *aspect_ratios[] = { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
88 "unchanged", "1/1", "4/3", "16/9", "2.21/1" |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
89 }; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
90 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
91 static char *conf_mux = "mpeg2"; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
92 static uint16_t conf_packet_size = 0; //dvd |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
93 static uint32_t conf_muxrate = 0; //kb/s |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
94 static float conf_vaspect = 0; |
14914 | 95 static float conf_vframerate = 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
96 static uint32_t conf_vwidth = 0, conf_vheight = 0, conf_panscan_width = 0, conf_panscan_height = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
97 static uint32_t conf_vbitrate = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
98 static int conf_init_vpts = 200, conf_init_apts = 200; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
99 static int conf_ts_allframes = 0; |
22881
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
100 static int conf_init_adelay = 0, conf_init_vdelay = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
101 static int conf_abuf_size = 0; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
102 static int conf_vbuf_size = 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
103 static int conf_drop = 0; |
14840 | 104 static int conf_telecine = 0; |
22929
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
105 static int conf_interleaving2 = 0; |
21467 | 106 static float conf_telecine_src = 0; |
107 static float conf_telecine_dest = 0; | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
108 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
109 enum FRAME_TYPE { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
110 I_FRAME = 1, |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
111 P_FRAME = 2, |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
112 B_FRAME = 3 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
113 }; |
8585 | 114 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
115 typedef struct { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
116 uint8_t *buffer; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
117 size_t size; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
118 size_t alloc_size; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
119 uint8_t type; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
120 uint64_t pts, dts, idur; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
121 uint32_t pos; //start offset for the frame |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
122 } mpeg_frame_t; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
123 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
124 typedef struct { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
125 uint8_t cnt; // how many entries we use |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
126 struct { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
127 uint8_t id, type; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
128 uint32_t bufsize; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
129 uint32_t format; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
130 } streams[50]; //16 video + 16 audio mpa + 16 audio private + bd/bf for dvd |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
131 } sys_info_t; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
132 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
133 typedef struct { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
134 uint8_t cnt; // how many entries we use |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
135 struct { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
136 uint8_t id; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
137 uint8_t type; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
138 uint32_t format; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
139 } streams[50]; //16 video + 16 audio mpa + 16 audio private + bd/bf for dvd |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
140 } psm_info_t; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
141 |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
142 typedef struct { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
143 int size; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
144 uint64_t dts; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
145 } buffer_track_t; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
146 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
147 typedef struct { |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
148 uint64_t dts, pts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
149 uint64_t frame_dts, frame_pts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
150 int len, stflen; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
151 } pack_stats_t; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
152 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
153 typedef struct { |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
154 int mux; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
155 sys_info_t sys_info; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
156 psm_info_t psm_info; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
157 uint16_t packet_size; |
21141 | 158 int is_dvd, is_xvcd, is_xsvcd, is_genmpeg1, is_genmpeg2, rawpes, ts_allframes, has_video, has_audio; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
159 int update_system_header, use_psm; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
160 off_t headers_size, data_size; |
18200 | 161 uint64_t scr; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
162 uint64_t delta_scr; |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
163 uint64_t last_psm_scr; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
164 uint32_t muxrate; |
18200 | 165 uint8_t *buff; |
17271
9e20b0073d9b
simplification: don't use residual_buffer, but prepend remainder of current frame to next one (needed for future work; init frame->pos to 0 in reorder_frame(); fix: don't go beyond last frame in flush_buffer()
nicodvb
parents:
17091
diff
changeset
|
166 uint32_t headers_cnt; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
167 double init_adelay; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
168 int drop; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
169 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
170 //video patching parameters |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
171 uint8_t vaspect, vframerate; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
172 uint16_t vwidth, vheight, panscan_width, panscan_height; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
173 uint32_t vbitrate; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
174 int patch_seq, patch_sde; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
175 int psm_streams_cnt; |
25720
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
176 |
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
177 //2 million frames are enough |
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
178 #define MAX_PATTERN_LENGTH 2000000 |
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
179 uint8_t bff_mask[MAX_PATTERN_LENGTH]; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
180 } muxer_priv_t; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
181 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
182 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
183 typedef struct { |
24906 | 184 int has_pts, has_dts, pes_is_aligned, type, min_pes_hlen; |
22328 | 185 int delay_rff; |
18200 | 186 uint64_t pts, last_pts, last_dts, dts, size, frame_duration, delta_pts, nom_delta_pts, last_saved_pts; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
187 uint32_t buffer_size; |
18200 | 188 double delta_clock, timer; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
189 int drop_delayed_frames; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
190 mpeg_frame_t *framebuf; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
191 uint16_t framebuf_cnt; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
192 uint16_t framebuf_used; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
193 int32_t last_tr; |
14880
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
194 int max_tr; |
17301
bbf5438d646a
removed previously forgotten reording options/flags
nicodvb
parents:
17298
diff
changeset
|
195 uint8_t id, is_mpeg12, telecine; |
14840 | 196 uint64_t vframes; |
21485
2d87895e58fb
since display_frames in increased by a possibly negative number it had better be signed
nicodvb
parents:
21484
diff
changeset
|
197 int64_t display_frame; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
198 mp_mpeg_header_t picture; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
199 int max_buffer_size; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
200 buffer_track_t *buffer_track; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
201 int track_pos, track_len, track_bufsize; //pos and len control the array, bufsize is the size of the buffer |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
202 unsigned char *pack; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
203 int pack_offset, pes_offset, pes_set, payload_offset; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
204 int frames; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
205 int last_frame_rest; //the rest of the previous frame |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
206 int is_ready; |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
207 int mpa_layer; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
208 } muxer_headers_t; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
209 |
17600
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
210 #define PULLDOWN32 1 |
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
211 #define TELECINE_FILM2PAL 2 |
21467 | 212 #define TELECINE_DGPULLDOWN 3 |
8585 | 213 |
30958 | 214 const m_option_t mpegopts_conf[] = { |
22243
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
215 {"format", &(conf_mux), CONF_TYPE_STRING, M_OPT_GLOBAL, 0 ,0, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
216 {"size", &(conf_packet_size), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 0, 65535, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
217 {"muxrate", &(conf_muxrate), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 0, 12000000, NULL}, //12 Mb/s |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
218 {"vaspect", &(conf_vaspect), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
219 {"vframerate", &(conf_vframerate), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
220 {"vwidth", &(conf_vwidth), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 1, 4095, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
221 {"vheight", &(conf_vheight), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 1, 4095, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
222 {"vpswidth", &(conf_panscan_width), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 1, 16383, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
223 {"vpsheight", &(conf_panscan_height), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 1, 16383, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
224 {"vbitrate", &(conf_vbitrate), CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 1, 104857599, NULL}, |
22881
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
225 {"vdelay", &conf_init_vdelay, CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 0, 32760, NULL}, |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
226 {"adelay", &conf_init_adelay, CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 0, 32760, NULL}, |
22243
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
227 {"vbuf_size", &conf_vbuf_size, CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 40, 1194, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
228 {"abuf_size", &conf_abuf_size, CONF_TYPE_INT, M_OPT_GLOBAL|M_OPT_RANGE, 4, 64, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
229 {"drop", &conf_drop, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
230 {"tsaf", &conf_ts_allframes, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
231 {"telecine", &conf_telecine, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, PULLDOWN32, NULL}, |
22929
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
232 {"interleaving2", &conf_interleaving2, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, 1, NULL}, |
22243
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
233 {"film2pal", &conf_telecine, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, TELECINE_FILM2PAL, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
234 {"tele_src", &(conf_telecine_src), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
235 {"tele_dest", &(conf_telecine_dest), CONF_TYPE_FLOAT, M_OPT_GLOBAL, 0, 0, NULL}, |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
236 {NULL, NULL, 0, 0, 0, 0, NULL} |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
237 }; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
238 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
239 static void fix_audio_sys_header(muxer_priv_t *priv, uint8_t id, uint8_t newid, uint32_t size) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
240 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
241 uint8_t i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
242 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
243 for(i = 0; i < priv->sys_info.cnt; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
244 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
245 if(priv->sys_info.streams[i].id == id) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
246 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
247 priv->sys_info.streams[i].id = newid; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
248 priv->sys_info.streams[i].type = 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
249 priv->sys_info.streams[i].bufsize = size; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
250 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
251 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
252 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
253 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
254 static inline int is_mpeg1(uint32_t x) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
255 { |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
256 return |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
257 (x == 0x10000001) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
258 (x == mmioFOURCC('m','p','g','1')) || |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
259 (x == mmioFOURCC('M','P','G','1')); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
260 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
261 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
262 static inline int is_mpeg2(uint32_t x) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
263 { |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
264 return |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
265 (x == 0x10000002) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
266 (x == mmioFOURCC('m','p','g','2')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
267 (x == mmioFOURCC('M','P','G','2')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
268 (x == mmioFOURCC('m','p','e','g')) || |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
269 (x == mmioFOURCC('M','P','E','G')); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
270 } |
8585 | 271 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
272 static inline int is_mpeg4(uint32_t x) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
273 { |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
274 return |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
275 (x == 0x10000004) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
276 (x == mmioFOURCC('d','i','v','x')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
277 (x == mmioFOURCC('D','I','V','X')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
278 (x == mmioFOURCC('x','v','i','d')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
279 (x == mmioFOURCC('X','V','I','D')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
280 (x == mmioFOURCC('X','v','i','D')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
281 (x == mmioFOURCC('x','v','i','x')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
282 (x == mmioFOURCC('X','V','I','X')) || |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
283 (x == mmioFOURCC('m','p','4','v')) || |
14880
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
284 (x == mmioFOURCC('M','P','4','V')) || |
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
285 (x == mmioFOURCC('F', 'M','P','4')) || |
18164 | 286 (x == mmioFOURCC('f', 'm','p','4')) || |
287 (x == mmioFOURCC('D', 'X','5','0')) || | |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
288 (x == mmioFOURCC('d', 'x','5','0')); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
289 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
290 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
291 //from unrarlib.c |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
292 static uint32_t CalcCRC32(uint8_t *buff, uint32_t size) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
293 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
294 uint32_t i, j, CRCTab[256], crc; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
295 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
296 for(i = 0;i < 256; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
297 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
298 for(crc = i, j = 0; j < 8; j++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
299 crc= (crc & 1) ? (crc >> 1)^0xEDB88320L : (crc >> 1); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
300 CRCTab[i] = crc; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
301 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
302 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
303 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
304 crc = 0xffffffff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
305 for(i = 0; i < size; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
306 crc = (crc << 8) ^ CRCTab[((crc >> 24) ^ buff[i]) & 0xff]; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
307 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
308 return crc; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
309 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
310 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
311 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
312 static void add_to_psm(muxer_priv_t *priv, uint8_t id, uint32_t format) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
313 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
314 uint8_t i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
315 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
316 i = priv->psm_info.cnt; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
317 priv->psm_info.streams[i].id = id; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
318 priv->psm_info.streams[i].format = format; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
319 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
320 if(is_mpeg1(format)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
321 priv->psm_info.streams[i].type = 0x01; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
322 else if(is_mpeg2(format)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
323 priv->psm_info.streams[i].type = 0x02; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
324 else if(is_mpeg4(format)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
325 priv->psm_info.streams[i].type = 0x10; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
326 else if(format == AUDIO_MP2 || format == AUDIO_MP3) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
327 priv->psm_info.streams[i].type = 0x03; |
32618
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
328 else if(format == AUDIO_AAC1 || format == AUDIO_AAC2 || format == AUDIO_AAC3) |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
329 priv->psm_info.streams[i].type = 0x0f; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
330 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
331 priv->psm_info.streams[i].type = 0x81; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
332 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
333 if(format == AUDIO_A52) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
334 memcpy((char*) &(priv->psm_info.streams[i].format), "AC-3", 4); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
335 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
336 priv->psm_info.cnt++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
337 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
338 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
339 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
340 static mpeg_frame_t *init_frames(uint16_t num, size_t size) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
341 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
342 mpeg_frame_t *tmp; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
343 uint16_t i; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
344 |
30702 | 345 tmp = calloc(num, sizeof(mpeg_frame_t)); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
346 if(tmp == NULL) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
347 return NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
348 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
349 for(i=0; i < num; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
350 { |
30702 | 351 tmp[i].buffer = calloc(1, size); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
352 if(tmp[i].buffer == NULL) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
353 return NULL; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
354 tmp[i].size = 0; |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
355 tmp[i].pos = 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
356 tmp[i].alloc_size = size; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
357 tmp[i].pts = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
358 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
359 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
360 return tmp; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
361 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
362 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
363 static int add_frame(muxer_headers_t *spriv, uint64_t idur, uint8_t *ptr, int len, uint8_t pt, uint64_t dts, uint64_t pts); |
8585 | 364 |
365 static muxer_stream_t* mpegfile_new_stream(muxer_t *muxer,int type){ | |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
366 muxer_priv_t *priv = (muxer_priv_t*) muxer->priv; |
8585 | 367 muxer_stream_t *s; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
368 muxer_headers_t *spriv; |
8585 | 369 |
9007
12fc55eb3373
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
370 if (!muxer) return NULL; |
8585 | 371 if(muxer->avih.dwStreams>=MUXER_MAX_STREAMS){ |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
372 mp_msg(MSGT_MUXER, MSGL_ERR, "Too many streams! increase MUXER_MAX_STREAMS !\n"); |
8585 | 373 return NULL; |
374 } | |
375 switch (type) { | |
376 case MUXER_TYPE_VIDEO: | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
377 if (muxer->num_videos >= 16) { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
378 mp_msg(MSGT_MUXER, MSGL_ERR, "MPEG files can't contain more than 16 video streams!\n"); |
8585 | 379 return NULL; |
380 } | |
381 break; | |
382 case MUXER_TYPE_AUDIO: | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
383 if (muxer->num_audios >= 16) { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
384 mp_msg(MSGT_MUXER, MSGL_ERR, "MPEG files can't contain more than 16 audio streams!\n"); |
8585 | 385 return NULL; |
386 } | |
387 break; | |
388 default: | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
389 mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown stream type!\n"); |
8585 | 390 return NULL; |
391 } | |
30702 | 392 s = calloc(1, sizeof(muxer_stream_t)); |
8585 | 393 if(!s) return NULL; // no mem!? |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
394 if (!(s->b_buffer = malloc(priv->packet_size))) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
395 goto init_fail; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
396 s->b_buffer_size = priv->packet_size; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
397 s->b_buffer_ptr = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
398 s->b_buffer_len = 0; |
30702 | 399 s->priv = calloc(1, sizeof(muxer_headers_t)); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
400 if(s->priv == NULL) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
401 goto init_fail; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
402 spriv = (muxer_headers_t *) s->priv; |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
403 spriv->pack = malloc(priv->packet_size); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
404 if(! spriv->pack) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
405 goto init_fail; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
406 spriv->buffer_track = calloc(1, 4096*sizeof(buffer_track_t)); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
407 if(!spriv->buffer_track) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
408 goto init_fail; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
409 spriv->track_pos = 0; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
410 spriv->track_len = 4096; |
8585 | 411 muxer->streams[muxer->avih.dwStreams]=s; |
412 s->type=type; | |
413 s->id=muxer->avih.dwStreams; | |
9007
12fc55eb3373
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
414 s->muxer=muxer; |
22879 | 415 |
11223 | 416 if (type == MUXER_TYPE_VIDEO) { |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
417 spriv->type = 1; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
418 spriv->last_pts = conf_init_vpts * 90 * 300; |
22881
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
419 if(conf_init_vdelay) { |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
420 spriv->last_dts += conf_init_vdelay * 90 * 300; |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
421 spriv->last_pts += conf_init_vdelay * 90 * 300; |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
422 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
423 spriv->id = 0xe0 + muxer->num_videos; |
31623
4d4ed6c9039c
Fix some remaining bswap-related compilation issues.
reimar
parents:
31618
diff
changeset
|
424 s->ckid = av_be2ne32(0x100 + spriv->id); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
425 if(priv->is_genmpeg1 || priv->is_genmpeg2) { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
426 int v = (conf_vbuf_size ? conf_vbuf_size*1024 : |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
427 (s->h.dwSuggestedBufferSize ? s->h.dwSuggestedBufferSize : 46*1024)); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
428 int n = priv->sys_info.cnt; |
22879 | 429 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
430 priv->sys_info.streams[n].id = spriv->id; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
431 priv->sys_info.streams[n].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
432 priv->sys_info.streams[n].bufsize = v; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
433 priv->sys_info.cnt++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
434 } |
11223 | 435 muxer->num_videos++; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
436 priv->has_video++; |
11223 | 437 s->h.fccType=streamtypeVIDEO; |
438 if(!muxer->def_v) muxer->def_v=s; | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
439 spriv->framebuf_cnt = 30; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
440 spriv->framebuf_used = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
441 spriv->framebuf = init_frames(spriv->framebuf_cnt, (size_t) 5000); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
442 if(spriv->framebuf == NULL) { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
443 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't allocate initial frames structure, abort!\n"); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
444 goto init_fail; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
445 } |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
446 memset(&(spriv->picture), 0, sizeof(spriv->picture)); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
447 if(priv->is_xvcd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
448 spriv->min_pes_hlen = 18; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
449 else if(priv->is_xsvcd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
450 spriv->min_pes_hlen = 22; |
14840 | 451 spriv->telecine = conf_telecine; |
11223 | 452 mp_msg (MSGT_MUXER, MSGL_DBG2, "Added video stream %d, ckid=%X\n", muxer->num_videos, s->ckid); |
453 } else { // MUXER_TYPE_AUDIO | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
454 spriv->type = 0; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
455 spriv->drop_delayed_frames = conf_drop; |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
456 spriv->last_pts = conf_init_apts * 90 * 300; |
22881
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
457 if(conf_init_adelay && ! spriv->drop_delayed_frames) |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
458 spriv->last_pts += conf_init_adelay * 90 * 300; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
459 spriv->pts = spriv->last_pts; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
460 spriv->id = 0xc0 + muxer->num_audios; |
31623
4d4ed6c9039c
Fix some remaining bswap-related compilation issues.
reimar
parents:
31618
diff
changeset
|
461 s->ckid = av_be2ne32(0x100 + spriv->id); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
462 if(priv->is_genmpeg1 || priv->is_genmpeg2) { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
463 int a1 = (conf_abuf_size ? conf_abuf_size*1024 : |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
464 (s->h.dwSuggestedBufferSize ? s->h.dwSuggestedBufferSize : 4*1024)); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
465 int n = priv->sys_info.cnt; |
22879 | 466 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
467 priv->sys_info.streams[n].id = spriv->id; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
468 priv->sys_info.streams[n].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
469 priv->sys_info.streams[n].bufsize = a1; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
470 priv->sys_info.cnt++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
471 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
472 if(priv->is_xvcd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
473 spriv->min_pes_hlen = 13; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
474 else if(priv->is_xsvcd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
475 spriv->min_pes_hlen = 17; |
22879 | 476 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
477 muxer->num_audios++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
478 priv->has_audio++; |
11223 | 479 s->h.fccType=streamtypeAUDIO; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
480 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
481 spriv->framebuf_cnt = 30; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
482 spriv->framebuf_used = 0; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
483 spriv->framebuf = init_frames(spriv->framebuf_cnt, (size_t) 2048); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
484 if(spriv->framebuf == NULL) { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
485 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't allocate initial frames structure, abort!\n"); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
486 goto init_fail; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
487 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
488 |
11223 | 489 mp_msg (MSGT_MUXER, MSGL_DBG2, "Added audio stream %d, ckid=%X\n", s->id - muxer->num_videos + 1, s->ckid); |
490 } | |
8585 | 491 muxer->avih.dwStreams++; |
492 return s; | |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
493 |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
494 init_fail: |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
495 if(s) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
496 { |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
497 if(s->priv) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
498 { |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
499 spriv = s->priv; |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32352
diff
changeset
|
500 free(spriv->pack); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32352
diff
changeset
|
501 free(spriv->buffer_track); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
502 free(s->priv); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
503 } |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32352
diff
changeset
|
504 free(s->b_buffer); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
505 free(s); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
506 } |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
507 return NULL; |
8585 | 508 } |
509 | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
510 static void write_mpeg_ts(unsigned char *b, uint64_t ts, uint8_t mod) { |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
511 ts /= 300; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
512 b[0] = mod | ((ts >> 29) & 0xf) | 1; |
8585 | 513 b[1] = (ts >> 22) & 0xff; |
514 b[2] = ((ts >> 14) & 0xff) | 1; | |
515 b[3] = (ts >> 7) & 0xff; | |
516 b[4] = ((ts << 1) & 0xff) | 1; | |
517 } | |
518 | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
519 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
520 static void write_mpeg_rate(int type, unsigned char *b, unsigned int rate) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
521 { |
22924
4822223d8425
small syntax fix: muxrate is expressed in units of 400 bits/second, not 50 bytes per second
nicodvb
parents:
22917
diff
changeset
|
522 rate = ((rate*8)+399) / 400; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
523 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
524 if(type == MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
525 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
526 b[0] = ((rate >> 15) & 0x7f) | 0x80; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
527 b[1] = (rate >> 7) & 0xff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
528 b[2] = ((rate << 1) & 0xff) | 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
529 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
530 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
531 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
532 b[0] = (rate >> 14); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
533 b[1] = (rate >> 6) & 0xff; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
534 b[2] = ((rate & 0x3f) << 2) | 0x03; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
535 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
536 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
537 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
538 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
539 static void write_mpeg_std(unsigned char *b, unsigned int size, unsigned int type, uint8_t mod) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
540 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
541 //type = 0:mpeg audio/128, 1:video and pes private streams (including ac3/dts/lpcm)/1024 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
542 if(type == 0) //audio |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
543 size = (size + 127) / 128; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
544 else //video or other |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
545 size = ((size + 1023) / 1024); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
546 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
547 if(! size) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
548 size++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
549 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
550 b[0] = ((size >> 8) & 0x3f) | (type==1 ? 0x60 : 0x40) | mod; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
551 b[1] = size & 0xff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
552 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
553 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
554 static void write_mpeg2_scr(unsigned char *b, uint64_t ts) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
555 { |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
556 uint16_t t1, t2, t3, scr_ext; |
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
557 scr_ext = ts % 300ULL; |
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
558 ts /= 300ULL; |
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
559 ts &= 0x1FFFFFFFFULL; //33 bits |
28576 | 560 t1 = (ts >> 30) & 0x7; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
561 t2 = (ts >> 15) & 0x7fff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
562 t3 = ts & 0x7fff; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
563 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
564 b[0] = (t1 << 3 ) | 0x44 | ((t2 >> 13) & 0x3); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
565 b[1] = (t2 >> 5); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
566 b[2] = (t2 & 0x1f) << 3 | 0x4 | ((t3 >> 13) & 0x3); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
567 b[3] = (t3 >> 5); |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
568 b[4] = (t3 & 0x1f) << 3 | ((scr_ext >> 7) & 0x03) | 0x4; |
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
569 b[5] = ((scr_ext << 1) & 0xFF) | 1; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
570 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
571 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
572 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
573 static int write_mpeg_pack_header(muxer_t *muxer, char *buff) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
574 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
575 int len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
576 muxer_priv_t *priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
577 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
578 priv = (muxer_priv_t *) muxer->priv; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
579 AV_WB32(buff, PACK_HEADER_START_CODE); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
580 if(priv->mux==MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
581 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
582 write_mpeg_ts(&buff[4], priv->scr, 0x20); // 0010 and SCR |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
583 write_mpeg_rate(priv->mux, &buff[9], muxer->sysrate); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
584 len = 12; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
585 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
586 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
587 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
588 write_mpeg2_scr(&buff[4], priv->scr); // 0010 and SCR |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
589 write_mpeg_rate(priv->mux, &buff[10], muxer->sysrate); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
590 buff[13] = 0xf8; //5 bits reserved + 3 set to 0 to indicate 0 stuffing bytes |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
591 len = 14; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
592 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
593 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
594 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
595 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
596 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
597 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
598 static int write_mpeg_system_header(muxer_t *muxer, char *buff) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
599 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
600 int len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
601 uint8_t i; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
602 muxer_priv_t *priv; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
603 priv = (muxer_priv_t *) muxer->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
604 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
605 len = 0; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
606 AV_WB32(&buff[len], SYSTEM_HEADER_START_CODE); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
607 len += 4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
608 *(uint16_t *)(&buff[len]) = 0; //fake length, we'll fix it later |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
609 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
610 write_mpeg_rate(MUX_MPEG1, &buff[len], muxer->sysrate); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
611 len += 3; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
612 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
613 buff[len++] = 0x4 | (priv->is_xvcd ? 1 : 0); //1 audio stream bound, no fixed, CSPS only for xvcd |
22925
a8f534c4e071
in the system header set audio_locked/video_locked only for dvd and vcd
nicodvb
parents:
22924
diff
changeset
|
614 //stolen from libavformat |
a8f534c4e071
in the system header set audio_locked/video_locked only for dvd and vcd
nicodvb
parents:
22924
diff
changeset
|
615 if(priv->is_xvcd || priv->is_dvd) |
22926 | 616 buff[len++] = 0xe1; //system_audio_lock, system_video_lock, marker, 1 video stream bound |
22925
a8f534c4e071
in the system header set audio_locked/video_locked only for dvd and vcd
nicodvb
parents:
22924
diff
changeset
|
617 else |
22926 | 618 buff[len++] = 0x21; //marker, 1 video stream bound |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
619 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
620 buff[len++] = ((priv->mux == MUX_MPEG1) ? 0xff : 0x7f); //in mpeg2 there's the packet rate restriction |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
621 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
622 for(i = 0; i < priv->sys_info.cnt; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
623 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
624 buff[len++] = priv->sys_info.streams[i].id; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
625 write_mpeg_std(&buff[len], priv->sys_info.streams[i].bufsize, priv->sys_info.streams[i].type, |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
626 (priv->sys_info.streams[i].type == 1 ? 0xe0: 0xc0)); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
627 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
628 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
629 |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
630 AV_WB16(&buff[4], len - 6); // length field fixed |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
631 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
632 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
633 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
634 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
635 static int write_mpeg_psm(muxer_t *muxer, char *buff) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
636 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
637 int len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
638 uint8_t i; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
639 uint16_t dlen; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
640 uint32_t crc; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
641 muxer_priv_t *priv; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
642 priv = (muxer_priv_t *) muxer->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
643 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
644 len = 0; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
645 AV_WB32(&buff[len], PSM_START_CODE); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
646 len += 4; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
647 AV_WB16(&buff[len], 0); //fake length, we'll fix it later |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
648 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
649 buff[len++] = 0xe0; //1 current, 2 bits reserved, 5 version 0 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
650 buff[len++] = 0xff; //7 reserved, 1 marker |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
651 buff[len] = buff[len+1] = 0; //length of the program descriptors (unused) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
652 len += 2; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
653 AV_WB16(&buff[len], 0); //length of the es descriptors |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
654 len += 2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
655 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
656 dlen = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
657 for(i = 0; i < priv->psm_info.cnt; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
658 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
659 if( |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
660 (priv->psm_info.streams[i].id == 0xbd) || |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
661 (priv->psm_info.streams[i].id >= 0xe0 && priv->psm_info.streams[i].id <= 0xef) || |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
662 (priv->psm_info.streams[i].id >= 0xc0 && priv->psm_info.streams[i].id <= 0xcf) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
663 ) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
664 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
665 buff[len++] = priv->psm_info.streams[i].type; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
666 buff[len++] = priv->psm_info.streams[i].id; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
667 buff[len++] = 0; //len of descriptor upper ... |
24903
b4cdc74f4496
remove the registration descriptor from the PSM: writing the fourcc in it makes it total crap
nicodvb
parents:
24902
diff
changeset
|
668 buff[len++] = 0; //... lower |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
669 |
24903
b4cdc74f4496
remove the registration descriptor from the PSM: writing the fourcc in it makes it total crap
nicodvb
parents:
24902
diff
changeset
|
670 dlen += 4; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
671 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
672 } |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
673 AV_WB16(&buff[10], dlen); //length of the es descriptors |
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
674 |
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
675 AV_WB16(&buff[4], len - 6 + 4); // length field fixed, including size of CRC32 |
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
676 |
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
677 crc = CalcCRC32(buff, len); |
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
678 AV_WB32(&buff[len], crc); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
679 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
680 len += 4; //for crc |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
681 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
682 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
683 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
684 |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
685 static int psm_is_late(muxer_priv_t *priv) |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
686 { |
26758
9fb1d2c3dbd4
cosmetics: Remove pointless parentheses from return statements.
diego
parents:
26570
diff
changeset
|
687 return !priv->data_size || (priv->scr >= priv->last_psm_scr + 27000000ULL); |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
688 } |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
689 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
690 static int write_mpeg_pes_header(muxer_headers_t *h, uint8_t *pes_id, uint8_t *buff, uint16_t plen, int stuffing_len, int mux_type) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
691 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
692 int len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
693 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
694 len = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
695 memcpy(&buff[len], pes_id, 4); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
696 len += 4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
697 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
698 buff[len] = buff[len+1] = 0; //fake len |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
699 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
700 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
701 if(mux_type == MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
702 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
703 if(stuffing_len > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
704 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
705 memset(&buff[len], 0xff, stuffing_len); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
706 len += stuffing_len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
707 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
708 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
709 if(h->buffer_size > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
710 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
711 write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); // 01 is pes1 format |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
712 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
713 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
714 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
715 else //MPEG2 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
716 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
717 buff[len] = (h->pes_is_aligned ? 0x84 : 0x80); //0x10... |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
718 len++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
719 buff[len] = ((h->buffer_size > 0) ? 1 : 0) | (h->pts ? (h->dts ? 0xC0 : 0x80) : 0); //pes extension + pts/dts flags |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
720 len++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
721 buff[len] = (h->pts ? (h->dts ? 10 : 5) : 0) + ((h->buffer_size > 0) ? 3 : 0) + stuffing_len;//pts + std + stuffing |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
722 len++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
723 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
724 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
725 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
726 if(h->pts) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
727 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
728 write_mpeg_ts(&buff[len], h->pts, (h->dts ? 0x30 : 0x20)); // 001x and both PTS/DTS |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
729 len += 5; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
730 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
731 if(h->dts) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
732 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
733 write_mpeg_ts(&buff[len], h->dts, 0x10); // 0001 before DTS |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
734 len += 5; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
735 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
736 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
737 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
738 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
739 if(mux_type == MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
740 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
741 buff[len] = 0x0f; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
742 len += 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
743 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
744 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
745 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
746 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
747 if(mux_type == MUX_MPEG2) |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
748 { |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
749 if(h->buffer_size > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
750 { |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
751 buff[len] = 0x1e; //std flag |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
752 len++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
753 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
754 write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
755 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
756 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
757 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
758 if(stuffing_len > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
759 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
760 memset(&buff[len], 0xff, stuffing_len); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
761 len += stuffing_len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
762 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
763 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
764 |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
765 AV_WB16(&buff[4], len + plen - 6); //fix pes packet size |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
766 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
767 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
768 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
769 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
770 static void write_pes_padding(uint8_t *buff, uint16_t len) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
771 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
772 //6 header bytes + len-6 0xff chars |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
773 buff[0] = buff[1] = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
774 buff[2] = 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
775 buff[3] = 0xbe; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
776 AV_WB16(&buff[4], len - 6); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
777 memset(&buff[6], 0xff, len - 6); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
778 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
779 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
780 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
781 static int write_nav_pack(uint8_t *buff) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
782 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
783 // concatenation of pes_private2 + 03d4 x 0 and pes_private2 + 03fa x 0 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
784 int len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
785 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
786 mp_msg(MSGT_MUXER, MSGL_DBG3, "NAV\n"); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
787 len = 0; |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
788 AV_WB32(&buff[len], PES_PRIVATE2); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
789 len += 4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
790 buff[len++] = 0x3; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
791 buff[len++] = 0xd4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
792 memset(&buff[len], 0, 0x03d4); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
793 len += 0x03d4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
794 |
31618
9318ad289bb0
Use AV_WB* where possible and be2me -> be2ne compilation fix.
reimar
parents:
31090
diff
changeset
|
795 AV_WB32(&buff[len], PES_PRIVATE2); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
796 len += 4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
797 buff[len++] = 0x3; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
798 buff[len++] = 0xfa; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
799 memset(&buff[len], 0, 0x03fa); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
800 len += 0x03fa; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
801 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
802 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
803 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
804 |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
805 static unsigned int calc_psm_len(muxer_priv_t *priv) |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
806 { |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
807 return 16 + 4*(priv->psm_info.cnt); |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
808 } |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
809 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
810 static uint32_t calc_pes_hlen(int format, muxer_headers_t *h, muxer_priv_t *priv) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
811 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
812 uint32_t len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
813 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
814 if(format == MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
815 len = 6; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
816 else |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
817 len = 9; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
818 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
819 if(h->pts) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
820 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
821 len += 5; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
822 if(h->dts) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
823 len += 5; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
824 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
825 else if(format == MUX_MPEG1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
826 len += 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
827 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
828 if(h->buffer_size > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
829 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
830 if(format == MUX_MPEG2) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
831 len += 3; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
832 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
833 len += 2; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
834 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
835 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
836 //len = max(h->min_pes_hlen, len); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
837 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
838 return len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
839 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
840 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
841 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
842 static int write_mpeg_pack(muxer_t *muxer, muxer_stream_t *s, stream_t *stream, int isoend) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
843 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
844 size_t tot, offset; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
845 muxer_priv_t *priv; |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
846 unsigned char *buff; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
847 int stuffing_len; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
848 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
849 priv = (muxer_priv_t *) muxer->priv; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
850 buff = priv->buff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
851 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
852 if(isoend) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
853 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
854 offset = priv->packet_size - 4; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
855 write_pes_padding(buff, offset); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
856 buff[offset + 0] = buff[offset + 1] = 0; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
857 buff[offset + 2] = 1; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
858 buff[offset + 3] = 0xb9; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
859 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
860 stream_write_buffer(stream, buff, priv->packet_size); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
861 return 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
862 } |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
863 else //FAKE DVD NAV PACK |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
864 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
865 offset = write_mpeg_pack_header(muxer, buff); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
866 offset += write_mpeg_system_header(muxer, &buff[offset]); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
867 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
868 //priv->update_system_header = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
869 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
870 if(priv->is_dvd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
871 offset += write_nav_pack(&buff[offset]); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
872 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
873 stuffing_len = priv->packet_size - offset; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
874 if(stuffing_len > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
875 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
876 //insert a PES padding packet |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
877 write_pes_padding(&buff[offset], stuffing_len); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
878 offset += stuffing_len; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
879 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
880 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
881 stream_write_buffer(stream, buff, offset); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
882 priv->headers_size += offset; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
883 tot = offset; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
884 muxer->movi_end += tot; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
885 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
886 return tot; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
887 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
888 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
889 |
22142
84f95595f31f
Fix a few gcc warnings, approved by Diego and Reimar.
rathann
parents:
21660
diff
changeset
|
890 static void update_demux_bufsize(muxer_headers_t *spriv, uint64_t dts, int framelen, int type) |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
891 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
892 int dim = (spriv->track_len+16)*sizeof(buffer_track_t); |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
893 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
894 if(spriv->track_pos+1 >= spriv->track_len) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
895 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
896 buffer_track_t *tmp = realloc(spriv->buffer_track, dim); |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
897 if(!tmp) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
898 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
899 mp_msg(MSGT_MUXER, MSGL_ERR, "\r\nERROR, couldn't realloc %d bytes for tracking buffer\r\n", dim); |
22142
84f95595f31f
Fix a few gcc warnings, approved by Diego and Reimar.
rathann
parents:
21660
diff
changeset
|
900 return; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
901 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
902 spriv->buffer_track = tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
903 memset(&(spriv->buffer_track[spriv->track_pos+1]), 0, 16*sizeof(buffer_track_t)); |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
904 spriv->track_len += 16; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
905 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
906 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
907 spriv->buffer_track[spriv->track_pos].size = framelen; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
908 spriv->buffer_track[spriv->track_pos].dts = dts; //must be dts |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
909 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
910 spriv->track_pos++; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
911 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
912 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
913 static void fix_a52_headers(muxer_stream_t *s) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
914 { |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
915 muxer_headers_t *spriv = s->priv; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
916 int x = spriv->payload_offset; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
917 |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
918 spriv->pack[x+0] = 0x80; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
919 spriv->pack[x+1] = spriv->frames; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
920 if(spriv->frames) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
921 { |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
922 spriv->pack[x+2] = ((spriv->last_frame_rest+1) >> 8) & 0xff; //256 * 0 ... |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
923 spriv->pack[x+3] = (spriv->last_frame_rest+1) & 0xff; // + 1 byte(s) to skip |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
924 } |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
925 else |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
926 spriv->pack[x+2] = spriv->pack[x+3] = 0; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
927 } |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
928 |
18197 | 929 static inline void remove_frames(muxer_headers_t *spriv, int n) |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
930 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
931 mpeg_frame_t tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
932 int i; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
933 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
934 for(i = n; i < spriv->framebuf_used; i++) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
935 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
936 tmp = spriv->framebuf[i - n]; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
937 spriv->framebuf[i - n] = spriv->framebuf[i]; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
938 spriv->framebuf[i] = tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
939 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
940 spriv->framebuf_used -= n; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
941 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
942 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
943 static int calc_packet_len(muxer_stream_t *s, int psize, int finalize) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
944 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
945 muxer_headers_t *spriv = s->priv; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
946 int n, len, frpos, m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
947 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
948 n = len = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
949 frpos = spriv->framebuf[0].pos; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
950 while(len < psize && n < spriv->framebuf_used) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
951 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
952 if(!frpos && len>0 && s->type == MUXER_TYPE_VIDEO && spriv->framebuf[n].type==I_FRAME) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
953 return len; |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
954 m = FFMIN(spriv->framebuf[n].size - frpos, psize - len); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
955 len += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
956 frpos += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
957 if(frpos == spriv->framebuf[n].size) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
958 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
959 frpos = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
960 n++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
961 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
962 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
963 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
964 if(len < psize && !finalize) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
965 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
966 return len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
967 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
968 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
969 static int find_packet_timestamps(muxer_priv_t *priv, muxer_stream_t *s, unsigned int start, uint64_t *dts, uint64_t *pts) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
970 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
971 muxer_headers_t *spriv = s->priv; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
972 int i, m, pes_hlen, ret, threshold; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
973 uint64_t spts, sdts, dpts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
974 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
975 if(!spriv->framebuf_used) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
976 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
977 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
978 spts = spriv->pts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
979 sdts = spriv->dts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
980 spriv->dts = spriv->pts = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
981 ret = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
982 if(spriv->framebuf[0].pos == 0) // start of frame |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
983 i = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
984 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
985 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
986 pes_hlen = calc_pes_hlen(priv->mux, spriv, priv); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
987 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
988 if(pes_hlen < spriv->min_pes_hlen) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
989 pes_hlen = spriv->min_pes_hlen; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
990 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
991 m = spriv->framebuf[0].size - spriv->framebuf[0].pos; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
992 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
993 if(start + pes_hlen + m >= priv->packet_size) //spriv->pack_offset |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
994 i = -1; //this pack won't have a pts: no space available |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
995 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
996 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
997 if(spriv->framebuf_used < 2) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
998 goto fail; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
999 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1000 if(spriv->framebuf[1].pts == spriv->framebuf[1].dts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1001 threshold = 5; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1002 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1003 threshold = 10; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1004 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1005 //headers+frame 0 < space available including timestamps |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1006 if(start + pes_hlen + m < priv->packet_size - threshold) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1007 i = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1008 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1009 i = -1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1010 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1011 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1012 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1013 if(i > -1) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1014 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1015 dpts = FFMAX(spriv->last_saved_pts, spriv->framebuf[i].pts) - |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
1016 FFMIN(spriv->last_saved_pts, spriv->framebuf[i].pts) + |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1017 spriv->framebuf[0].idur; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1018 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1019 if(s->type != MUXER_TYPE_VIDEO) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1020 ret = 1; |
18751
6dd7e4c77e3d
try to reduce the distance between consecutive frames with pts to no more than 0.4 seconds (required by dvds)
nicodvb
parents:
18745
diff
changeset
|
1021 else if((spriv->framebuf[i].type == I_FRAME || priv->ts_allframes || dpts >= 36000*300)) //0.4 seconds |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1022 ret = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1023 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1024 if(ret) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1025 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1026 *pts = spriv->framebuf[i].pts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1027 *dts = spriv->framebuf[i].dts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1028 if(*dts == *pts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1029 *dts = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1030 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1031 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1032 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1033 fail: |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1034 spriv->pts = spts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1035 spriv->dts = sdts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1036 return ret; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1037 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1038 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1039 static int get_packet_stats(muxer_priv_t *priv, muxer_stream_t *s, pack_stats_t *p, int finalize) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1040 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1041 muxer_headers_t *spriv = s->priv; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1042 int len, len2, pack_hlen, pes_hlen, hlen, target, stflen, stuffing_len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1043 uint64_t pts, dts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1044 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1045 spriv->pts = spriv->dts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1046 p->dts = p->pts = p->frame_pts = p->frame_dts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1047 p->len = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1048 |
21141 | 1049 if(priv->rawpes) |
1050 pack_hlen = 0; | |
1051 else if(priv->mux == MUX_MPEG1) | |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1052 pack_hlen = 12; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1053 else |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1054 pack_hlen = 14; |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1055 if(priv->use_psm && psm_is_late(priv)) |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1056 pack_hlen += calc_psm_len(priv); |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1057 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1058 if(find_packet_timestamps(priv, s, pack_hlen, &dts, &pts)) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1059 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1060 p->pts = p->frame_pts = pts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1061 p->dts = p->frame_dts = dts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1062 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1063 spriv->pts = pts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1064 spriv->dts = dts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1065 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1066 pes_hlen = calc_pes_hlen(priv->mux, spriv, priv); |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1067 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1068 p->stflen = stflen = (spriv->min_pes_hlen > pes_hlen ? spriv->min_pes_hlen - pes_hlen : 0); |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1069 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1070 target = len = priv->packet_size - pack_hlen - pes_hlen - stflen; //max space available |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1071 if(s->type == MUXER_TYPE_AUDIO && s->wf->wFormatTag == AUDIO_A52) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1072 hlen = 4; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1073 else |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1074 hlen = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1075 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1076 len -= hlen; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1077 target -= hlen; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1078 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1079 len2 = calc_packet_len(s, target, finalize); |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1080 if(!len2 || (len2 < target && s->type == MUXER_TYPE_AUDIO && !finalize)) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1081 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1082 //p->len = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1083 //p->dts = p->pts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1084 spriv->pts = spriv->dts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1085 //fprintf(stderr, "\r\nLEN2: %d, target: %d, type: %d\r\n", len2, target, s->type); |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1086 return 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1087 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1088 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1089 len = len2; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1090 stuffing_len = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1091 if(len < target) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1092 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1093 if(s->type == MUXER_TYPE_VIDEO) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1094 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1095 if(spriv->pts) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1096 target += 5; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1097 if(spriv->dts) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1098 target += 5; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1099 spriv->pts = spriv->dts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1100 p->pts = p->dts = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1101 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1102 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1103 stuffing_len = target - len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1104 if(stuffing_len > 0 && stuffing_len < 7) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1105 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1106 if(stflen + stuffing_len > 16) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1107 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1108 int x = 7 - stuffing_len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1109 stflen -= x; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1110 stuffing_len += x; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1111 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1112 else |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1113 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1114 stflen += stuffing_len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1115 stuffing_len = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1116 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1117 } |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1118 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1119 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1120 len += hlen; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1121 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1122 p->len = len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1123 p->stflen = stflen; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1124 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1125 return p->len; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1126 } |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1127 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1128 static int fill_packet(muxer_t *muxer, muxer_stream_t *s, int finalize) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1129 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1130 //try to fill a packet as much as possible |
25962 | 1131 //spriv->pack_offset is the start position initialized to 0 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1132 //data is taken from spriv->framebuf |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1133 //if audio and a52 insert the headers |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1134 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1135 muxer_headers_t *spriv = (muxer_headers_t *) s->priv; |
18958
a8e681ad7c90
Remove unused variables, patch by Stefan Huehner stefan at huehner org.
diego
parents:
18751
diff
changeset
|
1136 int len, m, n, dvd_pack = 0; |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1137 int write_psm = 0; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1138 mpeg_frame_t *frm; |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1139 pack_stats_t p; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1140 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1141 spriv->dts = spriv->pts = 0; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1142 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1143 if(! spriv->framebuf_used) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1144 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1145 spriv->pack_offset = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1146 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1147 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1148 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1149 if(!spriv->pack_offset) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1150 { |
21141 | 1151 if(priv->rawpes) |
1152 spriv->pack_offset = 0; | |
1153 else | |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1154 spriv->pack_offset = write_mpeg_pack_header(muxer, spriv->pack); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1155 if(priv->update_system_header && (priv->is_genmpeg1 || priv->is_genmpeg2)) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1156 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1157 spriv->pack_offset += write_mpeg_system_header(muxer, &spriv->pack[spriv->pack_offset]); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1158 priv->update_system_header = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1159 } |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1160 |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1161 if(priv->use_psm && psm_is_late(priv)) |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1162 { |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1163 spriv->pack_offset += write_mpeg_psm(muxer, &spriv->pack[spriv->pack_offset]); |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1164 write_psm = 1; |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1165 } |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1166 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1167 spriv->pes_set = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1168 spriv->pes_offset = spriv->pack_offset; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1169 spriv->payload_offset = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1170 spriv->frames = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1171 spriv->last_frame_rest = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1172 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1173 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1174 if(!spriv->pes_set) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1175 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1176 int bufsize = 0; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1177 //search the pts. yes if either it's video && (I-frame or priv->ts_allframes) && framebuf[i].pos == 0 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1178 //or it's audio && framebuf[i].pos == 0 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1179 //NB pts and dts can only be relative to the first frame beginning in this pack |
21141 | 1180 if((priv->is_xsvcd || priv->is_xvcd || priv->rawpes) && spriv->size == 0) |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1181 { |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1182 if(s->type == MUXER_TYPE_VIDEO) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1183 bufsize = (conf_vbuf_size ? conf_vbuf_size : (priv->is_xvcd ? 46 : 232)); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1184 else |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1185 bufsize = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1186 spriv->buffer_size = bufsize*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1187 } |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1188 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1189 if(priv->is_dvd && s->type == MUXER_TYPE_VIDEO |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1190 && spriv->framebuf[0].type==I_FRAME && spriv->framebuf[0].pos==0) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1191 dvd_pack = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1192 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1193 if(! get_packet_stats(priv, s, &p, finalize)) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1194 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1195 spriv->pack_offset = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1196 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1197 } |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1198 spriv->dts = p.dts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1199 spriv->pts = p.pts; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1200 if(spriv->pts) |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1201 spriv->last_saved_pts = p.pts; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1202 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1203 spriv->pack_offset += write_mpeg_pes_header(spriv, (uint8_t *) &s->ckid, &(spriv->pack[spriv->pack_offset]), |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1204 p.len, p.stflen, priv->mux); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1205 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1206 if(s->type == MUXER_TYPE_AUDIO && s->wf->wFormatTag == AUDIO_A52) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1207 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1208 spriv->payload_offset = spriv->pack_offset; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1209 spriv->pack_offset += 4; //for the 4 bytes of header |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1210 if(!spriv->framebuf[0].pos) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1211 spriv->last_frame_rest = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1212 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1213 spriv->last_frame_rest = spriv->framebuf[0].size - spriv->framebuf[0].pos; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1214 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1215 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1216 spriv->pes_set = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1217 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1218 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1219 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1220 if(spriv->dts || spriv->pts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1221 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1222 if((spriv->dts && priv->scr >= spriv->dts) || priv->scr >= spriv->pts) |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1223 mp_msg(MSGT_MUXER, MSGL_ERR, "\r\nERROR: scr %.3f, dts %.3f, pts %.3f\r\n", (double) priv->scr/27000000.0, (double) spriv->dts/27000000.0, (double) spriv->pts/27000000.0); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1224 else if(priv->scr + 63000*300 < spriv->dts) |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1225 mp_msg(MSGT_MUXER, MSGL_INFO, "\r\nWARNING>: scr %.3f, dts %.3f, pts %.3f, diff %.3f, piff %.3f\r\n", (double) priv->scr/27000000.0, (double) spriv->dts/27000000.0, (double) spriv->pts/27000000.0, (double)(spriv->dts - priv->scr)/27000000.0, (double)(spriv->pts - priv->scr)/27000000.0); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1226 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1227 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1228 n = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1229 len = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1230 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1231 frm = spriv->framebuf; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1232 while(spriv->pack_offset < priv->packet_size && n < spriv->framebuf_used) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1233 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1234 if(!frm->pos) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1235 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1236 //since iframes must always be aligned at block boundaries exit when we find the |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1237 //beginning of one in the middle of the flush |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1238 if(len > 0 && s->type == MUXER_TYPE_VIDEO && frm->type == I_FRAME) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1239 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1240 break; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1241 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1242 spriv->frames++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1243 update_demux_bufsize(spriv, frm->dts, frm->size, s->type); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1244 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1245 |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
1246 m = FFMIN(frm->size - frm->pos, priv->packet_size - spriv->pack_offset); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1247 memcpy(&(spriv->pack[spriv->pack_offset]), &(frm->buffer[frm->pos]), m); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1248 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1249 len += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1250 spriv->pack_offset += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1251 frm->pos += m; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1252 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1253 if(frm->pos == frm->size) //end of frame |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1254 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1255 frm->pos = frm->size = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1256 frm->pts = frm->dts = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1257 n++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1258 frm++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1259 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1260 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1261 |
21141 | 1262 if((priv->is_xsvcd || priv->is_xvcd || priv->rawpes) && spriv->size == 0) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1263 spriv->buffer_size = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1264 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1265 spriv->size += len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1266 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1267 if(dvd_pack && (spriv->pack_offset == priv->packet_size)) |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
1268 write_mpeg_pack(muxer, NULL, muxer->stream, 0); //insert fake Nav Packet |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1269 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1270 if(n > 0) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1271 remove_frames(spriv, n); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1272 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1273 spriv->track_bufsize += len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1274 if(spriv->track_bufsize > spriv->max_buffer_size) |
23637 | 1275 mp_msg(MSGT_MUXER, MSGL_ERR, "\r\nBUFFER OVERFLOW: %d > %d, pts: %"PRIu64"\r\n", spriv->track_bufsize, spriv->max_buffer_size, spriv->pts); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1276 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1277 if(s->type == MUXER_TYPE_AUDIO && s->wf->wFormatTag == AUDIO_A52) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1278 fix_a52_headers(s); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1279 |
21141 | 1280 if(spriv->pack_offset < priv->packet_size && !priv->rawpes) //here finalize is set |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1281 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1282 int diff = priv->packet_size - spriv->pack_offset; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1283 write_pes_padding(&(spriv->pack[spriv->pack_offset]), diff); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1284 spriv->pack_offset += diff; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1285 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1286 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
1287 stream_write_buffer(muxer->stream, spriv->pack, spriv->pack_offset); |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1288 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1289 priv->headers_size += spriv->pack_offset - len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1290 priv->data_size += len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1291 muxer->movi_end += spriv->pack_offset; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1292 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1293 spriv->pack_offset = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1294 spriv->pes_set = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1295 spriv->frames = 0; |
24904
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1296 if(write_psm) |
75e930e20f48
repeat the PSM once every second (in terms of delta_scr) otherwise playing the file from the middle would miss the first instance
nicodvb
parents:
24903
diff
changeset
|
1297 priv->last_psm_scr = priv->scr; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1298 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1299 return len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1300 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1301 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1302 static inline int find_best_stream(muxer_t *muxer) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1303 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1304 int i, ndts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1305 uint64_t dts = -1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1306 muxer_priv_t *priv = muxer->priv; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1307 muxer_headers_t *spriv; |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1308 pack_stats_t p; |
22929
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1309 unsigned int perc, sperc; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1310 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1311 ndts = -1; |
22929
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1312 perc = -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1313 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1314 //THIS RULE MUST ALWAYS apply: dts <= SCR + 0.7 seconds |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1315 for(i = 0; i < muxer->avih.dwStreams; i++) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1316 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1317 spriv = muxer->streams[i]->priv; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1318 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1319 p.len = 0; |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1320 get_packet_stats(priv, muxer->streams[i], &p, 0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1321 |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1322 if(spriv->track_bufsize + p.len > spriv->max_buffer_size) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1323 continue; |
18745
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1324 if(p.frame_pts && p.frame_dts > priv->scr + 63000*300) |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1325 continue; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1326 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1327 if(spriv->framebuf[0].dts <= dts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1328 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1329 dts = spriv->framebuf[0].dts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1330 ndts = i; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1331 } |
22929
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1332 |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1333 if(conf_interleaving2) |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1334 { |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1335 sperc = (spriv->track_bufsize * 1024) / spriv->max_buffer_size; |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1336 if(sperc < perc) |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1337 { |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1338 ndts = i; |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1339 perc = sperc; |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1340 } |
a60dbae6ee1d
added :interleaving2, a better method to determine which stream whouls be flushed
nicodvb
parents:
22927
diff
changeset
|
1341 } |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1342 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1343 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1344 return ndts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1345 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1346 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1347 static void patch_seq(muxer_priv_t *priv, unsigned char *buf) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1348 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1349 if(priv->vwidth > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1350 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1351 buf[4] = (priv->vwidth >> 4) & 0xff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1352 buf[5] &= 0x0f; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1353 buf[5] |= (priv->vwidth & 0x0f) << 4; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1354 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1355 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1356 if(priv->vheight > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1357 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1358 buf[5] &= 0xf0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1359 buf[5] |= (priv->vheight >> 8) & 0x0f; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1360 buf[6] = priv->vheight & 0xff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1361 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1362 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1363 if(priv->vaspect > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1364 buf[7] = (buf[7] & 0x0f) | (priv->vaspect << 4); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1365 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1366 if(priv->vframerate > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1367 buf[7] = (buf[7] & 0xf0) | priv->vframerate; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1368 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1369 if(priv->vbitrate > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1370 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1371 buf[8] = (priv->vbitrate >> 10); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1372 buf[9] = (priv->vbitrate >> 2); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1373 buf[10] = (buf[10] & 0x3f) | (unsigned char) ((priv->vbitrate & 0x4) << 2); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1374 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1375 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1376 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1377 static void patch_panscan(muxer_priv_t *priv, unsigned char *buf) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1378 { //patches sequence display extension (display_horizontal_size and display_vertical_size) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1379 //1: |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1380 int offset = 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1381 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1382 if(buf[0] & 0x01) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1383 offset += 3; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1384 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1385 if(priv->panscan_width > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1386 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1387 buf[offset] = (priv->panscan_width >> 6); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1388 buf[offset+1] = ((priv->panscan_width & 0x3F) << 2) | (buf[offset + 1] & 0x03); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1389 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1390 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1391 offset++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1392 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1393 if(priv->panscan_height > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1394 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1395 buf[offset] = (priv->panscan_height >> 13) << 7; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1396 buf[offset+1] = (priv->panscan_height >> 5) & 0xFF; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1397 buf[offset+2] = ((priv->panscan_height & 0x1F) << 3) | (buf[offset+2] & 0x07); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1398 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1399 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1400 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1401 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1402 static void update_scr(muxer_t *muxer) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1403 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1404 muxer_priv_t *priv = muxer->priv; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1405 muxer_stream_t *stream; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1406 muxer_headers_t *spriv; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1407 int i, j; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1408 uint64_t mindts = (uint64_t) -1; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1409 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1410 priv->scr += priv->delta_scr; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1411 |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1412 for(i = 0; i < muxer->avih.dwStreams; i++) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1413 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1414 stream = muxer->streams[i]; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1415 spriv = stream->priv; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1416 if(spriv->framebuf_used && spriv->framebuf[0].dts < mindts) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1417 mindts = spriv->framebuf[0].dts; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1418 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1419 |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1420 mp_msg(MSGT_MUXER, MSGL_DBG2, "UPDATE SCR TO %"PRIu64" (%.3f)\n", priv->scr, (double) (priv->scr/27000000.0)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1421 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1422 for(i = 0; i < muxer->avih.dwStreams; i++) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1423 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1424 stream = muxer->streams[i]; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1425 spriv = stream->priv; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1426 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1427 j = 0; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1428 while(j < spriv->track_pos && priv->scr >= spriv->buffer_track[j].dts) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1429 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1430 spriv->track_bufsize -= spriv->buffer_track[j].size; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1431 j++; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1432 } |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1433 if(spriv->track_bufsize < 0) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1434 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1435 double d; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1436 muxer->sysrate = (muxer->sysrate * 11) / 10; //raise by 10% |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1437 d = (double) priv->packet_size / (double)muxer->sysrate; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1438 priv->delta_scr = (uint64_t) (d * 27000000.0f); |
23637 | 1439 mp_msg(MSGT_MUXER, MSGL_INFO, "\r\nBUFFER UNDEFLOW at stream %d, raising muxrate to %d kb/s, delta_scr: %"PRIu64"\r\n", i, muxer->sysrate/125, priv->delta_scr); |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1440 spriv->track_bufsize = 0; |
21448 | 1441 } |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1442 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1443 if(j > 0) |
21448 | 1444 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1445 memmove(spriv->buffer_track, &(spriv->buffer_track[j]), (spriv->track_len - j) * sizeof(buffer_track_t)); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1446 spriv->track_pos -= j; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1447 for(j = spriv->track_pos; j < spriv->track_len; j++) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1448 spriv->buffer_track[j].size = 0; |
21448 | 1449 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1450 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1451 if(spriv->framebuf_used && spriv->framebuf[0].dts < mindts) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1452 mindts = spriv->framebuf[0].dts; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1453 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1454 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1455 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1456 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1457 static int calc_frames_to_flush(muxer_headers_t *vpriv) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1458 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1459 int n, found = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1460 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1461 if(vpriv->framebuf_used > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1462 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1463 n = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1464 //let's count how many frames we'll store in the next pack sequence |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1465 mp_msg(MSGT_MUXER, MSGL_DBG2, "\n"); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1466 while(n < vpriv->framebuf_used) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1467 { |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1468 mp_msg(MSGT_MUXER, MSGL_DBG2, "CALC_FRAMES, n=%d, type=%c, pts=%.3f\n", n, FTYPE(vpriv->framebuf[n].type), (double)vpriv->framebuf[n].pts/27000000.0f); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1469 if(n+1 < vpriv->framebuf_used) |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1470 mp_msg(MSGT_MUXER, MSGL_DBG2, "n+1=%d, type=%c, pts=%.3f\n", n+1, FTYPE(vpriv->framebuf[n+1].type), (double)vpriv->framebuf[n+1].pts/27000000.0f); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1471 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1472 if(vpriv->framebuf[n].type == I_FRAME) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1473 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1474 if(n > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1475 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1476 found = 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1477 break; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1478 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1479 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1480 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1481 n++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1482 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1483 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1484 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1485 if(found && (n < vpriv->framebuf_used+1)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1486 return n; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1487 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1488 return 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1489 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1490 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1491 static int flush_buffers(muxer_t *muxer, int finalize) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1492 { |
18199 | 1493 int i, n, found; |
1494 int skip_cnt; | |
1495 uint64_t init_delay = 0; | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1496 muxer_stream_t *s, *vs, *as; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1497 muxer_headers_t *vpriv = NULL, *apriv = NULL; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1498 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
22909
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1499 double duration; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1500 uint64_t iduration, iaduration; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1501 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1502 /* |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1503 analyzes all streams and decides what to flush |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1504 trying to respect an interleaving distribution |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1505 equal to the v_bitrate/a_bitrate proportion |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1506 */ |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1507 n = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1508 vs = as = NULL; |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1509 found = 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1510 for(i = 0; i < muxer->avih.dwStreams; i++) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1511 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1512 s = muxer->streams[i]; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1513 if(s->type == MUXER_TYPE_VIDEO) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1514 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1515 vs = muxer->streams[i]; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1516 vpriv = (muxer_headers_t*) vs->priv; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1517 if(!vpriv->is_ready) |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1518 return 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1519 n = found = calc_frames_to_flush(vpriv); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1520 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1521 else if(s->type == MUXER_TYPE_AUDIO) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1522 as = s; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1523 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1524 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1525 if((! found) && finalize) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1526 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1527 if(vpriv != NULL) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1528 found = n = vpriv->framebuf_used; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1529 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1530 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1531 if(found) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1532 { |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1533 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nVIDEO, FLUSH %d frames (of %d), 0 to %d\n", n, vpriv->framebuf_used, n-1); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1534 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1535 vpriv = (muxer_headers_t*) vs->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1536 |
22909
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1537 duration = 0; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1538 iduration = 0; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1539 for(i = 0; i < n; i++) |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1540 iduration += vpriv->framebuf[i].idur; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1541 duration = (double) (iduration / 27000000.0); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1542 |
22909
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1543 if(as != NULL) |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1544 { |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1545 apriv = (muxer_headers_t*) as->priv; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1546 iaduration = 0; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1547 for(i = 0; i < apriv->framebuf_used; i++) |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1548 { |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1549 iaduration += apriv->framebuf[i].idur; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1550 } |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1551 if(iaduration < iduration) |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1552 { |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1553 mp_msg(MSGT_MUXER, MSGL_DBG2, "Not enough audio data exit\n"); |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1554 return 0; |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1555 } |
94183c81ec0c
reversed r22879 until I discover why it's giving so many sync problems; I'll eventually recommit it in a fixed form
nicodvb
parents:
22881
diff
changeset
|
1556 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1557 |
22861
a9b5d1ddbd80
in flush_buffers() removed code that required the presence of an amount of audio data >= video data in the temporal domain
nicodvb
parents:
22605
diff
changeset
|
1558 if(as != NULL && (apriv->size == 0)) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1559 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1560 init_delay = vpriv->framebuf[0].pts - vpriv->framebuf[0].dts; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1561 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1562 for(i = 0; i < apriv->framebuf_cnt; i++) |
21448 | 1563 { |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1564 apriv->framebuf[i].pts += init_delay; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1565 apriv->framebuf[i].dts += init_delay; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1566 } |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1567 apriv->last_pts += init_delay; |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1568 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nINITIAL VIDEO DELAY: %.3f, currAPTS: %.3f\r\n", (double) init_delay/27000000.0f, (double) apriv->last_pts/27000000.0f); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1569 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1570 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1571 if((priv->is_xvcd || priv->is_xsvcd) && (vpriv->size == 0)) |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1572 vpriv->buffer_size = (conf_vbuf_size ? conf_vbuf_size : (priv->is_xvcd ? 46 : 230))*1024; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1573 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1574 i = 0; |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1575 skip_cnt = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1576 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1577 while(1) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1578 { |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1579 update_scr(muxer); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1580 i = find_best_stream(muxer); |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1581 if(i < 0) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1582 continue; |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1583 if(!fill_packet(muxer, muxer->streams[i], finalize)) |
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1584 skip_cnt++; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1585 |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1586 if(skip_cnt == muxer->avih.dwStreams) |
20344
5ccb2b837b1c
if no stream could be muxed flush_buffers() returns 0: prevents while(1) stall at the end
nicodvb
parents:
20153
diff
changeset
|
1587 { |
5ccb2b837b1c
if no stream could be muxed flush_buffers() returns 0: prevents while(1) stall at the end
nicodvb
parents:
20153
diff
changeset
|
1588 found = 0; |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1589 break; |
20344
5ccb2b837b1c
if no stream could be muxed flush_buffers() returns 0: prevents while(1) stall at the end
nicodvb
parents:
20153
diff
changeset
|
1590 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1591 } |
18196
f7f6984638f8
finally replaced the old interleaving with the new one that respects buffering and [pd]ts<->scr constraints; don't check spriv->framebuf_used in find_best_stream()
nicodvb
parents:
18192
diff
changeset
|
1592 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1593 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1594 muxer->file_end = priv->scr; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1595 return found; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1596 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1597 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1598 |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1599 static inline uint64_t parse_fps(float fps) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1600 { |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1601 // 90000 * 300 * 1001 / d , there's no rounding error with any of the admitted framerates |
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1602 int d = (int)(fps*1001+0.5); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1603 |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1604 return 27027000000ULL / d; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1605 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1606 |
14880
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
1607 |
21467 | 1608 static int soft_telecine(muxer_priv_t *priv, muxer_headers_t *vpriv, uint8_t *fps_ptr, uint8_t *se_ptr, uint8_t *pce_ptr, int n) |
14840 | 1609 { |
17814 | 1610 if(! pce_ptr) |
1611 return 0; | |
14840 | 1612 if(fps_ptr != NULL) |
1613 { | |
21484 | 1614 *fps_ptr = (*fps_ptr & 0xf0) | priv->vframerate; |
1615 vpriv->nom_delta_pts = parse_fps(conf_vframerate); | |
14840 | 1616 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1617 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1618 //in pce_ptr starting from bit 0 bit 24 is tff, bit 30 is rff, |
14840 | 1619 if(pce_ptr[3] & 0x2) |
1620 { | |
1621 mp_msg(MSGT_MUXER, MSGL_ERR, "\nERROR! RFF bit is already set, disabling telecining\n"); | |
1622 vpriv->telecine = 0; | |
1623 return 0; | |
1624 } | |
14880
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
1625 |
14894 | 1626 vpriv->picture.progressive_sequence = 0; |
1627 vpriv->picture.progressive_frame = 1; | |
14880
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
1628 if(se_ptr) |
991f5a7b1b7d
telecine now works in display order (rather than decoding), as far as there are no more than 4 consecutive b-frames; added support for FMP4
nicodvb
parents:
14840
diff
changeset
|
1629 se_ptr[1] &= 0xf7; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1630 |
24630
dcba95743b2f
1000l, the tff flag was never cleared before being overwritten with the value on bff_mask;
nicodvb
parents:
23637
diff
changeset
|
1631 //disable tff and rff and overwrite them with the value in bff_mask |
25720
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
1632 pce_ptr[3] = (pce_ptr[3] & 0x7d) | priv->bff_mask[vpriv->display_frame % MAX_PATTERN_LENGTH]; |
17600
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
1633 pce_ptr[4] |= 0x80; //sets progressive frame |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1634 |
21467 | 1635 vpriv->display_frame += n; |
14840 | 1636 if(! vpriv->vframes) |
21483 | 1637 mp_msg(MSGT_MUXER, MSGL_INFO, "\nENABLED SOFT TELECINING, FPS=%.3f\n",conf_vframerate); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1638 |
14840 | 1639 return 1; |
1640 } | |
1641 | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1642 static size_t parse_mpeg12_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_headers_t *spriv, float fps, size_t len) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1643 { |
14840 | 1644 uint8_t *fps_ptr = NULL; //pointer to the fps byte in the sequence header |
1645 uint8_t *se_ptr = NULL; //pointer to sequence extension | |
1646 uint8_t *pce_ptr = NULL; //pointer to picture coding extension | |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
1647 int frames_diff, d1, gop_reset = 0; //how any frames we advanced respect to the last one |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1648 int ret; |
22330 | 1649 int i, err; |
1650 uint32_t temp_ref; | |
1651 int pt; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1652 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1653 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, len=%u\n", (uint32_t) len); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1654 if(s->buffer[0] != 0 || s->buffer[1] != 0 || s->buffer[2] != 1 || len<6) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1655 { |
31798
2d9044967a46
Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents:
31623
diff
changeset
|
1656 mp_msg(MSGT_MUXER, MSGL_ERR,"Unknown video format, possibly non-MPEG1/2 stream, len=%zd!\n", len); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1657 return 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1658 } |
22330 | 1659 |
1660 temp_ref = 0; | |
1661 pt = 0; | |
1662 err = 0; | |
1663 i = 0; | |
1664 while(i + 4 < len) | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1665 { // Video (0) Sequence header (b3) or GOP (b8) |
22330 | 1666 if((s->buffer[i] == 0) && (s->buffer[i+1] == 0) && (s->buffer[i+2] == 1)) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1667 { |
22330 | 1668 switch(s->buffer[i+3]) |
14840 | 1669 { |
22330 | 1670 case 0xb3: //sequence |
1671 { | |
1672 if(i + 11 > len) | |
1673 { | |
1674 err=1; | |
1675 break; | |
1676 } | |
1677 fps_ptr = &(s->buffer[i+7]); | |
1678 mp_header_process_sequence_header(&(spriv->picture), &(s->buffer[i+4])); | |
1679 spriv->delta_pts = spriv->nom_delta_pts = parse_fps(spriv->picture.fps); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1680 |
22330 | 1681 spriv->delta_clock = (double) 1/fps; |
1682 //the 2 lines below are needed to handle non-standard frame rates (such as 18) | |
1683 if(! spriv->delta_pts) | |
1684 spriv->delta_pts = spriv->nom_delta_pts = (uint64_t) ((double)27000000.0 * spriv->delta_clock ); | |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1685 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nFPS: %.3f, FRAMETIME: %.3f\n", fps, (double)1/fps); |
22330 | 1686 if(priv->patch_seq) |
1687 patch_seq(priv, &(s->buffer[i])); | |
1688 } | |
1689 break; | |
1690 | |
1691 case 0xb5: | |
1692 if(i + 9 > len) | |
1693 { | |
1694 err = 1; | |
1695 break; | |
1696 } | |
1697 mp_header_process_extension(&(spriv->picture), &(s->buffer[i+4])); | |
24630
dcba95743b2f
1000l, the tff flag was never cleared before being overwritten with the value on bff_mask;
nicodvb
parents:
23637
diff
changeset
|
1698 if(((s->buffer[i+4] & 0xf0) == 0x10)) |
dcba95743b2f
1000l, the tff flag was never cleared before being overwritten with the value on bff_mask;
nicodvb
parents:
23637
diff
changeset
|
1699 se_ptr = &(s->buffer[i+4]); |
22330 | 1700 if(((s->buffer[i+4] & 0xf0) == 0x20)) |
1701 { | |
1702 if(priv->patch_sde) | |
24631
f61c325bca3c
fixed bug introduced with previous commit: patch_panscan() must work in the sequence_display_extension, not on se_ptr
nicodvb
parents:
24630
diff
changeset
|
1703 patch_panscan(priv, &(s->buffer[i+4])); |
22330 | 1704 } |
1705 if((s->buffer[i+4] & 0xf0) == 0x80) | |
1706 { | |
1707 pce_ptr = &(s->buffer[i+4]); | |
1708 } | |
1709 break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1710 |
22330 | 1711 case 0xb8: |
1712 gop_reset = 1; | |
1713 break; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1714 |
22330 | 1715 case 0x00: |
1716 if(i + 5 > len) | |
1717 { | |
1718 err = 1; | |
1719 break; | |
1720 } | |
1721 pt = (s->buffer[i+5] & 0x1c) >> 3; | |
1722 temp_ref = (s->buffer[i+4]<<2)+(s->buffer[i+5]>>6); | |
1723 break; | |
1724 } | |
1725 if(err) break; //something went wrong | |
1726 if(s->buffer[i+3] >= 0x01 && s->buffer[i+3] <= 0xAF) break; //slice, we have already analized what we need | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1727 } |
22330 | 1728 i++; |
1729 } | |
1730 if(err) | |
1731 mp_msg(MSGT_MUXER, MSGL_ERR,"Warning: picture too short or broken!\n"); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1732 |
22332 | 1733 //following 2 lines are workaround: lavf doesn't sync to sequence headers before passing demux_packets |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1734 if(!spriv->nom_delta_pts) |
22332 | 1735 spriv->delta_pts = spriv->nom_delta_pts = parse_fps(fps); |
1736 if(!spriv->vframes) | |
1737 spriv->last_tr = spriv->max_tr = temp_ref; | |
1738 d1 = temp_ref - spriv->last_tr; | |
1739 if(gop_reset) | |
1740 frames_diff = spriv->max_tr + 1 + temp_ref - spriv->last_tr; | |
1741 else | |
1742 { | |
1743 if(d1 < -6) //there's a wraparound | |
1744 frames_diff = spriv->max_tr + 1 + temp_ref - spriv->last_tr; | |
1745 else if(d1 > 6) //there's a wraparound | |
1746 frames_diff = spriv->max_tr + 1 + spriv->last_tr - temp_ref; | |
1747 else if(!d1) //pre-emptive fix against broken sequences | |
1748 frames_diff = 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1749 else |
22332 | 1750 frames_diff = d1; |
1751 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1752 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nLAST: %d, TR: %d, GOP: %d, DIFF: %d, MAX: %d, d1: %d\n", |
22332 | 1753 spriv->last_tr, temp_ref, gop_reset, frames_diff, spriv->max_tr, d1); |
1754 | |
1755 if(temp_ref > spriv->max_tr || gop_reset) | |
1756 spriv->max_tr = temp_ref; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1757 |
22332 | 1758 spriv->last_tr = temp_ref; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1759 if(spriv->picture.mpeg1 == 0) |
22332 | 1760 { |
1761 if(spriv->telecine && pce_ptr) | |
1762 { | |
1763 soft_telecine(priv, spriv, fps_ptr, se_ptr, pce_ptr, frames_diff); | |
1764 spriv->picture.display_time = 100; | |
1765 mp_header_process_extension(&(spriv->picture), pce_ptr); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1766 if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) |
22332 | 1767 spriv->delta_pts = (spriv->nom_delta_pts * spriv->picture.display_time) / 100; |
1768 } | |
1769 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1770 |
22332 | 1771 if(! spriv->vframes) |
1772 frames_diff = 1; | |
1773 | |
1774 spriv->last_dts += spriv->delta_pts; | |
1775 spriv->last_pts += spriv->nom_delta_pts*(frames_diff-1) + spriv->delta_pts; | |
1776 | |
1777 ret = add_frame(spriv, spriv->delta_pts, s->buffer, len, pt, spriv->last_dts, spriv->last_pts); | |
1778 if(ret < 0) | |
1779 { | |
31798
2d9044967a46
Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents:
31623
diff
changeset
|
1780 mp_msg(MSGT_MUXER, MSGL_FATAL, "\r\nPARSE_MPEG12: add_frames(%zd) failed, exit\r\n", len); |
22332 | 1781 return 0; |
1782 } | |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1783 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nVIDEO FRAME, PT: %C, tr: %d, diff: %d, dts: %.3f, pts: %.3f, pdt: %u, gop_reset: %d\r\n", |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1784 ftypes[pt], temp_ref, frames_diff, ((double) spriv->last_dts/27000000.0f), |
22332 | 1785 ((double) spriv->last_pts/27000000.0f), spriv->picture.display_time, gop_reset); |
1786 | |
1787 if(pt == B_FRAME) | |
1788 { | |
1789 int j, n, adj = 0; | |
1790 int64_t diff = spriv->last_dts - spriv->last_pts; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1791 |
22332 | 1792 if(diff != 0) |
1793 { | |
1794 n = spriv->framebuf_used - 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1795 |
22332 | 1796 for(j = n; j >= 0; j--) |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
1797 { |
22332 | 1798 if(spriv->framebuf[j].pts >= spriv->last_pts) |
14894 | 1799 { |
22332 | 1800 spriv->framebuf[j].pts += diff; |
1801 adj++; | |
14894 | 1802 } |
1803 } | |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1804 mp_msg(MSGT_MUXER, MSGL_V, "\r\nResynced B-frame by %d units, DIFF: %"PRId64" (%.3f),[pd]ts=%.3f\r\n", |
22332 | 1805 n, diff, (double) diff/27000000.0f, (double) spriv->last_pts/27000000.0f); |
1806 spriv->last_pts = spriv->last_dts; | |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1807 } |
22332 | 1808 } |
1809 spriv->vframes++; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1810 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1811 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, return %u\n", (uint32_t) len); |
18166
e952e8cdf98e
removed useless (and broken as hell) buffering code from muxer1; buffering constraints will be fully respected when one of the forthcoming patches is applied
nicodvb
parents:
18165
diff
changeset
|
1812 return len; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1813 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1814 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1815 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1816 static uint64_t fix_mp4_frame_duration(muxer_headers_t *vpriv) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1817 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1818 uint64_t mn, md, mx, diff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1819 uint32_t i; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1820 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1821 mn = mx = vpriv->framebuf[0].pts; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1822 for(i = 0; i < 3; i++) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1823 { |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16192
diff
changeset
|
1824 mp_msg(MSGT_DECVIDEO,MSGL_DBG2, "PTS: %"PRIu64"\n", vpriv->framebuf[i].pts); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1825 if(vpriv->framebuf[i].pts < mn) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1826 mn = vpriv->framebuf[i].pts; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1827 if(vpriv->framebuf[i].pts > mx) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1828 mx = vpriv->framebuf[i].pts; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1829 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1830 md = mn; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1831 for(i=0; i<3; i++) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1832 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1833 if((vpriv->framebuf[i].pts > mn) && (vpriv->framebuf[i].pts < mx)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1834 md = vpriv->framebuf[i].pts; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1835 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1836 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1837 if(mx - md > md - mn) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1838 diff = md - mn; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1839 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1840 diff = mx - md; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1841 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1842 mp_msg(MSGT_DECVIDEO,MSGL_DBG2, "MIN: %"PRIu64", mid: %"PRIu64", max: %"PRIu64", diff: %"PRIu64"\n", mn, md, mx, diff); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1843 if(diff > 0) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1844 { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1845 for(i=0; i<3; i++) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1846 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1847 vpriv->framebuf[i].pts += diff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1848 vpriv->framebuf[i].dts += i * diff; |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1849 mp_msg(MSGT_MUXER, MSGL_DBG2, "FIXED_PTS: %.3f, FIXED_DTS: %.3f\n", |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1850 (double) (vpriv->framebuf[i].pts/27000000.0), (double) (vpriv->framebuf[i].dts/27000000.0)); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1851 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1852 return diff; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1853 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1854 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1855 return 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1856 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1857 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1858 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1859 static size_t parse_mpeg4_video(muxer_stream_t *s, muxer_priv_t *priv, muxer_headers_t *vpriv, float fps, size_t len) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1860 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1861 size_t ptr = 0; |
17815 | 1862 int64_t delta_pts=0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1863 uint8_t pt; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1864 int ret; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1865 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1866 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg4_video, len=%u\n", (uint32_t) len); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1867 if(len<6) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1868 { |
31798
2d9044967a46
Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents:
31623
diff
changeset
|
1869 mp_msg(MSGT_MUXER, MSGL_ERR,"Frame too short: %zd, exit!\n", len); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1870 return 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1871 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1872 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1873 pt = 0; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1874 while(ptr < len - 5) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1875 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1876 if(s->buffer[ptr] != 0 || s->buffer[ptr+1] != 0 || s->buffer[ptr+2] != 1) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1877 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1878 ptr++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1879 continue; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1880 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1881 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1882 if(s->buffer[ptr+3] >= 0x20 && s->buffer[ptr+3] <= 0x2f) //VOL |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1883 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1884 mp4_header_process_vol(&(vpriv->picture), &(s->buffer[ptr+4])); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1885 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1886 else if(s->buffer[ptr+3] == 0xb3) //gov |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1887 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1888 //fprintf(stderr, "\nGOV\n"); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1889 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1890 else if(s->buffer[ptr+3] == 0xb6) //vop |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1891 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1892 int32_t delta; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1893 mp4_header_process_vop(&(vpriv->picture), &(s->buffer[ptr+4])); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1894 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1895 delta = vpriv->picture.timeinc_unit - vpriv->last_tr; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1896 if((delta > 0) && (delta > (vpriv->picture.timeinc_resolution/2))) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1897 delta -= vpriv->picture.timeinc_resolution; |
18163
1e4caa08161d
fixed wrong operator precedence in parse_mpeg4_video()
nicodvb
parents:
18162
diff
changeset
|
1898 else if((delta < 0) && (delta < (-(vpriv->picture.timeinc_resolution/2)))) |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1899 delta += vpriv->picture.timeinc_resolution; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1900 |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1901 delta_pts = (27000000 * (int64_t) delta) / vpriv->picture.timeinc_resolution; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1902 //warning, it seems that packed bops can lead to delta == 0 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1903 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1904 pt = vpriv->picture.picture_type + 1; |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1905 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nTYPE: %c, RESOLUTION: %d, TEMP: %d, delta: %d, delta_pts: %"PRId64" = %.3f, delta2: %.3f\n", |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1906 FTYPE(pt), vpriv->picture.timeinc_resolution, vpriv->picture.timeinc_unit, delta, delta_pts, (double) (delta_pts/27000000.0), |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1907 (double) delta / (double) vpriv->picture.timeinc_resolution); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1908 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1909 vpriv->last_tr = vpriv->picture.timeinc_unit; |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1910 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1911 break; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1912 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1913 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1914 ptr++; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1915 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1916 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1917 if(vpriv->vframes) |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1918 { |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1919 vpriv->last_dts += vpriv->frame_duration; |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1920 vpriv->last_pts += delta_pts; |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1921 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1922 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1923 ret = add_frame(vpriv, delta_pts, s->buffer, len, pt, vpriv->last_dts, vpriv->last_pts); |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1924 if(ret < 0) |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1925 { |
31798
2d9044967a46
Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents:
31623
diff
changeset
|
1926 mp_msg(MSGT_MUXER, MSGL_FATAL, "\r\nPARSE_MPEG4: add_frames(%zd) failed, exit\r\n", len); |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1927 return 0; |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1928 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1929 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1930 if(!vpriv->frame_duration && vpriv->framebuf_used == 3) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1931 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1932 vpriv->frame_duration = fix_mp4_frame_duration(vpriv); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1933 if(vpriv->frame_duration) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1934 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1935 vpriv->last_pts += vpriv->frame_duration; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1936 vpriv->last_dts = vpriv->framebuf[vpriv->framebuf_used-1].dts; |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1937 vpriv->delta_clock = ((double) vpriv->frame_duration)/27000000.0; |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1938 mp_msg(MSGT_MUXER, MSGL_INFO, "FRAME DURATION: %"PRIu64" %.3f\n", |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1939 vpriv->frame_duration, (double) (vpriv->frame_duration/27000000.0)); |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1940 vpriv->is_ready = 1; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1941 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1942 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1943 |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
1944 mp_msg(MSGT_MUXER, MSGL_DBG2, "LAST_PTS: %.3f, LAST_DTS: %.3f\n", |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
1945 (double) (vpriv->last_pts/27000000.0), (double) (vpriv->last_dts/27000000.0)); |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1946 |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1947 vpriv->vframes++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1948 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1949 return len; |
8585 | 1950 } |
1951 | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1952 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1953 static int fill_last_frame(muxer_headers_t *spriv, uint8_t *ptr, int len) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1954 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1955 int idx; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1956 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1957 if(!len) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1958 return 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1959 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1960 if(spriv->framebuf_used == 0) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1961 idx = spriv->framebuf_used; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1962 else |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1963 idx = spriv->framebuf_used - 1; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1964 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1965 if(spriv->framebuf[idx].alloc_size < spriv->framebuf[idx].size + len) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1966 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1967 if(spriv->framebuf[idx].size > SIZE_MAX - (size_t)len) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1968 return 0; |
30702 | 1969 spriv->framebuf[idx].buffer = realloc(spriv->framebuf[idx].buffer, spriv->framebuf[idx].size + len); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1970 if(! spriv->framebuf[idx].buffer) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1971 return 0; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1972 spriv->framebuf[idx].alloc_size = spriv->framebuf[idx].size + len; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1973 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1974 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1975 memcpy(&(spriv->framebuf[idx].buffer[spriv->framebuf[idx].size]), ptr, len); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1976 spriv->framebuf[idx].size += len; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1977 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1978 return len; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1979 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1980 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1981 static int add_frame(muxer_headers_t *spriv, uint64_t idur, uint8_t *ptr, int len, uint8_t pt, uint64_t dts, uint64_t pts) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1982 { |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
1983 int idx; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1984 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1985 idx = spriv->framebuf_used; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1986 if(idx >= spriv->framebuf_cnt) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1987 { |
30702 | 1988 spriv->framebuf = realloc_struct(spriv->framebuf, (spriv->framebuf_cnt+1), sizeof(mpeg_frame_t)); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1989 if(spriv->framebuf == NULL) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1990 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1991 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't realloc frame buffer(idx), abort\n"); |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
1992 return -1; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1993 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1994 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1995 spriv->framebuf[spriv->framebuf_cnt].size = 0; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1996 spriv->framebuf[spriv->framebuf_cnt].alloc_size = 0; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1997 spriv->framebuf[spriv->framebuf_cnt].pos = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
1998 |
30702 | 1999 spriv->framebuf[spriv->framebuf_cnt].buffer = malloc(len); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2000 if(spriv->framebuf[spriv->framebuf_cnt].buffer == NULL) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2001 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2002 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't realloc frame buffer(frame), abort\n"); |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2003 return -1; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2004 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2005 spriv->framebuf[spriv->framebuf_cnt].alloc_size = len; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2006 spriv->framebuf_cnt++; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2007 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2008 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2009 if(spriv->framebuf[idx].alloc_size < spriv->framebuf[idx].size + len) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2010 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2011 if(spriv->framebuf[idx].size > SIZE_MAX - (size_t)len) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2012 { |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2013 mp_msg(MSGT_MUXER, MSGL_FATAL, "Size overflow, couldn't realloc frame buffer(frame), abort\n"); |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2014 return -1; |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2015 } |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2016 spriv->framebuf[idx].buffer = realloc(spriv->framebuf[idx].buffer, spriv->framebuf[idx].size + len); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2017 if(spriv->framebuf[idx].buffer == NULL) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2018 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2019 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't realloc frame buffer(frame), abort\n"); |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2020 return -1; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2021 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2022 spriv->framebuf[idx].alloc_size = spriv->framebuf[idx].size + len; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2023 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2024 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2025 memcpy(&(spriv->framebuf[idx].buffer[spriv->framebuf[idx].size]), ptr, len); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2026 spriv->framebuf[idx].size += len; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2027 spriv->framebuf[idx].pos = 0; |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2028 spriv->framebuf[idx].type = pt; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2029 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2030 spriv->framebuf[idx].idur = idur; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2031 spriv->framebuf[idx].dts = dts; |
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2032 spriv->framebuf[idx].pts = pts; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2033 spriv->framebuf_used++; |
23637 | 2034 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nAdded frame, size: %u, idur: %"PRIu64", dts: %"PRIu64", pts: %"PRIu64", used: %u\r\n", len, idur, dts, pts, spriv->framebuf_used); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2035 |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2036 return idx; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2037 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2038 |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2039 static int analyze_mpa(muxer_stream_t *s) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2040 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2041 int i = 0, len, max, chans, srate, spf, layer; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2042 int score[4] = {0, 0, 0, 0}; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2043 |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2044 while(i < s->b_buffer_len + 3) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2045 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2046 if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xE0) == 0xE0)) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2047 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2048 len = mp_get_mp3_header(&(s->b_buffer[i]), &chans, &srate, &spf, &layer, NULL); |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2049 if(len > 0 && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len)) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2050 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2051 score[layer]++; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2052 i += len; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2053 } |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2054 } |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2055 i++; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2056 } |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2057 |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2058 max = 0; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2059 layer = 2; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2060 for(i = 1; i <= 3; i++) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2061 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2062 if(score[i] >= max) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2063 { |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2064 max = score[i]; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2065 layer = i; |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2066 } |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2067 } |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2068 |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2069 return layer; //actual layer with the highest score |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2070 } |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2071 |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2072 static int parse_audio(muxer_stream_t *s, int finalize, unsigned int *nf, double *timer, double delay, int drop) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2073 { |
31799
fe2e3c755706
Use mp_a52_framesize() in all cases; gets rid of liba52 dependency.
diego
parents:
31798
diff
changeset
|
2074 int i, j, len, chans, srate, spf, layer, tot, num, frm_idx; |
18238 | 2075 int finished; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2076 unsigned int frames; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2077 uint64_t idur; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2078 double dur; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2079 muxer_headers_t *spriv = (muxer_headers_t *) s->priv; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2080 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2081 i = tot = frames = 0; |
18238 | 2082 finished = 0; |
2083 while(1) | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2084 { |
18238 | 2085 len = 0; |
2086 switch(s->wf->wFormatTag) | |
2087 { | |
32618
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
2088 default: |
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
2089 mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown audio format, assuming MP2/3, use -fafmttag!\n"); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2090 case AUDIO_MP2: |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2091 case AUDIO_MP3: |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2092 { |
18238 | 2093 if(i + 3 >= s->b_buffer_len) |
2094 { | |
2095 finished = 1; | |
2096 break; | |
2097 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2098 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2099 if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xE0) == 0xE0)) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2100 { |
16162
b5c2254d13f8
set i_bps in demux_audio for WAV and MP3 to avoid division by zero before
reimar
parents:
15947
diff
changeset
|
2101 len = mp_get_mp3_header(&(s->b_buffer[i]), &chans, &srate, &spf, &layer, NULL); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2102 if(len > 0 && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len) |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2103 && layer == spriv->mpa_layer) |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2104 { |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2105 dur = (double) spf / (double) srate; |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
2106 idur = (27000000ULL * spf) / srate; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2107 } |
18238 | 2108 else |
2109 len = 0; | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2110 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2111 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2112 break; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2113 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2114 case AUDIO_A52: |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2115 { |
18238 | 2116 if(i + 6 >= s->b_buffer_len) |
2117 { | |
2118 finished = 1; | |
2119 break; | |
2120 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2121 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2122 if(s->b_buffer[i] == 0x0B && s->b_buffer[i+1] == 0x77) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2123 { |
17493
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2124 srate = 0; |
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2125 len = mp_a52_framesize(&(s->b_buffer[i]), &srate); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2126 if((len > 0) && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len)) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2127 { |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2128 dur = (double) 1536 / (double) srate; |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
2129 idur = (27000000ULL * 1536) / srate; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2130 } |
18238 | 2131 else |
2132 len = 0; | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2133 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2134 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2135 break; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2136 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2137 case AUDIO_AAC1: |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2138 case AUDIO_AAC2: |
32618
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
2139 case AUDIO_AAC3: |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2140 { |
18238 | 2141 if(i + 7 >= s->b_buffer_len) |
2142 { | |
2143 finished = 1; | |
2144 break; | |
2145 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2146 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2147 if(s->b_buffer[i] == 0xFF && ((s->b_buffer[i+1] & 0xF6) == 0xF0)) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2148 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2149 len = aac_parse_frame(&(s->b_buffer[i]), &srate, &num); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2150 if((len > 0) && (srate == s->wf->nSamplesPerSec) && (i + len <= s->b_buffer_len)) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2151 { |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2152 dur = (double) 1024 / (double) srate; |
18161
516d7874450b
changed timebase from 1024 to 300 (no rounding errors with any of the allowed framerates); write scr_extension accordingly. This is the first of a long series of patches to rewrite the muxer
nicodvb
parents:
18044
diff
changeset
|
2153 idur = (27000000ULL * 1024 * num) / srate; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2154 } |
18238 | 2155 else |
2156 len = 0; | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2157 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2158 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2159 } |
18238 | 2160 |
2161 if(finished) | |
2162 break; | |
2163 | |
2164 if(!len) | |
2165 { | |
2166 i++; | |
2167 continue; | |
2168 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2169 |
18238 | 2170 spriv->timer += dur; |
2171 if(spriv->drop_delayed_frames && delay < 0 && spriv->timer <= -delay) | |
2172 { | |
2173 i += len; | |
2174 tot = i; | |
2175 continue; | |
2176 } | |
2177 | |
2178 frames++; | |
2179 fill_last_frame(spriv, &(s->b_buffer[tot]), i - tot); | |
2180 frm_idx = add_frame(spriv, idur, &(s->b_buffer[i]), len, 0, spriv->last_pts, spriv->last_pts); | |
2181 if(frm_idx < 0) | |
2182 { | |
2183 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't add audio frame buffer(frame), abort\n"); | |
2184 goto audio_exit; | |
2185 } | |
2186 for(j = frm_idx; j < spriv->framebuf_cnt; j++) | |
2187 spriv->framebuf[j].pts = spriv->last_pts; | |
2188 spriv->last_pts += idur; | |
2189 | |
2190 i += len; | |
2191 tot = i; | |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2192 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2193 |
18238 | 2194 audio_exit: |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2195 if(tot) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2196 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2197 memmove(s->b_buffer, &(s->b_buffer[tot]), s->b_buffer_len - tot); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2198 s->b_buffer_len -= tot; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2199 s->b_buffer_ptr += tot; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2200 if(s->b_buffer_len > 0) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2201 memmove(s->b_buffer, &(s->b_buffer[s->b_buffer_ptr]), s->b_buffer_len); |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2202 s->b_buffer_ptr = 0; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2203 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2204 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2205 if(finalize) |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2206 { |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2207 frm_idx = add_frame(spriv, 0, s->b_buffer, s->b_buffer_len, 0, spriv->last_pts, spriv->last_pts); |
17298
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2208 if(frm_idx >= 0) |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2209 { |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2210 for(j = frm_idx; j < spriv->framebuf_cnt; j++) |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2211 spriv->framebuf[j].pts = spriv->last_pts; |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2212 } |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2213 } |
104b09de82b9
removed broken frame reording code; unified audio and video frame storing code (in memory, not in the packets); simple workaround to handle non-standard framerate mpeg1/2 video
nicodvb
parents:
17271
diff
changeset
|
2214 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2215 *nf = frames; |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2216 *timer = spriv->timer; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2217 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2218 return tot; |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2219 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2220 |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2221 static void fix_parameters(muxer_stream_t *stream) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2222 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2223 muxer_headers_t *spriv = stream->priv; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2224 muxer_t *muxer = stream->muxer; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2225 muxer_priv_t *priv = muxer->priv; |
24905
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2226 uint32_t stream_format; |
24909
55c96e871198
10l, priv->use_psm can be 1 only if the format is genmpeg2
nicodvb
parents:
24908
diff
changeset
|
2227 int needs_psm = 0; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2228 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2229 if(stream->type == MUXER_TYPE_AUDIO) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2230 { |
24905
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2231 stream_format = stream->wf->wFormatTag; |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2232 spriv->is_ready = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2233 if(conf_abuf_size) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2234 spriv->max_buffer_size = conf_abuf_size*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2235 else |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2236 spriv->max_buffer_size = 4*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2237 if(stream->wf->wFormatTag == AUDIO_A52) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2238 { |
31623
4d4ed6c9039c
Fix some remaining bswap-related compilation issues.
reimar
parents:
31618
diff
changeset
|
2239 stream->ckid = av_be2ne32(0x1bd); |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2240 if(priv->is_genmpeg1 || priv->is_genmpeg2) |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
2241 fix_audio_sys_header(priv, spriv->id, 0xbd, FFMAX(conf_abuf_size, 58)*1024); //only one audio at the moment |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2242 spriv->id = 0xbd; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2243 if(!conf_abuf_size) |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2244 spriv->max_buffer_size = 16*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2245 } |
32618
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
2246 else if(stream->wf->wFormatTag == AUDIO_AAC1 || stream->wf->wFormatTag == AUDIO_AAC2 || |
de37221dff02
Support 0xff as tag for AAC audio and avoid an endless loop for unknown
reimar
parents:
32537
diff
changeset
|
2247 stream->wf->wFormatTag == AUDIO_AAC3) |
24909
55c96e871198
10l, priv->use_psm can be 1 only if the format is genmpeg2
nicodvb
parents:
24908
diff
changeset
|
2248 needs_psm = 1; |
18248
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2249 else if(stream->wf->wFormatTag == AUDIO_MP2 || stream->wf->wFormatTag == AUDIO_MP3) |
595d94213ad0
when muxing mpeg audio streams analyze the first 32 KB of data to obtain the most likely correct layer, otherwise every misdetection during parse_audio() will lead to wrong timestamps and loss of synchrony
nicodvb
parents:
18238
diff
changeset
|
2250 spriv->is_ready = 0; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2251 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2252 else //video |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2253 { |
24905
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2254 stream_format = stream->bih->biCompression; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2255 if(conf_vbuf_size) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2256 spriv->max_buffer_size = conf_vbuf_size*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2257 else |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2258 { |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2259 if(priv->is_dvd) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2260 spriv->max_buffer_size = 232*1024; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2261 else if(priv->is_xsvcd) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2262 spriv->max_buffer_size = 230*1024; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2263 else if(priv->is_xvcd) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2264 spriv->max_buffer_size = 46*1024; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2265 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2266 spriv->max_buffer_size = 232*1024; //no profile => unconstrained :) FIXME!!! |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2267 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2268 |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2269 if(is_mpeg4(stream->bih->biCompression)) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2270 spriv->is_ready = 0; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2271 else |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2272 spriv->is_ready = 1; |
24907
91d30168e22e
moved to fix_parameters() the decision of the necessity of the PSM based on the format of the video stream
nicodvb
parents:
24906
diff
changeset
|
2273 |
91d30168e22e
moved to fix_parameters() the decision of the necessity of the PSM based on the format of the video stream
nicodvb
parents:
24906
diff
changeset
|
2274 if(!is_mpeg1(stream_format) && !is_mpeg2(stream_format)) |
24909
55c96e871198
10l, priv->use_psm can be 1 only if the format is genmpeg2
nicodvb
parents:
24908
diff
changeset
|
2275 needs_psm = 1; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2276 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2277 |
24909
55c96e871198
10l, priv->use_psm can be 1 only if the format is genmpeg2
nicodvb
parents:
24908
diff
changeset
|
2278 if(priv->is_genmpeg2 && needs_psm) |
24905
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2279 { |
24909
55c96e871198
10l, priv->use_psm can be 1 only if the format is genmpeg2
nicodvb
parents:
24908
diff
changeset
|
2280 priv->use_psm = 1; |
24905
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2281 add_to_psm(priv, spriv->id, stream_format); |
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2282 priv->psm_streams_cnt++; |
170dcb44069a
moved to fix_parameters() the code that decides if the PSM is needed
nicodvb
parents:
24904
diff
changeset
|
2283 } |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2284 } |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2285 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2286 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2287 static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts_arg, double pts_arg) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2288 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2289 size_t sz = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2290 uint64_t tmp; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2291 muxer_t *muxer = s->muxer; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2292 muxer_priv_t *priv = (muxer_priv_t *)muxer->priv; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2293 muxer_headers_t *spriv = (muxer_headers_t*) s->priv; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2294 float fps; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2295 uint32_t stream_format, nf; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2296 |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2297 if(s->buffer == NULL || len == -1) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2298 return; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2299 |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2300 if (s->type == MUXER_TYPE_VIDEO) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2301 { // try to recognize frame type... |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2302 fps = (float) s->h.dwRate/ (float) s->h.dwScale; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2303 spriv->type = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2304 stream_format = s->bih->biCompression; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2305 if(! spriv->vframes) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2306 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2307 spriv->last_dts = spriv->last_pts - (uint64_t)(27000000.0f/fps); |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
2308 mp_msg(MSGT_MUXER, MSGL_INFO,"INITV: %.3f, %.3f, fps: %.3f\r\n", (double) spriv->last_pts/27000000.0f, (double) spriv->last_dts/27000000.0f, fps); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2309 } |
21448 | 2310 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2311 if(is_mpeg1(stream_format) || is_mpeg2(stream_format)) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2312 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2313 spriv->is_mpeg12 = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2314 spriv->is_ready = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2315 if(len) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2316 sz = parse_mpeg12_video(s, priv, spriv, fps, len); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2317 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2318 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2319 tmp = (uint64_t) (27000000.0f / fps); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2320 spriv->last_pts += tmp; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2321 spriv->last_dts += tmp; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2322 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2323 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2324 else if(is_mpeg4(stream_format)) |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2325 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2326 spriv->is_mpeg12 = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2327 spriv->telecine = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2328 if(len) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2329 sz = parse_mpeg4_video(s, priv, spriv, fps, len); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2330 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2331 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2332 tmp = (uint64_t) (27000000.0f / fps); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2333 spriv->last_pts += tmp; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2334 spriv->last_dts += tmp; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2335 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2336 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2337 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2338 mp_msg(MSGT_MUXER, MSGL_DBG2,"mpegfile_write_chunk, Video codec=%x, len=%u, mpeg12 returned %u\n", stream_format, (uint32_t) len, (uint32_t) sz); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2339 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2340 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2341 { // MUXER_TYPE_AUDIO |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2342 double fake_timer; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2343 spriv->type = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2344 stream_format = s->wf->wFormatTag; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2345 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2346 if(s->b_buffer_size - s->b_buffer_len < len) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2347 { |
24910 | 2348 void *tmp; |
2349 | |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2350 if(s->b_buffer_len > SIZE_MAX - len) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2351 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2352 mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc, integer overflow\n"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2353 return; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2354 } |
24910 | 2355 tmp = realloc(s->b_buffer, len + s->b_buffer_len); |
2356 if(!tmp) | |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2357 { |
31798
2d9044967a46
Add 'z' length modifier to %d printf format specifiers for size_t arguments.
diego
parents:
31623
diff
changeset
|
2358 mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc %zd bytes\n", len + s->b_buffer_len); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2359 return; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2360 } |
24910 | 2361 s->b_buffer = tmp; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2362 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2363 s->b_buffer_size = len + s->b_buffer_len; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2364 mp_msg(MSGT_MUXER, MSGL_DBG2, "REALLOC(%d) bytes to AUDIO backbuffer\n", s->b_buffer_size); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2365 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2366 memcpy(&(s->b_buffer[s->b_buffer_ptr + s->b_buffer_len]), s->buffer, len); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2367 s->b_buffer_len += len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2368 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2369 if(!spriv->is_ready) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2370 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2371 if(s->b_buffer_len >= 32*1024) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2372 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2373 spriv->mpa_layer = analyze_mpa(s); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2374 spriv->is_ready = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2375 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2376 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2377 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2378 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2379 parse_audio(s, 0, &nf, &fake_timer, priv->init_adelay, priv->drop); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2380 spriv->vframes += nf; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2381 if(! spriv->vframes) |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
2382 mp_msg(MSGT_MUXER, MSGL_INFO, "AINIT: %.3f\r\n", (double) spriv->last_pts/27000000.0f); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2383 } |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2384 } |
8585 | 2385 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2386 flush_buffers(muxer, 0); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2387 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2388 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2389 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2390 static void mpegfile_write_index(muxer_t *muxer) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2391 { |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2392 int i, nf; |
17023
dd5be8f8d16d
buffering in the muxer layer; patch by Corey Hickey (bugfood-ml ad fatooh punctum org) plus small fixes by me
nicodvb
parents:
17012
diff
changeset
|
2393 double fake_timer; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2394 muxer_priv_t *priv = (muxer_priv_t *) muxer->priv; |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2395 |
17065
cf6bfdf41143
Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents:
17023
diff
changeset
|
2396 mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingTrailer); |
cf6bfdf41143
Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents:
17023
diff
changeset
|
2397 |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2398 for(i = 0; i < muxer->avih.dwStreams; i++) |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2399 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2400 if(muxer->streams[i]->type == MUXER_TYPE_AUDIO) |
18181
afaa492536f6
new code to simplify assignment of timestamps; removed temp_ref from mpeg_frame_t and modified add_frame() accordingly; removed no more used drop_delayed_audio() and save_delayed_audio()
nicodvb
parents:
18166
diff
changeset
|
2401 parse_audio(muxer->streams[i], 1, &nf, &fake_timer, priv->init_adelay, priv->drop); |
15947
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2402 } |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2403 while(flush_buffers(muxer, 0) > 0); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2404 flush_buffers(muxer, 1); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2405 if(priv->is_genmpeg1 || priv->is_genmpeg2) |
22917
60498e21115a
10l, the scr must be reset before overwriting the first pack with the correct system header (format=mpeg1|2)
nicodvb
parents:
22909
diff
changeset
|
2406 { |
60498e21115a
10l, the scr must be reset before overwriting the first pack with the correct system header (format=mpeg1|2)
nicodvb
parents:
22909
diff
changeset
|
2407 priv->scr = 0; |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
2408 write_mpeg_pack(muxer, NULL, muxer->stream, 1); //insert fake Nav Packet |
22917
60498e21115a
10l, the scr must be reset before overwriting the first pack with the correct system header (format=mpeg1|2)
nicodvb
parents:
22909
diff
changeset
|
2409 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2410 |
32352
76f94c00a69f
1000l, %lf is not valid format string for printf (only for scanf) and actually
reimar
parents:
31864
diff
changeset
|
2411 mp_msg(MSGT_MUXER, MSGL_INFO, "\nOverhead: %.3f%% (%"PRIu64" / %"PRIu64")\n", 100.0 * (double)priv->headers_size / (double)priv->data_size, priv->headers_size, priv->data_size); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2412 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2413 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2414 static void mpegfile_write_header(muxer_t *muxer) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2415 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2416 muxer_priv_t *priv = (muxer_priv_t*) muxer->priv; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2417 |
17065
cf6bfdf41143
Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents:
17023
diff
changeset
|
2418 mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingHeader); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2419 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2420 priv->headers_cnt++; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2421 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2422 //write the first system header only for generic mpeg1/2 muxes, and only when we have collected all necessary infos |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2423 if(priv->is_genmpeg1 || priv->is_genmpeg2 || ((priv->is_xvcd || priv->is_xsvcd) && (priv->headers_cnt == 1))) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2424 { |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
2425 write_mpeg_pack(muxer, NULL, muxer->stream, 0); |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2426 priv->update_system_header = 0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2427 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2428 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2429 return; |
8585 | 2430 } |
2431 | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2432 static void setup_sys_params(muxer_priv_t *priv) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2433 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2434 if(priv->is_dvd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2435 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2436 int v = (conf_vbuf_size ? conf_vbuf_size : 232); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2437 int a1 = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2438 int a2 = (conf_abuf_size>58 ? conf_abuf_size : 58); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2439 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2440 priv->sys_info.cnt = 4; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2441 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2442 priv->sys_info.streams[0].id = 0xb9; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2443 priv->sys_info.streams[0].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2444 priv->sys_info.streams[0].bufsize = v*1024; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2445 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2446 priv->sys_info.streams[1].id = 0xb8; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2447 priv->sys_info.streams[1].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2448 priv->sys_info.streams[1].bufsize = a1*1024; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2449 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2450 priv->sys_info.streams[2].id = 0xbd; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2451 priv->sys_info.streams[2].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2452 priv->sys_info.streams[2].bufsize = a2*1024; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2453 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2454 priv->sys_info.streams[3].id = 0xbf; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2455 priv->sys_info.streams[3].type = 1; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2456 priv->sys_info.streams[3].bufsize = 2*1024; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2457 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2458 else if(priv->is_xvcd || priv->is_xsvcd) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2459 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2460 int v = (conf_vbuf_size ? conf_vbuf_size : (priv->is_xvcd ? 46: 230)); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2461 int a1 = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2462 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2463 priv->sys_info.cnt = 2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2464 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2465 priv->sys_info.streams[0].id = 0xe0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2466 priv->sys_info.streams[0].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2467 priv->sys_info.streams[0].bufsize = v*1024; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2468 |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2469 priv->sys_info.streams[1].id = 0xc0; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2470 priv->sys_info.streams[1].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2471 priv->sys_info.streams[1].bufsize = a1*1024; |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2472 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2473 else |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2474 priv->sys_info.cnt = 0; |
8585 | 2475 } |
2476 | |
21467 | 2477 /* excerpt from DGPulldown Copyright (C) 2005-2006, Donald Graft */ |
25720
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
2478 static void generate_flags(uint8_t *bff_mask, int source, int target) |
21467 | 2479 { |
2480 unsigned int i, trfp; | |
2481 uint64_t dfl,tfl; | |
21481
95c9f47c1cd8
pre-store in bff_mask the correct or-mask to be saved in the pce (slightly faster)
nicodvb
parents:
21469
diff
changeset
|
2482 unsigned char ormask[4] = {0x0, 0x2, 0x80, 0x82}; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2483 |
21467 | 2484 dfl = (target - source) << 1; |
2485 tfl = source >> 1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2486 |
21467 | 2487 trfp = 0; |
2488 for(i = 0; i < MAX_PATTERN_LENGTH; i++) | |
2489 { | |
2490 tfl += dfl; | |
2491 if(tfl >= source) | |
2492 { | |
2493 tfl -= source; | |
21481
95c9f47c1cd8
pre-store in bff_mask the correct or-mask to be saved in the pce (slightly faster)
nicodvb
parents:
21469
diff
changeset
|
2494 bff_mask[i] = ormask[trfp + 1]; |
21467 | 2495 trfp ^= 2; |
2496 } | |
2497 else | |
21481
95c9f47c1cd8
pre-store in bff_mask the correct or-mask to be saved in the pce (slightly faster)
nicodvb
parents:
21469
diff
changeset
|
2498 bff_mask[i] = ormask[trfp]; |
21467 | 2499 } |
2500 } | |
14753
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2501 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2502 int muxer_init_muxer_mpeg(muxer_t *muxer) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2503 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2504 muxer_priv_t *priv; |
30702 | 2505 priv = calloc(1, sizeof(muxer_priv_t)); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2506 if(priv == NULL) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2507 return 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2508 priv->update_system_header = 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2509 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2510 //calloc() already zero-ed all flags, so we assign only the ones we need |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2511 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2512 if(conf_mux != NULL) |
21467 | 2513 { |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2514 if(! strcasecmp(conf_mux, "mpeg1")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2515 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2516 priv->mux = MUX_MPEG1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2517 priv->packet_size = 2048; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2518 priv->is_genmpeg1 = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2519 priv->muxrate = 1800 * 125; //Constrained parameters |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2520 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2521 else if(! strcasecmp(conf_mux, "dvd")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2522 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2523 priv->mux = MUX_MPEG2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2524 priv->is_dvd = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2525 priv->packet_size = 2048; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2526 priv->muxrate = 10080 * 125; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2527 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2528 else if(! strcasecmp(conf_mux, "xsvcd")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2529 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2530 priv->mux = MUX_MPEG2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2531 priv->is_xsvcd = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2532 priv->packet_size = 2324; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2533 priv->muxrate = 150*2324; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2534 priv->ts_allframes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2535 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2536 else if(! strcasecmp(conf_mux, "xvcd")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2537 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2538 priv->mux = MUX_MPEG1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2539 priv->is_xvcd = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2540 priv->packet_size = 2324; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2541 priv->muxrate = 75*2352; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2542 priv->ts_allframes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2543 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2544 else if(! strcasecmp(conf_mux, "pes1")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2545 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2546 priv->mux = MUX_MPEG1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2547 priv->rawpes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2548 priv->packet_size = 2048; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2549 priv->muxrate = 10080 * 125; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2550 priv->ts_allframes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2551 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2552 else if(! strcasecmp(conf_mux, "pes2")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2553 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2554 priv->mux = MUX_MPEG2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2555 priv->rawpes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2556 priv->packet_size = 2048; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2557 priv->muxrate = 10080 * 125; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2558 priv->ts_allframes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2559 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2560 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2561 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2562 if(strcasecmp(conf_mux, "mpeg2")) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2563 mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown format %s, default to mpeg2\n", conf_mux); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2564 priv->mux = MUX_MPEG2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2565 priv->is_genmpeg2 = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2566 priv->packet_size = 2048; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2567 priv->muxrate = 1800 * 125; //Constrained parameters |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2568 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2569 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2570 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2571 if(conf_ts_allframes) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2572 priv->ts_allframes = 1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2573 if(conf_muxrate > 0) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2574 priv->muxrate = conf_muxrate * 125; // * 1000 / 8 |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2575 if(conf_packet_size) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2576 priv->packet_size = conf_packet_size; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2577 priv->delta_scr = (uint64_t) (90000.0f*300.0f*(double)priv->packet_size/(double)priv->muxrate); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2578 mp_msg(MSGT_MUXER, MSGL_INFO, "PACKET SIZE: %u bytes, deltascr: %"PRIu64"\n", priv->packet_size, priv->delta_scr); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2579 setup_sys_params(priv); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2580 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2581 if(conf_vaspect > 0) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2582 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2583 int asp = (int) (conf_vaspect * 1000.0f); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2584 if(asp >= 1332 && asp <= 1334) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2585 priv->vaspect = ASPECT_4_3; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2586 else if(asp >= 1776 && asp <= 1778) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2587 priv->vaspect = ASPECT_16_9; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2588 else if(asp >= 2209 && asp <= 2211) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2589 priv->vaspect = ASPECT_2_21_1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2590 else if(asp == 1000) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2591 priv->vaspect = ASPECT_1_1; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2592 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2593 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: unrecognized aspect %.3f\n", conf_vaspect); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2594 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2595 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2596 priv->vframerate = 0; // no change |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2597 if(conf_telecine && conf_vframerate > 0) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2598 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2599 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: options 'telecine' and 'vframerate' are mutually exclusive, vframerate disabled\n"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2600 conf_vframerate = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2601 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2602 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2603 if(conf_telecine == TELECINE_FILM2PAL) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2604 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2605 if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2606 conf_telecine_dest = 25; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2607 conf_telecine = TELECINE_DGPULLDOWN; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2608 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2609 else if(conf_telecine == PULLDOWN32) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2610 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2611 if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2612 conf_telecine_dest = 30000.0/1001.0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2613 conf_telecine = TELECINE_DGPULLDOWN; |
21467 | 2614 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2615 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2616 if(conf_telecine_src>0 && conf_telecine_dest>0 && conf_telecine_src < conf_telecine_dest) |
14914 | 2617 { |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2618 int sfps, tfps; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2619 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2620 sfps = (int) (conf_telecine_src * 1001 + 0.5); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2621 tfps = (int) (conf_telecine_dest * 1001 + 0.5); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2622 if(sfps % 2 || tfps % 2) |
21486 | 2623 { |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2624 sfps *= 2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2625 tfps *= 2; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2626 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2627 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2628 if(((tfps - sfps)>>1) > sfps) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2629 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2630 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR! Framerate increment must be <= 1.5, telecining disabled\n"); |
21486 | 2631 conf_telecine = 0; |
2632 } | |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2633 else |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2634 { |
25720
333540254bb4
Put bff_mask into muxer context instead of a global variable.
reimar
parents:
25098
diff
changeset
|
2635 generate_flags(priv->bff_mask, sfps, tfps); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2636 conf_telecine = TELECINE_DGPULLDOWN; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2637 conf_vframerate = conf_telecine_dest; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2638 } |
14914 | 2639 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2640 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2641 if(conf_vframerate) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2642 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2643 int fps; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2644 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2645 fps = (int) (conf_vframerate * 1001 + 0.5); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2646 switch(fps) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2647 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2648 case 24000: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2649 priv->vframerate = FRAMERATE_23976; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2650 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2651 case 24024: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2652 priv->vframerate = FRAMERATE_24; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2653 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2654 case 25025: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2655 priv->vframerate = FRAMERATE_25; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2656 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2657 case 30000: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2658 priv->vframerate = FRAMERATE_2997; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2659 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2660 case 30030: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2661 priv->vframerate = FRAMERATE_30; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2662 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2663 case 50050: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2664 priv->vframerate = FRAMERATE_50; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2665 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2666 case 60000: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2667 priv->vframerate = FRAMERATE_5994; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2668 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2669 case 60060: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2670 priv->vframerate = FRAMERATE_60; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2671 break; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2672 default: |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2673 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2674 mp_msg(MSGT_MUXER, MSGL_ERR, "WRONG FPS: %d/1000, ignoring\n", fps); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2675 if(conf_telecine) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2676 mp_msg(MSGT_MUXER, MSGL_ERR, "DISABLED TELECINING\n"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2677 conf_telecine = 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2678 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2679 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2680 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2681 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2682 priv->vwidth = (uint16_t) conf_vwidth; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2683 priv->vheight = (uint16_t) conf_vheight; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2684 priv->panscan_width = (uint16_t) conf_panscan_width; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2685 priv->panscan_height = (uint16_t) conf_panscan_height; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2686 priv->vbitrate = ((conf_vbitrate) * 10) >> 2; //*1000 / 400 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2687 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2688 if(priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate || priv->panscan_width || priv->panscan_height) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2689 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2690 priv->patch_seq = priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2691 priv->patch_sde = priv->panscan_width || priv->panscan_height; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2692 mp_msg(MSGT_MUXER, MSGL_INFO, "MPEG MUXER, patching"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2693 if(priv->vwidth || priv->vheight) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2694 mp_msg(MSGT_MUXER, MSGL_INFO, " resolution to %dx%d", priv->vwidth, priv->vheight); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2695 if(priv->panscan_width || priv->panscan_height) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2696 mp_msg(MSGT_MUXER, MSGL_INFO, " panscan to to %dx%d", priv->panscan_width, priv->panscan_height); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2697 if(priv->vframerate) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2698 mp_msg(MSGT_MUXER, MSGL_INFO, " framerate to %s fps", framerates[priv->vframerate]); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2699 if(priv->vaspect) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2700 mp_msg(MSGT_MUXER, MSGL_INFO, " aspect ratio to %s", aspect_ratios[priv->vaspect]); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2701 if(priv->vbitrate) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2702 mp_msg(MSGT_MUXER, MSGL_INFO, " bitrate to %u", conf_vbitrate); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2703 mp_msg(MSGT_MUXER, MSGL_INFO, "\n"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2704 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2705 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2706 priv->has_video = priv->has_audio = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2707 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2708 muxer->sysrate = priv->muxrate; // initial muxrate = constrained stream parameter |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2709 priv->scr = muxer->file_end = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2710 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2711 if(conf_init_vdelay && conf_drop) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2712 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2713 mp_msg(MSGT_MUXER, MSGL_ERR, "\nmuxer_mpg, :drop and :vdelay used together are not supported, exiting\n"); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2714 return 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2715 } |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2716 if(conf_init_adelay) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2717 priv->init_adelay = - (double) conf_init_adelay / (double) 1000.0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2718 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2719 priv->drop = conf_drop; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2720 |
30702 | 2721 priv->buff = malloc(priv->packet_size); |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2722 if((priv->buff == NULL)) |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2723 { |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2724 mp_msg(MSGT_MUXER, MSGL_ERR, "\nCouldn't allocate %d bytes, exit\n", priv->packet_size); |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2725 return 0; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2726 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29238
diff
changeset
|
2727 |
24902
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2728 muxer->priv = (void *) priv; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2729 muxer->cont_new_stream = &mpegfile_new_stream; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2730 muxer->cont_write_chunk = &mpegfile_write_chunk; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2731 muxer->cont_write_header = &mpegfile_write_header; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2732 muxer->cont_write_index = &mpegfile_write_index; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2733 muxer->fix_stream_parameters = &fix_parameters; |
c1660ecae8c4
100% cosmetics: reformatted with tabs and symmetric braces and removed useless braces and trailing tabs
nicodvb
parents:
24631
diff
changeset
|
2734 return 1; |
8585 | 2735 } |