Mercurial > mplayer.hg
annotate libmpdemux/muxer_mpeg.c @ 22890:3a738b9f35f1
r22845: Clarify -xineramascreen -2 behaviour
r22900: documented -mpegopts :adelay
r22901: removed unexplainable and escaped trailing spaces from -mpegopts :drop and :tsaf
r22902: restored previous definition of -mpegopts :drop and :tsaf (r22900); they were there for a good reason
author | voroshil |
---|---|
date | Tue, 03 Apr 2007 15:59:35 +0000 |
parents | 2d01760be338 |
children | 94183c81ec0c |
rev | line source |
---|---|
8585 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
4 #include <string.h> | |
5 #include <sys/types.h> | |
6 | |
7 #include "config.h" | |
17012 | 8 #include "version.h" |
9 #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
|
10 #include "help_mp.h" |
8585 | 11 |
12341
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
12 #include "aviheader.h" |
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
13 #include "ms_hdr.h" |
0db4a3a5b01d
removed loader/ dependancy, imported some files from g2, also used patches from Dominik Mierzejewski
alex
parents:
11223
diff
changeset
|
14 |
22605
4d81dbdf46b9
Add explicit location for headers from the stream/ directory.
diego
parents:
22333
diff
changeset
|
15 #include "stream/stream.h" |
8585 | 16 #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
|
17 #include "demuxer.h" |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
18 #include "stheader.h" |
17012 | 19 #include "m_option.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
|
20 #include "mpeg_hdr.h" |
17091 | 21 #include "mp3_hdr.h" |
22 #include "liba52/a52.h" | |
8585 | 23 |
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
|
24 #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
|
25 #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
|
26 #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
|
27 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
28 #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
|
29 #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
|
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
|
31 #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
|
32 #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
|
33 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
34 #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
|
35 #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
|
36 #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
|
37 #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
|
38 #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
|
39 #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
|
40 #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
|
41 //#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
|
42 #define AUDIO_AAC2 0x504D |
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
|
43 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
44 #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
|
45 #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
|
46 #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
|
47 #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
|
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 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
|
50 #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
|
51 #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
|
52 #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
|
53 #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
|
54 #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
|
55 #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
|
56 #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
|
57 |
70c446099f40
new mpeg 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 static char ftypes[] = {'?', 'I', 'P', 'B'}; |
70c446099f40
new mpeg 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 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
|
60 |
21467 | 61 #define MAX_PATTERN_LENGTH 2000000 |
62 static unsigned char bff_mask[MAX_PATTERN_LENGTH]; //2 million frames are enough | |
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
|
63 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
64 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
|
65 "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
|
66 }; |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
69 "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
|
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 |
70c446099f40
new mpeg 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 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
|
73 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
|
74 static uint32_t conf_muxrate = 0; //kb/s |
15083 | 75 static float conf_vaspect = 0; |
14914 | 76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 static int conf_abuf_size = 0; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
83 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
|
84 static int conf_drop = 0; |
14840 | 85 static int conf_telecine = 0; |
21467 | 86 static float conf_telecine_src = 0; |
87 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
|
88 |
70c446099f40
new mpeg 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 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
|
90 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
|
91 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
|
92 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
|
93 }; |
8585 | 94 |
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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 } 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
|
103 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 } 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
|
111 } 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
|
112 |
70c446099f40
new mpeg 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 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
|
114 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
|
115 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 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
|
117 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
|
118 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
|
119 } 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
|
120 } 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
|
121 |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
122 typedef struct { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
123 int size; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
124 uint64_t dts; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
125 } 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
|
126 |
70c446099f40
new mpeg 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 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
|
128 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
|
129 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
|
130 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
|
131 } 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
|
132 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 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
|
137 uint16_t packet_size; |
21141 | 138 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
|
139 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
|
140 off_t headers_size, data_size; |
18200 | 141 uint64_t scr; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
142 uint64_t delta_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
|
143 uint32_t muxrate; |
18200 | 144 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
|
145 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
|
146 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
|
147 int drop; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
148 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
149 //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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 int psm_streams_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
|
155 } 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
|
156 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
158 typedef struct { |
18200 | 159 int has_pts, has_dts, pes_is_aligned, type, min_pes_hlen, psm_fixed; |
22328 | 160 int delay_rff; |
18200 | 161 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
|
162 uint32_t buffer_size; |
18200 | 163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 int max_tr; |
17301
bbf5438d646a
removed previously forgotten reording options/flags
nicodvb
parents:
17298
diff
changeset
|
170 uint8_t id, is_mpeg12, telecine; |
14840 | 171 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
|
172 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
|
173 mp_mpeg_header_t picture; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
174 int max_buffer_size; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
175 buffer_track_t *buffer_track; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
176 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
|
177 unsigned char *pack; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
178 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
|
179 int frames; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
180 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
|
181 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
|
182 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
|
183 } 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
|
184 |
17600
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
185 #define PULLDOWN32 1 |
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
186 #define TELECINE_FILM2PAL 2 |
21467 | 187 #define TELECINE_DGPULLDOWN 3 |
8585 | 188 |
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
|
189 m_option_t mpegopts_conf[] = { |
22243
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
190 {"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
|
191 {"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
|
192 {"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
|
193 {"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
|
194 {"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
|
195 {"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
|
196 {"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
|
197 {"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
|
198 {"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
|
199 {"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
|
200 {"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
|
201 {"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
|
202 {"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
|
203 {"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
|
204 {"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
|
205 {"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
|
206 {"telecine", &conf_telecine, CONF_TYPE_FLAG, M_OPT_GLOBAL, 0, PULLDOWN32, NULL}, |
e085c85b29af
all options must be GLOBAL; patch by Trent Piepho (xyzzy speakeasy org)
nicodvb
parents:
22142
diff
changeset
|
207 {"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
|
208 {"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
|
209 {"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
|
210 {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
|
211 }; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
212 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
213 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
|
214 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
215 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
|
216 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
217 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
|
218 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
219 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
|
220 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
221 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
|
222 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
|
223 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
|
224 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
225 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
226 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
227 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
228 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
|
229 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
230 return ( |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
231 (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
|
232 (x == mmioFOURCC('m','p','g','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
|
233 (x == mmioFOURCC('M','P','G','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
|
234 ); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
235 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
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 return ( |
70c446099f40
new mpeg 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 (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
|
241 (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
|
242 (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
|
243 (x == mmioFOURCC('m','p','e','g')) || |
70c446099f40
new mpeg 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 (x == mmioFOURCC('M','P','E','G')) |
70c446099f40
new mpeg 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 ); |
70c446099f40
new mpeg 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 } |
8585 | 247 |
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
|
248 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
|
249 { |
70c446099f40
new mpeg 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 return ( |
70c446099f40
new mpeg 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 (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
|
252 (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
|
253 (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
|
254 (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
|
255 (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
|
256 (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
|
257 (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
|
258 (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
|
259 (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
|
260 (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
|
261 (x == mmioFOURCC('F', 'M','P','4')) || |
18164 | 262 (x == mmioFOURCC('f', 'm','p','4')) || |
263 (x == mmioFOURCC('D', 'X','5','0')) || | |
264 (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
|
265 ); |
70c446099f40
new mpeg 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 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 //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
|
269 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
|
270 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
271 uint32_t i, j, CRCTab[256], 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
|
272 |
70c446099f40
new mpeg 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 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
|
274 { |
70c446099f40
new mpeg 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 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
|
276 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
|
277 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
|
278 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
282 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
|
283 crc = (crc << 8) ^ CRCTab[((crc >> 24) ^ buff[i]) & 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
|
284 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
285 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
|
286 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
287 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
288 |
70c446099f40
new mpeg 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 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
|
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 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
|
292 |
70c446099f40
new mpeg 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 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
|
294 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
|
295 priv->psm_info.streams[i].format = 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
|
296 |
70c446099f40
new mpeg 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 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 priv->psm_info.streams[i].type = 0x03; |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
305 else if(format == AUDIO_AAC1 || format == AUDIO_AAC2) |
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
306 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
|
307 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
|
308 priv->psm_info.streams[i].type = 0x81; |
70c446099f40
new mpeg 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 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
|
311 memcpy((char*) &(priv->psm_info.streams[i].format), "AC-3", 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
|
312 |
70c446099f40
new mpeg 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 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
|
314 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
315 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
318 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
319 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
|
320 uint16_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
|
321 |
70c446099f40
new mpeg 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 tmp = (mpeg_frame_t *) calloc(num, sizeof(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
|
323 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
|
324 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
|
325 |
70c446099f40
new mpeg 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 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
|
327 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
328 tmp[i].buffer = (uint8_t *) calloc(1, 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 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
|
334 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
|
335 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
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 |
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
|
340 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 | 341 |
342 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
|
343 muxer_priv_t *priv = (muxer_priv_t*) muxer->priv; |
8585 | 344 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
|
345 muxer_headers_t *spriv; |
8585 | 346 |
9007
12fc55eb3373
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
347 if (!muxer) return NULL; |
8585 | 348 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
|
349 mp_msg(MSGT_MUXER, MSGL_ERR, "Too many streams! increase MUXER_MAX_STREAMS !\n"); |
8585 | 350 return NULL; |
351 } | |
352 switch (type) { | |
353 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
|
354 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
|
355 mp_msg(MSGT_MUXER, MSGL_ERR, "MPEG files can't contain more than 16 video streams!\n"); |
8585 | 356 return NULL; |
357 } | |
358 break; | |
359 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
|
360 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
|
361 mp_msg(MSGT_MUXER, MSGL_ERR, "MPEG files can't contain more than 16 audio streams!\n"); |
8585 | 362 return NULL; |
363 } | |
364 break; | |
365 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
|
366 mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown stream type!\n"); |
8585 | 367 return NULL; |
368 } | |
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
|
369 s = (muxer_stream_t*) calloc(1, sizeof(muxer_stream_t)); |
8585 | 370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 s->b_buffer_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
|
376 s->priv = (muxer_headers_t*) 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 spriv->track_len = 4096; |
8585 | 388 muxer->streams[muxer->avih.dwStreams]=s; |
389 s->type=type; | |
390 s->id=muxer->avih.dwStreams; | |
9007
12fc55eb3373
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
391 s->muxer=muxer; |
22879 | 392 |
11223 | 393 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
|
394 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
|
395 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
|
396 if(conf_init_vdelay) { |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
397 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
|
398 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
|
399 } |
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
|
400 spriv->id = 0xe0 + muxer->num_videos; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
401 s->ckid = be2me_32 (0x100 + 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
|
402 if(priv->is_genmpeg1 || priv->is_genmpeg2) { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
403 int v = (conf_vbuf_size ? conf_vbuf_size*1024 : |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
404 (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
|
405 int n = priv->sys_info.cnt; |
22879 | 406 |
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
|
407 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
|
408 priv->sys_info.streams[n].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
409 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
|
410 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
|
411 } |
11223 | 412 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
|
413 priv->has_video++; |
11223 | 414 s->h.fccType=streamtypeVIDEO; |
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 } |
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
|
423 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
|
424 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
|
425 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
|
426 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
|
427 spriv->min_pes_hlen = 22; |
14840 | 428 spriv->telecine = conf_telecine; |
11223 | 429 mp_msg (MSGT_MUXER, MSGL_DBG2, "Added video stream %d, ckid=%X\n", muxer->num_videos, s->ckid); |
430 } 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 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
|
437 spriv->id = 0xc0 + 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
|
438 s->ckid = be2me_32 (0x100 + 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
|
439 if(priv->is_genmpeg1 || priv->is_genmpeg2) { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
440 int a1 = (conf_abuf_size ? conf_abuf_size*1024 : |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
441 (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
|
442 int n = priv->sys_info.cnt; |
22879 | 443 |
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
|
444 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
|
445 priv->sys_info.streams[n].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
446 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
|
447 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
|
448 } |
70c446099f40
new mpeg 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 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
|
450 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
|
451 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
|
452 spriv->min_pes_hlen = 17; |
22879 | 453 |
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 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
|
455 priv->has_audio++; |
11223 | 456 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
|
457 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
458 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 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
|
464 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
465 |
11223 | 466 mp_msg (MSGT_MUXER, MSGL_DBG2, "Added audio stream %d, ckid=%X\n", s->id - muxer->num_videos + 1, s->ckid); |
467 } | |
8585 | 468 muxer->avih.dwStreams++; |
469 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
|
470 |
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
|
471 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
|
472 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
|
473 { |
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
|
474 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
|
475 { |
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
|
476 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
|
477 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
|
478 free(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
|
479 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
|
480 free(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
|
481 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
|
482 } |
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
|
483 if(s->b_buffer) |
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
|
484 free(s->b_buffer); |
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
|
485 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
|
486 } |
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
|
487 return NULL; |
8585 | 488 } |
489 | |
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
|
490 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
|
491 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
|
492 b[0] = mod | ((ts >> 29) & 0xf) | 1; |
8585 | 493 b[1] = (ts >> 22) & 0xff; |
494 b[2] = ((ts >> 14) & 0xff) | 1; | |
495 b[3] = (ts >> 7) & 0xff; | |
496 b[4] = ((ts << 1) & 0xff) | 1; | |
497 } | |
498 | |
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
|
499 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
500 static void write_mpeg_rate(int type, unsigned char *b, unsigned int rate) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
501 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
502 rate = (rate+49) / 50; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
503 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
504 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
|
505 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
506 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
|
507 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
|
508 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
|
509 } |
70c446099f40
new mpeg 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 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
|
511 { |
70c446099f40
new mpeg 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] = (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
|
513 b[1] = (rate >> 6) & 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
|
514 b[2] = ((rate & 0x3f) << 2) | 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
|
515 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
516 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
517 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
518 |
70c446099f40
new mpeg 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 static void write_mpeg_std(unsigned char *b, unsigned int size, unsigned int type, uint8_t 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
|
520 { |
70c446099f40
new mpeg 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 //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
|
522 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
|
523 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
|
524 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
|
525 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
|
526 |
70c446099f40
new mpeg 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 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
|
528 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
|
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 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
|
531 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
|
532 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
534 static void write_mpeg2_scr(unsigned char *b, uint64_t ts) |
70c446099f40
new mpeg 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 { |
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
|
536 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
|
537 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
|
538 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
|
539 ts &= 0x1FFFFFFFFULL; //33 bits |
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 t1 = (ts >> 30) & 0x7;; |
70c446099f40
new mpeg 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 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
|
542 t3 = ts & 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
|
543 |
70c446099f40
new mpeg 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 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
|
545 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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
554 { |
70c446099f40
new mpeg 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 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
|
556 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
|
557 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
558 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
|
559 *(uint32_t *)buff = be2me_32(PACK_HEADER_START_CODE); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
560 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
|
561 { |
70c446099f40
new mpeg 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 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
|
563 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
|
564 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
|
565 } |
70c446099f40
new mpeg 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 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
|
567 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
568 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
|
569 write_mpeg_rate(priv->mux, &buff[10], 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
|
570 buff[13] = 0xf8; //5 bits reserved + 3 set to 0 to indicate 0 stuffing bytes |
70c446099f40
new mpeg 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 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
|
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 |
70c446099f40
new mpeg 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 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
|
575 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
577 |
70c446099f40
new mpeg 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 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
|
579 { |
70c446099f40
new mpeg 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 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
|
581 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
|
582 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
|
583 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
|
584 |
70c446099f40
new mpeg 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 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
|
586 *(uint32_t *)(&buff[len]) = be2me_32(SYSTEM_HEADER_START_CODE); |
70c446099f40
new mpeg 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 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
|
588 *(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
|
589 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
|
590 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
|
591 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
|
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 buff[len++] = 0x4 | (priv->is_xvcd ? 1 : 0); //1 audio stream bound, no fixed, CSPS only for 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
|
594 buff[len++] = 0xe1; //system_audio_lock, system_video_lock, marker, 1 video stream bound |
70c446099f40
new mpeg 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 buff[len++] = ((priv->mux == MUX_MPEG1) ? 0xff : 0x7f); //in mpeg2 there's the packet rate restriction |
70c446099f40
new mpeg 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 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
|
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 buff[len++] = priv->sys_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
|
601 write_mpeg_std(&buff[len], priv->sys_info.streams[i].bufsize, priv->sys_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
|
602 (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
|
603 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
|
604 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
606 *(uint16_t *)(&buff[4]) = be2me_16(len - 6); // length field fixed |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
609 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
612 { |
70c446099f40
new mpeg 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 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
|
614 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
|
615 uint16_t dlen; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
616 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
|
617 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
|
618 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
619 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
|
620 *(uint32_t *)(&buff[len]) = be2me_32(PSM_START_CODE); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
621 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
|
622 *(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
|
623 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
|
624 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
|
625 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
|
626 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
|
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 *(uint16_t *)(&buff[len]) = 0; //length of the es descriptors |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
629 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
|
630 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
631 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
|
632 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
|
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 if( |
70c446099f40
new mpeg 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 (priv->psm_info.streams[i].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
|
636 (priv->psm_info.streams[i].id >= 0xe0 && priv->psm_info.streams[i].id <= 0xef) || |
70c446099f40
new mpeg 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 (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
|
638 ) |
70c446099f40
new mpeg 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 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
640 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
|
641 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
|
642 buff[len++] = 0; //len of descriptor upper ... |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
643 buff[len++] = 6; //... lower |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
645 //registration descriptor |
70c446099f40
new mpeg 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 buff[len++] = 0x5; //tag |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
647 buff[len++] = 4; //length: 4 bytes |
70c446099f40
new mpeg 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 memcpy(&(buff[len]), (char*) &(priv->psm_info.streams[i].format), 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
|
649 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
|
650 dlen += 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
|
651 } |
70c446099f40
new mpeg 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 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
653 *(uint16_t *)(&buff[10]) = be2me_16(dlen); //length of the es descriptors |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
655 *(uint16_t *)(&buff[4]) = be2me_16(len - 6 + 4); // length field fixed, including size of CRC32 |
70c446099f40
new mpeg 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 |
19637 | 657 *(uint32_t *)(&buff[len]) = be2me_32(CalcCRC32(buff, 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
|
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 len += 4; //for 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
|
660 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
661 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
|
662 } |
70c446099f40
new mpeg 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 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
|
665 { |
70c446099f40
new mpeg 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 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
|
667 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
668 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
|
669 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
|
670 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
|
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 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
|
673 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
|
674 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
675 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
|
676 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
677 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
|
678 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
679 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
|
680 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
|
681 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
684 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
685 write_mpeg_std(&buff[len], h->buffer_size, h->type, 0x40); // 01 is pes1 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
|
686 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
|
687 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
688 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
689 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
|
690 { |
70c446099f40
new mpeg 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 buff[len] = (h->pes_is_aligned ? 0x84 : 0x80); //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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 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
|
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 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
701 { |
70c446099f40
new mpeg 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 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
|
703 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
|
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 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
|
706 { |
70c446099f40
new mpeg 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 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
|
708 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
|
709 } |
70c446099f40
new mpeg 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 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
711 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
|
712 { |
70c446099f40
new mpeg 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 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
|
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 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
|
716 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
|
717 } |
70c446099f40
new mpeg 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 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 if(mux_type == 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
|
722 { |
70c446099f40
new mpeg 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 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
|
724 { |
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
|
725 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
|
726 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
|
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_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
|
729 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
|
730 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
733 { |
70c446099f40
new mpeg 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 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
|
735 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
|
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 } |
70c446099f40
new mpeg 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 *((uint16_t*) &buff[4]) = be2me_16(len + plen - 6); //fix pes 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
|
740 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
|
741 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
745 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
746 //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
|
747 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
|
748 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
|
749 buff[3] = 0xbe; |
70c446099f40
new mpeg 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 *((uint16_t*) &buff[4]) = be2me_16(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
|
751 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
|
752 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
753 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
754 static void write_psm_block(muxer_t *muxer, stream_t *stream) |
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
|
755 { |
70c446099f40
new mpeg 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 uint16_t 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
|
757 muxer_priv_t *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
|
758 uint8_t *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
|
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 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
|
761 offset += write_mpeg_psm(muxer, &buff[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
|
762 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
|
763 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
|
764 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
765 //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
|
766 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
|
767 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
|
768 } |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
769 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
|
770 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
|
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 |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
775 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
776 // 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
|
777 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
|
778 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
779 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
|
780 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
|
781 *(uint32_t *)(&buff[len]) = be2me_32(PES_PRIVATE2); |
70c446099f40
new mpeg 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 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
|
783 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
|
784 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
|
785 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
|
786 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
|
787 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
788 *(uint32_t *)(&buff[len]) = be2me_32(PES_PRIVATE2); |
70c446099f40
new mpeg 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++] = 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
|
792 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
|
793 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
|
794 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
795 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
|
796 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
799 { |
70c446099f40
new mpeg 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 uint32_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
|
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 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
|
803 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
|
804 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
|
805 len = 9; |
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
|
806 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
807 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
|
808 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
809 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
|
810 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
|
811 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
|
812 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
813 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
|
814 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
|
815 |
70c446099f40
new mpeg 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 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
|
817 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
818 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
|
819 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
|
820 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
|
821 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
|
822 } |
70c446099f40
new mpeg 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 |
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
|
824 //len = max(h->min_pes_hlen, 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
|
825 |
70c446099f40
new mpeg 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 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
|
827 } |
70c446099f40
new mpeg 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 |
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
|
829 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
830 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
|
831 { |
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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
837 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
|
838 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
|
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 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
|
841 { |
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
|
842 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
|
843 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
|
844 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
|
845 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
|
846 buff[offset + 3] = 0xb9; |
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 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
848 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
|
849 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
|
850 } |
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
|
851 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
|
852 { |
70c446099f40
new mpeg 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 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
|
854 offset += write_mpeg_system_header(muxer, &buff[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
|
855 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
856 //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
|
857 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
858 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
|
859 offset += write_nav_pack(&buff[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
|
860 |
70c446099f40
new mpeg 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 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
|
862 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
|
863 { |
70c446099f40
new mpeg 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 //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
|
865 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
|
866 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
|
867 } |
70c446099f40
new mpeg 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 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
869 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
|
870 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
|
871 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
|
872 muxer->movi_end += 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
|
873 |
70c446099f40
new mpeg 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 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
|
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 } |
70c446099f40
new mpeg 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 |
22142
84f95595f31f
Fix a few gcc warnings, approved by Diego and Reimar.
rathann
parents:
21660
diff
changeset
|
878 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
|
879 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
880 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
|
881 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
882 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
|
883 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
884 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
|
885 if(!tmp) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
886 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
887 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
|
888 return; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
889 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
890 spriv->buffer_track = tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
891 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
|
892 spriv->track_len += 16; |
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 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
895 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
|
896 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
|
897 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
898 spriv->track_pos++; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
899 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
900 |
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
|
901 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
|
902 { |
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
|
903 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
|
904 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
|
905 |
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
|
906 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
|
907 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
|
908 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
|
909 { |
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
|
910 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
|
911 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
|
912 } |
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 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
|
914 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
|
915 } |
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 |
18197 | 917 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
|
918 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
919 mpeg_frame_t tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
920 int i; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
921 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
922 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
|
923 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
924 tmp = spriv->framebuf[i - n]; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
925 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
|
926 spriv->framebuf[i] = tmp; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
927 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
928 spriv->framebuf_used -= n; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
929 } |
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
|
930 |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
931 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
|
932 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
933 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
|
934 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
|
935 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
936 n = len = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
937 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
|
938 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
|
939 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
940 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
|
941 return len; |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
942 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
|
943 len += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
944 frpos += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
945 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
|
946 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
947 frpos = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
948 n++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
949 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
950 } |
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(len < psize && !finalize) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
953 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
954 return len; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
955 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
956 |
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
|
957 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
|
958 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
959 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
|
960 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
|
961 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
|
962 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
963 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
|
964 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
965 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
966 spts = spriv->pts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
967 sdts = spriv->dts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
968 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
|
969 ret = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
970 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
|
971 i = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
972 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
973 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
974 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
|
975 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
976 if(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
|
977 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
|
978 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
979 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
|
980 |
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
|
981 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
|
982 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
|
983 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
984 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
985 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
|
986 goto fail; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
987 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
988 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
|
989 threshold = 5; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
990 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
991 threshold = 10; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
992 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
993 //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
|
994 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
|
995 i = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
996 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
997 i = -1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
998 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
999 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1000 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1001 if(i > -1) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1002 { |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
1003 dpts = FFMAX(spriv->last_saved_pts, spriv->framebuf[i].pts) - |
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
1004 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
|
1005 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
|
1006 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1007 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
|
1008 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
|
1009 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
|
1010 ret = 1; |
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 if(ret) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1013 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1014 *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
|
1015 *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
|
1016 if(*dts == *pts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1017 *dts = 0; |
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 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1020 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1021 fail: |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1022 spriv->pts = spts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1023 spriv->dts = sdts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1024 return 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 |
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
|
1027 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
|
1028 { |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1029 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
|
1030 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
|
1031 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
|
1032 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1033 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
|
1034 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
|
1035 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
|
1036 |
21141 | 1037 if(priv->rawpes) |
1038 pack_hlen = 0; | |
1039 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
|
1040 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
|
1041 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
|
1042 pack_hlen = 14; |
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 |
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 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
|
1045 { |
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->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
|
1047 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
|
1048 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1049 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
|
1050 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
|
1051 } |
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 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
|
1053 |
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 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
|
1055 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1056 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
|
1057 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
|
1058 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
|
1059 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
|
1060 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
|
1061 |
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 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
|
1063 target -= 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
|
1064 |
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 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
|
1066 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
|
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->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
|
1069 //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
|
1070 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
|
1071 //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
|
1072 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
|
1073 } |
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 |
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 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
|
1076 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
|
1077 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
|
1078 { |
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 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
|
1080 { |
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 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
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 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
|
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 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
|
1090 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
|
1091 { |
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 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
|
1093 { |
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 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
|
1095 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
|
1096 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
|
1097 } |
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 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
|
1099 { |
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 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
|
1101 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
|
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 } |
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 } |
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 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
|
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 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
|
1109 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
|
1110 |
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 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
|
1112 } |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1113 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1114 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
|
1115 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1116 //try to fill a packet as much as possible |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1117 //spriv->pack_offset is the start position inited to 0 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1118 //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
|
1119 //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
|
1120 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
|
1121 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
|
1122 int len, m, n, dvd_pack = 0; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1123 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
|
1124 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
|
1125 |
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
|
1126 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
|
1127 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1128 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
|
1129 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1130 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
|
1131 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1132 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1133 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1134 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
|
1135 { |
21141 | 1136 if(priv->rawpes) |
1137 spriv->pack_offset = 0; | |
1138 else | |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1139 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
|
1140 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
|
1141 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1142 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
|
1143 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
|
1144 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1145 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
|
1146 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
|
1147 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
|
1148 spriv->frames = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1149 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
|
1150 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1151 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1152 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
|
1153 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1154 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
|
1155 //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
|
1156 //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
|
1157 //NB pts and dts can only be relative to the first frame beginning in this pack |
21141 | 1158 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
|
1159 { |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1160 if(s->type == MUXER_TYPE_VIDEO) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1161 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
|
1162 else |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1163 bufsize = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1164 spriv->buffer_size = bufsize*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
1165 } |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1166 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1167 if(priv->is_dvd && 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
|
1168 && 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
|
1169 dvd_pack = 1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1170 |
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
|
1171 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
|
1172 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1173 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
|
1174 return 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1175 } |
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
|
1176 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
|
1177 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
|
1178 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
|
1179 spriv->last_saved_pts = p.pts; |
18192
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1180 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1181 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
|
1182 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
|
1183 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1184 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
|
1185 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1186 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
|
1187 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
|
1188 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
|
1189 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
|
1190 else |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1191 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
|
1192 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1193 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1194 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
|
1195 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1196 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1197 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1198 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
|
1199 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1200 if((spriv->dts && priv->scr >= spriv->dts) || priv->scr >= spriv->pts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1201 mp_msg(MSGT_MUXER, MSGL_ERR, "\r\nERROR: scr %.3lf, dts %.3lf, pts %.3lf\r\n", (double) priv->scr/27000000.0, (double) spriv->dts/27000000.0, (double) spriv->pts/27000000.0); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1202 else if(priv->scr + 63000*300 < spriv->dts) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1203 mp_msg(MSGT_MUXER, MSGL_INFO, "\r\nWARNING>: scr %.3lf, dts %.3lf, pts %.3lf, diff %.3lf, piff %.3lf\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); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1204 } |
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 n = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1207 len = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1208 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1209 frm = spriv->framebuf; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1210 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
|
1211 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1212 if(!frm->pos) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1213 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1214 //since iframes must always be aligned at block boundaries exit when we find the |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1215 //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
|
1216 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
|
1217 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1218 break; |
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 spriv->frames++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1221 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
|
1222 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1223 |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
21486
diff
changeset
|
1224 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
|
1225 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
|
1226 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1227 len += m; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1228 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
|
1229 frm->pos += m; |
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 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
|
1232 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1233 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
|
1234 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
|
1235 n++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1236 frm++; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1237 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1238 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1239 |
21141 | 1240 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
|
1241 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
|
1242 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1243 spriv->size += len; |
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 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
|
1246 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
|
1247 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1248 if(n > 0) |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1249 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
|
1250 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1251 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
|
1252 if(spriv->track_bufsize > spriv->max_buffer_size) |
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
|
1253 mp_msg(MSGT_MUXER, MSGL_ERR, "\r\nBUFFER OVERFLOW: %d > %d, pts: %llu\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
|
1254 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1255 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
|
1256 fix_a52_headers(s); |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1257 |
21141 | 1258 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
|
1259 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1260 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
|
1261 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
|
1262 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
|
1263 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1264 |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
1265 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
|
1266 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1267 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
|
1268 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
|
1269 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
|
1270 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1271 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
|
1272 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
|
1273 spriv->frames = 0; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1274 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1275 return len; |
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 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1278 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
|
1279 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1280 int i, ndts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1281 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
|
1282 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
|
1283 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
|
1284 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
|
1285 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1286 ndts = -1; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1287 |
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
|
1288 //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
|
1289 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
|
1290 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1291 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
|
1292 |
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
|
1293 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
|
1294 get_packet_stats(priv, muxer->streams[i], &p, 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
|
1295 |
19cd9e0f8ac4
prevent buffer overflow in the STD; simplified fill_packet() (moving part of the code to get_packet_stats())
nicodvb
parents:
18558
diff
changeset
|
1296 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
|
1297 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
|
1298 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
|
1299 continue; |
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 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
|
1302 { |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1303 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
|
1304 ndts = i; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1305 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1306 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1307 |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1308 return ndts; |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1309 } |
0b77e66a7d32
introduced new functions to handle pack writing and interleaving strategy (will soon replace current ones)
nicodvb
parents:
18187
diff
changeset
|
1310 |
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
|
1311 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
|
1312 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1313 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
|
1314 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1315 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
|
1316 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
|
1317 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
|
1318 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1319 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1320 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
|
1321 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1322 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
|
1323 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
|
1324 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
|
1325 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1326 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1327 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
|
1328 buf[7] = (buf[7] & 0x0f) | (priv->vaspect << 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
|
1329 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1330 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
|
1331 buf[7] = (buf[7] & 0xf0) | priv->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
|
1332 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1333 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
|
1334 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1335 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
|
1336 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
|
1337 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
|
1338 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1339 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1340 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1341 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
|
1342 { //patches sequence display extension (display_horizontal_size and display_vertical_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
|
1343 //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
|
1344 int offset = 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
|
1345 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1346 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
|
1347 offset += 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
|
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->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
|
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[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
|
1352 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
|
1353 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1355 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
|
1356 |
70c446099f40
new mpeg 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 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
|
1358 { |
70c446099f40
new mpeg 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[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
|
1360 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
|
1361 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
|
1362 } |
70c446099f40
new mpeg 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 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1365 |
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
|
1366 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
|
1367 { |
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
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 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
|
1373 |
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
|
1374 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
|
1375 |
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
|
1376 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
|
1377 { |
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
|
1378 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
|
1379 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
|
1380 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
|
1381 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
|
1382 } |
70c446099f40
new mpeg 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 |
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
|
1384 mp_msg(MSGT_MUXER, MSGL_DBG2, "UPDATE SCR TO %"PRIu64" (%.3lf)\n", priv->scr, (double) (priv->scr/27000000.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
|
1385 |
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
|
1386 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
|
1387 { |
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
|
1388 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
|
1389 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
|
1390 |
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
|
1391 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
|
1392 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
|
1393 { |
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
|
1394 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
|
1395 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
|
1396 } |
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
|
1397 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
|
1398 { |
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
|
1399 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
|
1400 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
|
1401 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
|
1402 priv->delta_scr = (uint64_t) (d * 27000000.0f); |
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
|
1403 mp_msg(MSGT_MUXER, MSGL_INFO, "\r\nBUFFER UNDEFLOW at stream %d, raising muxrate to %d kb/s, delta_scr: %llu\r\n", i, muxer->sysrate/125, 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
|
1404 spriv->track_bufsize = 0; |
21448 | 1405 } |
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
|
1406 |
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
|
1407 if(j > 0) |
21448 | 1408 { |
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
|
1409 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
|
1410 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
|
1411 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
|
1412 spriv->buffer_track[j].size = 0; |
21448 | 1413 } |
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
|
1414 |
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
|
1415 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
|
1416 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
|
1417 } |
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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1420 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1421 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
|
1422 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1423 int n, found = 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
|
1424 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1425 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
|
1426 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1427 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
|
1428 //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
|
1429 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
|
1430 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
|
1431 { |
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
|
1432 mp_msg(MSGT_MUXER, MSGL_DBG2, "CALC_FRAMES, n=%d, type=%c, pts=%.3lf\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
|
1433 if(n+1 < vpriv->framebuf_used) |
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
|
1434 mp_msg(MSGT_MUXER, MSGL_DBG2, "n+1=%d, type=%c, pts=%.3lf\n", n+1, FTYPE(vpriv->framebuf[n+1].type), (double)vpriv->framebuf[n+1].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
|
1435 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1436 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
|
1437 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1438 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
|
1439 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1440 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
|
1441 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
|
1442 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1443 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1444 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1445 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
|
1446 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1447 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1448 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1449 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
|
1450 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
|
1451 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
|
1452 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
|
1453 } |
70c446099f40
new mpeg 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 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
|
1456 { |
18199 | 1457 int i, n, found; |
1458 int skip_cnt; | |
1459 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
|
1460 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
|
1461 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
|
1462 muxer_priv_t *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
|
1463 |
70c446099f40
new mpeg 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 /* |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1465 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
|
1466 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
|
1467 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
|
1468 */ |
70c446099f40
new mpeg 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 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
|
1470 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
|
1471 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
|
1472 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
|
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 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
|
1475 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
|
1476 { |
70c446099f40
new mpeg 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 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
|
1478 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
|
1479 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
|
1480 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
|
1481 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
|
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 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
|
1484 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
|
1485 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
1488 { |
70c446099f40
new mpeg 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 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
|
1490 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
|
1491 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1493 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
|
1494 { |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1495 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
|
1496 |
70c446099f40
new mpeg 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 vpriv = (muxer_headers_t*) vs->priv; |
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
|
1498 |
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
|
1499 if(as != NULL) apriv = (muxer_headers_t*) as->priv; |
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
|
1500 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
|
1501 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1502 apriv = (muxer_headers_t*) as->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
|
1503 init_delay = vpriv->framebuf[0].pts - vpriv->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
|
1504 |
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
|
1505 for(i = 0; i < apriv->framebuf_cnt; i++) |
21448 | 1506 { |
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
|
1507 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
|
1508 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
|
1509 } |
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
|
1510 apriv->last_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
|
1511 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nINITIAL VIDEO DELAY: %.3lf, currAPTS: %.3lf\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
|
1512 } |
70c446099f40
new mpeg 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 |
70c446099f40
new mpeg 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 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
|
1515 vpriv->buffer_size = (conf_vbuf_size ? conf_vbuf_size : (priv->is_xvcd ? 46 : 230))*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
|
1516 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1517 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
|
1518 skip_cnt = 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 |
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
|
1520 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
|
1521 { |
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
|
1522 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
|
1523 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
|
1524 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
|
1525 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
|
1526 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
|
1527 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
|
1528 |
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
|
1529 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
|
1530 { |
5ccb2b837b1c
if no stream could be muxed flush_buffers() returns 0: prevents while(1) stall at the end
nicodvb
parents:
20153
diff
changeset
|
1531 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
|
1532 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
|
1533 } |
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 } |
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
|
1535 } |
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
|
1536 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1537 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
|
1538 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
|
1539 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1540 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1541 |
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
|
1542 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
|
1543 { |
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
|
1544 // 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
|
1545 int d = (int)(fps*1001+0.5); |
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
|
1546 |
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
|
1547 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
|
1548 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1549 |
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
|
1550 |
21467 | 1551 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 | 1552 { |
17814 | 1553 if(! pce_ptr) |
1554 return 0; | |
14840 | 1555 if(fps_ptr != NULL) |
1556 { | |
21484 | 1557 *fps_ptr = (*fps_ptr & 0xf0) | priv->vframerate; |
1558 vpriv->nom_delta_pts = parse_fps(conf_vframerate); | |
14840 | 1559 } |
1560 | |
1561 //in pce_ptr starting from bit 0 bit 24 is tff, bit 30 is rff, | |
1562 if(pce_ptr[3] & 0x2) | |
1563 { | |
1564 mp_msg(MSGT_MUXER, MSGL_ERR, "\nERROR! RFF bit is already set, disabling telecining\n"); | |
1565 vpriv->telecine = 0; | |
1566 return 0; | |
1567 } | |
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
|
1568 |
14894 | 1569 vpriv->picture.progressive_sequence = 0; |
1570 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
|
1571 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
|
1572 se_ptr[1] &= 0xf7; |
14840 | 1573 |
21484 | 1574 pce_ptr[3] = (pce_ptr[3] & 0xfd) | bff_mask[vpriv->display_frame % MAX_PATTERN_LENGTH]; |
17600
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
1575 pce_ptr[4] |= 0x80; //sets progressive frame |
6fa1149d8c80
experimental film2pal and ntsc2pal soft teleciner
nicodvb
parents:
17591
diff
changeset
|
1576 |
21467 | 1577 vpriv->display_frame += n; |
14840 | 1578 if(! vpriv->vframes) |
21483 | 1579 mp_msg(MSGT_MUXER, MSGL_INFO, "\nENABLED SOFT TELECINING, FPS=%.3f\n",conf_vframerate); |
14840 | 1580 |
1581 return 1; | |
1582 } | |
1583 | |
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
|
1584 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
|
1585 { |
14840 | 1586 uint8_t *fps_ptr = NULL; //pointer to the fps byte in the sequence header |
1587 uint8_t *se_ptr = NULL; //pointer to sequence extension | |
1588 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
|
1589 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
|
1590 int ret; |
22330 | 1591 int i, err; |
1592 uint32_t temp_ref; | |
1593 int pt; | |
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 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1595 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg12_video, len=%u\n", (uint32_t) 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
|
1596 if(s->buffer[0] != 0 || s->buffer[1] != 0 || s->buffer[2] != 1 || 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
|
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 mp_msg(MSGT_MUXER, MSGL_ERR,"Unknown video format, possibly non-MPEG1/2 stream, len=%d!\n", 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
|
1599 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
|
1600 } |
22330 | 1601 |
1602 temp_ref = 0; | |
1603 pt = 0; | |
1604 err = 0; | |
1605 i = 0; | |
1606 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
|
1607 { // Video (0) Sequence header (b3) or GOP (b8) |
22330 | 1608 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
|
1609 { |
22330 | 1610 switch(s->buffer[i+3]) |
14840 | 1611 { |
22330 | 1612 case 0xb3: //sequence |
1613 { | |
1614 if(i + 11 > len) | |
1615 { | |
1616 err=1; | |
1617 break; | |
1618 } | |
1619 fps_ptr = &(s->buffer[i+7]); | |
1620 mp_header_process_sequence_header(&(spriv->picture), &(s->buffer[i+4])); | |
1621 spriv->delta_pts = spriv->nom_delta_pts = parse_fps(spriv->picture.fps); | |
1622 | |
1623 spriv->delta_clock = (double) 1/fps; | |
1624 //the 2 lines below are needed to handle non-standard frame rates (such as 18) | |
1625 if(! spriv->delta_pts) | |
1626 spriv->delta_pts = spriv->nom_delta_pts = (uint64_t) ((double)27000000.0 * spriv->delta_clock ); | |
1627 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nFPS: %.3f, FRAMETIME: %.3lf\n", fps, (double)1/fps); | |
1628 if(priv->patch_seq) | |
1629 patch_seq(priv, &(s->buffer[i])); | |
1630 } | |
1631 break; | |
1632 | |
1633 case 0xb5: | |
1634 if(i + 9 > len) | |
1635 { | |
1636 err = 1; | |
1637 break; | |
1638 } | |
1639 mp_header_process_extension(&(spriv->picture), &(s->buffer[i+4])); | |
1640 if(((s->buffer[i+4] & 0xf0) == 0x20)) | |
1641 { | |
1642 se_ptr = &(s->buffer[i+4]); | |
1643 if(priv->patch_sde) | |
1644 patch_panscan(priv, se_ptr); | |
1645 } | |
1646 if((s->buffer[i+4] & 0xf0) == 0x80) | |
1647 { | |
1648 pce_ptr = &(s->buffer[i+4]); | |
1649 } | |
1650 break; | |
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
|
1651 |
22330 | 1652 case 0xb8: |
1653 gop_reset = 1; | |
1654 break; | |
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 |
22330 | 1656 case 0x00: |
1657 if(i + 5 > len) | |
1658 { | |
1659 err = 1; | |
1660 break; | |
1661 } | |
1662 pt = (s->buffer[i+5] & 0x1c) >> 3; | |
1663 temp_ref = (s->buffer[i+4]<<2)+(s->buffer[i+5]>>6); | |
1664 break; | |
1665 } | |
1666 if(err) break; //something went wrong | |
1667 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
|
1668 } |
22330 | 1669 i++; |
1670 } | |
1671 if(err) | |
1672 mp_msg(MSGT_MUXER, MSGL_ERR,"Warning: picture too short or broken!\n"); | |
1673 | |
22332 | 1674 //following 2 lines are workaround: lavf doesn't sync to sequence headers before passing demux_packets |
1675 if(!spriv->nom_delta_pts) | |
1676 spriv->delta_pts = spriv->nom_delta_pts = parse_fps(fps); | |
1677 if(!spriv->vframes) | |
1678 spriv->last_tr = spriv->max_tr = temp_ref; | |
1679 d1 = temp_ref - spriv->last_tr; | |
1680 if(gop_reset) | |
1681 frames_diff = spriv->max_tr + 1 + temp_ref - spriv->last_tr; | |
1682 else | |
1683 { | |
1684 if(d1 < -6) //there's a wraparound | |
1685 frames_diff = spriv->max_tr + 1 + temp_ref - spriv->last_tr; | |
1686 else if(d1 > 6) //there's a wraparound | |
1687 frames_diff = spriv->max_tr + 1 + spriv->last_tr - temp_ref; | |
1688 else if(!d1) //pre-emptive fix against broken sequences | |
1689 frames_diff = 1; | |
1690 else | |
1691 frames_diff = d1; | |
1692 } | |
1693 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nLAST: %d, TR: %d, GOP: %d, DIFF: %d, MAX: %d, d1: %d\n", | |
1694 spriv->last_tr, temp_ref, gop_reset, frames_diff, spriv->max_tr, d1); | |
1695 | |
1696 if(temp_ref > spriv->max_tr || gop_reset) | |
1697 spriv->max_tr = temp_ref; | |
1698 | |
1699 spriv->last_tr = temp_ref; | |
1700 if(spriv->picture.mpeg1 == 0) | |
1701 { | |
1702 if(spriv->telecine && pce_ptr) | |
1703 { | |
1704 soft_telecine(priv, spriv, fps_ptr, se_ptr, pce_ptr, frames_diff); | |
1705 spriv->picture.display_time = 100; | |
1706 mp_header_process_extension(&(spriv->picture), pce_ptr); | |
1707 if(spriv->picture.display_time >= 50 && spriv->picture.display_time <= 300) | |
1708 spriv->delta_pts = (spriv->nom_delta_pts * spriv->picture.display_time) / 100; | |
1709 } | |
1710 } | |
1711 | |
1712 if(! spriv->vframes) | |
1713 frames_diff = 1; | |
1714 | |
1715 spriv->last_dts += spriv->delta_pts; | |
1716 spriv->last_pts += spriv->nom_delta_pts*(frames_diff-1) + spriv->delta_pts; | |
1717 | |
1718 ret = add_frame(spriv, spriv->delta_pts, s->buffer, len, pt, spriv->last_dts, spriv->last_pts); | |
1719 if(ret < 0) | |
1720 { | |
1721 mp_msg(MSGT_MUXER, MSGL_FATAL, "\r\nPARSE_MPEG12: add_frames(%d) failed, exit\r\n", len); | |
1722 return 0; | |
1723 } | |
1724 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nVIDEO FRAME, PT: %C, tr: %d, diff: %d, dts: %.3lf, pts: %.3lf, pdt: %u, gop_reset: %d\r\n", | |
1725 ftypes[pt], temp_ref, frames_diff, ((double) spriv->last_dts/27000000.0f), | |
1726 ((double) spriv->last_pts/27000000.0f), spriv->picture.display_time, gop_reset); | |
1727 | |
1728 if(pt == B_FRAME) | |
1729 { | |
1730 int j, n, adj = 0; | |
1731 int64_t diff = spriv->last_dts - spriv->last_pts; | |
1732 | |
1733 if(diff != 0) | |
1734 { | |
1735 n = spriv->framebuf_used - 1; | |
1736 | |
1737 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
|
1738 { |
22332 | 1739 if(spriv->framebuf[j].pts >= spriv->last_pts) |
14894 | 1740 { |
22332 | 1741 spriv->framebuf[j].pts += diff; |
1742 adj++; | |
14894 | 1743 } |
1744 } | |
22332 | 1745 mp_msg(MSGT_MUXER, MSGL_V, "\r\nResynced B-frame by %d units, DIFF: %lld (%.3lf),[pd]ts=%.3lf\r\n", |
1746 n, diff, (double) diff/27000000.0f, (double) spriv->last_pts/27000000.0f); | |
1747 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
|
1748 } |
22332 | 1749 } |
1750 spriv->vframes++; | |
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
|
1751 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1752 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
|
1753 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
|
1754 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1755 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1756 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1757 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
|
1758 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1759 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
|
1760 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
|
1761 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1762 mn = mx = vpriv->framebuf[0].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
|
1763 for(i = 0; i < 3; 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
|
1764 { |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16192
diff
changeset
|
1765 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
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1771 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
|
1772 for(i=0; i<3; 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
|
1773 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1774 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
|
1775 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
|
1776 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1777 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1778 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
|
1779 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
|
1780 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
|
1781 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
|
1782 |
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
|
1783 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
|
1784 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
|
1785 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1786 for(i=0; i<3; 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
|
1787 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1788 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
|
1789 vpriv->framebuf[i].dts += i * diff; |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1790 mp_msg(MSGT_MUXER, MSGL_DBG2, "FIXED_PTS: %.3lf, FIXED_DTS: %.3lf\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
|
1791 (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
|
1792 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1793 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
|
1794 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1795 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
|
1796 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
|
1797 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1798 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1799 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1800 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
|
1801 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1802 size_t ptr = 0; |
17815 | 1803 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
|
1804 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
|
1805 int ret; |
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
|
1806 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1807 mp_msg(MSGT_MUXER, MSGL_DBG2,"parse_mpeg4_video, len=%u\n", (uint32_t) 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
|
1808 if(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
|
1809 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1810 mp_msg(MSGT_MUXER, MSGL_ERR,"Frame too short: %d, exit!\n", 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
|
1811 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
|
1812 } |
70c446099f40
new mpeg 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 |
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
|
1814 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
|
1815 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
|
1816 { |
70c446099f40
new mpeg 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 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
|
1818 { |
70c446099f40
new mpeg 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 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
|
1820 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
|
1821 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1822 |
70c446099f40
new mpeg 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 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
|
1824 { |
70c446099f40
new mpeg 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 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
|
1826 } |
70c446099f40
new mpeg 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 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
|
1828 { |
70c446099f40
new mpeg 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 //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
|
1830 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1831 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
|
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 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
|
1834 mp4_header_process_vop(&(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
|
1835 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1836 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
|
1837 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
|
1838 delta -= vpriv->picture.timeinc_resolution; |
18163
1e4caa08161d
fixed wrong operator precedence in parse_mpeg4_video()
nicodvb
parents:
18162
diff
changeset
|
1839 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
|
1840 delta += vpriv->picture.timeinc_resolution; |
70c446099f40
new mpeg 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 |
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
|
1842 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
|
1843 //warning, it seems that packed bops can lead to delta == 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
|
1844 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1845 pt = vpriv->picture.picture_type + 1; |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16192
diff
changeset
|
1846 mp_msg(MSGT_MUXER, MSGL_DBG2, "\nTYPE: %c, RESOLUTION: %d, TEMP: %d, delta: %d, delta_pts: %"PRId64" = %.3lf, delta2: %.3lf\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
|
1847 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
|
1848 (double) delta / (double) vpriv->picture.timeinc_resolution); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1849 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1850 vpriv->last_tr = vpriv->picture.timeinc_unit; |
70c446099f40
new mpeg 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 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
|
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 |
70c446099f40
new mpeg 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 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
|
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 |
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
|
1858 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
|
1859 { |
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
|
1860 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
|
1861 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
|
1862 } |
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 |
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 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
|
1865 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
|
1866 { |
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
|
1867 mp_msg(MSGT_MUXER, MSGL_FATAL, "\r\nPARSE_MPEG4: add_frames(%d) 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
|
1868 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
|
1869 } |
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 |
70c446099f40
new mpeg 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 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
|
1872 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
1873 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
|
1874 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
|
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 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
|
1877 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
|
1878 vpriv->delta_clock = ((double) vpriv->frame_duration)/27000000.0; |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16192
diff
changeset
|
1879 mp_msg(MSGT_MUXER, MSGL_INFO, "FRAME DURATION: %"PRIu64" %.3lf\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
|
1880 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
|
1881 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
|
1882 } |
70c446099f40
new mpeg 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 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
1885 mp_msg(MSGT_MUXER, MSGL_DBG2, "LAST_PTS: %.3lf, LAST_DTS: %.3lf\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
|
1886 (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
|
1887 |
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
|
1888 vpriv->vframes++; |
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
|
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 return len; |
8585 | 1891 } |
1892 | |
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
|
1893 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1894 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
|
1895 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1896 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
|
1897 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1898 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
|
1899 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
|
1900 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1901 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
|
1902 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
|
1903 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
|
1904 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
|
1905 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1906 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
|
1907 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1908 if(spriv->framebuf[idx].size > SIZE_MAX - (size_t)len) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1909 return 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
|
1910 spriv->framebuf[idx].buffer = (uint8_t*) 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
|
1911 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
|
1912 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
|
1913 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
|
1914 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1915 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1916 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
|
1917 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
|
1918 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1919 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
|
1920 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1921 |
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
|
1922 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
|
1923 { |
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
|
1924 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
|
1925 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1926 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
|
1927 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
|
1928 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1929 spriv->framebuf = (mpeg_frame_t*) 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
|
1930 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
|
1931 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1932 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
|
1933 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
|
1934 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1935 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1936 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
|
1937 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
|
1938 spriv->framebuf[spriv->framebuf_cnt].pos = 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
|
1939 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1940 spriv->framebuf[spriv->framebuf_cnt].buffer = (uint8_t*) malloc(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
|
1941 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
|
1942 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1943 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
|
1944 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
|
1945 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1946 spriv->framebuf[spriv->framebuf_cnt].alloc_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
|
1947 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
|
1948 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1949 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
1950 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
|
1951 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1952 if(spriv->framebuf[idx].size > SIZE_MAX - (size_t)len) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1953 { |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1954 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
|
1955 return -1; |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
1956 } |
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
|
1957 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
|
1958 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
|
1959 { |
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 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
|
1961 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
|
1962 } |
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 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
|
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 |
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 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
|
1967 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
|
1968 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
|
1969 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
|
1970 |
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 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
|
1972 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
|
1973 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
|
1974 spriv->framebuf_used++; |
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
|
1975 mp_msg(MSGT_MUXER, MSGL_DBG2, "\r\nAdded frame, size: %u, idur: %llu, dts: %llu, pts: %llu, 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
|
1976 |
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
|
1977 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
|
1978 } |
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 |
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
|
1980 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
|
1981 { |
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
|
1982 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
|
1983 int score[4] = {0, 0, 0, 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
|
1984 |
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
|
1985 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
|
1986 { |
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
|
1987 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
|
1988 { |
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
|
1989 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
|
1990 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
|
1991 { |
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
|
1992 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
|
1993 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
|
1994 } |
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
|
1995 } |
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
|
1996 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
|
1997 } |
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
|
1998 |
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
|
1999 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
|
2000 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
|
2001 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
|
2002 { |
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
|
2003 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
|
2004 { |
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
|
2005 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
|
2006 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
|
2007 } |
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
|
2008 } |
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
|
2009 |
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
|
2010 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
|
2011 } |
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
|
2012 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2013 extern int aac_parse_frame(uint8_t *buf, int *srate, int *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
|
2014 |
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
|
2015 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
|
2016 { |
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
|
2017 int i, j, len, chans, srate, spf, layer, dummy, tot, num, frm_idx; |
18238 | 2018 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
|
2019 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
|
2020 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
|
2021 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
|
2022 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
|
2023 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2024 i = tot = frames = 0; |
18238 | 2025 finished = 0; |
2026 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
|
2027 { |
18238 | 2028 len = 0; |
2029 switch(s->wf->wFormatTag) | |
2030 { | |
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
|
2031 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
|
2032 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
|
2033 { |
18238 | 2034 if(i + 3 >= s->b_buffer_len) |
2035 { | |
2036 finished = 1; | |
2037 break; | |
2038 } | |
2039 | |
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
|
2040 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
|
2041 { |
16162
b5c2254d13f8
set i_bps in demux_audio for WAV and MP3 to avoid division by zero before
reimar
parents:
15947
diff
changeset
|
2042 len = mp_get_mp3_header(&(s->b_buffer[i]), &chans, &srate, &spf, &layer, NULL); |
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
|
2043 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
|
2044 && 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
|
2045 { |
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
|
2046 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
|
2047 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
|
2048 } |
18238 | 2049 else |
2050 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
|
2051 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2052 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2053 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
|
2054 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2055 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
|
2056 { |
18238 | 2057 if(i + 6 >= s->b_buffer_len) |
2058 { | |
2059 finished = 1; | |
2060 break; | |
2061 } | |
2062 | |
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
|
2063 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
|
2064 { |
17493
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2065 srate = 0; |
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2066 #ifdef USE_LIBA52 |
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
|
2067 len = a52_syncinfo(&(s->b_buffer[i]), &dummy, &srate, &dummy); |
17493
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2068 #else |
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2069 len = mp_a52_framesize(&(s->b_buffer[i]), &srate); |
f71e678e6216
use mp_a52_framesize() when liba52 is not available
nicodvb
parents:
17487
diff
changeset
|
2070 #endif |
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 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
|
2072 { |
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
|
2073 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
|
2074 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
|
2075 } |
18238 | 2076 else |
2077 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
|
2078 } |
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 } |
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 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
|
2081 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2082 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
|
2083 case AUDIO_AAC2: |
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 if(i + 7 >= s->b_buffer_len) |
2086 { | |
2087 finished = 1; | |
2088 break; | |
2089 } | |
2090 | |
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
|
2091 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
|
2092 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2093 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
|
2094 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
|
2095 { |
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
|
2096 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
|
2097 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
|
2098 } |
18238 | 2099 else |
2100 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
|
2101 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2102 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2103 } |
18238 | 2104 |
2105 if(finished) | |
2106 break; | |
2107 | |
2108 if(!len) | |
2109 { | |
2110 i++; | |
2111 continue; | |
2112 } | |
2113 | |
2114 spriv->timer += dur; | |
2115 if(spriv->drop_delayed_frames && delay < 0 && spriv->timer <= -delay) | |
2116 { | |
2117 i += len; | |
2118 tot = i; | |
2119 continue; | |
2120 } | |
2121 | |
2122 frames++; | |
2123 fill_last_frame(spriv, &(s->b_buffer[tot]), i - tot); | |
2124 frm_idx = add_frame(spriv, idur, &(s->b_buffer[i]), len, 0, spriv->last_pts, spriv->last_pts); | |
2125 if(frm_idx < 0) | |
2126 { | |
2127 mp_msg(MSGT_MUXER, MSGL_FATAL, "Couldn't add audio frame buffer(frame), abort\n"); | |
2128 goto audio_exit; | |
2129 } | |
2130 for(j = frm_idx; j < spriv->framebuf_cnt; j++) | |
2131 spriv->framebuf[j].pts = spriv->last_pts; | |
2132 spriv->last_pts += idur; | |
2133 | |
2134 i += len; | |
2135 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
|
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 |
18238 | 2138 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
|
2139 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
|
2140 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2141 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
|
2142 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
|
2143 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
|
2144 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
|
2145 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
|
2146 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
|
2147 } |
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 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
|
2150 { |
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
|
2151 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
|
2152 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
|
2153 { |
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
|
2154 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
|
2155 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
|
2156 } |
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
|
2157 } |
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
|
2158 |
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
|
2159 *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
|
2160 *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
|
2161 |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2162 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
|
2163 } |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2164 |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2165 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
|
2166 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2167 muxer_headers_t *spriv = stream->priv; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2168 muxer_t *muxer = stream->muxer; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2169 muxer_priv_t *priv = muxer->priv; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2170 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2171 if(stream->type == MUXER_TYPE_AUDIO) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2172 { |
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
|
2173 spriv->is_ready = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2174 if(conf_abuf_size) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2175 spriv->max_buffer_size = conf_abuf_size*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2176 else |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2177 spriv->max_buffer_size = 4*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2178 if(stream->wf->wFormatTag == AUDIO_A52) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2179 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2180 stream->ckid = be2me_32 (0x1bd); |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2181 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
|
2182 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
|
2183 spriv->id = 0xbd; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2184 if(!conf_abuf_size) |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2185 spriv->max_buffer_size = 16*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2186 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2187 else if(stream->wf->wFormatTag == AUDIO_AAC1 || stream->wf->wFormatTag == AUDIO_AAC2) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2188 { |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2189 priv->use_psm = 1; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2190 } |
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
|
2191 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
|
2192 spriv->is_ready = 0; |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2193 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2194 else //video |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2195 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2196 if(conf_vbuf_size) |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2197 spriv->max_buffer_size = conf_vbuf_size*1024; |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2198 else |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2199 { |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2200 if(priv->is_dvd) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2201 spriv->max_buffer_size = 232*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2202 else if(priv->is_xsvcd) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2203 spriv->max_buffer_size = 230*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2204 else if(priv->is_xvcd) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2205 spriv->max_buffer_size = 46*1024; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2206 else |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2207 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
|
2208 } |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2209 |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2210 if(is_mpeg4(stream->bih->biCompression)) |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2211 spriv->is_ready = 0; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2212 else |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2213 spriv->is_ready = 1; |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2214 } |
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2215 } |
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
|
2216 |
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 |
17487
fa17424b4c7b
change muxer_write_chunk() so that pts/dts _could_ be passed from encoder to muxer
michael
parents:
17366
diff
changeset
|
2218 static void mpegfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags, double dts_arg, double pts_arg){ |
18249 | 2219 size_t sz = 0; |
2220 uint64_t tmp; | |
9007
12fc55eb3373
Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents:
8585
diff
changeset
|
2221 muxer_t *muxer = s->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
|
2222 muxer_priv_t *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
|
2223 muxer_headers_t *spriv = (muxer_headers_t*) s->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
|
2224 float fps; |
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
|
2225 uint32_t stream_format, nf; |
21448 | 2226 |
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
|
2227 if(s->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
|
2228 return; |
18044
b693d92e6210
workaround to prevent segfault: when using -ve lavc with b-frames write_chunk(1st video frame) gets called with len=-1UL; -1ULl to whomever calls me that way
nicodvb
parents:
17818
diff
changeset
|
2229 if(len == -1) |
b693d92e6210
workaround to prevent segfault: when using -ve lavc with b-frames write_chunk(1st video frame) gets called with len=-1UL; -1ULl to whomever calls me that way
nicodvb
parents:
17818
diff
changeset
|
2230 return; |
21448 | 2231 |
8585 | 2232 if (s->type == MUXER_TYPE_VIDEO) { // try to recognize frame 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
|
2233 fps = (float) s->h.dwRate/ (float) s->h.dwScale; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2234 spriv->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
|
2235 stream_format = s->bih->biCompression; |
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
|
2236 if(! spriv->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
|
2237 { |
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
|
2238 spriv->last_dts = spriv->last_pts - (uint64_t)(27000000.0f/fps); |
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
|
2239 mp_msg(MSGT_MUXER, MSGL_INFO,"INITV: %.3lf, %.3lf, fps: %.3f\r\n", (double) spriv->last_pts/27000000.0f, (double) spriv->last_dts/27000000.0f, fps); |
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
|
2240 } |
8585 | 2241 |
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
|
2242 if(is_mpeg1(stream_format) || is_mpeg2(stream_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
|
2243 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2244 spriv->is_mpeg12 = 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
|
2245 spriv->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
|
2246 if(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
|
2247 sz = parse_mpeg12_video(s, priv, spriv, fps, 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
|
2248 else { |
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
|
2249 tmp = (uint64_t) (27000000.0f / 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
|
2250 spriv->last_pts += 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
|
2251 spriv->last_dts += tmp; |
8585 | 2252 } |
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
|
2253 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2254 else if(is_mpeg4(stream_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
|
2255 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2256 spriv->is_mpeg12 = 0; |
14840 | 2257 spriv->telecine = 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
|
2258 if(spriv->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
|
2259 priv->use_psm = 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
|
2260 if(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
|
2261 sz = parse_mpeg4_video(s, priv, spriv, fps, 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
|
2262 else { |
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
|
2263 tmp = (uint64_t) (27000000.0f / 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
|
2264 spriv->last_pts += 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
|
2265 spriv->last_dts += tmp; |
8585 | 2266 } |
2267 } | |
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
|
2268 |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
2269 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); |
8585 | 2270 } else { // MUXER_TYPE_AUDIO |
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
|
2271 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
|
2272 spriv->type = 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
|
2273 stream_format = s->wf->wFormatTag; |
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
|
2274 |
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
|
2275 if(s->b_buffer_size - s->b_buffer_len < 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
|
2276 { |
18558
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2277 if(s->b_buffer_len > SIZE_MAX - len) |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2278 { |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2279 mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc, integer overflow\n"); |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2280 return; |
4928dd61f136
Fix potential integer overflows in memory allocation.
rtogni
parents:
18249
diff
changeset
|
2281 } |
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
|
2282 s->b_buffer = realloc(s->b_buffer, len + s->b_buffer_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
|
2283 if(s->b_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
|
2284 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2285 mp_msg(MSGT_MUXER, MSGL_FATAL, "\nFATAL! couldn't realloc %d bytes\n", len + s->b_buffer_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
|
2286 return; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2287 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2288 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2289 s->b_buffer_size = len + s->b_buffer_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
|
2290 mp_msg(MSGT_MUXER, MSGL_DBG2, "REALLOC(%d) bytes to AUDIO backbuffer\n", s->b_buffer_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
|
2291 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2292 memcpy(&(s->b_buffer[s->b_buffer_ptr + s->b_buffer_len]), s->buffer, 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
|
2293 s->b_buffer_len += 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
|
2294 |
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
|
2295 if(!spriv->is_ready) |
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
|
2296 { |
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
|
2297 if(s->b_buffer_len >= 32*1024) |
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
|
2298 { |
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
|
2299 spriv->mpa_layer = analyze_mpa(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
|
2300 spriv->is_ready = 1; |
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
|
2301 } |
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
|
2302 } |
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
|
2303 else |
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
|
2304 { |
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
|
2305 parse_audio(s, 0, &nf, &fake_timer, priv->init_adelay, priv->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
|
2306 spriv->vframes += nf; |
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
|
2307 if(! spriv->vframes) |
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
|
2308 mp_msg(MSGT_MUXER, MSGL_INFO, "AINIT: %.3lf\r\n", (double) spriv->last_pts/27000000.0f); |
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
|
2309 } |
8585 | 2310 } |
21448 | 2311 |
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
|
2312 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2313 if(spriv->psm_fixed == 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
|
2314 add_to_psm(priv, spriv->id, stream_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
|
2315 spriv->psm_fixed = 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
|
2316 priv->psm_streams_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
|
2317 if((priv->psm_streams_cnt == muxer->num_videos + muxer->num_audios) && priv->use_psm) |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
2318 write_psm_block(muxer, muxer->stream); |
8585 | 2319 } |
21448 | 2320 |
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
|
2321 flush_buffers(muxer, 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
|
2322 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2323 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2324 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2325 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
|
2326 { |
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
|
2327 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
|
2328 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
|
2329 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
|
2330 |
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
|
2331 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
|
2332 |
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
|
2333 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
|
2334 { |
e3d7f52776ff
added support for vbr audio (frames are parsed individually); fixed small bugs in the management of pes_extension
nicodvb
parents:
15278
diff
changeset
|
2335 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
|
2336 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
|
2337 } |
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
|
2338 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
|
2339 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
|
2340 if(priv->is_genmpeg1 || priv->is_genmpeg2) |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
2341 write_mpeg_pack(muxer, NULL, muxer->stream, 1); //insert fake Nav Packet |
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
|
2342 |
16750
0a31740dd5e6
Use PRI?64 defines as format strings for 64 bit variables.
reimar
parents:
16192
diff
changeset
|
2343 mp_msg(MSGT_MUXER, MSGL_INFO, "\nOverhead: %.3lf%% (%"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
|
2344 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2345 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2346 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
|
2347 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2348 muxer_priv_t *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
|
2349 |
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
|
2350 mp_msg(MSGT_MUXER, MSGL_INFO, MSGTR_WritingHeader); |
cf6bfdf41143
Clean up some muxer messages, patch by Corey Hickey bugfood-ml AT -fatooh/org- , small fixes by me
reynaldo
parents:
17023
diff
changeset
|
2351 |
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
|
2352 priv->headers_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
|
2353 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2354 if((priv->is_genmpeg1 || priv->is_genmpeg2) && (priv->headers_cnt == muxer->avih.dwStreams)) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2355 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2356 int 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
|
2357 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
|
2358 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2359 priv->sys_info.streams[i].bufsize = muxer->streams[i]->h.dwSuggestedBufferSize; |
15278
a45c7e1b998f
added support for AAC; moved most of MSGL_V to MSGL_DBG2 to reduce verbosity
nicodvb
parents:
15083
diff
changeset
|
2360 mp_msg(MSGT_MUXER, MSGL_DBG2, "IDX: %d, BUFSIZE: %u\n", i, priv->sys_info.streams[i].bufsize); |
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
|
2361 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2362 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2363 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2364 //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
|
2365 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
|
2366 { |
21660
ca9da45d13e9
muxers now write to output muxer->stream rather than to muxer->file
nicodvb
parents:
21544
diff
changeset
|
2367 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
|
2368 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
|
2369 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2370 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2371 return; |
8585 | 2372 } |
2373 | |
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
|
2374 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
|
2375 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2376 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
|
2377 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2378 int v = (conf_vbuf_size ? conf_vbuf_size : 232); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2379 int a1 = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2380 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
|
2381 |
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
|
2382 priv->sys_info.cnt = 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
|
2383 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2384 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
|
2385 priv->sys_info.streams[0].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2386 priv->sys_info.streams[0].bufsize = v*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
|
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 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
|
2389 priv->sys_info.streams[1].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2390 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
|
2391 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2392 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
|
2393 priv->sys_info.streams[2].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2394 priv->sys_info.streams[2].bufsize = a2*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
|
2395 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2396 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
|
2397 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
|
2398 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
|
2399 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2400 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
|
2401 { |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2402 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
|
2403 int a1 = (conf_abuf_size ? conf_abuf_size : 4); |
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2404 |
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
|
2405 priv->sys_info.cnt = 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
|
2406 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2407 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
|
2408 priv->sys_info.streams[0].type = 1; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2409 priv->sys_info.streams[0].bufsize = v*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
|
2410 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2411 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
|
2412 priv->sys_info.streams[1].type = 0; |
21413
06d63614eeaa
permit to specify the sizes of the decoders' buffers
nicodvb
parents:
21372
diff
changeset
|
2413 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
|
2414 } |
70c446099f40
new mpeg 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 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
|
2416 priv->sys_info.cnt = 0; |
8585 | 2417 } |
2418 | |
21467 | 2419 /* excerpt from DGPulldown Copyright (C) 2005-2006, Donald Graft */ |
2420 static void generate_flags(int source, int target) | |
2421 { | |
2422 unsigned int i, trfp; | |
2423 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
|
2424 unsigned char ormask[4] = {0x0, 0x2, 0x80, 0x82}; |
21467 | 2425 |
2426 dfl = (target - source) << 1; | |
2427 tfl = source >> 1; | |
2428 | |
2429 trfp = 0; | |
2430 for(i = 0; i < MAX_PATTERN_LENGTH; i++) | |
2431 { | |
2432 tfl += dfl; | |
2433 if(tfl >= source) | |
2434 { | |
2435 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
|
2436 bff_mask[i] = ormask[trfp + 1]; |
21467 | 2437 trfp ^= 2; |
2438 } | |
2439 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
|
2440 bff_mask[i] = ormask[trfp]; |
21467 | 2441 } |
2442 } | |
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
|
2443 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2444 int muxer_init_muxer_mpeg(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
|
2445 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
|
2446 priv = (muxer_priv_t *) calloc(1, sizeof(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
|
2447 if(priv == 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
|
2448 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
|
2449 priv->update_system_header = 1; |
21484 | 2450 |
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
|
2451 //calloc() already zero-ed all flags, so we assign only the ones we need |
21484 | 2452 |
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
|
2453 if(conf_mux != NULL) { |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2454 if(! strcasecmp(conf_mux, "mpeg1")) |
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
|
2455 { |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2456 priv->mux = MUX_MPEG1; |
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
|
2457 priv->packet_size = 2048; |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2458 priv->is_genmpeg1 = 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
|
2459 priv->muxrate = 1800 * 125; //Constrained 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
|
2460 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2461 else if(! strcasecmp(conf_mux, "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
|
2462 { |
70c446099f40
new mpeg 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->mux = 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
|
2464 priv->is_dvd = 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
|
2465 priv->packet_size = 2048; |
70c446099f40
new mpeg 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->muxrate = 10080 * 125; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2467 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2468 else if(! strcasecmp(conf_mux, "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
|
2469 { |
70c446099f40
new mpeg 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->mux = 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
|
2471 priv->is_xsvcd = 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
|
2472 priv->packet_size = 2324; |
18187 | 2473 priv->muxrate = 150*2324; |
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
|
2474 priv->ts_allframes = 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
|
2475 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2476 else if(! strcasecmp(conf_mux, "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
|
2477 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2478 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
|
2479 priv->is_xvcd = 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
|
2480 priv->packet_size = 2324; |
18187 | 2481 priv->muxrate = 75*2352; |
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
|
2482 priv->ts_allframes = 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
|
2483 } |
21141 | 2484 else if(! strcasecmp(conf_mux, "pes1")) |
2485 { | |
2486 priv->mux = MUX_MPEG1; | |
2487 priv->rawpes = 1; | |
2488 priv->packet_size = 2048; | |
2489 priv->muxrate = 10080 * 125; | |
2490 priv->ts_allframes = 1; | |
2491 } | |
2492 else if(! strcasecmp(conf_mux, "pes2")) | |
2493 { | |
2494 priv->mux = MUX_MPEG2; | |
2495 priv->rawpes = 1; | |
2496 priv->packet_size = 2048; | |
2497 priv->muxrate = 10080 * 125; | |
2498 priv->ts_allframes = 1; | |
2499 } | |
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
|
2500 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
|
2501 { |
17066
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2502 if(strcasecmp(conf_mux, "mpeg2")) |
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2503 mp_msg(MSGT_MUXER, MSGL_ERR, "Unknown format %s, default to mpeg2\n", conf_mux); |
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2504 priv->mux = MUX_MPEG2; |
e84e5e9e9ef4
fixed wrong telecine trf pattern; fall back to mpeg2 when user specifies unknown format
nicodvb
parents:
17065
diff
changeset
|
2505 priv->is_genmpeg2 = 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
|
2506 priv->packet_size = 2048; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2507 priv->muxrate = 1800 * 125; //Constrained 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
|
2508 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2509 } |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2510 |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2511 if(conf_ts_allframes) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2512 priv->ts_allframes = 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
|
2513 if(conf_muxrate > 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
|
2514 priv->muxrate = conf_muxrate * 125; // * 1000 / 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
|
2515 if(conf_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
|
2516 priv->packet_size = conf_packet_size; |
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
|
2517 priv->delta_scr = (uint64_t) (90000.0f*300.0f*(double)priv->packet_size/(double)priv->muxrate); |
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
|
2518 mp_msg(MSGT_MUXER, MSGL_INFO, "PACKET SIZE: %u bytes, deltascr: %llu\n", priv->packet_size, priv->delta_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
|
2519 setup_sys_params(priv); |
8585 | 2520 |
15083 | 2521 if(conf_vaspect > 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
|
2522 { |
15083 | 2523 int asp = (int) (conf_vaspect * 1000.0f); |
2524 if(asp >= 1332 && asp <= 1334) | |
2525 priv->vaspect = ASPECT_4_3; | |
2526 else if(asp >= 1776 && asp <= 1778) | |
2527 priv->vaspect = ASPECT_16_9; | |
2528 else if(asp >= 2209 && asp <= 2211) | |
2529 priv->vaspect = ASPECT_2_21_1; | |
2530 else if(asp == 1000) | |
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
|
2531 priv->vaspect = ASPECT_1_1; |
15083 | 2532 else |
2533 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: unrecognized aspect %.3f\n", conf_vaspect); | |
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
|
2534 } |
21484 | 2535 |
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
|
2536 priv->vframerate = 0; // no change |
14914 | 2537 if(conf_telecine && conf_vframerate > 0) |
2538 { | |
2539 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR: options 'telecine' and 'vframerate' are mutually exclusive, vframerate disabled\n"); | |
2540 conf_vframerate = 0; | |
2541 } | |
21467 | 2542 |
21482
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2543 if(conf_telecine == TELECINE_FILM2PAL) |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2544 { |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2545 if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2546 conf_telecine_dest = 25; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2547 conf_telecine = TELECINE_DGPULLDOWN; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2548 } |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2549 else if(conf_telecine == PULLDOWN32) |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2550 { |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2551 if(conf_telecine_src==0.0f) conf_telecine_src = 24000.0/1001.0; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2552 conf_telecine_dest = 30000.0/1001.0; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2553 conf_telecine = TELECINE_DGPULLDOWN; |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2554 } |
1dd284e31549
reimplemented :telecine and :film2pal in terms of dgpulldown
nicodvb
parents:
21481
diff
changeset
|
2555 |
21467 | 2556 if(conf_telecine_src>0 && conf_telecine_dest>0 && conf_telecine_src < conf_telecine_dest) |
2557 { | |
22331 | 2558 int sfps, tfps; |
21467 | 2559 |
2560 sfps = (int) (conf_telecine_src * 1001 + 0.5); | |
2561 tfps = (int) (conf_telecine_dest * 1001 + 0.5); | |
2562 if(sfps % 2 || tfps % 2) | |
2563 { | |
2564 sfps *= 2; | |
2565 tfps *= 2; | |
2566 } | |
2567 | |
21486 | 2568 if(((tfps - sfps)>>1) > sfps) |
2569 { | |
2570 mp_msg(MSGT_MUXER, MSGL_ERR, "ERROR! Framerate increment must be <= 1.5, telecining disabled\n"); | |
2571 conf_telecine = 0; | |
2572 } | |
2573 else | |
2574 { | |
21467 | 2575 generate_flags(sfps, tfps); |
2576 conf_telecine = TELECINE_DGPULLDOWN; | |
2577 conf_vframerate = conf_telecine_dest; | |
21486 | 2578 } |
21467 | 2579 } |
21484 | 2580 |
14914 | 2581 if(conf_vframerate) |
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
|
2582 { |
14914 | 2583 int fps; |
2584 | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2585 fps = (int) (conf_vframerate * 1001 + 0.5); |
14914 | 2586 switch(fps) |
2587 { | |
2588 case 24000: | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2589 priv->vframerate = FRAMERATE_23976; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2590 break; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2591 case 24024: |
14914 | 2592 priv->vframerate = FRAMERATE_24; |
2593 break; | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2594 case 25025: |
14914 | 2595 priv->vframerate = FRAMERATE_25; |
2596 break; | |
2597 case 30000: | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2598 priv->vframerate = FRAMERATE_2997; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2599 break; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2600 case 30030: |
14914 | 2601 priv->vframerate = FRAMERATE_30; |
2602 break; | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2603 case 50050: |
14914 | 2604 priv->vframerate = FRAMERATE_50; |
2605 break; | |
2606 case 60000: | |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2607 priv->vframerate = FRAMERATE_5994; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2608 break; |
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2609 case 60060: |
14914 | 2610 priv->vframerate = FRAMERATE_60; |
2611 break; | |
2612 default: | |
21486 | 2613 { |
18162
1b4bf0c9ecb3
simplified code to patch the video framerate (removed silly comparisons)
nicodvb
parents:
18161
diff
changeset
|
2614 mp_msg(MSGT_MUXER, MSGL_ERR, "WRONG FPS: %d/1000, ignoring\n", fps); |
21486 | 2615 if(conf_telecine) |
2616 mp_msg(MSGT_MUXER, MSGL_ERR, "DISABLED TELECINING\n"); | |
2617 conf_telecine = 0; | |
2618 } | |
14914 | 2619 } |
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
|
2620 } |
21484 | 2621 |
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
|
2622 priv->vwidth = (uint16_t) conf_vwidth; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2623 priv->vheight = (uint16_t) conf_vheight; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2624 priv->panscan_width = (uint16_t) conf_panscan_width; |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2625 priv->panscan_height = (uint16_t) conf_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
|
2626 priv->vbitrate = ((conf_vbitrate) * 10) >> 2; //*1000 / 400 |
21484 | 2627 |
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
|
2628 if(priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->vbitrate || priv->panscan_width || priv->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
|
2629 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2630 priv->patch_seq = priv->vaspect || priv->vframerate || priv->vwidth || priv->vheight || priv->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
|
2631 priv->patch_sde = priv->panscan_width || priv->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
|
2632 mp_msg(MSGT_MUXER, MSGL_INFO, "MPEG MUXER, patching"); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2633 if(priv->vwidth || priv->vheight) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2634 mp_msg(MSGT_MUXER, MSGL_INFO, " resolution to %dx%d", priv->vwidth, priv->vheight); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2635 if(priv->panscan_width || priv->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
|
2636 mp_msg(MSGT_MUXER, MSGL_INFO, " panscan to to %dx%d", priv->panscan_width, priv->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
|
2637 if(priv->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
|
2638 mp_msg(MSGT_MUXER, MSGL_INFO, " framerate to %s fps", framerates[priv->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
|
2639 if(priv->vaspect) |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2640 mp_msg(MSGT_MUXER, MSGL_INFO, " aspect ratio to %s", aspect_ratios[priv->vaspect]); |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2641 if(priv->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
|
2642 mp_msg(MSGT_MUXER, MSGL_INFO, " bitrate to %u", conf_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
|
2643 mp_msg(MSGT_MUXER, MSGL_INFO, "\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
|
2644 } |
21484 | 2645 |
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
|
2646 priv->has_video = priv->has_audio = 0; |
21484 | 2647 |
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
|
2648 muxer->sysrate = priv->muxrate; // initial muxrate = constrained stream parameter |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2649 priv->scr = muxer->file_end = 0; |
21484 | 2650 |
22881
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
2651 if(conf_init_vdelay && conf_drop) |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
2652 { |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
2653 mp_msg(MSGT_MUXER, MSGL_ERR, "\nmuxer_mpg, :drop and :vdelay used together are not supported, exiting\n"); |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
2654 return 0; |
2d01760be338
removed init_apts and init_vpts; added :adelay in addition to :vdelay
nicodvb
parents:
22879
diff
changeset
|
2655 } |
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
|
2656 if(conf_init_adelay) |
14772
70f0de24b30a
renamed init_adelay to vdelay with opposite range
nicodvb
parents:
14753
diff
changeset
|
2657 priv->init_adelay = - (double) conf_init_adelay / (double) 1000.0; |
21484 | 2658 |
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
|
2659 priv->drop = conf_drop; |
21484 | 2660 |
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
|
2661 priv->buff = (uint8_t *) malloc(priv->packet_size); |
18200 | 2662 if((priv->buff == 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
|
2663 { |
70c446099f40
new mpeg muxer compatible with dvd/[s]vcd; small changes in the muxer layer (sanity checks in the muxer_init functions)
nicodvb
parents:
12341
diff
changeset
|
2664 mp_msg(MSGT_MUXER, MSGL_ERR, "\nCouldn't allocate %d bytes, exit\n", 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
|
2665 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
|
2666 } |
21484 | 2667 |
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
|
2668 muxer->priv = (void *) priv; |
8585 | 2669 muxer->cont_new_stream = &mpegfile_new_stream; |
2670 muxer->cont_write_chunk = &mpegfile_write_chunk; | |
2671 muxer->cont_write_header = &mpegfile_write_header; | |
2672 muxer->cont_write_index = &mpegfile_write_index; | |
18183
ac03acb92d24
introduced structures and code to keep track of decoder's buffers sizes
nicodvb
parents:
18181
diff
changeset
|
2673 muxer->fix_stream_parameters = &fix_parameters; |
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
|
2674 return 1; |
8585 | 2675 } |
2676 |