├── .gitignore ├── COPYING ├── Makefile ├── README ├── TODO ├── atsc ├── atsc.c └── atsc.h ├── bitstream.h ├── cablelabs ├── cablelabs.c └── cablelabs.h ├── codecs.h ├── common.h ├── config.guess ├── config.sub ├── configure ├── crc ├── crc.c └── crc.h ├── dvb ├── dvb.c └── dvb.h ├── hdmv ├── hdmv.c └── hdmv.h ├── isdb └── isdb.h ├── libmpegts.c ├── libmpegts.h ├── smpte ├── smpte.c └── smpte.h └── version.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.a 3 | *.diff 4 | *.dll* 5 | *.exe 6 | *.mo 7 | *.o 8 | *.pc 9 | *.pot 10 | *.so* 11 | .*.swp 12 | *.gch 13 | .depend 14 | config.h 15 | config.mak 16 | config.log 17 | x264 18 | checkasm 19 | 20 | *.264 21 | *.2pass 22 | *.mkv 23 | *.mp4 24 | *.y4m 25 | *.yuv 26 | x264_2pass.log 27 | NUL 28 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile 2 | 3 | include config.mak 4 | 5 | all: default 6 | 7 | SRCS = crc/crc.c atsc/atsc.c cablelabs/cablelabs.c dvb/dvb.c hdmv/hdmv.c smpte/smpte.c libmpegts.c 8 | 9 | SRCSO = 10 | 11 | CONFIG := $(shell cat config.h) 12 | 13 | OBJS = $(SRCS:%.c=%.o) 14 | OBJCLI = $(SRCCLI:%.c=%.o) 15 | OBJSO = $(SRCSO:%.c=%.o) 16 | DEP = depend libmpegts.a 17 | 18 | .PHONY: all default clean distclean install uninstall dox test testclean 19 | 20 | default: $(DEP) 21 | 22 | libmpegts.a: .depend $(OBJS) 23 | $(AR) rc libmpegts.a $(OBJS) 24 | $(RANLIB) libmpegts.a 25 | 26 | $(SONAME): .depend $(OBJS) $(OBJSO) 27 | $(CC) -shared -o $@ $(OBJS) $(OBJSO) $(SOFLAGS) $(LDFLAGS) 28 | 29 | .depend: config.mak 30 | @rm -f .depend 31 | @$(foreach SRC, $(SRCS) $(SRCSO), $(CC) $(CFLAGS) $(SRC) -MT $(SRC:%.c=%.o) -MM -g0 1>> .depend;) 32 | 33 | config.mak: 34 | ./configure 35 | 36 | depend: .depend 37 | ifneq ($(wildcard .depend),) 38 | include .depend 39 | endif 40 | 41 | SRC2 = $(SRCS) 42 | 43 | clean: 44 | rm -f $(OBJS) $(OBJSO) $(OBJCLI) $(SONAME) *.a .depend TAGS 45 | rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) 46 | - sed -e 's/ *-fprofile-\(generate\|use\)//g' config.mak > config.mak2 && mv config.mak2 config.mak 47 | 48 | distclean: clean 49 | rm -f config.mak config.h config.log libmpegts.pc 50 | rm -rf test/ 51 | 52 | install: $(SONAME) 53 | install -d $(DESTDIR)$(bindir) 54 | install -d $(DESTDIR)$(includedir) 55 | install -d $(DESTDIR)$(libdir) 56 | install -d $(DESTDIR)$(libdir)/pkgconfig 57 | install -m 644 libmpegts.h $(DESTDIR)$(includedir) 58 | install -m 644 libmpegts.a $(DESTDIR)$(libdir) 59 | install -m 644 libmpegts.pc $(DESTDIR)$(libdir)/pkgconfig 60 | $(RANLIB) $(DESTDIR)$(libdir)/libmpegts.a 61 | ifeq ($(SYS),MINGW) 62 | $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir)) 63 | else 64 | $(if $(SONAME), ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libmpegts.$(SOSUFFIX)) 65 | $(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir)) 66 | endif 67 | $(if $(IMPLIBNAME), install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)) 68 | 69 | uninstall: 70 | rm -f $(DESTDIR)$(includedir)/libmpegts.h $(DESTDIR)$(libdir)/libmpegts.a 71 | rm -f $(DESTDIR)$(libdir)/pkgconfig/libmpegts.pc 72 | $(if $(SONAME), rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libmpegts.$(SOSUFFIX)) 73 | 74 | etags: TAGS 75 | 76 | TAGS: 77 | etags $(SRCS) 78 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | libmpegts README 2 | 3 | Single Program Transport stream muxer 4 | 5 | Things which work: 6 | 7 | CBR and VBR TS muxing of AVC, AC-3, MP2 and AAC/HE-AAC. 8 | DVB AU_Information 9 | (Very likely MPEG-2 as well but not tested) 10 | 11 | Things which don't work: 12 | 13 | Blu-Ray and associated formats 14 | DTS 15 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | libmpegts TODO list 2 | 3 | Most important TODO is to get streams verified with a good analyzer 4 | Is there a need to implement full T-STD modelling or use the simpler version currently implemented? 5 | Do we need to control EB buffer fullness more? 6 | Find out why some streams where muxrate is larger than TB leak rate fail to mux. 7 | A true VBR mode? How to implement? Within Spec? 8 | Write ATSC PSIP 9 | Write DVB Tables (SIT, NIT, EIT) etc 10 | Sort out T-STD on Data streams 11 | Add more formats 12 | Add Blu-ray formats - dealing with vbr audio? 13 | -------------------------------------------------------------------------------- /atsc/atsc.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * atsc.c : ATSC specific functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include "../common.h" 22 | #include "atsc.h" 23 | 24 | /* Second Loop of PMT */ 25 | void parse_ac3_frame( ts_atsc_ac3_info *atsc_ac3_ctx, uint8_t *frame ) 26 | { 27 | atsc_ac3_ctx->sample_rate_code = frame[4] >> 6; 28 | atsc_ac3_ctx->bsid = frame[5] >> 3; 29 | atsc_ac3_ctx->bit_rate_code = (frame[4] & 0x3f) >> 1; 30 | atsc_ac3_ctx->surround_mode = (frame[6] & 1) << 1 | (frame[7] >> 7); 31 | atsc_ac3_ctx->bsmod = frame[5] & 0x7; 32 | atsc_ac3_ctx->num_channels = frame[6] >> 5; 33 | } 34 | 35 | void write_atsc_ac3_descriptor( bs_t *s, ts_atsc_ac3_info *atsc_ac3_ctx ) 36 | { 37 | bs_write( s, 8, ATSC_AC3_DESCRIPTOR_TAG ); // descriptor_tag 38 | bs_write( s, 8, 3 ); // descriptor_length 39 | bs_write( s, 3, atsc_ac3_ctx->sample_rate_code ); // sample_rate_code 40 | bs_write( s, 5, atsc_ac3_ctx->bsid ); // bsid 41 | bs_write( s, 6, atsc_ac3_ctx->bit_rate_code ); // bit_rate_code 42 | bs_write( s, 2, atsc_ac3_ctx->surround_mode ); // surround_mode 43 | bs_write( s, 3, atsc_ac3_ctx->bsmod ); // bsmod 44 | bs_write( s, 4, atsc_ac3_ctx->num_channels ); // num_channels 45 | bs_write1( s, 1 ); // full_svc 46 | } 47 | 48 | /* Also in EIT */ 49 | // FIXME fill in the blanks 50 | void write_caption_service_descriptor( bs_t *s ) 51 | { 52 | bs_write( s, 8, ATSC_CAPTION_SERVICE_DESCRIPTOR_TAG ); // descriptor_tag 53 | bs_write( s, 8, 0 ); // descriptor_length 54 | bs_write( s, 3, 0x7 ); // reserved 55 | 56 | bs_write( s, 5, 0 ); // number_of_services 57 | 58 | for( int i = 0; i < 0; i++ ) 59 | { 60 | bs_write( s, 8, 0 ); // language[0] 61 | bs_write( s, 8, 0 ); // language[1] 62 | bs_write( s, 8, 0 ); // language[2] 63 | bs_write1( s, 0 ); // digital_cc 64 | bs_write1( s, 1 ); // reserved 65 | 66 | if( 0 ) 67 | bs_write( s, 6, 0x3f ); // reserved 68 | else 69 | bs_write( s, 6, 0 ); // caption_service_number 70 | 71 | bs_write1( s, 0 ); // easy_reader 72 | bs_write1( s, 0 ); // wide_aspect_ratio 73 | bs_write( s, 13, 0x3fff ); // reserved 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /atsc/atsc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * atsc.h : ATSC specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_ATSC_H 22 | #define LIBMPEGTS_ATSC_H 23 | 24 | /* ATSC stream_types */ 25 | #define AUDIO_AC3 0x81 26 | #define AUDIO_EAC3 0x84 27 | 28 | /* Descriptors */ 29 | #define ATSC_AC3_DESCRIPTOR_TAG 0x81 30 | #define ATSC_CAPTION_SERVICE_DESCRIPTOR_TAG 0x86 31 | #define ATSC_EXTENDED_CHANNEL_NAME_DESCRIPTOR_TAG 0xa0 32 | 33 | void parse_ac3_frame( ts_atsc_ac3_info *atsc_ac3_ctx, uint8_t *frame ); 34 | void write_atsc_ac3_descriptor( bs_t *s, ts_atsc_ac3_info *atsc_ac3_ctx ); 35 | void write_caption_service_descriptor( bs_t *s ); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /bitstream.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * bitstream.h: bitstream writing 3 | ***************************************************************************** 4 | * Copyright (C) 2003-2010 x264 project 5 | * 6 | * Authors: Loren Merritt 7 | * Jason Garrett-Glaser 8 | * Laurent Aimar 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 23 | * 24 | * This program is also available under a commercial proprietary license. 25 | * For more information, contact us at licensing@x264.com. 26 | *****************************************************************************/ 27 | 28 | #ifndef LIBMPEGTS_BS_H 29 | #define LIBMPEGTS_BS_H 30 | 31 | #define WORD_SIZE sizeof(long) 32 | 33 | /* Unions for type-punning. 34 | * Mn: load or store n bits, aligned, native-endian 35 | * CPn: copy n bits, aligned, native-endian 36 | * we don't use memcpy for CPn because memcpy's args aren't assumed to be aligned */ 37 | typedef union { uint16_t i; uint8_t c[2]; } x264_union16_t; 38 | typedef union { uint32_t i; uint16_t b[2]; uint8_t c[4]; } x264_union32_t; 39 | typedef union { uint64_t i; uint32_t a[2]; uint16_t b[4]; uint8_t c[8]; } x264_union64_t; 40 | typedef struct { uint64_t i[2]; } x264_uint128_t; 41 | typedef union { x264_uint128_t i; uint64_t a[2]; uint32_t b[4]; uint16_t c[8]; uint8_t d[16]; } x264_union128_t; 42 | #define M16(src) (((x264_union16_t*)(src))->i) 43 | #define M32(src) (((x264_union32_t*)(src))->i) 44 | #define M64(src) (((x264_union64_t*)(src))->i) 45 | #define M128(src) (((x264_union128_t*)(src))->i) 46 | #define M128_ZERO ((x264_uint128_t){{0,0}}) 47 | #define CP16(dst,src) M16(dst) = M16(src) 48 | #define CP32(dst,src) M32(dst) = M32(src) 49 | #define CP64(dst,src) M64(dst) = M64(src) 50 | #define CP128(dst,src) M128(dst) = M128(src) 51 | 52 | #if WORDS_BIGENDIAN 53 | #define endian_fix(x) (x) 54 | #define endian_fix64(x) (x) 55 | #define endian_fix32(x) (x) 56 | #define endian_fix16(x) (x) 57 | #else 58 | static inline uint32_t endian_fix32( uint32_t x ) 59 | { 60 | return (x<<24) + ((x<<8)&0xff0000) + ((x>>8)&0xff00) + (x>>24); 61 | } 62 | static inline uint64_t endian_fix64( uint64_t x ) 63 | { 64 | return endian_fix32(x>>32) + ((uint64_t)endian_fix32(x)<<32); 65 | } 66 | static inline intptr_t endian_fix( intptr_t x ) 67 | { 68 | return WORD_SIZE == 8 ? endian_fix64(x) : endian_fix32(x); 69 | } 70 | static inline uint16_t endian_fix16( uint16_t x ) 71 | { 72 | return (x<<8)|(x>>8); 73 | } 74 | #endif 75 | 76 | typedef struct bs_s 77 | { 78 | uint8_t *p_start; 79 | uint8_t *p; 80 | uint8_t *p_end; 81 | 82 | intptr_t cur_bits; 83 | int i_left; /* i_count number of available bits */ 84 | } bs_t; 85 | 86 | static inline void bs_init( bs_t *s, void *p_data, int i_data ) 87 | { 88 | int offset = ((intptr_t)p_data & 3); 89 | s->p = s->p_start = (uint8_t*)p_data - offset; 90 | s->p_end = (uint8_t*)p_data + i_data; 91 | s->i_left = (WORD_SIZE - offset)*8; 92 | s->cur_bits = endian_fix32( M32(s->p) ); 93 | s->cur_bits >>= (4-offset)*8; 94 | } 95 | static inline int bs_pos( bs_t *s ) 96 | { 97 | return( 8 * (s->p - s->p_start) + (WORD_SIZE*8) - s->i_left ); 98 | } 99 | 100 | /* Write the rest of cur_bits to the bitstream; results in a bitstream no longer 32-bit aligned. */ 101 | static inline void bs_flush( bs_t *s ) 102 | { 103 | M32( s->p ) = endian_fix32( s->cur_bits << (s->i_left&31) ); 104 | s->p += WORD_SIZE - (s->i_left >> 3); 105 | s->i_left = WORD_SIZE*8; 106 | } 107 | /* The inverse of bs_flush: prepare the bitstream to be written to again. */ 108 | static inline void bs_realign( bs_t *s ) 109 | { 110 | int offset = ((intptr_t)s->p & 3); 111 | if( offset ) 112 | { 113 | s->p = (uint8_t*)s->p - offset; 114 | s->i_left = (WORD_SIZE - offset)*8; 115 | s->cur_bits = endian_fix32( M32(s->p) ); 116 | s->cur_bits >>= (4-offset)*8; 117 | } 118 | } 119 | 120 | static inline void bs_write( bs_t *s, int i_count, uint32_t i_bits ) 121 | { 122 | if( WORD_SIZE == 8 ) 123 | { 124 | s->cur_bits = (s->cur_bits << i_count) | i_bits; 125 | s->i_left -= i_count; 126 | if( s->i_left <= 32 ) 127 | { 128 | #if WORDS_BIGENDIAN 129 | M32( s->p ) = s->cur_bits >> (32 - s->i_left); 130 | #else 131 | M32( s->p ) = endian_fix( s->cur_bits << s->i_left ); 132 | #endif 133 | s->i_left += 32; 134 | s->p += 4; 135 | } 136 | } 137 | else 138 | { 139 | if( i_count < s->i_left ) 140 | { 141 | s->cur_bits = (s->cur_bits << i_count) | i_bits; 142 | s->i_left -= i_count; 143 | } 144 | else 145 | { 146 | i_count -= s->i_left; 147 | s->cur_bits = (s->cur_bits << s->i_left) | (i_bits >> i_count); 148 | M32( s->p ) = endian_fix( s->cur_bits ); 149 | s->p += 4; 150 | s->cur_bits = i_bits; 151 | s->i_left = 32 - i_count; 152 | } 153 | } 154 | } 155 | 156 | /* Special case to eliminate branch in normal bs_write. */ 157 | /* Golomb never writes an even-size code, so this is only used in slice headers. */ 158 | static inline void bs_write32( bs_t *s, uint32_t i_bits ) 159 | { 160 | bs_write( s, 16, i_bits >> 16 ); 161 | bs_write( s, 16, i_bits ); 162 | } 163 | 164 | static inline void bs_write1( bs_t *s, uint32_t i_bit ) 165 | { 166 | s->cur_bits <<= 1; 167 | s->cur_bits |= i_bit; 168 | s->i_left--; 169 | if( s->i_left == WORD_SIZE*8-32 ) 170 | { 171 | M32( s->p ) = endian_fix32( s->cur_bits ); 172 | s->p += 4; 173 | s->i_left = WORD_SIZE*8; 174 | } 175 | } 176 | 177 | #endif 178 | -------------------------------------------------------------------------------- /cablelabs/cablelabs.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cablelabs.c : CableLabs (includes SCTE) specific functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include "../common.h" 22 | #include "cablelabs.h" 23 | 24 | /**** First Loop of PMT Descriptors ****/ 25 | /* 3D descriptor */ 26 | void write_cablelabs_3d_descriptor( bs_t *s ) 27 | { 28 | bs_write( s, 8, CABLELABS_3D_MPEG2_DESCRIPTOR_TAG ); // descriptor_tag 29 | bs_write( s, 8, 1 ); // descriptor_length 30 | bs_write1( s, 1 ); // 3d_frame_packing_data_present 31 | bs_write( s, 7, 0 ); // reserved 32 | } 33 | 34 | /**** Second Loop of PMT Descriptors ****/ 35 | /* Adaptation Descriptor */ 36 | void write_scte_adaptation_descriptor( bs_t *s ) 37 | { 38 | bs_write( s, 8, SCTE_ADAPTATION_FIELD_DESCRIPTOR_TAG ); // descriptor_tag 39 | bs_write( s, 8, 0 ); // descriptor_length 40 | } 41 | 42 | void write_scte35_cue_identifier_descriptor( bs_t *s ) 43 | { 44 | bs_write( s, 8, SCTE35_CUE_IDENTIFIER_DESCRIPTOR_TAG ); // descriptor_tag 45 | bs_write( s, 8, 1 ); // descriptor_length 46 | bs_write( s, 8, 0 ); // cue_stream_type 47 | } -------------------------------------------------------------------------------- /cablelabs/cablelabs.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * cablelabs.h : CableLabs (includes SCTE) specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_CABLELABS_H 22 | #define LIBMPEGTS_CABLELABS_H 23 | 24 | /* Descriptors */ 25 | #define SCTE_ADAPTATION_FIELD_DESCRIPTOR_TAG 0x97 26 | #define CABLELABS_3D_MPEG2_DESCRIPTOR_TAG 0xe8 27 | #define SCTE35_CUE_IDENTIFIER_DESCRIPTOR_TAG 0x8a 28 | 29 | void write_cablelabs_3d_descriptor( bs_t *s ); 30 | void write_scte_adaptation_descriptor( bs_t *s ); 31 | void write_scte35_cue_identifier_descriptor( bs_t *s ); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /codecs.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * codecs.h : Codec specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_CODECS_H 22 | #define LIBMPEGTS_CODECS_H 23 | 24 | /* Video */ 25 | typedef struct 26 | { 27 | int level; 28 | int profile; 29 | int bitrate; /* max bitrate (kbit/sec) */ 30 | int vbv; /* max vbv buffer (kbit) */ 31 | } mpeg2_level_t; 32 | 33 | const mpeg2_level_t mpeg2_levels[] = 34 | { 35 | { LIBMPEGTS_MPEG2_LEVEL_LOW, LIBMPEGTS_MPEG2_PROFILE_MAIN, 4000000, 475136 }, 36 | { LIBMPEGTS_MPEG2_LEVEL_MAIN, LIBMPEGTS_MPEG2_PROFILE_SIMPLE, 15000000, 1835008 }, 37 | { LIBMPEGTS_MPEG2_LEVEL_MAIN, LIBMPEGTS_MPEG2_PROFILE_MAIN, 15000000, 1835008 }, 38 | { LIBMPEGTS_MPEG2_LEVEL_MAIN, LIBMPEGTS_MPEG2_PROFILE_422, 50000000, 9437184 }, 39 | { LIBMPEGTS_MPEG2_LEVEL_HIGH_1440,LIBMPEGTS_MPEG2_PROFILE_MAIN, 60000000, 7340732 }, 40 | { LIBMPEGTS_MPEG2_LEVEL_HIGH, LIBMPEGTS_MPEG2_PROFILE_MAIN, 80000000, 9781248 }, 41 | { LIBMPEGTS_MPEG2_LEVEL_HIGHP, LIBMPEGTS_MPEG2_PROFILE_MAIN, 80000000, 9781248 }, 42 | { 0 } 43 | }; 44 | 45 | typedef struct 46 | { 47 | int level_idc; 48 | int bitrate; /* max bitrate (kbit/sec) */ 49 | int cpb; /* max vbv buffer (kbit) */ 50 | } avc_level_t; 51 | 52 | const avc_level_t avc_levels[] = 53 | { 54 | { 10, 64, 64 }, 55 | { 9, 128, 350 }, /* 1b */ 56 | { 11, 192, 500 }, 57 | { 12, 384, 1000 }, 58 | { 13, 768, 2000 }, 59 | { 20, 2000, 2000 }, 60 | { 21, 4000, 4000 }, 61 | { 22, 4000, 4000 }, 62 | { 30, 10000, 10000 }, 63 | { 31, 14000, 14000 }, 64 | { 32, 20000, 20000 }, 65 | { 40, 20000, 25000 }, 66 | { 41, 50000, 62500 }, 67 | { 42, 50000, 62500 }, 68 | { 50, 135000, 135000 }, 69 | { 51, 240000, 240000 }, 70 | { 52, 240000, 240000 }, 71 | { 0 } 72 | }; 73 | 74 | const uint8_t avc_profiles[] = 75 | { 76 | [AVC_BASELINE] = 66, 77 | [AVC_MAIN] = 77, 78 | [AVC_HIGH] = 100, 79 | [AVC_HIGH_10] = 110, 80 | [AVC_HIGH_422] = 122, 81 | [AVC_HIGH_444_PRED] = 244, 82 | [AVC_HIGH_10_INTRA] = 110, 83 | [AVC_HIGH_422_INTRA] = 122, 84 | [AVC_HIGH_444_INTRA] = 244, 85 | [AVC_CAVLC_444_INTRA] = 44, 86 | }; 87 | 88 | const int nal_factor[] = 89 | { 90 | [AVC_BASELINE] = 1200, 91 | [AVC_MAIN] = 1200, 92 | [AVC_HIGH] = 1500, 93 | [AVC_HIGH_10] = 3600, 94 | [AVC_HIGH_422] = 4800, 95 | [AVC_HIGH_444_PRED] = 4800, 96 | [AVC_HIGH_10_INTRA] = 3600, 97 | [AVC_HIGH_422_INTRA] = 4800, 98 | [AVC_HIGH_444_INTRA] = 4800, 99 | [AVC_CAVLC_444_INTRA] = 4800, 100 | }; 101 | 102 | /* Audio */ 103 | typedef struct 104 | { 105 | int max_channels; 106 | int rxn; /* Leak rate from Transport Buffer */ 107 | int bsn; /* Size of Main buffer */ 108 | } aac_buffer_t; 109 | 110 | const aac_buffer_t aac_buffers[] = 111 | { 112 | { 2, 2000000, 3584*8 }, 113 | { 8, 5529600, 8976*8 }, 114 | { 12, 8294400, 12804*8 }, 115 | { 48, 33177600, 51216*8 }, 116 | { 0 }, 117 | }; 118 | 119 | /* AC3 buffer sizes */ 120 | #define AC3_BS_ATSC 2592*8 121 | #define AC3_BS_DVB 5696*8 122 | 123 | /* SMPTE 302M */ 124 | #define SMPTE_302M_AUDIO_BS 65024*8 125 | #define SMPTE_302M_AUDIO_SR 48000 126 | 127 | /* Misc Audio */ 128 | #define MISC_AUDIO_BS 3584*8 129 | #define MISC_AUDIO_RXN 2000000 130 | 131 | /* DVB Subtitles */ 132 | #define DVB_SUB_RXN 192000 133 | #define DVB_SUB_MB_SIZE 24000 134 | #define DVB_SUB_DDS_TB_SIZE TB_SIZE*2*8 135 | #define DVB_SUB_DDS_RXN 400000 136 | #define DVB_SUB_DDS_MB_SIZE 100000 137 | 138 | /* Teletext */ 139 | #define TELETEXT_T_BS 480*8 /* Seems to have an odd Transport Buffer size */ 140 | #define TELETEXT_RXN 6750000 141 | #define TELETEXT_BTTX 1504*8 142 | 143 | /* SCTE VBI */ 144 | #define SCTE_VBI_RXN 324539 145 | #define SCTE_VBI_MB_SIZE 2256*8 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /common.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * common.h : common data 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_COMMON_H 22 | #define LIBMPEGTS_COMMON_H 23 | 24 | #include 25 | #include 26 | #if HAVE_STDINT_H 27 | #include 28 | #else 29 | #include 30 | #endif 31 | #include "bitstream.h" 32 | #include "libmpegts.h" 33 | #include 34 | 35 | /* Standardised Audio/Video stream_types */ 36 | #define VIDEO_MPEG2 0x02 37 | #define VIDEO_AVC 0x1b 38 | 39 | #define AUDIO_MPEG1 0x03 40 | #define AUDIO_MPEG2 0x04 41 | #define AUDIO_ADTS 0x0f 42 | #define AUDIO_LATM 0x11 43 | 44 | #define PRIVATE_SECTION 0x05 45 | #define PRIVATE_DATA 0x06 46 | 47 | #define DATA_SCTE35 0x86 48 | 49 | #define TS_HEADER_SIZE 4 50 | #define TS_PACKET_SIZE 188 51 | #define TS_CLOCK 27000000LL 52 | #define TS_START 10 53 | #define TIMESTAMP_CLOCK 90000LL 54 | 55 | // arbitrary 56 | #define MAX_PROGRAMS 100 57 | #define MAX_STREAMS 100 58 | 59 | /* DVB 40ms recommendation */ 60 | #define PCR_MAX_RETRANS_TIME 40 61 | #define PAT_MAX_RETRANS_TIME 100 62 | 63 | /* PIDs */ 64 | #define PAT_PID 0x0000 65 | #define NIT_PID 0x0010 66 | #define SIT_PID 0x001f 67 | #define NULL_PID 0xffff 68 | 69 | /* TIDs */ 70 | #define PAT_TID 0x00 71 | #define PMT_TID 0x02 72 | #define NIT_TID 0x40 73 | #define SIT_TID 0x7f 74 | 75 | /* NIT */ 76 | /* ETSI TS 101 162 - Temporary Private Use 77 | * Used for both "Original Network ID" and "Network ID" */ 78 | #define DEFAULT_NID 0xffff 79 | 80 | /* Program and Program Element Descriptor Tags */ 81 | #define VIDEO_STREAM_DESCRIPTOR_TAG 0x2 82 | #define AUDIO_STREAM_DESCRIPTOR_TAG 0x3 83 | #define REGISTRATION_DESCRIPTOR_TAG 0x5 84 | #define DATA_STREAM_ALIGNMENT_DESCRIPTOR_TAG 0x6 85 | #define ISO_693_LANGUAGE_DESCRIPTOR_TAG 0xa 86 | #define PRIVATE_DATA_DESCRIPTOR_TAG 0xe 87 | #define SMOOTHING_BUFFER_DESCRIPTOR_TAG 0x10 88 | #define AVC_DESCRIPTOR_TAG 0x28 89 | #define MPEG2_AAC_AUDIO_DESCRIPTOR 0x2b 90 | #define SVC_EXTENSION_DESCRIPTOR_TAG 0x30 91 | #define MVC_EXTENSION_DESCRIPTOR_TAG 0x31 92 | #define USER_DEFINED_DESCRIPTOR_TAG 0xc4 93 | 94 | #define TB_SIZE 4096 95 | #define RX_SYS 1000000 96 | #define R_SYS_DEFAULT 80000 97 | 98 | /* Macros */ 99 | #define BOOLIFY(x) x = !!x 100 | #define MIN(a,b) ( (a)<(b) ? (a) : (b) ) 101 | #define MAX(a,b) ( (a)>(b) ? (a) : (b) ) 102 | 103 | #define IS_VIDEO(x) ( x->stream_format == LIBMPEGTS_VIDEO_MPEG2 || x->stream_format == LIBMPEGTS_VIDEO_AVC || x->stream_format == LIBMPEGTS_VIDEO_DIRAC ) 104 | 105 | /* Internal Program & Stream Structures */ 106 | typedef struct 107 | { 108 | int level; 109 | int profile; 110 | int frame_rate; 111 | } mpegvideo_stream_ctx_t; 112 | 113 | typedef struct 114 | { 115 | int num_channels; 116 | int sample_rate; 117 | int bits_per_sample; 118 | } lpcm_stream_ctx_t; 119 | 120 | typedef struct 121 | { 122 | int frame_rate; 123 | int aspect_ratio; 124 | } hdmv_video_stream_ctx_t; 125 | 126 | typedef struct 127 | { 128 | int sample_rate_code; 129 | int bsid; 130 | int bit_rate_code; 131 | int surround_mode; 132 | int bsmod; 133 | int num_channels; 134 | } ts_atsc_ac3_info; 135 | 136 | /* Blu-Ray DTCP */ 137 | typedef struct 138 | { 139 | uint8_t byte_1; 140 | uint8_t byte_2; 141 | } ts_dtcp_t; 142 | 143 | typedef struct 144 | { 145 | /* in bytes */ 146 | int adapt_field_size; 147 | int pes_header_size; 148 | int cur_pos; 149 | } buffer_queue_t; 150 | 151 | typedef struct 152 | { 153 | int buf_size; /* size of buffer */ 154 | int cur_buf; /* current buffer fill */ 155 | 156 | double last_byte_removal_time; 157 | 158 | buffer_queue_t queued_packets[10]; 159 | } buffer_t; 160 | 161 | typedef struct 162 | { 163 | int pid; 164 | int cc; 165 | int stream_format; /* internal stream format type */ 166 | int stream_type; /* stream_type syntax element */ 167 | int stream_id; 168 | 169 | int version_number; 170 | 171 | int64_t last_pkt_pcr; 172 | 173 | /* Stream contexts */ 174 | mpegvideo_stream_ctx_t *mpegvideo_ctx; 175 | lpcm_stream_ctx_t *lpcm_ctx; 176 | ts_atsc_ac3_info *atsc_ac3_ctx; 177 | 178 | int num_dvb_sub; 179 | ts_dvb_sub_t *dvb_sub_ctx; 180 | 181 | int num_dvb_ttx; 182 | ts_dvb_ttx_t *dvb_ttx_ctx; 183 | 184 | int num_dvb_vbi; 185 | ts_dvb_vbi_t *dvb_vbi_ctx; 186 | 187 | int num_channels; 188 | int max_frame_size; 189 | 190 | /* T_STD */ 191 | buffer_t tb; /* transport buffer */ 192 | int rx; /* flow from transport to multiplex buffer (video) or main buffer (audio) */ 193 | buffer_t mb; /* multiplex buffer (video) or main buffer (audio) */ 194 | buffer_t eb; /* elementary buffer */ 195 | int rbx; /* flow from multiplex to elementary buffer (video) */ 196 | 197 | /* Language Codes */ 198 | int write_lang_code; 199 | char lang_code[4]; 200 | int audio_type; 201 | 202 | /* AAC */ 203 | int aac_is_mpeg4; 204 | int aac_profile; 205 | int aac_channel_map; 206 | 207 | /* Opus */ 208 | int opus_channel_map; 209 | 210 | /* ATSC */ 211 | 212 | /* DVB */ 213 | /* Stream Identifier */ 214 | int has_stream_identifier; 215 | int stream_identifier; 216 | 217 | /* DVB AU_Information */ 218 | int dvb_au; 219 | int dvb_au_frame_rate; 220 | 221 | /* ISDB */ 222 | 223 | /* CableLabs */ 224 | 225 | /* Blu-Ray */ 226 | int hdmv_video_format; 227 | int hdmv_frame_rate; 228 | int hdmv_aspect_ratio; 229 | } ts_int_stream_t; 230 | 231 | typedef struct 232 | { 233 | uint8_t *data; 234 | int size; 235 | uint8_t *cur_pos; 236 | int bytes_left; 237 | 238 | /* stream context associated with pes */ 239 | ts_int_stream_t *stream; 240 | 241 | int header_size; 242 | int random_access; 243 | int priority; 244 | 245 | int64_t initial_arrival_time; 246 | int64_t final_arrival_time; 247 | int64_t dts; 248 | int64_t pts; 249 | 250 | /* DVB AU_Information specific fields */ 251 | uint8_t frame_type; 252 | int ref_pic_idc; 253 | int write_pulldown_info; 254 | int pic_struct; 255 | } ts_int_pes_t; 256 | 257 | typedef struct 258 | { 259 | ts_int_stream_t pmt; 260 | int program_num; 261 | 262 | int num_queued_pmt; 263 | uint8_t **pmt_packets; 264 | 265 | int num_streams; 266 | ts_int_stream_t *streams[MAX_STREAMS]; 267 | ts_int_stream_t *pcr_stream; 268 | 269 | int pmt_version; 270 | 271 | uint64_t last_pcr; 272 | 273 | int64_t video_dts; 274 | 275 | sdt_program_ctx_t sdt_ctx; 276 | int is_3dtv; 277 | 278 | int sb_leak_rate; 279 | int sb_size; 280 | } ts_int_program_t; 281 | 282 | struct ts_writer_t 283 | { 284 | struct 285 | { 286 | int i_bitstream; 287 | uint8_t *p_bitstream; 288 | bs_t bs; 289 | } out; 290 | 291 | uint64_t bytes_written; 292 | uint64_t packets_written; 293 | uint64_t pcr_start; 294 | 295 | int ts_type; 296 | int ts_id; 297 | 298 | int cbr; 299 | int ts_muxrate; 300 | int lowlatency; 301 | 302 | int pat_cc; 303 | 304 | int num_programs; 305 | ts_int_program_t *programs[MAX_PROGRAMS]; 306 | 307 | int pat_period; 308 | int pcr_period; 309 | int sdt_period; 310 | int first_input; 311 | 312 | int pat_version; 313 | 314 | int network_pid; 315 | int network_id; 316 | 317 | int num_buffered_frames; 318 | ts_int_pes_t **buffered_frames; 319 | 320 | int num_pcrs; 321 | int pcr_list_alloced; 322 | int64_t *pcr_list; 323 | 324 | /* system control */ 325 | buffer_t tb; /* transport buffer */ 326 | buffer_t main_b; /* main buffer */ 327 | 328 | int rx_sys; /* flow from transport to main buffer */ 329 | int r_sys; /* flow from main buffer to system decoder */ 330 | 331 | /* CableLabs */ 332 | int legacy_constraints; 333 | 334 | /* DVB-specific */ 335 | ts_int_stream_t *nit; 336 | ts_int_stream_t *sdt; 337 | ts_int_stream_t *eit; 338 | ts_int_stream_t *tdt; 339 | ts_int_stream_t *sit; 340 | 341 | uint64_t last_pat; 342 | uint64_t last_pmt; 343 | uint64_t last_nit; 344 | uint64_t last_sdt; 345 | uint64_t last_eit; 346 | uint64_t last_tdt; 347 | uint64_t last_sit; 348 | 349 | ts_dtcp_t *dtcp_ctx; 350 | }; 351 | 352 | enum adaptation_field_control_e 353 | { 354 | PAYLOAD_ONLY = 1, 355 | ADAPT_FIELD_ONLY = 2, 356 | ADAPT_FIELD_AND_PAYLOAD = 3, 357 | }; 358 | 359 | void write_bytes( bs_t *s, uint8_t *bytes, int length ); 360 | void write_packet_header( ts_writer_t *w, bs_t *s, int start, int pid, int adapt_field, int *cc ); 361 | void write_registration_descriptor( bs_t *s, int descriptor_tag, int descriptor_length, char *format_id ); 362 | void write_crc( bs_t *s, int start ); 363 | int write_padding( bs_t *s, int start ); 364 | int increase_pcr( ts_writer_t *w, int num_packets, int imaginary ); 365 | ts_int_stream_t *find_stream( ts_writer_t *w, int pid ); 366 | 367 | #endif 368 | -------------------------------------------------------------------------------- /config.guess: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Attempt to guess a canonical system name. 3 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 5 | # Free Software Foundation, Inc. 6 | 7 | timestamp='2009-09-18' 8 | 9 | # This file is free software; you can redistribute it and/or modify it 10 | # under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, but 15 | # WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 22 | # 02110-1301, USA. 23 | # 24 | # As a special exception to the GNU General Public License, if you 25 | # distribute this file as part of a program that contains a 26 | # configuration script generated by Autoconf, you may include it under 27 | # the same distribution terms that you use for the rest of that program. 28 | 29 | 30 | # Originally written by Per Bothner. Please send patches (context 31 | # diff format) to and include a ChangeLog 32 | # entry. 33 | # 34 | # This script attempts to guess a canonical system name similar to 35 | # config.sub. If it succeeds, it prints the system name on stdout, and 36 | # exits with 0. Otherwise, it exits with 1. 37 | # 38 | # You can get the latest version of this script from: 39 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD 40 | 41 | me=`echo "$0" | sed -e 's,.*/,,'` 42 | 43 | usage="\ 44 | Usage: $0 [OPTION] 45 | 46 | Output the configuration name of the system \`$me' is run on. 47 | 48 | Operation modes: 49 | -h, --help print this help, then exit 50 | -t, --time-stamp print date of last modification, then exit 51 | -v, --version print version number, then exit 52 | 53 | Report bugs and patches to ." 54 | 55 | version="\ 56 | GNU config.guess ($timestamp) 57 | 58 | Originally written by Per Bothner. 59 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 60 | 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 61 | 62 | This is free software; see the source for copying conditions. There is NO 63 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 64 | 65 | help=" 66 | Try \`$me --help' for more information." 67 | 68 | # Parse command line 69 | while test $# -gt 0 ; do 70 | case $1 in 71 | --time-stamp | --time* | -t ) 72 | echo "$timestamp" ; exit ;; 73 | --version | -v ) 74 | echo "$version" ; exit ;; 75 | --help | --h* | -h ) 76 | echo "$usage"; exit ;; 77 | -- ) # Stop option processing 78 | shift; break ;; 79 | - ) # Use stdin as input. 80 | break ;; 81 | -* ) 82 | echo "$me: invalid option $1$help" >&2 83 | exit 1 ;; 84 | * ) 85 | break ;; 86 | esac 87 | done 88 | 89 | if test $# != 0; then 90 | echo "$me: too many arguments$help" >&2 91 | exit 1 92 | fi 93 | 94 | trap 'exit 1' 1 2 15 95 | 96 | # CC_FOR_BUILD -- compiler used by this script. Note that the use of a 97 | # compiler to aid in system detection is discouraged as it requires 98 | # temporary files to be created and, as you can see below, it is a 99 | # headache to deal with in a portable fashion. 100 | 101 | # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still 102 | # use `HOST_CC' if defined, but it is deprecated. 103 | 104 | # Portable tmp directory creation inspired by the Autoconf team. 105 | 106 | set_cc_for_build=' 107 | trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; 108 | trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; 109 | : ${TMPDIR=/tmp} ; 110 | { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || 111 | { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || 112 | { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || 113 | { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; 114 | dummy=$tmp/dummy ; 115 | tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; 116 | case $CC_FOR_BUILD,$HOST_CC,$CC in 117 | ,,) echo "int x;" > $dummy.c ; 118 | for c in cc gcc c89 c99 ; do 119 | if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then 120 | CC_FOR_BUILD="$c"; break ; 121 | fi ; 122 | done ; 123 | if test x"$CC_FOR_BUILD" = x ; then 124 | CC_FOR_BUILD=no_compiler_found ; 125 | fi 126 | ;; 127 | ,,*) CC_FOR_BUILD=$CC ;; 128 | ,*,*) CC_FOR_BUILD=$HOST_CC ;; 129 | esac ; set_cc_for_build= ;' 130 | 131 | # This is needed to find uname on a Pyramid OSx when run in the BSD universe. 132 | # (ghazi@noc.rutgers.edu 1994-08-24) 133 | if (test -f /.attbin/uname) >/dev/null 2>&1 ; then 134 | PATH=$PATH:/.attbin ; export PATH 135 | fi 136 | 137 | UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown 138 | UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown 139 | UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown 140 | UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 141 | 142 | # Note: order is significant - the case branches are not exclusive. 143 | 144 | case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in 145 | *:NetBSD:*:*) 146 | # NetBSD (nbsd) targets should (where applicable) match one or 147 | # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, 148 | # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently 149 | # switched to ELF, *-*-netbsd* would select the old 150 | # object file format. This provides both forward 151 | # compatibility and a consistent mechanism for selecting the 152 | # object file format. 153 | # 154 | # Note: NetBSD doesn't particularly care about the vendor 155 | # portion of the name. We always set it to "unknown". 156 | sysctl="sysctl -n hw.machine_arch" 157 | UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ 158 | /usr/sbin/$sysctl 2>/dev/null || echo unknown)` 159 | case "${UNAME_MACHINE_ARCH}" in 160 | armeb) machine=armeb-unknown ;; 161 | arm*) machine=arm-unknown ;; 162 | sh3el) machine=shl-unknown ;; 163 | sh3eb) machine=sh-unknown ;; 164 | sh5el) machine=sh5le-unknown ;; 165 | *) machine=${UNAME_MACHINE_ARCH}-unknown ;; 166 | esac 167 | # The Operating System including object format, if it has switched 168 | # to ELF recently, or will in the future. 169 | case "${UNAME_MACHINE_ARCH}" in 170 | arm*|i386|m68k|ns32k|sh3*|sparc|vax) 171 | eval $set_cc_for_build 172 | if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ 173 | | grep -q __ELF__ 174 | then 175 | # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). 176 | # Return netbsd for either. FIX? 177 | os=netbsd 178 | else 179 | os=netbsdelf 180 | fi 181 | ;; 182 | *) 183 | os=netbsd 184 | ;; 185 | esac 186 | # The OS release 187 | # Debian GNU/NetBSD machines have a different userland, and 188 | # thus, need a distinct triplet. However, they do not need 189 | # kernel version information, so it can be replaced with a 190 | # suitable tag, in the style of linux-gnu. 191 | case "${UNAME_VERSION}" in 192 | Debian*) 193 | release='-gnu' 194 | ;; 195 | *) 196 | release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` 197 | ;; 198 | esac 199 | # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: 200 | # contains redundant information, the shorter form: 201 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. 202 | echo "${machine}-${os}${release}" 203 | exit ;; 204 | *:OpenBSD:*:*) 205 | UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` 206 | echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} 207 | exit ;; 208 | *:ekkoBSD:*:*) 209 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} 210 | exit ;; 211 | *:SolidBSD:*:*) 212 | echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} 213 | exit ;; 214 | macppc:MirBSD:*:*) 215 | echo powerpc-unknown-mirbsd${UNAME_RELEASE} 216 | exit ;; 217 | *:MirBSD:*:*) 218 | echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} 219 | exit ;; 220 | alpha:OSF1:*:*) 221 | case $UNAME_RELEASE in 222 | *4.0) 223 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` 224 | ;; 225 | *5.*) 226 | UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` 227 | ;; 228 | esac 229 | # According to Compaq, /usr/sbin/psrinfo has been available on 230 | # OSF/1 and Tru64 systems produced since 1995. I hope that 231 | # covers most systems running today. This code pipes the CPU 232 | # types through head -n 1, so we only detect the type of CPU 0. 233 | ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` 234 | case "$ALPHA_CPU_TYPE" in 235 | "EV4 (21064)") 236 | UNAME_MACHINE="alpha" ;; 237 | "EV4.5 (21064)") 238 | UNAME_MACHINE="alpha" ;; 239 | "LCA4 (21066/21068)") 240 | UNAME_MACHINE="alpha" ;; 241 | "EV5 (21164)") 242 | UNAME_MACHINE="alphaev5" ;; 243 | "EV5.6 (21164A)") 244 | UNAME_MACHINE="alphaev56" ;; 245 | "EV5.6 (21164PC)") 246 | UNAME_MACHINE="alphapca56" ;; 247 | "EV5.7 (21164PC)") 248 | UNAME_MACHINE="alphapca57" ;; 249 | "EV6 (21264)") 250 | UNAME_MACHINE="alphaev6" ;; 251 | "EV6.7 (21264A)") 252 | UNAME_MACHINE="alphaev67" ;; 253 | "EV6.8CB (21264C)") 254 | UNAME_MACHINE="alphaev68" ;; 255 | "EV6.8AL (21264B)") 256 | UNAME_MACHINE="alphaev68" ;; 257 | "EV6.8CX (21264D)") 258 | UNAME_MACHINE="alphaev68" ;; 259 | "EV6.9A (21264/EV69A)") 260 | UNAME_MACHINE="alphaev69" ;; 261 | "EV7 (21364)") 262 | UNAME_MACHINE="alphaev7" ;; 263 | "EV7.9 (21364A)") 264 | UNAME_MACHINE="alphaev79" ;; 265 | esac 266 | # A Pn.n version is a patched version. 267 | # A Vn.n version is a released version. 268 | # A Tn.n version is a released field test version. 269 | # A Xn.n version is an unreleased experimental baselevel. 270 | # 1.2 uses "1.2" for uname -r. 271 | echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 272 | exit ;; 273 | Alpha\ *:Windows_NT*:*) 274 | # How do we know it's Interix rather than the generic POSIX subsystem? 275 | # Should we change UNAME_MACHINE based on the output of uname instead 276 | # of the specific Alpha model? 277 | echo alpha-pc-interix 278 | exit ;; 279 | 21064:Windows_NT:50:3) 280 | echo alpha-dec-winnt3.5 281 | exit ;; 282 | Amiga*:UNIX_System_V:4.0:*) 283 | echo m68k-unknown-sysv4 284 | exit ;; 285 | *:[Aa]miga[Oo][Ss]:*:*) 286 | echo ${UNAME_MACHINE}-unknown-amigaos 287 | exit ;; 288 | *:[Mm]orph[Oo][Ss]:*:*) 289 | echo ${UNAME_MACHINE}-unknown-morphos 290 | exit ;; 291 | *:OS/390:*:*) 292 | echo i370-ibm-openedition 293 | exit ;; 294 | *:z/VM:*:*) 295 | echo s390-ibm-zvmoe 296 | exit ;; 297 | *:OS400:*:*) 298 | echo powerpc-ibm-os400 299 | exit ;; 300 | arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) 301 | echo arm-acorn-riscix${UNAME_RELEASE} 302 | exit ;; 303 | arm:riscos:*:*|arm:RISCOS:*:*) 304 | echo arm-unknown-riscos 305 | exit ;; 306 | SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) 307 | echo hppa1.1-hitachi-hiuxmpp 308 | exit ;; 309 | Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) 310 | # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. 311 | if test "`(/bin/universe) 2>/dev/null`" = att ; then 312 | echo pyramid-pyramid-sysv3 313 | else 314 | echo pyramid-pyramid-bsd 315 | fi 316 | exit ;; 317 | NILE*:*:*:dcosx) 318 | echo pyramid-pyramid-svr4 319 | exit ;; 320 | DRS?6000:unix:4.0:6*) 321 | echo sparc-icl-nx6 322 | exit ;; 323 | DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) 324 | case `/usr/bin/uname -p` in 325 | sparc) echo sparc-icl-nx7; exit ;; 326 | esac ;; 327 | s390x:SunOS:*:*) 328 | echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 329 | exit ;; 330 | sun4H:SunOS:5.*:*) 331 | echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 332 | exit ;; 333 | sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) 334 | echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 335 | exit ;; 336 | i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) 337 | eval $set_cc_for_build 338 | SUN_ARCH="i386" 339 | # If there is a compiler, see if it is configured for 64-bit objects. 340 | # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. 341 | # This test works for both compilers. 342 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 343 | if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ 344 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 345 | grep IS_64BIT_ARCH >/dev/null 346 | then 347 | SUN_ARCH="x86_64" 348 | fi 349 | fi 350 | echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 351 | exit ;; 352 | sun4*:SunOS:6*:*) 353 | # According to config.sub, this is the proper way to canonicalize 354 | # SunOS6. Hard to guess exactly what SunOS6 will be like, but 355 | # it's likely to be more like Solaris than SunOS4. 356 | echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 357 | exit ;; 358 | sun4*:SunOS:*:*) 359 | case "`/usr/bin/arch -k`" in 360 | Series*|S4*) 361 | UNAME_RELEASE=`uname -v` 362 | ;; 363 | esac 364 | # Japanese Language versions have a version number like `4.1.3-JL'. 365 | echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` 366 | exit ;; 367 | sun3*:SunOS:*:*) 368 | echo m68k-sun-sunos${UNAME_RELEASE} 369 | exit ;; 370 | sun*:*:4.2BSD:*) 371 | UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` 372 | test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 373 | case "`/bin/arch`" in 374 | sun3) 375 | echo m68k-sun-sunos${UNAME_RELEASE} 376 | ;; 377 | sun4) 378 | echo sparc-sun-sunos${UNAME_RELEASE} 379 | ;; 380 | esac 381 | exit ;; 382 | aushp:SunOS:*:*) 383 | echo sparc-auspex-sunos${UNAME_RELEASE} 384 | exit ;; 385 | # The situation for MiNT is a little confusing. The machine name 386 | # can be virtually everything (everything which is not 387 | # "atarist" or "atariste" at least should have a processor 388 | # > m68000). The system name ranges from "MiNT" over "FreeMiNT" 389 | # to the lowercase version "mint" (or "freemint"). Finally 390 | # the system name "TOS" denotes a system which is actually not 391 | # MiNT. But MiNT is downward compatible to TOS, so this should 392 | # be no problem. 393 | atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) 394 | echo m68k-atari-mint${UNAME_RELEASE} 395 | exit ;; 396 | atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) 397 | echo m68k-atari-mint${UNAME_RELEASE} 398 | exit ;; 399 | *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) 400 | echo m68k-atari-mint${UNAME_RELEASE} 401 | exit ;; 402 | milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) 403 | echo m68k-milan-mint${UNAME_RELEASE} 404 | exit ;; 405 | hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) 406 | echo m68k-hades-mint${UNAME_RELEASE} 407 | exit ;; 408 | *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) 409 | echo m68k-unknown-mint${UNAME_RELEASE} 410 | exit ;; 411 | m68k:machten:*:*) 412 | echo m68k-apple-machten${UNAME_RELEASE} 413 | exit ;; 414 | powerpc:machten:*:*) 415 | echo powerpc-apple-machten${UNAME_RELEASE} 416 | exit ;; 417 | RISC*:Mach:*:*) 418 | echo mips-dec-mach_bsd4.3 419 | exit ;; 420 | RISC*:ULTRIX:*:*) 421 | echo mips-dec-ultrix${UNAME_RELEASE} 422 | exit ;; 423 | VAX*:ULTRIX*:*:*) 424 | echo vax-dec-ultrix${UNAME_RELEASE} 425 | exit ;; 426 | 2020:CLIX:*:* | 2430:CLIX:*:*) 427 | echo clipper-intergraph-clix${UNAME_RELEASE} 428 | exit ;; 429 | mips:*:*:UMIPS | mips:*:*:RISCos) 430 | eval $set_cc_for_build 431 | sed 's/^ //' << EOF >$dummy.c 432 | #ifdef __cplusplus 433 | #include /* for printf() prototype */ 434 | int main (int argc, char *argv[]) { 435 | #else 436 | int main (argc, argv) int argc; char *argv[]; { 437 | #endif 438 | #if defined (host_mips) && defined (MIPSEB) 439 | #if defined (SYSTYPE_SYSV) 440 | printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); 441 | #endif 442 | #if defined (SYSTYPE_SVR4) 443 | printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); 444 | #endif 445 | #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) 446 | printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); 447 | #endif 448 | #endif 449 | exit (-1); 450 | } 451 | EOF 452 | $CC_FOR_BUILD -o $dummy $dummy.c && 453 | dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && 454 | SYSTEM_NAME=`$dummy $dummyarg` && 455 | { echo "$SYSTEM_NAME"; exit; } 456 | echo mips-mips-riscos${UNAME_RELEASE} 457 | exit ;; 458 | Motorola:PowerMAX_OS:*:*) 459 | echo powerpc-motorola-powermax 460 | exit ;; 461 | Motorola:*:4.3:PL8-*) 462 | echo powerpc-harris-powermax 463 | exit ;; 464 | Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) 465 | echo powerpc-harris-powermax 466 | exit ;; 467 | Night_Hawk:Power_UNIX:*:*) 468 | echo powerpc-harris-powerunix 469 | exit ;; 470 | m88k:CX/UX:7*:*) 471 | echo m88k-harris-cxux7 472 | exit ;; 473 | m88k:*:4*:R4*) 474 | echo m88k-motorola-sysv4 475 | exit ;; 476 | m88k:*:3*:R3*) 477 | echo m88k-motorola-sysv3 478 | exit ;; 479 | AViiON:dgux:*:*) 480 | # DG/UX returns AViiON for all architectures 481 | UNAME_PROCESSOR=`/usr/bin/uname -p` 482 | if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] 483 | then 484 | if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ 485 | [ ${TARGET_BINARY_INTERFACE}x = x ] 486 | then 487 | echo m88k-dg-dgux${UNAME_RELEASE} 488 | else 489 | echo m88k-dg-dguxbcs${UNAME_RELEASE} 490 | fi 491 | else 492 | echo i586-dg-dgux${UNAME_RELEASE} 493 | fi 494 | exit ;; 495 | M88*:DolphinOS:*:*) # DolphinOS (SVR3) 496 | echo m88k-dolphin-sysv3 497 | exit ;; 498 | M88*:*:R3*:*) 499 | # Delta 88k system running SVR3 500 | echo m88k-motorola-sysv3 501 | exit ;; 502 | XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) 503 | echo m88k-tektronix-sysv3 504 | exit ;; 505 | Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) 506 | echo m68k-tektronix-bsd 507 | exit ;; 508 | *:IRIX*:*:*) 509 | echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` 510 | exit ;; 511 | ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. 512 | echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id 513 | exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' 514 | i*86:AIX:*:*) 515 | echo i386-ibm-aix 516 | exit ;; 517 | ia64:AIX:*:*) 518 | if [ -x /usr/bin/oslevel ] ; then 519 | IBM_REV=`/usr/bin/oslevel` 520 | else 521 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 522 | fi 523 | echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} 524 | exit ;; 525 | *:AIX:2:3) 526 | if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then 527 | eval $set_cc_for_build 528 | sed 's/^ //' << EOF >$dummy.c 529 | #include 530 | 531 | main() 532 | { 533 | if (!__power_pc()) 534 | exit(1); 535 | puts("powerpc-ibm-aix3.2.5"); 536 | exit(0); 537 | } 538 | EOF 539 | if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` 540 | then 541 | echo "$SYSTEM_NAME" 542 | else 543 | echo rs6000-ibm-aix3.2.5 544 | fi 545 | elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then 546 | echo rs6000-ibm-aix3.2.4 547 | else 548 | echo rs6000-ibm-aix3.2 549 | fi 550 | exit ;; 551 | *:AIX:*:[456]) 552 | IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` 553 | if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then 554 | IBM_ARCH=rs6000 555 | else 556 | IBM_ARCH=powerpc 557 | fi 558 | if [ -x /usr/bin/oslevel ] ; then 559 | IBM_REV=`/usr/bin/oslevel` 560 | else 561 | IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} 562 | fi 563 | echo ${IBM_ARCH}-ibm-aix${IBM_REV} 564 | exit ;; 565 | *:AIX:*:*) 566 | echo rs6000-ibm-aix 567 | exit ;; 568 | ibmrt:4.4BSD:*|romp-ibm:BSD:*) 569 | echo romp-ibm-bsd4.4 570 | exit ;; 571 | ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and 572 | echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to 573 | exit ;; # report: romp-ibm BSD 4.3 574 | *:BOSX:*:*) 575 | echo rs6000-bull-bosx 576 | exit ;; 577 | DPX/2?00:B.O.S.:*:*) 578 | echo m68k-bull-sysv3 579 | exit ;; 580 | 9000/[34]??:4.3bsd:1.*:*) 581 | echo m68k-hp-bsd 582 | exit ;; 583 | hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) 584 | echo m68k-hp-bsd4.4 585 | exit ;; 586 | 9000/[34678]??:HP-UX:*:*) 587 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 588 | case "${UNAME_MACHINE}" in 589 | 9000/31? ) HP_ARCH=m68000 ;; 590 | 9000/[34]?? ) HP_ARCH=m68k ;; 591 | 9000/[678][0-9][0-9]) 592 | if [ -x /usr/bin/getconf ]; then 593 | sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` 594 | sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` 595 | case "${sc_cpu_version}" in 596 | 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 597 | 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 598 | 532) # CPU_PA_RISC2_0 599 | case "${sc_kernel_bits}" in 600 | 32) HP_ARCH="hppa2.0n" ;; 601 | 64) HP_ARCH="hppa2.0w" ;; 602 | '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 603 | esac ;; 604 | esac 605 | fi 606 | if [ "${HP_ARCH}" = "" ]; then 607 | eval $set_cc_for_build 608 | sed 's/^ //' << EOF >$dummy.c 609 | 610 | #define _HPUX_SOURCE 611 | #include 612 | #include 613 | 614 | int main () 615 | { 616 | #if defined(_SC_KERNEL_BITS) 617 | long bits = sysconf(_SC_KERNEL_BITS); 618 | #endif 619 | long cpu = sysconf (_SC_CPU_VERSION); 620 | 621 | switch (cpu) 622 | { 623 | case CPU_PA_RISC1_0: puts ("hppa1.0"); break; 624 | case CPU_PA_RISC1_1: puts ("hppa1.1"); break; 625 | case CPU_PA_RISC2_0: 626 | #if defined(_SC_KERNEL_BITS) 627 | switch (bits) 628 | { 629 | case 64: puts ("hppa2.0w"); break; 630 | case 32: puts ("hppa2.0n"); break; 631 | default: puts ("hppa2.0"); break; 632 | } break; 633 | #else /* !defined(_SC_KERNEL_BITS) */ 634 | puts ("hppa2.0"); break; 635 | #endif 636 | default: puts ("hppa1.0"); break; 637 | } 638 | exit (0); 639 | } 640 | EOF 641 | (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` 642 | test -z "$HP_ARCH" && HP_ARCH=hppa 643 | fi ;; 644 | esac 645 | if [ ${HP_ARCH} = "hppa2.0w" ] 646 | then 647 | eval $set_cc_for_build 648 | 649 | # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating 650 | # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler 651 | # generating 64-bit code. GNU and HP use different nomenclature: 652 | # 653 | # $ CC_FOR_BUILD=cc ./config.guess 654 | # => hppa2.0w-hp-hpux11.23 655 | # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess 656 | # => hppa64-hp-hpux11.23 657 | 658 | if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | 659 | grep -q __LP64__ 660 | then 661 | HP_ARCH="hppa2.0w" 662 | else 663 | HP_ARCH="hppa64" 664 | fi 665 | fi 666 | echo ${HP_ARCH}-hp-hpux${HPUX_REV} 667 | exit ;; 668 | ia64:HP-UX:*:*) 669 | HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` 670 | echo ia64-hp-hpux${HPUX_REV} 671 | exit ;; 672 | 3050*:HI-UX:*:*) 673 | eval $set_cc_for_build 674 | sed 's/^ //' << EOF >$dummy.c 675 | #include 676 | int 677 | main () 678 | { 679 | long cpu = sysconf (_SC_CPU_VERSION); 680 | /* The order matters, because CPU_IS_HP_MC68K erroneously returns 681 | true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct 682 | results, however. */ 683 | if (CPU_IS_PA_RISC (cpu)) 684 | { 685 | switch (cpu) 686 | { 687 | case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; 688 | case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; 689 | case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; 690 | default: puts ("hppa-hitachi-hiuxwe2"); break; 691 | } 692 | } 693 | else if (CPU_IS_HP_MC68K (cpu)) 694 | puts ("m68k-hitachi-hiuxwe2"); 695 | else puts ("unknown-hitachi-hiuxwe2"); 696 | exit (0); 697 | } 698 | EOF 699 | $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && 700 | { echo "$SYSTEM_NAME"; exit; } 701 | echo unknown-hitachi-hiuxwe2 702 | exit ;; 703 | 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) 704 | echo hppa1.1-hp-bsd 705 | exit ;; 706 | 9000/8??:4.3bsd:*:*) 707 | echo hppa1.0-hp-bsd 708 | exit ;; 709 | *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) 710 | echo hppa1.0-hp-mpeix 711 | exit ;; 712 | hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) 713 | echo hppa1.1-hp-osf 714 | exit ;; 715 | hp8??:OSF1:*:*) 716 | echo hppa1.0-hp-osf 717 | exit ;; 718 | i*86:OSF1:*:*) 719 | if [ -x /usr/sbin/sysversion ] ; then 720 | echo ${UNAME_MACHINE}-unknown-osf1mk 721 | else 722 | echo ${UNAME_MACHINE}-unknown-osf1 723 | fi 724 | exit ;; 725 | parisc*:Lites*:*:*) 726 | echo hppa1.1-hp-lites 727 | exit ;; 728 | C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) 729 | echo c1-convex-bsd 730 | exit ;; 731 | C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) 732 | if getsysinfo -f scalar_acc 733 | then echo c32-convex-bsd 734 | else echo c2-convex-bsd 735 | fi 736 | exit ;; 737 | C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) 738 | echo c34-convex-bsd 739 | exit ;; 740 | C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) 741 | echo c38-convex-bsd 742 | exit ;; 743 | C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) 744 | echo c4-convex-bsd 745 | exit ;; 746 | CRAY*Y-MP:*:*:*) 747 | echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 748 | exit ;; 749 | CRAY*[A-Z]90:*:*:*) 750 | echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ 751 | | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ 752 | -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ 753 | -e 's/\.[^.]*$/.X/' 754 | exit ;; 755 | CRAY*TS:*:*:*) 756 | echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 757 | exit ;; 758 | CRAY*T3E:*:*:*) 759 | echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 760 | exit ;; 761 | CRAY*SV1:*:*:*) 762 | echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 763 | exit ;; 764 | *:UNICOS/mp:*:*) 765 | echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 766 | exit ;; 767 | F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) 768 | FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` 769 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 770 | FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` 771 | echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 772 | exit ;; 773 | 5000:UNIX_System_V:4.*:*) 774 | FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` 775 | FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` 776 | echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" 777 | exit ;; 778 | i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) 779 | echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} 780 | exit ;; 781 | sparc*:BSD/OS:*:*) 782 | echo sparc-unknown-bsdi${UNAME_RELEASE} 783 | exit ;; 784 | *:BSD/OS:*:*) 785 | echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} 786 | exit ;; 787 | *:FreeBSD:*:*) 788 | case ${UNAME_MACHINE} in 789 | pc98) 790 | echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 791 | amd64) 792 | echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 793 | *) 794 | echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; 795 | esac 796 | exit ;; 797 | i*:CYGWIN*:*) 798 | echo ${UNAME_MACHINE}-pc-cygwin 799 | exit ;; 800 | *:MINGW*:*) 801 | echo ${UNAME_MACHINE}-pc-mingw32 802 | exit ;; 803 | i*:windows32*:*) 804 | # uname -m includes "-pc" on this system. 805 | echo ${UNAME_MACHINE}-mingw32 806 | exit ;; 807 | i*:PW*:*) 808 | echo ${UNAME_MACHINE}-pc-pw32 809 | exit ;; 810 | *:Interix*:[3456]*) 811 | case ${UNAME_MACHINE} in 812 | x86) 813 | echo i586-pc-interix${UNAME_RELEASE} 814 | exit ;; 815 | EM64T | authenticamd | genuineintel) 816 | echo x86_64-unknown-interix${UNAME_RELEASE} 817 | exit ;; 818 | IA64) 819 | echo ia64-unknown-interix${UNAME_RELEASE} 820 | exit ;; 821 | esac ;; 822 | [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) 823 | echo i${UNAME_MACHINE}-pc-mks 824 | exit ;; 825 | 8664:Windows_NT:*) 826 | echo x86_64-pc-mks 827 | exit ;; 828 | i*:Windows_NT*:* | Pentium*:Windows_NT*:*) 829 | # How do we know it's Interix rather than the generic POSIX subsystem? 830 | # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we 831 | # UNAME_MACHINE based on the output of uname instead of i386? 832 | echo i586-pc-interix 833 | exit ;; 834 | i*:UWIN*:*) 835 | echo ${UNAME_MACHINE}-pc-uwin 836 | exit ;; 837 | amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) 838 | echo x86_64-unknown-cygwin 839 | exit ;; 840 | p*:CYGWIN*:*) 841 | echo powerpcle-unknown-cygwin 842 | exit ;; 843 | prep*:SunOS:5.*:*) 844 | echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` 845 | exit ;; 846 | *:GNU:*:*) 847 | # the GNU system 848 | echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` 849 | exit ;; 850 | *:GNU/*:*:*) 851 | # other systems with GNU libc and userland 852 | echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu 853 | exit ;; 854 | i*86:Minix:*:*) 855 | echo ${UNAME_MACHINE}-pc-minix 856 | exit ;; 857 | alpha:Linux:*:*) 858 | case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in 859 | EV5) UNAME_MACHINE=alphaev5 ;; 860 | EV56) UNAME_MACHINE=alphaev56 ;; 861 | PCA56) UNAME_MACHINE=alphapca56 ;; 862 | PCA57) UNAME_MACHINE=alphapca56 ;; 863 | EV6) UNAME_MACHINE=alphaev6 ;; 864 | EV67) UNAME_MACHINE=alphaev67 ;; 865 | EV68*) UNAME_MACHINE=alphaev68 ;; 866 | esac 867 | objdump --private-headers /bin/sh | grep -q ld.so.1 868 | if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi 869 | echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} 870 | exit ;; 871 | arm*:Linux:*:*) 872 | eval $set_cc_for_build 873 | if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ 874 | | grep -q __ARM_EABI__ 875 | then 876 | echo ${UNAME_MACHINE}-unknown-linux-gnu 877 | else 878 | echo ${UNAME_MACHINE}-unknown-linux-gnueabi 879 | fi 880 | exit ;; 881 | avr32*:Linux:*:*) 882 | echo ${UNAME_MACHINE}-unknown-linux-gnu 883 | exit ;; 884 | cris:Linux:*:*) 885 | echo cris-axis-linux-gnu 886 | exit ;; 887 | crisv32:Linux:*:*) 888 | echo crisv32-axis-linux-gnu 889 | exit ;; 890 | frv:Linux:*:*) 891 | echo frv-unknown-linux-gnu 892 | exit ;; 893 | i*86:Linux:*:*) 894 | echo ${UNAME_MACHINE}-pc-linux-gnu 895 | exit ;; 896 | ia64:Linux:*:*) 897 | echo ${UNAME_MACHINE}-unknown-linux-gnu 898 | exit ;; 899 | m32r*:Linux:*:*) 900 | echo ${UNAME_MACHINE}-unknown-linux-gnu 901 | exit ;; 902 | m68*:Linux:*:*) 903 | echo ${UNAME_MACHINE}-unknown-linux-gnu 904 | exit ;; 905 | mips:Linux:*:* | mips64:Linux:*:*) 906 | eval $set_cc_for_build 907 | sed 's/^ //' << EOF >$dummy.c 908 | #undef CPU 909 | #undef ${UNAME_MACHINE} 910 | #undef ${UNAME_MACHINE}el 911 | #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) 912 | CPU=${UNAME_MACHINE}el 913 | #else 914 | #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) 915 | CPU=${UNAME_MACHINE} 916 | #else 917 | CPU= 918 | #endif 919 | #endif 920 | EOF 921 | eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' 922 | /^CPU/{ 923 | s: ::g 924 | p 925 | }'`" 926 | test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } 927 | ;; 928 | or32:Linux:*:*) 929 | echo or32-unknown-linux-gnu 930 | exit ;; 931 | padre:Linux:*:*) 932 | echo sparc-unknown-linux-gnu 933 | exit ;; 934 | parisc64:Linux:*:* | hppa64:Linux:*:*) 935 | echo hppa64-unknown-linux-gnu 936 | exit ;; 937 | parisc:Linux:*:* | hppa:Linux:*:*) 938 | # Look for CPU level 939 | case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in 940 | PA7*) echo hppa1.1-unknown-linux-gnu ;; 941 | PA8*) echo hppa2.0-unknown-linux-gnu ;; 942 | *) echo hppa-unknown-linux-gnu ;; 943 | esac 944 | exit ;; 945 | ppc64:Linux:*:*) 946 | echo powerpc64-unknown-linux-gnu 947 | exit ;; 948 | ppc:Linux:*:*) 949 | echo powerpc-unknown-linux-gnu 950 | exit ;; 951 | s390:Linux:*:* | s390x:Linux:*:*) 952 | echo ${UNAME_MACHINE}-ibm-linux 953 | exit ;; 954 | sh64*:Linux:*:*) 955 | echo ${UNAME_MACHINE}-unknown-linux-gnu 956 | exit ;; 957 | sh*:Linux:*:*) 958 | echo ${UNAME_MACHINE}-unknown-linux-gnu 959 | exit ;; 960 | sparc:Linux:*:* | sparc64:Linux:*:*) 961 | echo ${UNAME_MACHINE}-unknown-linux-gnu 962 | exit ;; 963 | vax:Linux:*:*) 964 | echo ${UNAME_MACHINE}-dec-linux-gnu 965 | exit ;; 966 | x86_64:Linux:*:*) 967 | echo x86_64-unknown-linux-gnu 968 | exit ;; 969 | xtensa*:Linux:*:*) 970 | echo ${UNAME_MACHINE}-unknown-linux-gnu 971 | exit ;; 972 | i*86:DYNIX/ptx:4*:*) 973 | # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. 974 | # earlier versions are messed up and put the nodename in both 975 | # sysname and nodename. 976 | echo i386-sequent-sysv4 977 | exit ;; 978 | i*86:UNIX_SV:4.2MP:2.*) 979 | # Unixware is an offshoot of SVR4, but it has its own version 980 | # number series starting with 2... 981 | # I am not positive that other SVR4 systems won't match this, 982 | # I just have to hope. -- rms. 983 | # Use sysv4.2uw... so that sysv4* matches it. 984 | echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} 985 | exit ;; 986 | i*86:OS/2:*:*) 987 | # If we were able to find `uname', then EMX Unix compatibility 988 | # is probably installed. 989 | echo ${UNAME_MACHINE}-pc-os2-emx 990 | exit ;; 991 | i*86:XTS-300:*:STOP) 992 | echo ${UNAME_MACHINE}-unknown-stop 993 | exit ;; 994 | i*86:atheos:*:*) 995 | echo ${UNAME_MACHINE}-unknown-atheos 996 | exit ;; 997 | i*86:syllable:*:*) 998 | echo ${UNAME_MACHINE}-pc-syllable 999 | exit ;; 1000 | i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) 1001 | echo i386-unknown-lynxos${UNAME_RELEASE} 1002 | exit ;; 1003 | i*86:*DOS:*:*) 1004 | echo ${UNAME_MACHINE}-pc-msdosdjgpp 1005 | exit ;; 1006 | i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) 1007 | UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` 1008 | if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then 1009 | echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} 1010 | else 1011 | echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} 1012 | fi 1013 | exit ;; 1014 | i*86:*:5:[678]*) 1015 | # UnixWare 7.x, OpenUNIX and OpenServer 6. 1016 | case `/bin/uname -X | grep "^Machine"` in 1017 | *486*) UNAME_MACHINE=i486 ;; 1018 | *Pentium) UNAME_MACHINE=i586 ;; 1019 | *Pent*|*Celeron) UNAME_MACHINE=i686 ;; 1020 | esac 1021 | echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} 1022 | exit ;; 1023 | i*86:*:3.2:*) 1024 | if test -f /usr/options/cb.name; then 1025 | UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then 1028 | UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` 1029 | (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 1030 | (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ 1031 | && UNAME_MACHINE=i586 1032 | (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ 1033 | && UNAME_MACHINE=i686 1034 | (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ 1035 | && UNAME_MACHINE=i686 1036 | echo ${UNAME_MACHINE}-pc-sco$UNAME_REL 1037 | else 1038 | echo ${UNAME_MACHINE}-pc-sysv32 1039 | fi 1040 | exit ;; 1041 | pc:*:*:*) 1042 | # Left here for compatibility: 1043 | # uname -m prints for DJGPP always 'pc', but it prints nothing about 1044 | # the processor, so we play safe by assuming i586. 1045 | # Note: whatever this is, it MUST be the same as what config.sub 1046 | # prints for the "djgpp" host, or else GDB configury will decide that 1047 | # this is a cross-build. 1048 | echo i586-pc-msdosdjgpp 1049 | exit ;; 1050 | Intel:Mach:3*:*) 1051 | echo i386-pc-mach3 1052 | exit ;; 1053 | paragon:*:*:*) 1054 | echo i860-intel-osf1 1055 | exit ;; 1056 | i860:*:4.*:*) # i860-SVR4 1057 | if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then 1058 | echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 1059 | else # Add other i860-SVR4 vendors below as they are discovered. 1060 | echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 1061 | fi 1062 | exit ;; 1063 | mini*:CTIX:SYS*5:*) 1064 | # "miniframe" 1065 | echo m68010-convergent-sysv 1066 | exit ;; 1067 | mc68k:UNIX:SYSTEM5:3.51m) 1068 | echo m68k-convergent-sysv 1069 | exit ;; 1070 | M680?0:D-NIX:5.3:*) 1071 | echo m68k-diab-dnix 1072 | exit ;; 1073 | M68*:*:R3V[5678]*:*) 1074 | test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 1075 | 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) 1076 | OS_REL='' 1077 | test -r /etc/.relid \ 1078 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1079 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1080 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1081 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1082 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1083 | 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) 1084 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1085 | && { echo i486-ncr-sysv4; exit; } ;; 1086 | NCR*:*:4.2:* | MPRAS*:*:4.2:*) 1087 | OS_REL='.3' 1088 | test -r /etc/.relid \ 1089 | && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` 1090 | /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ 1091 | && { echo i486-ncr-sysv4.3${OS_REL}; exit; } 1092 | /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ 1093 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } 1094 | /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ 1095 | && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 1096 | m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) 1097 | echo m68k-unknown-lynxos${UNAME_RELEASE} 1098 | exit ;; 1099 | mc68030:UNIX_System_V:4.*:*) 1100 | echo m68k-atari-sysv4 1101 | exit ;; 1102 | TSUNAMI:LynxOS:2.*:*) 1103 | echo sparc-unknown-lynxos${UNAME_RELEASE} 1104 | exit ;; 1105 | rs6000:LynxOS:2.*:*) 1106 | echo rs6000-unknown-lynxos${UNAME_RELEASE} 1107 | exit ;; 1108 | PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) 1109 | echo powerpc-unknown-lynxos${UNAME_RELEASE} 1110 | exit ;; 1111 | SM[BE]S:UNIX_SV:*:*) 1112 | echo mips-dde-sysv${UNAME_RELEASE} 1113 | exit ;; 1114 | RM*:ReliantUNIX-*:*:*) 1115 | echo mips-sni-sysv4 1116 | exit ;; 1117 | RM*:SINIX-*:*:*) 1118 | echo mips-sni-sysv4 1119 | exit ;; 1120 | *:SINIX-*:*:*) 1121 | if uname -p 2>/dev/null >/dev/null ; then 1122 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1123 | echo ${UNAME_MACHINE}-sni-sysv4 1124 | else 1125 | echo ns32k-sni-sysv 1126 | fi 1127 | exit ;; 1128 | PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort 1129 | # says 1130 | echo i586-unisys-sysv4 1131 | exit ;; 1132 | *:UNIX_System_V:4*:FTX*) 1133 | # From Gerald Hewes . 1134 | # How about differentiating between stratus architectures? -djm 1135 | echo hppa1.1-stratus-sysv4 1136 | exit ;; 1137 | *:*:*:FTX*) 1138 | # From seanf@swdc.stratus.com. 1139 | echo i860-stratus-sysv4 1140 | exit ;; 1141 | i*86:VOS:*:*) 1142 | # From Paul.Green@stratus.com. 1143 | echo ${UNAME_MACHINE}-stratus-vos 1144 | exit ;; 1145 | *:VOS:*:*) 1146 | # From Paul.Green@stratus.com. 1147 | echo hppa1.1-stratus-vos 1148 | exit ;; 1149 | mc68*:A/UX:*:*) 1150 | echo m68k-apple-aux${UNAME_RELEASE} 1151 | exit ;; 1152 | news*:NEWS-OS:6*:*) 1153 | echo mips-sony-newsos6 1154 | exit ;; 1155 | R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) 1156 | if [ -d /usr/nec ]; then 1157 | echo mips-nec-sysv${UNAME_RELEASE} 1158 | else 1159 | echo mips-unknown-sysv${UNAME_RELEASE} 1160 | fi 1161 | exit ;; 1162 | BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. 1163 | echo powerpc-be-beos 1164 | exit ;; 1165 | BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. 1166 | echo powerpc-apple-beos 1167 | exit ;; 1168 | BePC:BeOS:*:*) # BeOS running on Intel PC compatible. 1169 | echo i586-pc-beos 1170 | exit ;; 1171 | BePC:Haiku:*:*) # Haiku running on Intel PC compatible. 1172 | echo i586-pc-haiku 1173 | exit ;; 1174 | SX-4:SUPER-UX:*:*) 1175 | echo sx4-nec-superux${UNAME_RELEASE} 1176 | exit ;; 1177 | SX-5:SUPER-UX:*:*) 1178 | echo sx5-nec-superux${UNAME_RELEASE} 1179 | exit ;; 1180 | SX-6:SUPER-UX:*:*) 1181 | echo sx6-nec-superux${UNAME_RELEASE} 1182 | exit ;; 1183 | SX-7:SUPER-UX:*:*) 1184 | echo sx7-nec-superux${UNAME_RELEASE} 1185 | exit ;; 1186 | SX-8:SUPER-UX:*:*) 1187 | echo sx8-nec-superux${UNAME_RELEASE} 1188 | exit ;; 1189 | SX-8R:SUPER-UX:*:*) 1190 | echo sx8r-nec-superux${UNAME_RELEASE} 1191 | exit ;; 1192 | Power*:Rhapsody:*:*) 1193 | echo powerpc-apple-rhapsody${UNAME_RELEASE} 1194 | exit ;; 1195 | *:Rhapsody:*:*) 1196 | echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} 1197 | exit ;; 1198 | *:Darwin:*:*) 1199 | UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown 1200 | case $UNAME_PROCESSOR in 1201 | i386) 1202 | eval $set_cc_for_build 1203 | if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then 1204 | if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ 1205 | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ 1206 | grep IS_64BIT_ARCH >/dev/null 1207 | then 1208 | UNAME_PROCESSOR="x86_64" 1209 | fi 1210 | fi ;; 1211 | unknown) UNAME_PROCESSOR=powerpc ;; 1212 | esac 1213 | echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} 1214 | exit ;; 1215 | *:procnto*:*:* | *:QNX:[0123456789]*:*) 1216 | UNAME_PROCESSOR=`uname -p` 1217 | if test "$UNAME_PROCESSOR" = "x86"; then 1218 | UNAME_PROCESSOR=i386 1219 | UNAME_MACHINE=pc 1220 | fi 1221 | echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} 1222 | exit ;; 1223 | *:QNX:*:4*) 1224 | echo i386-pc-qnx 1225 | exit ;; 1226 | NSE-?:NONSTOP_KERNEL:*:*) 1227 | echo nse-tandem-nsk${UNAME_RELEASE} 1228 | exit ;; 1229 | NSR-?:NONSTOP_KERNEL:*:*) 1230 | echo nsr-tandem-nsk${UNAME_RELEASE} 1231 | exit ;; 1232 | *:NonStop-UX:*:*) 1233 | echo mips-compaq-nonstopux 1234 | exit ;; 1235 | BS2000:POSIX*:*:*) 1236 | echo bs2000-siemens-sysv 1237 | exit ;; 1238 | DS/*:UNIX_System_V:*:*) 1239 | echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} 1240 | exit ;; 1241 | *:Plan9:*:*) 1242 | # "uname -m" is not consistent, so use $cputype instead. 386 1243 | # is converted to i386 for consistency with other x86 1244 | # operating systems. 1245 | if test "$cputype" = "386"; then 1246 | UNAME_MACHINE=i386 1247 | else 1248 | UNAME_MACHINE="$cputype" 1249 | fi 1250 | echo ${UNAME_MACHINE}-unknown-plan9 1251 | exit ;; 1252 | *:TOPS-10:*:*) 1253 | echo pdp10-unknown-tops10 1254 | exit ;; 1255 | *:TENEX:*:*) 1256 | echo pdp10-unknown-tenex 1257 | exit ;; 1258 | KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) 1259 | echo pdp10-dec-tops20 1260 | exit ;; 1261 | XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) 1262 | echo pdp10-xkl-tops20 1263 | exit ;; 1264 | *:TOPS-20:*:*) 1265 | echo pdp10-unknown-tops20 1266 | exit ;; 1267 | *:ITS:*:*) 1268 | echo pdp10-unknown-its 1269 | exit ;; 1270 | SEI:*:*:SEIUX) 1271 | echo mips-sei-seiux${UNAME_RELEASE} 1272 | exit ;; 1273 | *:DragonFly:*:*) 1274 | echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` 1275 | exit ;; 1276 | *:*VMS:*:*) 1277 | UNAME_MACHINE=`(uname -p) 2>/dev/null` 1278 | case "${UNAME_MACHINE}" in 1279 | A*) echo alpha-dec-vms ; exit ;; 1280 | I*) echo ia64-dec-vms ; exit ;; 1281 | V*) echo vax-dec-vms ; exit ;; 1282 | esac ;; 1283 | *:XENIX:*:SysV) 1284 | echo i386-pc-xenix 1285 | exit ;; 1286 | i*86:skyos:*:*) 1287 | echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' 1288 | exit ;; 1289 | i*86:rdos:*:*) 1290 | echo ${UNAME_MACHINE}-pc-rdos 1291 | exit ;; 1292 | i*86:AROS:*:*) 1293 | echo ${UNAME_MACHINE}-pc-aros 1294 | exit ;; 1295 | esac 1296 | 1297 | #echo '(No uname command or uname output not recognized.)' 1>&2 1298 | #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 1299 | 1300 | eval $set_cc_for_build 1301 | cat >$dummy.c < 1304 | # include 1305 | #endif 1306 | main () 1307 | { 1308 | #if defined (sony) 1309 | #if defined (MIPSEB) 1310 | /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, 1311 | I don't know.... */ 1312 | printf ("mips-sony-bsd\n"); exit (0); 1313 | #else 1314 | #include 1315 | printf ("m68k-sony-newsos%s\n", 1316 | #ifdef NEWSOS4 1317 | "4" 1318 | #else 1319 | "" 1320 | #endif 1321 | ); exit (0); 1322 | #endif 1323 | #endif 1324 | 1325 | #if defined (__arm) && defined (__acorn) && defined (__unix) 1326 | printf ("arm-acorn-riscix\n"); exit (0); 1327 | #endif 1328 | 1329 | #if defined (hp300) && !defined (hpux) 1330 | printf ("m68k-hp-bsd\n"); exit (0); 1331 | #endif 1332 | 1333 | #if defined (NeXT) 1334 | #if !defined (__ARCHITECTURE__) 1335 | #define __ARCHITECTURE__ "m68k" 1336 | #endif 1337 | int version; 1338 | version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; 1339 | if (version < 4) 1340 | printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); 1341 | else 1342 | printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); 1343 | exit (0); 1344 | #endif 1345 | 1346 | #if defined (MULTIMAX) || defined (n16) 1347 | #if defined (UMAXV) 1348 | printf ("ns32k-encore-sysv\n"); exit (0); 1349 | #else 1350 | #if defined (CMU) 1351 | printf ("ns32k-encore-mach\n"); exit (0); 1352 | #else 1353 | printf ("ns32k-encore-bsd\n"); exit (0); 1354 | #endif 1355 | #endif 1356 | #endif 1357 | 1358 | #if defined (__386BSD__) 1359 | printf ("i386-pc-bsd\n"); exit (0); 1360 | #endif 1361 | 1362 | #if defined (sequent) 1363 | #if defined (i386) 1364 | printf ("i386-sequent-dynix\n"); exit (0); 1365 | #endif 1366 | #if defined (ns32000) 1367 | printf ("ns32k-sequent-dynix\n"); exit (0); 1368 | #endif 1369 | #endif 1370 | 1371 | #if defined (_SEQUENT_) 1372 | struct utsname un; 1373 | 1374 | uname(&un); 1375 | 1376 | if (strncmp(un.version, "V2", 2) == 0) { 1377 | printf ("i386-sequent-ptx2\n"); exit (0); 1378 | } 1379 | if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ 1380 | printf ("i386-sequent-ptx1\n"); exit (0); 1381 | } 1382 | printf ("i386-sequent-ptx\n"); exit (0); 1383 | 1384 | #endif 1385 | 1386 | #if defined (vax) 1387 | # if !defined (ultrix) 1388 | # include 1389 | # if defined (BSD) 1390 | # if BSD == 43 1391 | printf ("vax-dec-bsd4.3\n"); exit (0); 1392 | # else 1393 | # if BSD == 199006 1394 | printf ("vax-dec-bsd4.3reno\n"); exit (0); 1395 | # else 1396 | printf ("vax-dec-bsd\n"); exit (0); 1397 | # endif 1398 | # endif 1399 | # else 1400 | printf ("vax-dec-bsd\n"); exit (0); 1401 | # endif 1402 | # else 1403 | printf ("vax-dec-ultrix\n"); exit (0); 1404 | # endif 1405 | #endif 1406 | 1407 | #if defined (alliant) && defined (i860) 1408 | printf ("i860-alliant-bsd\n"); exit (0); 1409 | #endif 1410 | 1411 | exit (1); 1412 | } 1413 | EOF 1414 | 1415 | $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && 1416 | { echo "$SYSTEM_NAME"; exit; } 1417 | 1418 | # Apollos put the system type in the environment. 1419 | 1420 | test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } 1421 | 1422 | # Convex versions that predate uname can use getsysinfo(1) 1423 | 1424 | if [ -x /usr/convex/getsysinfo ] 1425 | then 1426 | case `getsysinfo -f cpu_type` in 1427 | c1*) 1428 | echo c1-convex-bsd 1429 | exit ;; 1430 | c2*) 1431 | if getsysinfo -f scalar_acc 1432 | then echo c32-convex-bsd 1433 | else echo c2-convex-bsd 1434 | fi 1435 | exit ;; 1436 | c34*) 1437 | echo c34-convex-bsd 1438 | exit ;; 1439 | c38*) 1440 | echo c38-convex-bsd 1441 | exit ;; 1442 | c4*) 1443 | echo c4-convex-bsd 1444 | exit ;; 1445 | esac 1446 | fi 1447 | 1448 | cat >&2 < in order to provide the needed 1462 | information to handle your system. 1463 | 1464 | config.guess timestamp = $timestamp 1465 | 1466 | uname -m = `(uname -m) 2>/dev/null || echo unknown` 1467 | uname -r = `(uname -r) 2>/dev/null || echo unknown` 1468 | uname -s = `(uname -s) 2>/dev/null || echo unknown` 1469 | uname -v = `(uname -v) 2>/dev/null || echo unknown` 1470 | 1471 | /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` 1472 | /bin/uname -X = `(/bin/uname -X) 2>/dev/null` 1473 | 1474 | hostinfo = `(hostinfo) 2>/dev/null` 1475 | /bin/universe = `(/bin/universe) 2>/dev/null` 1476 | /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` 1477 | /bin/arch = `(/bin/arch) 2>/dev/null` 1478 | /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` 1479 | /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` 1480 | 1481 | UNAME_MACHINE = ${UNAME_MACHINE} 1482 | UNAME_RELEASE = ${UNAME_RELEASE} 1483 | UNAME_SYSTEM = ${UNAME_SYSTEM} 1484 | UNAME_VERSION = ${UNAME_VERSION} 1485 | EOF 1486 | 1487 | exit 1 1488 | 1489 | # Local variables: 1490 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1491 | # time-stamp-start: "timestamp='" 1492 | # time-stamp-format: "%:y-%02m-%02d" 1493 | # time-stamp-end: "'" 1494 | # End: 1495 | -------------------------------------------------------------------------------- /config.sub: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Configuration validation subroutine script. 3 | # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 4 | # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 5 | # Free Software Foundation, Inc. 6 | 7 | timestamp='2009-08-19' 8 | 9 | # This file is (in principle) common to ALL GNU software. 10 | # The presence of a machine in this file suggests that SOME GNU software 11 | # can handle that machine. It does not imply ALL GNU software can. 12 | # 13 | # This file is free software; you can redistribute it and/or modify 14 | # it under the terms of the GNU General Public License as published by 15 | # the Free Software Foundation; either version 2 of the License, or 16 | # (at your option) any later version. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # You should have received a copy of the GNU General Public License 24 | # along with this program; if not, write to the Free Software 25 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 26 | # 02110-1301, USA. 27 | # 28 | # As a special exception to the GNU General Public License, if you 29 | # distribute this file as part of a program that contains a 30 | # configuration script generated by Autoconf, you may include it under 31 | # the same distribution terms that you use for the rest of that program. 32 | 33 | 34 | # Please send patches to . Submit a context 35 | # diff and a properly formatted GNU ChangeLog entry. 36 | # 37 | # Configuration subroutine to validate and canonicalize a configuration type. 38 | # Supply the specified configuration type as an argument. 39 | # If it is invalid, we print an error message on stderr and exit with code 1. 40 | # Otherwise, we print the canonical config type on stdout and succeed. 41 | 42 | # You can get the latest version of this script from: 43 | # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD 44 | 45 | # This file is supposed to be the same for all GNU packages 46 | # and recognize all the CPU types, system types and aliases 47 | # that are meaningful with *any* GNU software. 48 | # Each package is responsible for reporting which valid configurations 49 | # it does not support. The user should be able to distinguish 50 | # a failure to support a valid configuration from a meaningless 51 | # configuration. 52 | 53 | # The goal of this file is to map all the various variations of a given 54 | # machine specification into a single specification in the form: 55 | # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM 56 | # or in some cases, the newer four-part form: 57 | # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM 58 | # It is wrong to echo any other type of specification. 59 | 60 | me=`echo "$0" | sed -e 's,.*/,,'` 61 | 62 | usage="\ 63 | Usage: $0 [OPTION] CPU-MFR-OPSYS 64 | $0 [OPTION] ALIAS 65 | 66 | Canonicalize a configuration name. 67 | 68 | Operation modes: 69 | -h, --help print this help, then exit 70 | -t, --time-stamp print date of last modification, then exit 71 | -v, --version print version number, then exit 72 | 73 | Report bugs and patches to ." 74 | 75 | version="\ 76 | GNU config.sub ($timestamp) 77 | 78 | Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 79 | 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. 80 | 81 | This is free software; see the source for copying conditions. There is NO 82 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 83 | 84 | help=" 85 | Try \`$me --help' for more information." 86 | 87 | # Parse command line 88 | while test $# -gt 0 ; do 89 | case $1 in 90 | --time-stamp | --time* | -t ) 91 | echo "$timestamp" ; exit ;; 92 | --version | -v ) 93 | echo "$version" ; exit ;; 94 | --help | --h* | -h ) 95 | echo "$usage"; exit ;; 96 | -- ) # Stop option processing 97 | shift; break ;; 98 | - ) # Use stdin as input. 99 | break ;; 100 | -* ) 101 | echo "$me: invalid option $1$help" 102 | exit 1 ;; 103 | 104 | *local*) 105 | # First pass through any local machine types. 106 | echo $1 107 | exit ;; 108 | 109 | * ) 110 | break ;; 111 | esac 112 | done 113 | 114 | case $# in 115 | 0) echo "$me: missing argument$help" >&2 116 | exit 1;; 117 | 1) ;; 118 | *) echo "$me: too many arguments$help" >&2 119 | exit 1;; 120 | esac 121 | 122 | # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). 123 | # Here we must recognize all the valid KERNEL-OS combinations. 124 | maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` 125 | case $maybe_os in 126 | nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ 127 | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ 128 | kopensolaris*-gnu* | \ 129 | storm-chaos* | os2-emx* | rtmk-nova*) 130 | os=-$maybe_os 131 | basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` 132 | ;; 133 | *) 134 | basic_machine=`echo $1 | sed 's/-[^-]*$//'` 135 | if [ $basic_machine != $1 ] 136 | then os=`echo $1 | sed 's/.*-/-/'` 137 | else os=; fi 138 | ;; 139 | esac 140 | 141 | ### Let's recognize common machines as not being operating systems so 142 | ### that things like config.sub decstation-3100 work. We also 143 | ### recognize some manufacturers as not being operating systems, so we 144 | ### can provide default operating systems below. 145 | case $os in 146 | -sun*os*) 147 | # Prevent following clause from handling this invalid input. 148 | ;; 149 | -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ 150 | -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ 151 | -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ 152 | -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ 153 | -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ 154 | -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ 155 | -apple | -axis | -knuth | -cray | -microblaze) 156 | os= 157 | basic_machine=$1 158 | ;; 159 | -bluegene*) 160 | os=-cnk 161 | ;; 162 | -sim | -cisco | -oki | -wec | -winbond) 163 | os= 164 | basic_machine=$1 165 | ;; 166 | -scout) 167 | ;; 168 | -wrs) 169 | os=-vxworks 170 | basic_machine=$1 171 | ;; 172 | -chorusos*) 173 | os=-chorusos 174 | basic_machine=$1 175 | ;; 176 | -chorusrdb) 177 | os=-chorusrdb 178 | basic_machine=$1 179 | ;; 180 | -hiux*) 181 | os=-hiuxwe2 182 | ;; 183 | -sco6) 184 | os=-sco5v6 185 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 186 | ;; 187 | -sco5) 188 | os=-sco3.2v5 189 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 190 | ;; 191 | -sco4) 192 | os=-sco3.2v4 193 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 194 | ;; 195 | -sco3.2.[4-9]*) 196 | os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` 197 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 198 | ;; 199 | -sco3.2v[4-9]*) 200 | # Don't forget version if it is 3.2v4 or newer. 201 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 202 | ;; 203 | -sco5v6*) 204 | # Don't forget version if it is 3.2v4 or newer. 205 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 206 | ;; 207 | -sco*) 208 | os=-sco3.2v2 209 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 210 | ;; 211 | -udk*) 212 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 213 | ;; 214 | -isc) 215 | os=-isc2.2 216 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 217 | ;; 218 | -clix*) 219 | basic_machine=clipper-intergraph 220 | ;; 221 | -isc*) 222 | basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` 223 | ;; 224 | -lynx*) 225 | os=-lynxos 226 | ;; 227 | -ptx*) 228 | basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` 229 | ;; 230 | -windowsnt*) 231 | os=`echo $os | sed -e 's/windowsnt/winnt/'` 232 | ;; 233 | -psos*) 234 | os=-psos 235 | ;; 236 | -mint | -mint[0-9]*) 237 | basic_machine=m68k-atari 238 | os=-mint 239 | ;; 240 | esac 241 | 242 | # Decode aliases for certain CPU-COMPANY combinations. 243 | case $basic_machine in 244 | # Recognize the basic CPU types without company name. 245 | # Some are omitted here because they have special meanings below. 246 | 1750a | 580 \ 247 | | a29k \ 248 | | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ 249 | | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ 250 | | am33_2.0 \ 251 | | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ 252 | | bfin \ 253 | | c4x | clipper \ 254 | | d10v | d30v | dlx | dsp16xx \ 255 | | fido | fr30 | frv \ 256 | | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ 257 | | i370 | i860 | i960 | ia64 \ 258 | | ip2k | iq2000 \ 259 | | lm32 \ 260 | | m32c | m32r | m32rle | m68000 | m68k | m88k \ 261 | | maxq | mb | microblaze | mcore | mep | metag \ 262 | | mips | mipsbe | mipseb | mipsel | mipsle \ 263 | | mips16 \ 264 | | mips64 | mips64el \ 265 | | mips64octeon | mips64octeonel \ 266 | | mips64orion | mips64orionel \ 267 | | mips64r5900 | mips64r5900el \ 268 | | mips64vr | mips64vrel \ 269 | | mips64vr4100 | mips64vr4100el \ 270 | | mips64vr4300 | mips64vr4300el \ 271 | | mips64vr5000 | mips64vr5000el \ 272 | | mips64vr5900 | mips64vr5900el \ 273 | | mipsisa32 | mipsisa32el \ 274 | | mipsisa32r2 | mipsisa32r2el \ 275 | | mipsisa64 | mipsisa64el \ 276 | | mipsisa64r2 | mipsisa64r2el \ 277 | | mipsisa64sb1 | mipsisa64sb1el \ 278 | | mipsisa64sr71k | mipsisa64sr71kel \ 279 | | mipstx39 | mipstx39el \ 280 | | mn10200 | mn10300 \ 281 | | moxie \ 282 | | mt \ 283 | | msp430 \ 284 | | nios | nios2 \ 285 | | ns16k | ns32k \ 286 | | or32 \ 287 | | pdp10 | pdp11 | pj | pjl \ 288 | | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ 289 | | pyramid \ 290 | | score \ 291 | | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ 292 | | sh64 | sh64le \ 293 | | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ 294 | | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ 295 | | spu | strongarm \ 296 | | tahoe | thumb | tic4x | tic80 | tron \ 297 | | v850 | v850e \ 298 | | we32k \ 299 | | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ 300 | | z8k | z80) 301 | basic_machine=$basic_machine-unknown 302 | ;; 303 | m6811 | m68hc11 | m6812 | m68hc12) 304 | # Motorola 68HC11/12. 305 | basic_machine=$basic_machine-unknown 306 | os=-none 307 | ;; 308 | m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) 309 | ;; 310 | ms1) 311 | basic_machine=mt-unknown 312 | ;; 313 | 314 | # We use `pc' rather than `unknown' 315 | # because (1) that's what they normally are, and 316 | # (2) the word "unknown" tends to confuse beginning users. 317 | i*86 | x86_64) 318 | basic_machine=$basic_machine-pc 319 | ;; 320 | # Object if more than one company name word. 321 | *-*-*) 322 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 323 | exit 1 324 | ;; 325 | # Recognize the basic CPU types with company name. 326 | 580-* \ 327 | | a29k-* \ 328 | | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ 329 | | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ 330 | | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ 331 | | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ 332 | | avr-* | avr32-* \ 333 | | bfin-* | bs2000-* \ 334 | | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ 335 | | clipper-* | craynv-* | cydra-* \ 336 | | d10v-* | d30v-* | dlx-* \ 337 | | elxsi-* \ 338 | | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ 339 | | h8300-* | h8500-* \ 340 | | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ 341 | | i*86-* | i860-* | i960-* | ia64-* \ 342 | | ip2k-* | iq2000-* \ 343 | | lm32-* \ 344 | | m32c-* | m32r-* | m32rle-* \ 345 | | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ 346 | | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ 347 | | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ 348 | | mips16-* \ 349 | | mips64-* | mips64el-* \ 350 | | mips64octeon-* | mips64octeonel-* \ 351 | | mips64orion-* | mips64orionel-* \ 352 | | mips64r5900-* | mips64r5900el-* \ 353 | | mips64vr-* | mips64vrel-* \ 354 | | mips64vr4100-* | mips64vr4100el-* \ 355 | | mips64vr4300-* | mips64vr4300el-* \ 356 | | mips64vr5000-* | mips64vr5000el-* \ 357 | | mips64vr5900-* | mips64vr5900el-* \ 358 | | mipsisa32-* | mipsisa32el-* \ 359 | | mipsisa32r2-* | mipsisa32r2el-* \ 360 | | mipsisa64-* | mipsisa64el-* \ 361 | | mipsisa64r2-* | mipsisa64r2el-* \ 362 | | mipsisa64sb1-* | mipsisa64sb1el-* \ 363 | | mipsisa64sr71k-* | mipsisa64sr71kel-* \ 364 | | mipstx39-* | mipstx39el-* \ 365 | | mmix-* \ 366 | | mt-* \ 367 | | msp430-* \ 368 | | nios-* | nios2-* \ 369 | | none-* | np1-* | ns16k-* | ns32k-* \ 370 | | orion-* \ 371 | | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ 372 | | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ 373 | | pyramid-* \ 374 | | romp-* | rs6000-* \ 375 | | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ 376 | | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ 377 | | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ 378 | | sparclite-* \ 379 | | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ 380 | | tahoe-* | thumb-* \ 381 | | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ 382 | | tron-* \ 383 | | v850-* | v850e-* | vax-* \ 384 | | we32k-* \ 385 | | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ 386 | | xstormy16-* | xtensa*-* \ 387 | | ymp-* \ 388 | | z8k-* | z80-*) 389 | ;; 390 | # Recognize the basic CPU types without company name, with glob match. 391 | xtensa*) 392 | basic_machine=$basic_machine-unknown 393 | ;; 394 | # Recognize the various machine names and aliases which stand 395 | # for a CPU type and a company and sometimes even an OS. 396 | 386bsd) 397 | basic_machine=i386-unknown 398 | os=-bsd 399 | ;; 400 | 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) 401 | basic_machine=m68000-att 402 | ;; 403 | 3b*) 404 | basic_machine=we32k-att 405 | ;; 406 | a29khif) 407 | basic_machine=a29k-amd 408 | os=-udi 409 | ;; 410 | abacus) 411 | basic_machine=abacus-unknown 412 | ;; 413 | adobe68k) 414 | basic_machine=m68010-adobe 415 | os=-scout 416 | ;; 417 | alliant | fx80) 418 | basic_machine=fx80-alliant 419 | ;; 420 | altos | altos3068) 421 | basic_machine=m68k-altos 422 | ;; 423 | am29k) 424 | basic_machine=a29k-none 425 | os=-bsd 426 | ;; 427 | amd64) 428 | basic_machine=x86_64-pc 429 | ;; 430 | amd64-*) 431 | basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` 432 | ;; 433 | amdahl) 434 | basic_machine=580-amdahl 435 | os=-sysv 436 | ;; 437 | amiga | amiga-*) 438 | basic_machine=m68k-unknown 439 | ;; 440 | amigaos | amigados) 441 | basic_machine=m68k-unknown 442 | os=-amigaos 443 | ;; 444 | amigaunix | amix) 445 | basic_machine=m68k-unknown 446 | os=-sysv4 447 | ;; 448 | apollo68) 449 | basic_machine=m68k-apollo 450 | os=-sysv 451 | ;; 452 | apollo68bsd) 453 | basic_machine=m68k-apollo 454 | os=-bsd 455 | ;; 456 | aros) 457 | basic_machine=i386-pc 458 | os=-aros 459 | ;; 460 | aux) 461 | basic_machine=m68k-apple 462 | os=-aux 463 | ;; 464 | balance) 465 | basic_machine=ns32k-sequent 466 | os=-dynix 467 | ;; 468 | blackfin) 469 | basic_machine=bfin-unknown 470 | os=-linux 471 | ;; 472 | blackfin-*) 473 | basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` 474 | os=-linux 475 | ;; 476 | bluegene*) 477 | basic_machine=powerpc-ibm 478 | os=-cnk 479 | ;; 480 | c90) 481 | basic_machine=c90-cray 482 | os=-unicos 483 | ;; 484 | cegcc) 485 | basic_machine=arm-unknown 486 | os=-cegcc 487 | ;; 488 | convex-c1) 489 | basic_machine=c1-convex 490 | os=-bsd 491 | ;; 492 | convex-c2) 493 | basic_machine=c2-convex 494 | os=-bsd 495 | ;; 496 | convex-c32) 497 | basic_machine=c32-convex 498 | os=-bsd 499 | ;; 500 | convex-c34) 501 | basic_machine=c34-convex 502 | os=-bsd 503 | ;; 504 | convex-c38) 505 | basic_machine=c38-convex 506 | os=-bsd 507 | ;; 508 | cray | j90) 509 | basic_machine=j90-cray 510 | os=-unicos 511 | ;; 512 | craynv) 513 | basic_machine=craynv-cray 514 | os=-unicosmp 515 | ;; 516 | cr16) 517 | basic_machine=cr16-unknown 518 | os=-elf 519 | ;; 520 | crds | unos) 521 | basic_machine=m68k-crds 522 | ;; 523 | crisv32 | crisv32-* | etraxfs*) 524 | basic_machine=crisv32-axis 525 | ;; 526 | cris | cris-* | etrax*) 527 | basic_machine=cris-axis 528 | ;; 529 | crx) 530 | basic_machine=crx-unknown 531 | os=-elf 532 | ;; 533 | da30 | da30-*) 534 | basic_machine=m68k-da30 535 | ;; 536 | decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) 537 | basic_machine=mips-dec 538 | ;; 539 | decsystem10* | dec10*) 540 | basic_machine=pdp10-dec 541 | os=-tops10 542 | ;; 543 | decsystem20* | dec20*) 544 | basic_machine=pdp10-dec 545 | os=-tops20 546 | ;; 547 | delta | 3300 | motorola-3300 | motorola-delta \ 548 | | 3300-motorola | delta-motorola) 549 | basic_machine=m68k-motorola 550 | ;; 551 | delta88) 552 | basic_machine=m88k-motorola 553 | os=-sysv3 554 | ;; 555 | dicos) 556 | basic_machine=i686-pc 557 | os=-dicos 558 | ;; 559 | djgpp) 560 | basic_machine=i586-pc 561 | os=-msdosdjgpp 562 | ;; 563 | dpx20 | dpx20-*) 564 | basic_machine=rs6000-bull 565 | os=-bosx 566 | ;; 567 | dpx2* | dpx2*-bull) 568 | basic_machine=m68k-bull 569 | os=-sysv3 570 | ;; 571 | ebmon29k) 572 | basic_machine=a29k-amd 573 | os=-ebmon 574 | ;; 575 | elxsi) 576 | basic_machine=elxsi-elxsi 577 | os=-bsd 578 | ;; 579 | encore | umax | mmax) 580 | basic_machine=ns32k-encore 581 | ;; 582 | es1800 | OSE68k | ose68k | ose | OSE) 583 | basic_machine=m68k-ericsson 584 | os=-ose 585 | ;; 586 | fx2800) 587 | basic_machine=i860-alliant 588 | ;; 589 | genix) 590 | basic_machine=ns32k-ns 591 | ;; 592 | gmicro) 593 | basic_machine=tron-gmicro 594 | os=-sysv 595 | ;; 596 | go32) 597 | basic_machine=i386-pc 598 | os=-go32 599 | ;; 600 | h3050r* | hiux*) 601 | basic_machine=hppa1.1-hitachi 602 | os=-hiuxwe2 603 | ;; 604 | h8300hms) 605 | basic_machine=h8300-hitachi 606 | os=-hms 607 | ;; 608 | h8300xray) 609 | basic_machine=h8300-hitachi 610 | os=-xray 611 | ;; 612 | h8500hms) 613 | basic_machine=h8500-hitachi 614 | os=-hms 615 | ;; 616 | harris) 617 | basic_machine=m88k-harris 618 | os=-sysv3 619 | ;; 620 | hp300-*) 621 | basic_machine=m68k-hp 622 | ;; 623 | hp300bsd) 624 | basic_machine=m68k-hp 625 | os=-bsd 626 | ;; 627 | hp300hpux) 628 | basic_machine=m68k-hp 629 | os=-hpux 630 | ;; 631 | hp3k9[0-9][0-9] | hp9[0-9][0-9]) 632 | basic_machine=hppa1.0-hp 633 | ;; 634 | hp9k2[0-9][0-9] | hp9k31[0-9]) 635 | basic_machine=m68000-hp 636 | ;; 637 | hp9k3[2-9][0-9]) 638 | basic_machine=m68k-hp 639 | ;; 640 | hp9k6[0-9][0-9] | hp6[0-9][0-9]) 641 | basic_machine=hppa1.0-hp 642 | ;; 643 | hp9k7[0-79][0-9] | hp7[0-79][0-9]) 644 | basic_machine=hppa1.1-hp 645 | ;; 646 | hp9k78[0-9] | hp78[0-9]) 647 | # FIXME: really hppa2.0-hp 648 | basic_machine=hppa1.1-hp 649 | ;; 650 | hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) 651 | # FIXME: really hppa2.0-hp 652 | basic_machine=hppa1.1-hp 653 | ;; 654 | hp9k8[0-9][13679] | hp8[0-9][13679]) 655 | basic_machine=hppa1.1-hp 656 | ;; 657 | hp9k8[0-9][0-9] | hp8[0-9][0-9]) 658 | basic_machine=hppa1.0-hp 659 | ;; 660 | hppa-next) 661 | os=-nextstep3 662 | ;; 663 | hppaosf) 664 | basic_machine=hppa1.1-hp 665 | os=-osf 666 | ;; 667 | hppro) 668 | basic_machine=hppa1.1-hp 669 | os=-proelf 670 | ;; 671 | i370-ibm* | ibm*) 672 | basic_machine=i370-ibm 673 | ;; 674 | # I'm not sure what "Sysv32" means. Should this be sysv3.2? 675 | i*86v32) 676 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 677 | os=-sysv32 678 | ;; 679 | i*86v4*) 680 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 681 | os=-sysv4 682 | ;; 683 | i*86v) 684 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 685 | os=-sysv 686 | ;; 687 | i*86sol2) 688 | basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` 689 | os=-solaris2 690 | ;; 691 | i386mach) 692 | basic_machine=i386-mach 693 | os=-mach 694 | ;; 695 | i386-vsta | vsta) 696 | basic_machine=i386-unknown 697 | os=-vsta 698 | ;; 699 | iris | iris4d) 700 | basic_machine=mips-sgi 701 | case $os in 702 | -irix*) 703 | ;; 704 | *) 705 | os=-irix4 706 | ;; 707 | esac 708 | ;; 709 | isi68 | isi) 710 | basic_machine=m68k-isi 711 | os=-sysv 712 | ;; 713 | m68knommu) 714 | basic_machine=m68k-unknown 715 | os=-linux 716 | ;; 717 | m68knommu-*) 718 | basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` 719 | os=-linux 720 | ;; 721 | m88k-omron*) 722 | basic_machine=m88k-omron 723 | ;; 724 | magnum | m3230) 725 | basic_machine=mips-mips 726 | os=-sysv 727 | ;; 728 | merlin) 729 | basic_machine=ns32k-utek 730 | os=-sysv 731 | ;; 732 | microblaze) 733 | basic_machine=microblaze-xilinx 734 | ;; 735 | mingw32) 736 | basic_machine=i386-pc 737 | os=-mingw32 738 | ;; 739 | mingw32ce) 740 | basic_machine=arm-unknown 741 | os=-mingw32ce 742 | ;; 743 | miniframe) 744 | basic_machine=m68000-convergent 745 | ;; 746 | *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) 747 | basic_machine=m68k-atari 748 | os=-mint 749 | ;; 750 | mips3*-*) 751 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` 752 | ;; 753 | mips3*) 754 | basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown 755 | ;; 756 | monitor) 757 | basic_machine=m68k-rom68k 758 | os=-coff 759 | ;; 760 | morphos) 761 | basic_machine=powerpc-unknown 762 | os=-morphos 763 | ;; 764 | msdos) 765 | basic_machine=i386-pc 766 | os=-msdos 767 | ;; 768 | ms1-*) 769 | basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` 770 | ;; 771 | mvs) 772 | basic_machine=i370-ibm 773 | os=-mvs 774 | ;; 775 | ncr3000) 776 | basic_machine=i486-ncr 777 | os=-sysv4 778 | ;; 779 | netbsd386) 780 | basic_machine=i386-unknown 781 | os=-netbsd 782 | ;; 783 | netwinder) 784 | basic_machine=armv4l-rebel 785 | os=-linux 786 | ;; 787 | news | news700 | news800 | news900) 788 | basic_machine=m68k-sony 789 | os=-newsos 790 | ;; 791 | news1000) 792 | basic_machine=m68030-sony 793 | os=-newsos 794 | ;; 795 | news-3600 | risc-news) 796 | basic_machine=mips-sony 797 | os=-newsos 798 | ;; 799 | necv70) 800 | basic_machine=v70-nec 801 | os=-sysv 802 | ;; 803 | next | m*-next ) 804 | basic_machine=m68k-next 805 | case $os in 806 | -nextstep* ) 807 | ;; 808 | -ns2*) 809 | os=-nextstep2 810 | ;; 811 | *) 812 | os=-nextstep3 813 | ;; 814 | esac 815 | ;; 816 | nh3000) 817 | basic_machine=m68k-harris 818 | os=-cxux 819 | ;; 820 | nh[45]000) 821 | basic_machine=m88k-harris 822 | os=-cxux 823 | ;; 824 | nindy960) 825 | basic_machine=i960-intel 826 | os=-nindy 827 | ;; 828 | mon960) 829 | basic_machine=i960-intel 830 | os=-mon960 831 | ;; 832 | nonstopux) 833 | basic_machine=mips-compaq 834 | os=-nonstopux 835 | ;; 836 | np1) 837 | basic_machine=np1-gould 838 | ;; 839 | nsr-tandem) 840 | basic_machine=nsr-tandem 841 | ;; 842 | op50n-* | op60c-*) 843 | basic_machine=hppa1.1-oki 844 | os=-proelf 845 | ;; 846 | openrisc | openrisc-*) 847 | basic_machine=or32-unknown 848 | ;; 849 | os400) 850 | basic_machine=powerpc-ibm 851 | os=-os400 852 | ;; 853 | OSE68000 | ose68000) 854 | basic_machine=m68000-ericsson 855 | os=-ose 856 | ;; 857 | os68k) 858 | basic_machine=m68k-none 859 | os=-os68k 860 | ;; 861 | pa-hitachi) 862 | basic_machine=hppa1.1-hitachi 863 | os=-hiuxwe2 864 | ;; 865 | paragon) 866 | basic_machine=i860-intel 867 | os=-osf 868 | ;; 869 | parisc) 870 | basic_machine=hppa-unknown 871 | os=-linux 872 | ;; 873 | parisc-*) 874 | basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` 875 | os=-linux 876 | ;; 877 | pbd) 878 | basic_machine=sparc-tti 879 | ;; 880 | pbb) 881 | basic_machine=m68k-tti 882 | ;; 883 | pc532 | pc532-*) 884 | basic_machine=ns32k-pc532 885 | ;; 886 | pc98) 887 | basic_machine=i386-pc 888 | ;; 889 | pc98-*) 890 | basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` 891 | ;; 892 | pentium | p5 | k5 | k6 | nexgen | viac3) 893 | basic_machine=i586-pc 894 | ;; 895 | pentiumpro | p6 | 6x86 | athlon | athlon_*) 896 | basic_machine=i686-pc 897 | ;; 898 | pentiumii | pentium2 | pentiumiii | pentium3) 899 | basic_machine=i686-pc 900 | ;; 901 | pentium4) 902 | basic_machine=i786-pc 903 | ;; 904 | pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) 905 | basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` 906 | ;; 907 | pentiumpro-* | p6-* | 6x86-* | athlon-*) 908 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 909 | ;; 910 | pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) 911 | basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` 912 | ;; 913 | pentium4-*) 914 | basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` 915 | ;; 916 | pn) 917 | basic_machine=pn-gould 918 | ;; 919 | power) basic_machine=power-ibm 920 | ;; 921 | ppc) basic_machine=powerpc-unknown 922 | ;; 923 | ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` 924 | ;; 925 | ppcle | powerpclittle | ppc-le | powerpc-little) 926 | basic_machine=powerpcle-unknown 927 | ;; 928 | ppcle-* | powerpclittle-*) 929 | basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` 930 | ;; 931 | ppc64) basic_machine=powerpc64-unknown 932 | ;; 933 | ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` 934 | ;; 935 | ppc64le | powerpc64little | ppc64-le | powerpc64-little) 936 | basic_machine=powerpc64le-unknown 937 | ;; 938 | ppc64le-* | powerpc64little-*) 939 | basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` 940 | ;; 941 | ps2) 942 | basic_machine=i386-ibm 943 | ;; 944 | pw32) 945 | basic_machine=i586-unknown 946 | os=-pw32 947 | ;; 948 | rdos) 949 | basic_machine=i386-pc 950 | os=-rdos 951 | ;; 952 | rom68k) 953 | basic_machine=m68k-rom68k 954 | os=-coff 955 | ;; 956 | rm[46]00) 957 | basic_machine=mips-siemens 958 | ;; 959 | rtpc | rtpc-*) 960 | basic_machine=romp-ibm 961 | ;; 962 | s390 | s390-*) 963 | basic_machine=s390-ibm 964 | ;; 965 | s390x | s390x-*) 966 | basic_machine=s390x-ibm 967 | ;; 968 | sa29200) 969 | basic_machine=a29k-amd 970 | os=-udi 971 | ;; 972 | sb1) 973 | basic_machine=mipsisa64sb1-unknown 974 | ;; 975 | sb1el) 976 | basic_machine=mipsisa64sb1el-unknown 977 | ;; 978 | sde) 979 | basic_machine=mipsisa32-sde 980 | os=-elf 981 | ;; 982 | sei) 983 | basic_machine=mips-sei 984 | os=-seiux 985 | ;; 986 | sequent) 987 | basic_machine=i386-sequent 988 | ;; 989 | sh) 990 | basic_machine=sh-hitachi 991 | os=-hms 992 | ;; 993 | sh5el) 994 | basic_machine=sh5le-unknown 995 | ;; 996 | sh64) 997 | basic_machine=sh64-unknown 998 | ;; 999 | sparclite-wrs | simso-wrs) 1000 | basic_machine=sparclite-wrs 1001 | os=-vxworks 1002 | ;; 1003 | sps7) 1004 | basic_machine=m68k-bull 1005 | os=-sysv2 1006 | ;; 1007 | spur) 1008 | basic_machine=spur-unknown 1009 | ;; 1010 | st2000) 1011 | basic_machine=m68k-tandem 1012 | ;; 1013 | stratus) 1014 | basic_machine=i860-stratus 1015 | os=-sysv4 1016 | ;; 1017 | sun2) 1018 | basic_machine=m68000-sun 1019 | ;; 1020 | sun2os3) 1021 | basic_machine=m68000-sun 1022 | os=-sunos3 1023 | ;; 1024 | sun2os4) 1025 | basic_machine=m68000-sun 1026 | os=-sunos4 1027 | ;; 1028 | sun3os3) 1029 | basic_machine=m68k-sun 1030 | os=-sunos3 1031 | ;; 1032 | sun3os4) 1033 | basic_machine=m68k-sun 1034 | os=-sunos4 1035 | ;; 1036 | sun4os3) 1037 | basic_machine=sparc-sun 1038 | os=-sunos3 1039 | ;; 1040 | sun4os4) 1041 | basic_machine=sparc-sun 1042 | os=-sunos4 1043 | ;; 1044 | sun4sol2) 1045 | basic_machine=sparc-sun 1046 | os=-solaris2 1047 | ;; 1048 | sun3 | sun3-*) 1049 | basic_machine=m68k-sun 1050 | ;; 1051 | sun4) 1052 | basic_machine=sparc-sun 1053 | ;; 1054 | sun386 | sun386i | roadrunner) 1055 | basic_machine=i386-sun 1056 | ;; 1057 | sv1) 1058 | basic_machine=sv1-cray 1059 | os=-unicos 1060 | ;; 1061 | symmetry) 1062 | basic_machine=i386-sequent 1063 | os=-dynix 1064 | ;; 1065 | t3e) 1066 | basic_machine=alphaev5-cray 1067 | os=-unicos 1068 | ;; 1069 | t90) 1070 | basic_machine=t90-cray 1071 | os=-unicos 1072 | ;; 1073 | tic54x | c54x*) 1074 | basic_machine=tic54x-unknown 1075 | os=-coff 1076 | ;; 1077 | tic55x | c55x*) 1078 | basic_machine=tic55x-unknown 1079 | os=-coff 1080 | ;; 1081 | tic6x | c6x*) 1082 | basic_machine=tic6x-unknown 1083 | os=-coff 1084 | ;; 1085 | tile*) 1086 | basic_machine=tile-unknown 1087 | os=-linux-gnu 1088 | ;; 1089 | tx39) 1090 | basic_machine=mipstx39-unknown 1091 | ;; 1092 | tx39el) 1093 | basic_machine=mipstx39el-unknown 1094 | ;; 1095 | toad1) 1096 | basic_machine=pdp10-xkl 1097 | os=-tops20 1098 | ;; 1099 | tower | tower-32) 1100 | basic_machine=m68k-ncr 1101 | ;; 1102 | tpf) 1103 | basic_machine=s390x-ibm 1104 | os=-tpf 1105 | ;; 1106 | udi29k) 1107 | basic_machine=a29k-amd 1108 | os=-udi 1109 | ;; 1110 | ultra3) 1111 | basic_machine=a29k-nyu 1112 | os=-sym1 1113 | ;; 1114 | v810 | necv810) 1115 | basic_machine=v810-nec 1116 | os=-none 1117 | ;; 1118 | vaxv) 1119 | basic_machine=vax-dec 1120 | os=-sysv 1121 | ;; 1122 | vms) 1123 | basic_machine=vax-dec 1124 | os=-vms 1125 | ;; 1126 | vpp*|vx|vx-*) 1127 | basic_machine=f301-fujitsu 1128 | ;; 1129 | vxworks960) 1130 | basic_machine=i960-wrs 1131 | os=-vxworks 1132 | ;; 1133 | vxworks68) 1134 | basic_machine=m68k-wrs 1135 | os=-vxworks 1136 | ;; 1137 | vxworks29k) 1138 | basic_machine=a29k-wrs 1139 | os=-vxworks 1140 | ;; 1141 | w65*) 1142 | basic_machine=w65-wdc 1143 | os=-none 1144 | ;; 1145 | w89k-*) 1146 | basic_machine=hppa1.1-winbond 1147 | os=-proelf 1148 | ;; 1149 | xbox) 1150 | basic_machine=i686-pc 1151 | os=-mingw32 1152 | ;; 1153 | xps | xps100) 1154 | basic_machine=xps100-honeywell 1155 | ;; 1156 | ymp) 1157 | basic_machine=ymp-cray 1158 | os=-unicos 1159 | ;; 1160 | z8k-*-coff) 1161 | basic_machine=z8k-unknown 1162 | os=-sim 1163 | ;; 1164 | z80-*-coff) 1165 | basic_machine=z80-unknown 1166 | os=-sim 1167 | ;; 1168 | none) 1169 | basic_machine=none-none 1170 | os=-none 1171 | ;; 1172 | 1173 | # Here we handle the default manufacturer of certain CPU types. It is in 1174 | # some cases the only manufacturer, in others, it is the most popular. 1175 | w89k) 1176 | basic_machine=hppa1.1-winbond 1177 | ;; 1178 | op50n) 1179 | basic_machine=hppa1.1-oki 1180 | ;; 1181 | op60c) 1182 | basic_machine=hppa1.1-oki 1183 | ;; 1184 | romp) 1185 | basic_machine=romp-ibm 1186 | ;; 1187 | mmix) 1188 | basic_machine=mmix-knuth 1189 | ;; 1190 | rs6000) 1191 | basic_machine=rs6000-ibm 1192 | ;; 1193 | vax) 1194 | basic_machine=vax-dec 1195 | ;; 1196 | pdp10) 1197 | # there are many clones, so DEC is not a safe bet 1198 | basic_machine=pdp10-unknown 1199 | ;; 1200 | pdp11) 1201 | basic_machine=pdp11-dec 1202 | ;; 1203 | we32k) 1204 | basic_machine=we32k-att 1205 | ;; 1206 | sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) 1207 | basic_machine=sh-unknown 1208 | ;; 1209 | sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) 1210 | basic_machine=sparc-sun 1211 | ;; 1212 | cydra) 1213 | basic_machine=cydra-cydrome 1214 | ;; 1215 | orion) 1216 | basic_machine=orion-highlevel 1217 | ;; 1218 | orion105) 1219 | basic_machine=clipper-highlevel 1220 | ;; 1221 | mac | mpw | mac-mpw) 1222 | basic_machine=m68k-apple 1223 | ;; 1224 | pmac | pmac-mpw) 1225 | basic_machine=powerpc-apple 1226 | ;; 1227 | *-unknown) 1228 | # Make sure to match an already-canonicalized machine name. 1229 | ;; 1230 | *) 1231 | echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 1232 | exit 1 1233 | ;; 1234 | esac 1235 | 1236 | # Here we canonicalize certain aliases for manufacturers. 1237 | case $basic_machine in 1238 | *-digital*) 1239 | basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` 1240 | ;; 1241 | *-commodore*) 1242 | basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` 1243 | ;; 1244 | *) 1245 | ;; 1246 | esac 1247 | 1248 | # Decode manufacturer-specific aliases for certain operating systems. 1249 | 1250 | if [ x"$os" != x"" ] 1251 | then 1252 | case $os in 1253 | # First match some system type aliases 1254 | # that might get confused with valid system types. 1255 | # -solaris* is a basic system type, with this one exception. 1256 | -solaris1 | -solaris1.*) 1257 | os=`echo $os | sed -e 's|solaris1|sunos4|'` 1258 | ;; 1259 | -solaris) 1260 | os=-solaris2 1261 | ;; 1262 | -svr4*) 1263 | os=-sysv4 1264 | ;; 1265 | -unixware*) 1266 | os=-sysv4.2uw 1267 | ;; 1268 | -gnu/linux*) 1269 | os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` 1270 | ;; 1271 | # First accept the basic system types. 1272 | # The portable systems comes first. 1273 | # Each alternative MUST END IN A *, to match a version number. 1274 | # -sysv* is not here because it comes later, after sysvr4. 1275 | -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ 1276 | | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ 1277 | | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ 1278 | | -kopensolaris* \ 1279 | | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ 1280 | | -aos* | -aros* \ 1281 | | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ 1282 | | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ 1283 | | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ 1284 | | -openbsd* | -solidbsd* \ 1285 | | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ 1286 | | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ 1287 | | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ 1288 | | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ 1289 | | -chorusos* | -chorusrdb* | -cegcc* \ 1290 | | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ 1291 | | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ 1292 | | -uxpv* | -beos* | -mpeix* | -udk* \ 1293 | | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ 1294 | | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ 1295 | | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ 1296 | | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ 1297 | | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ 1298 | | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ 1299 | | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) 1300 | # Remember, each alternative MUST END IN *, to match a version number. 1301 | ;; 1302 | -qnx*) 1303 | case $basic_machine in 1304 | x86-* | i*86-*) 1305 | ;; 1306 | *) 1307 | os=-nto$os 1308 | ;; 1309 | esac 1310 | ;; 1311 | -nto-qnx*) 1312 | ;; 1313 | -nto*) 1314 | os=`echo $os | sed -e 's|nto|nto-qnx|'` 1315 | ;; 1316 | -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ 1317 | | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ 1318 | | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) 1319 | ;; 1320 | -mac*) 1321 | os=`echo $os | sed -e 's|mac|macos|'` 1322 | ;; 1323 | -linux-dietlibc) 1324 | os=-linux-dietlibc 1325 | ;; 1326 | -linux*) 1327 | os=`echo $os | sed -e 's|linux|linux-gnu|'` 1328 | ;; 1329 | -sunos5*) 1330 | os=`echo $os | sed -e 's|sunos5|solaris2|'` 1331 | ;; 1332 | -sunos6*) 1333 | os=`echo $os | sed -e 's|sunos6|solaris3|'` 1334 | ;; 1335 | -opened*) 1336 | os=-openedition 1337 | ;; 1338 | -os400*) 1339 | os=-os400 1340 | ;; 1341 | -wince*) 1342 | os=-wince 1343 | ;; 1344 | -osfrose*) 1345 | os=-osfrose 1346 | ;; 1347 | -osf*) 1348 | os=-osf 1349 | ;; 1350 | -utek*) 1351 | os=-bsd 1352 | ;; 1353 | -dynix*) 1354 | os=-bsd 1355 | ;; 1356 | -acis*) 1357 | os=-aos 1358 | ;; 1359 | -atheos*) 1360 | os=-atheos 1361 | ;; 1362 | -syllable*) 1363 | os=-syllable 1364 | ;; 1365 | -386bsd) 1366 | os=-bsd 1367 | ;; 1368 | -ctix* | -uts*) 1369 | os=-sysv 1370 | ;; 1371 | -nova*) 1372 | os=-rtmk-nova 1373 | ;; 1374 | -ns2 ) 1375 | os=-nextstep2 1376 | ;; 1377 | -nsk*) 1378 | os=-nsk 1379 | ;; 1380 | # Preserve the version number of sinix5. 1381 | -sinix5.*) 1382 | os=`echo $os | sed -e 's|sinix|sysv|'` 1383 | ;; 1384 | -sinix*) 1385 | os=-sysv4 1386 | ;; 1387 | -tpf*) 1388 | os=-tpf 1389 | ;; 1390 | -triton*) 1391 | os=-sysv3 1392 | ;; 1393 | -oss*) 1394 | os=-sysv3 1395 | ;; 1396 | -svr4) 1397 | os=-sysv4 1398 | ;; 1399 | -svr3) 1400 | os=-sysv3 1401 | ;; 1402 | -sysvr4) 1403 | os=-sysv4 1404 | ;; 1405 | # This must come after -sysvr4. 1406 | -sysv*) 1407 | ;; 1408 | -ose*) 1409 | os=-ose 1410 | ;; 1411 | -es1800*) 1412 | os=-ose 1413 | ;; 1414 | -xenix) 1415 | os=-xenix 1416 | ;; 1417 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1418 | os=-mint 1419 | ;; 1420 | -aros*) 1421 | os=-aros 1422 | ;; 1423 | -kaos*) 1424 | os=-kaos 1425 | ;; 1426 | -zvmoe) 1427 | os=-zvmoe 1428 | ;; 1429 | -dicos*) 1430 | os=-dicos 1431 | ;; 1432 | -none) 1433 | ;; 1434 | *) 1435 | # Get rid of the `-' at the beginning of $os. 1436 | os=`echo $os | sed 's/[^-]*-//'` 1437 | echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 1438 | exit 1 1439 | ;; 1440 | esac 1441 | else 1442 | 1443 | # Here we handle the default operating systems that come with various machines. 1444 | # The value should be what the vendor currently ships out the door with their 1445 | # machine or put another way, the most popular os provided with the machine. 1446 | 1447 | # Note that if you're going to try to match "-MANUFACTURER" here (say, 1448 | # "-sun"), then you have to tell the case statement up towards the top 1449 | # that MANUFACTURER isn't an operating system. Otherwise, code above 1450 | # will signal an error saying that MANUFACTURER isn't an operating 1451 | # system, and we'll never get to this point. 1452 | 1453 | case $basic_machine in 1454 | score-*) 1455 | os=-elf 1456 | ;; 1457 | spu-*) 1458 | os=-elf 1459 | ;; 1460 | *-acorn) 1461 | os=-riscix1.2 1462 | ;; 1463 | arm*-rebel) 1464 | os=-linux 1465 | ;; 1466 | arm*-semi) 1467 | os=-aout 1468 | ;; 1469 | c4x-* | tic4x-*) 1470 | os=-coff 1471 | ;; 1472 | # This must come before the *-dec entry. 1473 | pdp10-*) 1474 | os=-tops20 1475 | ;; 1476 | pdp11-*) 1477 | os=-none 1478 | ;; 1479 | *-dec | vax-*) 1480 | os=-ultrix4.2 1481 | ;; 1482 | m68*-apollo) 1483 | os=-domain 1484 | ;; 1485 | i386-sun) 1486 | os=-sunos4.0.2 1487 | ;; 1488 | m68000-sun) 1489 | os=-sunos3 1490 | # This also exists in the configure program, but was not the 1491 | # default. 1492 | # os=-sunos4 1493 | ;; 1494 | m68*-cisco) 1495 | os=-aout 1496 | ;; 1497 | mep-*) 1498 | os=-elf 1499 | ;; 1500 | mips*-cisco) 1501 | os=-elf 1502 | ;; 1503 | mips*-*) 1504 | os=-elf 1505 | ;; 1506 | or32-*) 1507 | os=-coff 1508 | ;; 1509 | *-tti) # must be before sparc entry or we get the wrong os. 1510 | os=-sysv3 1511 | ;; 1512 | sparc-* | *-sun) 1513 | os=-sunos4.1.1 1514 | ;; 1515 | *-be) 1516 | os=-beos 1517 | ;; 1518 | *-haiku) 1519 | os=-haiku 1520 | ;; 1521 | *-ibm) 1522 | os=-aix 1523 | ;; 1524 | *-knuth) 1525 | os=-mmixware 1526 | ;; 1527 | *-wec) 1528 | os=-proelf 1529 | ;; 1530 | *-winbond) 1531 | os=-proelf 1532 | ;; 1533 | *-oki) 1534 | os=-proelf 1535 | ;; 1536 | *-hp) 1537 | os=-hpux 1538 | ;; 1539 | *-hitachi) 1540 | os=-hiux 1541 | ;; 1542 | i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) 1543 | os=-sysv 1544 | ;; 1545 | *-cbm) 1546 | os=-amigaos 1547 | ;; 1548 | *-dg) 1549 | os=-dgux 1550 | ;; 1551 | *-dolphin) 1552 | os=-sysv3 1553 | ;; 1554 | m68k-ccur) 1555 | os=-rtu 1556 | ;; 1557 | m88k-omron*) 1558 | os=-luna 1559 | ;; 1560 | *-next ) 1561 | os=-nextstep 1562 | ;; 1563 | *-sequent) 1564 | os=-ptx 1565 | ;; 1566 | *-crds) 1567 | os=-unos 1568 | ;; 1569 | *-ns) 1570 | os=-genix 1571 | ;; 1572 | i370-*) 1573 | os=-mvs 1574 | ;; 1575 | *-next) 1576 | os=-nextstep3 1577 | ;; 1578 | *-gould) 1579 | os=-sysv 1580 | ;; 1581 | *-highlevel) 1582 | os=-bsd 1583 | ;; 1584 | *-encore) 1585 | os=-bsd 1586 | ;; 1587 | *-sgi) 1588 | os=-irix 1589 | ;; 1590 | *-siemens) 1591 | os=-sysv4 1592 | ;; 1593 | *-masscomp) 1594 | os=-rtu 1595 | ;; 1596 | f30[01]-fujitsu | f700-fujitsu) 1597 | os=-uxpv 1598 | ;; 1599 | *-rom68k) 1600 | os=-coff 1601 | ;; 1602 | *-*bug) 1603 | os=-coff 1604 | ;; 1605 | *-apple) 1606 | os=-macos 1607 | ;; 1608 | *-atari*) 1609 | os=-mint 1610 | ;; 1611 | *) 1612 | os=-none 1613 | ;; 1614 | esac 1615 | fi 1616 | 1617 | # Here we handle the case where we know the os, and the CPU type, but not the 1618 | # manufacturer. We pick the logical manufacturer. 1619 | vendor=unknown 1620 | case $basic_machine in 1621 | *-unknown) 1622 | case $os in 1623 | -riscix*) 1624 | vendor=acorn 1625 | ;; 1626 | -sunos*) 1627 | vendor=sun 1628 | ;; 1629 | -cnk*|-aix*) 1630 | vendor=ibm 1631 | ;; 1632 | -beos*) 1633 | vendor=be 1634 | ;; 1635 | -hpux*) 1636 | vendor=hp 1637 | ;; 1638 | -mpeix*) 1639 | vendor=hp 1640 | ;; 1641 | -hiux*) 1642 | vendor=hitachi 1643 | ;; 1644 | -unos*) 1645 | vendor=crds 1646 | ;; 1647 | -dgux*) 1648 | vendor=dg 1649 | ;; 1650 | -luna*) 1651 | vendor=omron 1652 | ;; 1653 | -genix*) 1654 | vendor=ns 1655 | ;; 1656 | -mvs* | -opened*) 1657 | vendor=ibm 1658 | ;; 1659 | -os400*) 1660 | vendor=ibm 1661 | ;; 1662 | -ptx*) 1663 | vendor=sequent 1664 | ;; 1665 | -tpf*) 1666 | vendor=ibm 1667 | ;; 1668 | -vxsim* | -vxworks* | -windiss*) 1669 | vendor=wrs 1670 | ;; 1671 | -aux*) 1672 | vendor=apple 1673 | ;; 1674 | -hms*) 1675 | vendor=hitachi 1676 | ;; 1677 | -mpw* | -macos*) 1678 | vendor=apple 1679 | ;; 1680 | -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) 1681 | vendor=atari 1682 | ;; 1683 | -vos*) 1684 | vendor=stratus 1685 | ;; 1686 | esac 1687 | basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` 1688 | ;; 1689 | esac 1690 | 1691 | echo $basic_machine$os 1692 | exit 1693 | 1694 | # Local variables: 1695 | # eval: (add-hook 'write-file-hooks 'time-stamp) 1696 | # time-stamp-start: "timestamp='" 1697 | # time-stamp-format: "%:y-%02m-%02d" 1698 | # time-stamp-end: "'" 1699 | # End: 1700 | -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if test x"$1" = x"-h" -o x"$1" = x"--help" ; then 4 | 5 | echo "Usage: ./configure [options]" 6 | echo "" 7 | echo "available options:" 8 | echo "" 9 | echo " --help print this message" 10 | echo " --enable-debug adds -g, doesn't strip" 11 | echo " --enable-pic build position-independent code" 12 | echo " --disable-shared don't build libmpegts.so" 13 | echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS" 14 | echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS" 15 | echo " --host=HOST build programs to run on HOST" 16 | echo " --cross-prefix=PREFIX use PREFIX for compilation tools" 17 | echo " --sysroot=SYSROOT root of cross-build tree" 18 | echo "" 19 | exit 1 20 | fi 21 | 22 | log_check() { 23 | echo -n "checking $1... " >> config.log 24 | } 25 | 26 | log_ok() { 27 | echo "yes" >> config.log 28 | } 29 | 30 | log_fail() { 31 | echo "no" >> config.log 32 | } 33 | 34 | log_msg() { 35 | echo "$1" >> config.log 36 | } 37 | 38 | cc_check() { 39 | if [ -z "$3" ]; then 40 | if [ -z "$1$2" ]; then 41 | log_check "whether $CC works" 42 | elif [ -z "$1" ]; then 43 | log_check "for $2" 44 | else 45 | log_check "for $1" 46 | fi 47 | elif [ -z "$1" ]; then 48 | log_check "whether $CC supports $3" 49 | else 50 | log_check "for $3 in $1"; 51 | fi 52 | rm -f conftest.c 53 | [ -n "$1" ] && echo "#include <$1>" > conftest.c 54 | echo "int main () { $3 return 0; }" >> conftest.c 55 | if $CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS -o conftest >conftest.log 2>&1; then 56 | res=$? 57 | log_ok 58 | else 59 | res=$? 60 | log_fail 61 | log_msg "Failed commandline was:" 62 | log_msg "--------------------------------------------------" 63 | log_msg "$CC conftest.c $CFLAGS $2 $LDFLAGSCLI $LDFLAGS" 64 | cat conftest.log >> config.log 65 | log_msg "--------------------------------------------------" 66 | fi 67 | return $res 68 | } 69 | 70 | define() { 71 | echo "#define $1$([ -n "$2" ] && echo " $2" || echo " 1")" >> config.h 72 | } 73 | 74 | die() { 75 | log_msg "DIED: $@" 76 | echo "$@" 77 | exit 1 78 | } 79 | 80 | rm -f config.h config.mak config.log libmpegts.pc conftest* 81 | 82 | prefix='/usr/local' 83 | exec_prefix='${prefix}' 84 | bindir='${exec_prefix}/bin' 85 | libdir='${exec_prefix}/lib' 86 | includedir='${prefix}/include' 87 | DEVNULL='/dev/null' 88 | 89 | debug="no" 90 | pic="no" 91 | shared="no" 92 | 93 | CFLAGS="$CFLAGS -Wall -I." 94 | LDFLAGS="$LDFLAGS" 95 | LDFLAGSCLI="$LDFLAGSCLI" 96 | cross_prefix="" 97 | 98 | EXE="" 99 | 100 | # parse options 101 | 102 | for opt do 103 | optarg="${opt#*=}" 104 | case "$opt" in 105 | --prefix=*) 106 | prefix="$optarg" 107 | ;; 108 | --exec-prefix=*) 109 | exec_prefix="$optarg" 110 | ;; 111 | --bindir=*) 112 | bindir="$optarg" 113 | ;; 114 | --libdir=*) 115 | libdir="$optarg" 116 | ;; 117 | --includedir=*) 118 | includedir="$optarg" 119 | ;; 120 | --extra-cflags=*) 121 | CFLAGS="$CFLAGS ${opt#--extra-cflags=}" 122 | ;; 123 | --extra-ldflags=*) 124 | LDFLAGS="$LDFLAGS ${opt#--extra-ldflags=}" 125 | ;; 126 | --enable-debug) 127 | debug="yes" 128 | ;; 129 | --enable-pic) 130 | pic="yes" 131 | ;; 132 | --disable-shared) 133 | shared="no" 134 | ;; 135 | --host=*) 136 | host="${opt#--host=}" 137 | ;; 138 | --cross-prefix=*) 139 | cross_prefix="${opt#--cross-prefix=}" 140 | ;; 141 | --sysroot=*) 142 | CFLAGS="$CFLAGS --sysroot=${opt#--sysroot=}" 143 | LDFLAGS="$LDFLAGS --sysroot=${opt#--sysroot=}" 144 | ;; 145 | *) 146 | echo "Unknown option $opt, ignored" 147 | ;; 148 | esac 149 | done 150 | 151 | CC="${CC-${cross_prefix}gcc}" 152 | AR="${AR-${cross_prefix}ar}" 153 | RANLIB="${RANLIB-${cross_prefix}ranlib}" 154 | STRIP="${STRIP-${cross_prefix}strip}" 155 | 156 | if [ "x$host" = x ]; then 157 | host=`./config.guess` 158 | fi 159 | # normalize a triplet into a quadruplet 160 | host=`./config.sub $host` 161 | 162 | # split $host 163 | host_cpu="${host%%-*}" 164 | host="${host#*-}" 165 | host_vendor="${host%%-*}" 166 | host_os="${host#*-}" 167 | 168 | case $host_os in 169 | beos*) 170 | SYS="BEOS" 171 | define HAVE_MALLOC_H 172 | ;; 173 | darwin*) 174 | SYS="MACOSX" 175 | CFLAGS="$CFLAGS -falign-loops=16" 176 | LDFLAGS="$LDFLAGS -lm" 177 | if [ "$pic" = "no" ]; then 178 | cc_check "" -mdynamic-no-pic && CFLAGS="$CFLAGS -mdynamic-no-pic" 179 | fi 180 | ;; 181 | freebsd*) 182 | SYS="FREEBSD" 183 | LDFLAGS="$LDFLAGS -lm" 184 | ;; 185 | kfreebsd*-gnu) 186 | SYS="FREEBSD" 187 | define HAVE_MALLOC_H 188 | LDFLAGS="$LDFLAGS -lm" 189 | ;; 190 | netbsd*) 191 | SYS="NETBSD" 192 | LDFLAGS="$LDFLAGS -lm" 193 | ;; 194 | openbsd*) 195 | SYS="OPENBSD" 196 | LDFLAGS="$LDFLAGS -lm" 197 | ;; 198 | *linux*) 199 | SYS="LINUX" 200 | define HAVE_MALLOC_H 201 | LDFLAGS="$LDFLAGS -lm" 202 | ;; 203 | cygwin*) 204 | SYS="MINGW" 205 | EXE=".exe" 206 | DEVNULL="NUL" 207 | if cc_check "" -mno-cygwin; then 208 | CFLAGS="$CFLAGS -mno-cygwin" 209 | LDFLAGS="$LDFLAGS -mno-cygwin" 210 | fi 211 | ;; 212 | mingw*) 213 | SYS="MINGW" 214 | EXE=".exe" 215 | DEVNULL="NUL" 216 | ;; 217 | sunos*|solaris*) 218 | SYS="SunOS" 219 | define HAVE_MALLOC_H 220 | LDFLAGS="$LDFLAGS -lm" 221 | ;; 222 | *) 223 | die "Unknown system $host, edit the configure" 224 | ;; 225 | esac 226 | 227 | case $host_cpu in 228 | i*86) 229 | ARCH="X86" 230 | if [[ "$CFLAGS" != *-march* ]]; then 231 | CFLAGS="$CFLAGS -march=i686" 232 | fi 233 | if [[ "$CFLAGS" != *-mfpmath* ]]; then 234 | CFLAGS="$CFLAGS -mfpmath=sse -msse" 235 | fi 236 | if [ "$SYS" = MINGW ]; then 237 | LDFLAGS="$LDFLAGS -Wl,--large-address-aware" 238 | fi 239 | ;; 240 | x86_64) 241 | ARCH="X86_64" 242 | if [ "$SYS" = MACOSX ];then 243 | if cc_check '' "-arch x86_64"; then 244 | CFLAGS="$CFLAGS -arch x86_64" 245 | LDFLAGS="$LDFLAGS -arch x86_64" 246 | fi 247 | elif [ "$SYS" = MINGW ]; then 248 | cc_check "" "-S" && grep -q "_main:" conftest 249 | fi 250 | ;; 251 | powerpc|powerpc64) 252 | ARCH="PPC" 253 | if [ $SYS = MACOSX ] ; then 254 | CFLAGS="$CFLAGS -faltivec -fastf -mcpu=G4" 255 | else 256 | CFLAGS="$CFLAGS -maltivec -mabi=altivec" 257 | fi 258 | ;; 259 | sparc) 260 | if test "$(uname -m)" = "sun4u"; then 261 | ARCH="UltraSparc" 262 | CFLAGS="$CFLAGS -mcpu=ultrasparc" 263 | LDFLAGS="$LDFLAGS -mcpu=ultrasparc" 264 | else 265 | ARCH="Sparc" 266 | fi 267 | ;; 268 | mips|mipsel|mips64|mips64el) 269 | ARCH="MIPS" 270 | ;; 271 | arm*) 272 | ARCH="ARM" 273 | if [ "$SYS" = MACOSX ] ; then 274 | # build for armv7 by default 275 | if ! echo $CFLAGS | grep -Eq '\-arch' ; then 276 | CFLAGS="$CFLAGS -arch armv7" 277 | LDFLAGS="$LDFLAGS -arch armv7" 278 | fi 279 | fi 280 | ;; 281 | s390|s390x) 282 | ARCH="S390" 283 | ;; 284 | parisc|parisc64) 285 | ARCH="PARISC" 286 | ;; 287 | ia64) 288 | ARCH="IA64" 289 | ;; 290 | *) 291 | ARCH="$(echo $host_cpu | tr a-z A-Z)" 292 | ;; 293 | esac 294 | 295 | log_msg "libmpegts configure script" 296 | if [ -n "$*" ]; then 297 | msg="Command line options:" 298 | for i in $@; do 299 | msg="$msg \"$i\"" 300 | done 301 | log_msg "$msg" 302 | fi 303 | log_msg "" 304 | 305 | # check requirements 306 | 307 | cc_check || die "No working C compiler found." 308 | 309 | if cc_check '' -std=gnu99 ; then 310 | CFLAGS="$CFLAGS -std=gnu99" 311 | elif cc_check '' -std=c99 ; then 312 | CFLAGS="$CFLAGS -std=c99 -D_POSIX_C_SOURCE=200112L -D_BSD_SOURCE" 313 | fi 314 | 315 | if [ $shared = yes -a \( $ARCH = "X86_64" -o $ARCH = "PPC" -o $ARCH = "ALPHA" -o $ARCH = "ARM" -o $ARCH = "IA64" \) ] ; then 316 | pic="yes" 317 | fi 318 | 319 | define ARCH_$ARCH 320 | define SYS_$SYS 321 | 322 | echo "int i = 0x42494745; double f = 0x1.0656e6469616ep+102;" > conftest.c 323 | $CC $CFLAGS conftest.c -c -o conftest.o 2>$DEVNULL || die "endian test failed" 324 | if grep -q BIGE conftest.o && grep -q FPendian conftest.o ; then 325 | define WORDS_BIGENDIAN 326 | elif !(grep -q EGIB conftest.o && grep -q naidnePF conftest.o) ; then 327 | die "endian test failed" 328 | fi 329 | 330 | # autodetect options that weren't forced nor disabled 331 | 332 | if [ "$pic" = "yes" ] ; then 333 | CFLAGS="$CFLAGS -fPIC" 334 | # resolve textrels in the x86 asm 335 | cc_check stdio.h -Wl,-Bsymbolic && LDFLAGS="$LDFLAGS -Wl,-Bsymbolic" 336 | fi 337 | 338 | if [ "$debug" != "yes" -a "$gprof" != "yes" ]; then 339 | CFLAGS="$CFLAGS -s -fomit-frame-pointer" 340 | LDFLAGS="$LDFLAGS -s" 341 | fi 342 | 343 | if [ "$debug" = "yes" ]; then 344 | CFLAGS="-O1 -g $CFLAGS" 345 | elif [ $ARCH = ARM ]; then 346 | # arm-gcc-4.2 produces incorrect output with -ffast-math 347 | # and it doesn't save any speed anyway on 4.4, so disable it 348 | CFLAGS="-O3 -fno-fast-math $CFLAGS" 349 | else 350 | CFLAGS="-O3 -ffast-math $CFLAGS" 351 | fi 352 | 353 | if cc_check '' -fno-tree-vectorize ; then 354 | CFLAGS="$CFLAGS -fno-tree-vectorize" 355 | fi 356 | 357 | if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then 358 | define fseek fseeko 359 | define ftell ftello 360 | elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then 361 | define fseek fseeko64 362 | define ftell ftello64 363 | fi 364 | 365 | if cc_check '' -Wshadow ; then 366 | CFLAGS="-Wshadow $CFLAGS" 367 | fi 368 | 369 | rm -f conftest* 370 | 371 | # generate config files 372 | 373 | cat > config.mak << EOF 374 | prefix=$prefix 375 | exec_prefix=$exec_prefix 376 | bindir=$bindir 377 | libdir=$libdir 378 | includedir=$includedir 379 | ARCH=$ARCH 380 | SYS=$SYS 381 | CC=$CC 382 | CFLAGS=$CFLAGS 383 | LDFLAGS=$LDFLAGS 384 | LDFLAGSCLI=$LDFLAGSCLI 385 | AR=$AR 386 | RANLIB=$RANLIB 387 | STRIP=$STRIP 388 | EXE=$EXE 389 | DEVNULL=$DEVNULL 390 | EOF 391 | 392 | if [ "$shared" = "yes" ]; then 393 | API=$(grep '#define LIBMPEGTS_API_VERSION_MAJOR' < libmpegts.h | cut -f 3 -d ' ') 394 | if [ "$SYS" = "MINGW" ]; then 395 | echo "SONAME=libmpegts-$API.dll" >> config.mak 396 | echo 'IMPLIBNAME=libmpegts.dll.a' >> config.mak 397 | echo 'SOFLAGS=-Wl,--out-implib,$(IMPLIBNAME) -Wl,--enable-auto-image-base' >> config.mak 398 | elif [ "$SYS" = "MACOSX" ]; then 399 | echo "SOSUFFIX=dylib" >> config.mak 400 | echo "SONAME=libmpegts.$API.dylib" >> config.mak 401 | echo 'SOFLAGS=-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress -install_name $(DESTDIR)$(libdir)/$(SONAME)' >> config.mak 402 | elif [ "$SYS" = "SunOS" ]; then 403 | echo "SOSUFFIX=so" >> config.mak 404 | echo "SONAME=libmpegts.so.$API" >> config.mak 405 | echo 'SOFLAGS=-Wl,-h,$(SONAME)' >> config.mak 406 | else 407 | echo "SOSUFFIX=so" >> config.mak 408 | echo "SONAME=libmpegts.so.$API" >> config.mak 409 | echo 'SOFLAGS=-Wl,-soname,$(SONAME)' >> config.mak 410 | fi 411 | echo 'default: $(SONAME)' >> config.mak 412 | fi 413 | 414 | ./version.sh >> config.h 415 | 416 | pclibs="-L$libdir -lmpegts" 417 | 418 | cat > libmpegts.pc << EOF 419 | prefix=$prefix 420 | exec_prefix=$exec_prefix 421 | libdir=$libdir 422 | includedir=$includedir 423 | 424 | Name: libmpegts 425 | Description: MPEG-2 Systems Transport Stream Multiplexer 426 | Version: $(grep POINTVER < config.h | sed -e 's/.* "//; s/".*//') 427 | Libs: $pclibs 428 | Cflags: -I$includedir 429 | EOF 430 | 431 | cat > conftest.log <> config.log 440 | cat conftest.log >> config.log 441 | cat conftest.log 442 | rm conftest.log 443 | 444 | echo 445 | echo "You can run 'make' now." 446 | 447 | -------------------------------------------------------------------------------- /crc/crc.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * crc.c : CRC function 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public icense as published by 8 | * the Free Software Foundation; either version 2 of the icense, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABIITY or FITNESS FOR A PARTICUAR PURPOSE. See the 14 | * GNU General Public icense for more details. 15 | * 16 | * You should have received a copy of the GNU General Public icense 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include "../common.h" 22 | 23 | static const uint32_t crc_table[256] = 24 | { 25 | 0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 26 | 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005, 27 | 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 28 | 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD, 29 | 0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 30 | 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75, 31 | 0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 32 | 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD, 33 | 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 34 | 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 35 | 0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 36 | 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D, 37 | 0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 38 | 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95, 39 | 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 40 | 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 41 | 0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 42 | 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072, 43 | 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 44 | 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 45 | 0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 46 | 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02, 47 | 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 48 | 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA, 49 | 0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 50 | 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692, 51 | 0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 52 | 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A, 53 | 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 54 | 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 55 | 0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 56 | 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A, 57 | 0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 58 | 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB, 59 | 0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 60 | 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53, 61 | 0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 62 | 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B, 63 | 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 64 | 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 65 | 0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 66 | 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B, 67 | 0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 68 | 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3, 69 | 0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 70 | 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 71 | 0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 72 | 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3, 73 | 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 74 | 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 75 | 0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 76 | 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24, 77 | 0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 78 | 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC, 79 | 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 80 | 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 81 | 0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 82 | 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C, 83 | 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 84 | 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 85 | 0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 86 | 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C, 87 | 0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 88 | 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4 89 | }; 90 | 91 | uint32_t crc_32( uint8_t *bytes, int length ) 92 | { 93 | uint32_t crc = 0xffffffff; 94 | 95 | for( int i = 0; i < length; i++ ) 96 | { 97 | int idx = ((crc >> 24) ^ bytes[i]) & 0xff; 98 | crc = crc_table[idx] ^ (crc << 8); 99 | } 100 | return crc; 101 | } 102 | -------------------------------------------------------------------------------- /crc/crc.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * crc.h : crc function header 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_CRC_H 22 | #define LIBMPEGTS_CRC_H 23 | 24 | uint32_t crc_32( uint8_t *bytes, int length ); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /dvb/dvb.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dvb.c : DVB functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include 22 | 23 | #include "../common.h" 24 | #include "dvb.h" 25 | 26 | /**** PMT Second Loop Descriptors ****/ 27 | void write_aac_descriptor( bs_t *s, ts_int_stream_t *stream ) 28 | { 29 | bs_write( s, 8, DVB_AAC_DESCRIPTOR_TAG ); // descriptor_tag 30 | bs_write( s, 8, 2 ); // descriptor_length 31 | bs_write( s, 8, stream->aac_profile ); // profile_and_level 32 | bs_write( s, 1, 0 ); // AAC_type_flag 33 | bs_write( s, 7, 0 ); // reserved 34 | } 35 | 36 | void write_adaptation_field_data_descriptor( bs_t *s, uint8_t identifier ) 37 | { 38 | bs_write( s, 8, DVB_ADAPTATION_FIELD_DATA_DESCRIPTOR ); // descriptor_tag 39 | bs_write( s, 8, 1 ); // descriptor_length 40 | bs_write( s, 8, identifier ); // adaptation_field_data_identifier 41 | } 42 | 43 | void write_dvb_subtitling_descriptor( bs_t *s, ts_int_stream_t *stream ) 44 | { 45 | ts_dvb_sub_t *subtitle; 46 | 47 | bs_write( s, 8, DVB_SUBTITLING_DESCRIPTOR_TAG ); // descriptor_tag 48 | bs_write( s, 8, stream->num_dvb_sub * 8 ); // descriptor_length 49 | for( int i = 0; i < stream->num_dvb_sub; i++ ) 50 | { 51 | subtitle = &stream->dvb_sub_ctx[i]; 52 | for( int j = 0; j < 3; j++ ) 53 | bs_write( s, 8, subtitle->lang_code[j] ); // ISO_639_language_code 54 | bs_write( s, 8, subtitle->subtitling_type ); // subtitling_type 55 | bs_write( s, 16, subtitle->composition_page_id ); // composition_page_id 56 | bs_write( s, 16, subtitle->ancillary_page_id ); // ancillary_page_id 57 | } 58 | } 59 | 60 | void write_stream_identifier_descriptor( bs_t *s, uint8_t stream_identifier ) 61 | { 62 | bs_write( s, 8, DVB_STREAM_IDENTIFIER_DESCRIPTOR_TAG ); // descriptor_tag 63 | bs_write( s, 8, 1 ); // descriptor_length 64 | bs_write( s, 8, stream_identifier ); // component_tag 65 | } 66 | 67 | void write_teletext_descriptor( bs_t *s, ts_int_stream_t *stream, int vbi ) 68 | { 69 | ts_dvb_ttx_t *teletext; 70 | 71 | if( vbi ) 72 | bs_write( s, 8, DVB_VBI_TELETEXT_DESCRIPTOR_TAG ); // descriptor_tag 73 | else 74 | bs_write( s, 8, DVB_TELETEXT_DESCRIPTOR_TAG ); // descriptor_tag 75 | 76 | bs_write( s, 8, stream->num_dvb_ttx * 5 ); // descriptor_length 77 | for( int i = 0; i < stream->num_dvb_ttx; i++ ) 78 | { 79 | teletext = &stream->dvb_ttx_ctx[i]; 80 | for( int j = 0; j < 3; j++ ) 81 | bs_write( s, 8, teletext->lang_code[j] ); // ISO_639_language_code 82 | bs_write( s, 5, teletext->teletext_type ); // teletext_type 83 | bs_write( s, 3, teletext->teletext_magazine_number == 8 ? 0 : teletext->teletext_magazine_number ); // teletext_magazine_number 84 | bs_write( s, 8, teletext->teletext_page_number ); // teletext_page_number 85 | } 86 | } 87 | 88 | void write_vbi_descriptor( bs_t *s, ts_int_stream_t *stream ) 89 | { 90 | bs_t q; 91 | uint8_t temp[1024]; 92 | ts_dvb_vbi_t *vbi; 93 | 94 | bs_init( &q, temp, 1024 ); 95 | 96 | bs_write( s, 8, DVB_VBI_DESCRIPTOR_TAG ); // descriptor_tag 97 | 98 | for( int i = 0; i < stream->num_dvb_vbi; i++ ) 99 | { 100 | vbi = &stream->dvb_vbi_ctx[i]; 101 | 102 | bs_write( &q, 8, vbi->data_service_id ); // data_service_id 103 | bs_write( &q, 8, vbi->num_lines ); // data_service_descriptor_length 104 | 105 | for( int j = 0; j < vbi->num_lines; j++ ) 106 | { 107 | bs_write( &q, 2, 0x3 ); // reserved 108 | bs_write( &q, 1, vbi->lines[j].field_parity ); // field_parity 109 | bs_write( &q, 5, vbi->lines[j].line_offset ); // line_offset 110 | } 111 | } 112 | 113 | bs_flush( &q ); 114 | bs_write( s, 8, bs_pos( &q ) >> 3 ); // descriptor_length 115 | write_bytes( s, temp, bs_pos( &q ) >> 3 ); 116 | } 117 | 118 | 119 | static void write_service_descriptor( bs_t *s, int service_type, char *provider_name, char *service_name ) 120 | { 121 | int provider_name_length = strlen( provider_name ); 122 | int service_name_length = strlen( service_name ); 123 | 124 | bs_write( s, 8, DVB_SERVICE_DESCRIPTOR_TAG ); // descriptor_tag 125 | bs_write( s, 8, provider_name_length + service_name_length + 3 ); // descriptor_length 126 | bs_write( s, 8, service_type ); // service_type 127 | 128 | bs_write( s, 8, provider_name_length ); // service_provider_name_length 129 | while( *provider_name != '\0' ) 130 | bs_write( s, 8, (unsigned char)*provider_name++ ); 131 | 132 | bs_write( s, 8, service_name_length ); // service_name_length 133 | while( *service_name != '\0' ) 134 | bs_write( s, 8, (unsigned char)*service_name++ ); 135 | } 136 | 137 | /* DVB Service Information */ 138 | int write_nit( ts_writer_t *w ) 139 | { 140 | int start; 141 | 142 | bs_t *s = &w->out.bs; 143 | 144 | write_packet_header( w, s, 1, w->network_pid, PAYLOAD_ONLY, &w->nit->cc ); 145 | 146 | bs_write( s, 8, 0 ); // pointer field 147 | 148 | start = bs_pos( s ); 149 | bs_write( s, 8, NIT_TID ); // table_id = network_information_section 150 | bs_write1( s, 1 ); // section_syntax_indicator 151 | bs_write1( s, 1 ); // reserved_future_use 152 | bs_write( s, 2, 0x03 ); // reserved 153 | bs_write( s, 12, 0x13 ); // section_length 154 | bs_write( s, 16, w->network_id ); // network_id 155 | bs_write( s, 2, 0x02 ); // reserved 156 | bs_write( s, 5, 0 ); // version_number 157 | bs_write1( s, 1 ); // current_next_indicator 158 | bs_write(s, 8, 0 ); // section_number 159 | bs_write(s, 8, 0 ); // last_section_number 160 | bs_write(s, 4, 0xf ); // reserved_future_use 161 | bs_write(s, 12, 0 ); // network_descriptors_length 162 | 163 | // network descriptor(s) here 164 | 165 | bs_write(s, 4, 0xf ); // reserved_future_use 166 | bs_write(s, 12, 0 ); // transport_stream_loop_length 167 | 168 | bs_write( s, 16, w->ts_id ); // transport_stream_id 169 | bs_write( s, 16, w->network_id ); // original_network_id 170 | bs_write( s, 4, 0xf ); // reserved_future_use 171 | bs_write(s, 12, 0 ); // transport_descriptors_length 172 | 173 | // transport descriptor(s) here 174 | 175 | bs_flush( s ); 176 | write_crc( s, start ); 177 | 178 | // -40 to include header and pointer field 179 | write_padding( s, start - 40 ); 180 | if( increase_pcr( w, 1, 0 ) < 0 ) 181 | return -1; 182 | 183 | return 0; 184 | } 185 | 186 | /* "The SDT contains data describing the services in the system e.g. names of services, the service provider, etc" */ 187 | int write_sdt( ts_writer_t *w ) 188 | { 189 | int start; 190 | uint8_t *sdt_buf = NULL, *sdt_buf2 = NULL; 191 | int buf_size = 0; 192 | int ret = 0; 193 | int section_length; 194 | 195 | bs_t *s = &w->out.bs; 196 | bs_t q, r; 197 | 198 | buf_size = 200; 199 | 200 | /* Estimate size of buffer */ 201 | for( int i = 0; i < w->num_programs; i++ ) 202 | { 203 | buf_size += strlen( w->programs[i]->sdt_ctx.provider_name ); 204 | buf_size += strlen( w->programs[i]->sdt_ctx.service_name ); 205 | } 206 | 207 | buf_size <<= 1; 208 | sdt_buf = malloc( buf_size ); 209 | if( !sdt_buf ) 210 | { 211 | fprintf( stderr, "malloc failed" ); 212 | goto end; 213 | } 214 | 215 | sdt_buf2 = malloc( buf_size ); 216 | if( !sdt_buf2 ) 217 | { 218 | fprintf( stderr, "malloc failed" ); 219 | goto end; 220 | } 221 | 222 | start = bs_pos( s ); 223 | write_packet_header( w, s, 1, SDT_PID, PAYLOAD_ONLY, &w->sdt->cc ); 224 | bs_write( s, 8, 0 ); // pointer field 225 | 226 | bs_init( &q, sdt_buf, buf_size ); 227 | bs_write( &q, 8, SDT_TID ); // table_id 228 | bs_write1( &q, 1 ); // section_syntax_indicator 229 | bs_write1( &q, 1 ); // reserved_future_use 230 | bs_write( &q, 2, 0x3 ); // reserved 231 | 232 | bs_init( &r, sdt_buf2, buf_size ); 233 | bs_write( &r, 16, w->ts_id ); // transport_stream_id 234 | bs_write( &r, 2, 0x3 ); // reserved 235 | bs_write( &r, 5, 0 ); // version_number 236 | bs_write1( &r, 1 ); // current_next_indicator 237 | bs_write( &r, 8, 0 ); // section_number 238 | bs_write( &r, 8, 0 ); // last_section_number 239 | bs_write( &r, 16, w->network_id ); // original_network_id 240 | bs_write( &r, 8, 0xff ); // reserved_future_use 241 | 242 | for( int i = 0; i < w->num_programs; i++ ) 243 | { 244 | sdt_program_ctx_t *sdt_ctx = &w->programs[i]->sdt_ctx; 245 | 246 | bs_write( &r, 16, w->programs[i]->program_num & 0xffff ); // service_id (equivalent to program_number) 247 | bs_write( &r, 6, 0x3f ); // reserved_future_use 248 | bs_write1( &r, 0 ); // EIT_schedule_flag 249 | bs_write1( &r, 0 ); // EIT_present_following_flag 250 | bs_write( &r, 3, 4 ); // running_status 251 | bs_write1( &r, 0 ); // free_CA_mode 252 | 253 | int provider_name_len = strlen( sdt_ctx->provider_name ); 254 | int service_name_len = strlen( sdt_ctx->service_name ); 255 | 256 | char *provider_name = sdt_ctx->provider_name; 257 | char *service_name = sdt_ctx->service_name; 258 | 259 | int descriptors_len = 5 + provider_name_len + service_name_len; 260 | bs_write( &r, 12, descriptors_len ); // descriptors_loop_length 261 | 262 | // service descriptor (mandatory for DVB) 263 | write_service_descriptor( &r, sdt_ctx->service_type, provider_name, service_name ); 264 | 265 | // other descriptor(s) here 266 | } 267 | 268 | /* section length includes crc */ 269 | section_length = (bs_pos( &r ) >> 3) + 4; 270 | bs_write( &q, 12, section_length & 0x3ff ); // section_length 271 | 272 | /* write main chunk into sdt array */ 273 | bs_flush( &r ); 274 | write_bytes( &q, sdt_buf2, bs_pos( &r ) >> 3 ); 275 | 276 | /* take crc of the whole service description section */ 277 | bs_flush( &q ); 278 | write_crc( &q, 0 ); 279 | 280 | int length = bs_pos( &q ) >> 3; 281 | int bytes_left = TS_PACKET_SIZE - (( bs_pos( s ) - start ) >> 3); 282 | 283 | bs_flush( &q ); 284 | write_bytes( s, sdt_buf, MIN( bytes_left, length ) ); 285 | bs_flush( s ); 286 | 287 | write_padding( s, start ); 288 | if( increase_pcr( w, 1, 0 ) < 0 ) 289 | goto end; 290 | 291 | int pos = MIN( bytes_left, length ); 292 | length -= pos; 293 | 294 | bytes_left = 184; 295 | 296 | /* keep writing SDT packets */ 297 | while( length > 0 ) 298 | { 299 | start = bs_pos( s ); 300 | write_packet_header( w, s, 0, SDT_PID, PAYLOAD_ONLY, &w->sdt->cc ); 301 | write_bytes( s, &sdt_buf[pos], MIN( bytes_left, length ) ); 302 | write_padding( s, start ); 303 | pos += MIN( bytes_left, length ); 304 | length -= MIN( bytes_left, length ); 305 | 306 | if( increase_pcr( w, 1, 0 ) < 0 ) 307 | goto end; 308 | } 309 | 310 | end: 311 | free( sdt_buf ); 312 | free( sdt_buf2 ); 313 | return ret; 314 | } 315 | 316 | #if 0 317 | // FIXME 318 | // "the EIT contains data concerning events or programmes such as event name, start time, duration, etc.; " 319 | void write_eit( ts_writer_t *w ) 320 | { 321 | uint64_t start; 322 | 323 | bs_t *s = &w->out.bs; 324 | 325 | write_packet_header( w, s, 1, EIT_PID, PAYLOAD_ONLY, &w->eit->cc ); 326 | bs_write( s, 8, 0 ); // pointer field 327 | 328 | start = bs_pos( s ); 329 | bs_write( s, 8, EIT_TID ); // table_id 330 | bs_write1( s, 0 ); // section_syntax_indicator CHECKME 331 | bs_write1( s, 1 ); // reserved_future_use 332 | bs_write( s, 2, 0x03); // reserved 333 | 334 | 335 | bs_write( s, 12, len ); // section_length 336 | 337 | } 338 | #endif 339 | 340 | static void write_utc_time( bs_t *s ) 341 | { 342 | int l, mjd; 343 | time_t cur_time; 344 | struct tm *now; 345 | 346 | /* MJD conversions in Annex C of ETSI EN 300 468 */ 347 | cur_time = time( NULL ); 348 | now = gmtime( &cur_time ); 349 | 350 | l = ( ( now->tm_mon + 1 == 1 ) || ( now->tm_mon + 1 == 2 ) ) ? 1 : 0; 351 | mjd = 14956 + now->tm_mday + (int)((now->tm_year - l) * 365.25) + (int)((now->tm_mon + 1 + 1 + l * 12) * 30.6001); 352 | 353 | bs_write( s, 8, mjd >> 8 ); 354 | bs_write( s, 8, mjd & 0xff ); 355 | bs_write( s, 8, (now->tm_hour / 10) << 4 | (now->tm_hour % 10) ); // hours 356 | bs_write( s, 8, (now->tm_min / 10) << 4 | (now->tm_min % 10) ); // minutes 357 | bs_write( s, 8, (now->tm_sec / 10) << 4 | (now->tm_sec % 10) ); // seconds 358 | } 359 | 360 | int write_tdt( ts_writer_t *w ) 361 | { 362 | int start; 363 | bs_t *s = &w->out.bs; 364 | 365 | write_packet_header( w, s, 1, TDT_PID, PAYLOAD_ONLY, &w->tdt->cc ); 366 | bs_write( s, 8, 0 ); // pointer field 367 | 368 | start = bs_pos( s ); 369 | bs_write( s, 8, TDT_TID ); // table_id 370 | bs_write1( s, 0 ); // section_syntax_indicator 371 | bs_write1( s, 1 ); // reserved_future_use 372 | bs_write( s, 2, 0x03 ); // reserved 373 | bs_write( s, 12, 0x05 ); // section_length 374 | 375 | write_utc_time( s ); 376 | 377 | // -40 to include header and pointer field 378 | write_padding( s, start - 40 ); 379 | 380 | if( increase_pcr( w, 1, 0 ) < 0 ) 381 | return -1; 382 | 383 | return 0; 384 | } 385 | 386 | // TODO TOT 387 | 388 | void write_dvb_au_information( bs_t *s, ts_int_pes_t *pes ) 389 | { 390 | bs_t q; 391 | uint8_t temp[128]; 392 | 393 | ts_int_stream_t *stream = pes->stream; 394 | 395 | bs_write( s, 8, AU_INFORMATION_DATA_FIELD ); // data_field_tag 396 | bs_init( &q, temp, 128 ); 397 | 398 | if( stream->stream_format == LIBMPEGTS_VIDEO_MPEG2 ) 399 | bs_write( &q, 4, 1 ); // AU_coding_format 400 | else if( stream->stream_format == LIBMPEGTS_VIDEO_AVC ) 401 | bs_write( &q, 4, 0x2 ); // AU_coding_format 402 | 403 | bs_write( &q, 4, pes->frame_type ); // AU_coding_type_information 404 | bs_write( &q, 2, pes->ref_pic_idc ); // AU_ref_pic_idc 405 | if( stream->stream_format == LIBMPEGTS_VIDEO_MPEG2 ) 406 | bs_write( &q, 2, pes->pic_struct ); // AU_pic_struct 407 | else if( stream->stream_format == LIBMPEGTS_VIDEO_AVC ) 408 | bs_write( &q, 2, 0 ); // AU_coding_format 409 | 410 | bs_write1( &q, 1 ); // AU_PTS_present_flag 411 | bs_write1( &q, 1 ); // AU_profile_info_present_flag 412 | bs_write1( &q, 1 ); // AU_stream_info_present_flag 413 | bs_write1( &q, 0 ); // AU_trick_mode_info_present_flag 414 | 415 | bs_write32( &q, (pes->pts * 300) & 0xffffffff ); // AU_PTS_32 416 | 417 | bs_write( &q, 4, 0 ); // reserved 418 | bs_write( &q, 4, stream->dvb_au_frame_rate ); // AU_frame_rate_code 419 | 420 | bs_write( &q, 8, stream->mpegvideo_ctx->profile & 0xff ); // profile_idc 421 | 422 | if( stream->stream_format == LIBMPEGTS_VIDEO_AVC ) 423 | { 424 | bs_write1( &q, stream->mpegvideo_ctx->profile == AVC_BASELINE ); // constraint_set0_flag 425 | bs_write1( &q, stream->mpegvideo_ctx->profile <= AVC_MAIN ); // constraint_set1_flag 426 | bs_write1( &q, 0 ); // constraint_set2_flag 427 | if( stream->mpegvideo_ctx->level == 9 && stream->mpegvideo_ctx->profile <= AVC_MAIN ) // level 1b 428 | bs_write1( &q, 1 ); // constraint_set3_flag 429 | else if( stream->mpegvideo_ctx->profile == AVC_HIGH_10_INTRA || 430 | stream->mpegvideo_ctx->profile == AVC_CAVLC_444_INTRA || 431 | stream->mpegvideo_ctx->profile == AVC_HIGH_444_INTRA ) 432 | bs_write1( &q, 1 ); // constraint_set3_flag 433 | else 434 | bs_write1( &q, 0 ); // constraint_set3_flag 435 | bs_write1( &q, 0 ); // constraint_set4_flag 436 | bs_write1( &q, 0 ); // constraint_set5_flag 437 | } 438 | else 439 | bs_write( &q, 5, 0 ); 440 | 441 | bs_write( &q, 2, 0 ); // AU_AVC_compatible_flags 442 | bs_write( &q, 8, stream->mpegvideo_ctx->level & 0xff ); // level_idc 443 | 444 | if( pes->write_pulldown_info ) 445 | { 446 | bs_write1( &q, 1 ); // AU_Pulldown_info_present_flag 447 | bs_write( &q, 6, 0 ); // AU_reserved_zero 448 | bs_write1( &q, 0 ); // AU_flags_extension_1 449 | 450 | bs_write( &q, 4, 0 ); // AU_reserved_zero 451 | bs_write( &q, 4, pes->pic_struct & 0xf ); // AU_Pulldown_info 452 | } 453 | 454 | /* reserved bytes */ 455 | 456 | bs_flush( &q ); 457 | bs_write( s, 8, bs_pos( &q ) >> 3 ); // data_field_length 458 | write_bytes( s, temp, bs_pos( &q ) >> 3 ); 459 | } 460 | 461 | 462 | -------------------------------------------------------------------------------- /dvb/dvb.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * dvb.h : DVB specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_DVB_H 22 | #define LIBMPEGTS_DVB_H 23 | 24 | /* Descriptor Tags */ 25 | #define DVB_VBI_DESCRIPTOR_TAG 0x45 26 | #define DVB_VBI_TELETEXT_DESCRIPTOR_TAG 0x46 27 | #define DVB_SERVICE_DESCRIPTOR_TAG 0x48 28 | #define DVB_STREAM_IDENTIFIER_DESCRIPTOR_TAG 0x52 29 | #define DVB_TELETEXT_DESCRIPTOR_TAG 0x56 30 | #define DVB_SUBTITLING_DESCRIPTOR_TAG 0x59 31 | #define DVB_AC3_DESCRIPTOR_TAG 0x6a 32 | #define DVB_ADAPTATION_FIELD_DATA_DESCRIPTOR 0x70 33 | #define DVB_EAC3_DESCRIPTOR_TAG 0x7a 34 | #define DVB_AAC_DESCRIPTOR_TAG 0x7c 35 | #define DVB_EXTENSION_DESCRIPTOR_TAG 0x7f 36 | 37 | /* PIDs */ 38 | #define SDT_PID 0x0011 39 | #define EIT_PID 0x0012 40 | #define TDT_PID 0x0014 41 | 42 | /* TIDs */ 43 | #define SDT_TID 0x42 44 | #define EIT_TID 0x4e 45 | #define TDT_TID 0x70 46 | 47 | /* Default Retransmit times (ms) */ 48 | #define SDT_MAX_RETRANS_TIME 2000 49 | #define EIT_MAX_RETRANS_TIME 2000 50 | #define EIT_OTHER_TS_MAX_RETRANS_TIME 10000 51 | #define TDT_MAX_RETRANS_TIME 25000 52 | #define TOT_MAX_RETRANS_TIME 25000 53 | 54 | /* Private Data Bytes data_field_tags */ 55 | #define ANNOUNCEMENT_SWITCHING_DATA_FIELD 0x01 56 | #define AU_INFORMATION_DATA_FIELD 0x02 57 | #define PVR_ASSIST_INFORMATION_DATA_FIELD 0x03 58 | 59 | void write_aac_descriptor( bs_t *s, ts_int_stream_t *stream ); 60 | void write_adaptation_field_data_descriptor( bs_t *s, uint8_t identifier ); 61 | void write_dvb_subtitling_descriptor( bs_t *s, ts_int_stream_t *stream ); 62 | void write_stream_identifier_descriptor( bs_t *s, uint8_t stream_identifier ); 63 | void write_teletext_descriptor( bs_t *s, ts_int_stream_t *stream, int vbi ); 64 | void write_vbi_descriptor( bs_t *s, ts_int_stream_t *stream ); 65 | 66 | int write_nit( ts_writer_t *w ); 67 | int write_sdt( ts_writer_t *w ); 68 | //void write_eit( ts_writer_t *w ); 69 | int write_tdt( ts_writer_t *w ); 70 | 71 | void write_dvb_au_information( bs_t *s, ts_int_pes_t *pes ); 72 | #endif 73 | -------------------------------------------------------------------------------- /hdmv/hdmv.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * hdmv.c : HDMV specific functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include "../common.h" 22 | #include "hdmv.h" 23 | 24 | int ts_setup_hdmv_lpcm_stream( ts_writer_t *w, int pid, int num_channels, int sample_rate, int bits_per_sample ) 25 | { 26 | ts_int_stream_t *stream = find_stream( w, pid ); 27 | 28 | if( !stream ) 29 | { 30 | fprintf( stderr, "Invalid PID\n" ); 31 | return -1; 32 | } 33 | 34 | stream->lpcm_ctx = calloc( 1, sizeof(*stream->lpcm_ctx) ); 35 | if( !stream->lpcm_ctx ) 36 | return -1; 37 | 38 | stream->lpcm_ctx->num_channels = num_channels; 39 | stream->lpcm_ctx->sample_rate = sample_rate; 40 | stream->lpcm_ctx->bits_per_sample = bits_per_sample; 41 | 42 | return 0; 43 | } 44 | 45 | int ts_setup_dtcp( ts_writer_t *w, uint8_t byte_1, uint8_t byte_2 ) 46 | { 47 | w->dtcp_ctx = calloc( 1, sizeof(*w->dtcp_ctx) ); 48 | if( !w->dtcp_ctx ) 49 | return -1; 50 | 51 | w->dtcp_ctx->byte_1 = byte_1; 52 | w->dtcp_ctx->byte_2 = byte_2; 53 | 54 | return 0; 55 | } 56 | 57 | /**** First Loop of PMT Descriptors ****/ 58 | void write_hdmv_copy_control_descriptor( ts_writer_t *w, bs_t *s ) 59 | { 60 | bs_write( s, 8, HDMV_COPY_CTRL_DESCRIPTOR_TAG ); // descriptor_tag 61 | bs_write( s, 8, 0x04 ); // descriptor_length 62 | bs_write( s, 16, 0x0fff ); // CA_System_ID 63 | bs_write( s, 8, w->dtcp_ctx->byte_1 ); // private_data_byte 64 | bs_write( s, 8, w->dtcp_ctx->byte_2 ); // private_data_byte 65 | } 66 | 67 | /**** Second Loop of PMT Descriptors ****/ 68 | void write_hdmv_video_registration_descriptor( bs_t *s, ts_int_stream_t *stream ) 69 | { 70 | char *format_id = "HDMV"; 71 | 72 | bs_write( s, 8, REGISTRATION_DESCRIPTOR_TAG ); // descriptor_tag 73 | bs_write( s, 8, 0x8 ); // descriptor_length 74 | while( *format_id != '\0' ) 75 | bs_write( s, 8, *format_id++ ); // format_identifier 76 | 77 | bs_write( s, 8, 0xff ); // stuffing_bits 78 | bs_write( s, 8, stream->stream_id ); // stream_coding_type 79 | bs_write( s, 4, stream->hdmv_video_format ); // video_format 80 | bs_write( s, 4, stream->hdmv_frame_rate ); // frame_rate 81 | bs_write( s, 4, stream->hdmv_aspect_ratio ); // aspect_ratio 82 | bs_write( s, 4, 0xf ); // stuffing_bits 83 | } 84 | 85 | void write_hdmv_lpcm_descriptor( bs_t *s, ts_int_stream_t *stream ) 86 | { 87 | write_registration_descriptor( s, REGISTRATION_DESCRIPTOR_TAG, 8, "HDMV" ); 88 | bs_write( s, 8, 0xff ); // stuffing_bits 89 | bs_write( s, 8, stream->stream_type ); // stream_coding_type 90 | 91 | if( stream->lpcm_ctx->num_channels == 1 ) 92 | bs_write( s, 4, 1 ); // audio_presentation_type 93 | else if( stream->lpcm_ctx->num_channels == 2 ) 94 | bs_write( s, 4, 0x03 ); // audio_presentation_type 95 | else 96 | bs_write( s, 4, 0x06 ); // audio_presentation_type 97 | 98 | if( stream->lpcm_ctx->sample_rate == 48 ) 99 | bs_write( s, 4, 1 ); // sampling_frequency 100 | else if( stream->lpcm_ctx->sample_rate == 96 ) 101 | bs_write( s, 4, 0x04 ); // sampling_frequency 102 | else 103 | bs_write( s, 4, 0x05 ); // sampling_frequency 104 | 105 | if( stream->lpcm_ctx->bits_per_sample == 16 ) 106 | bs_write( s, 2, 1 ); // bits_per_sample 107 | else if( stream->lpcm_ctx->bits_per_sample == 20 ) 108 | bs_write( s, 2, 0x02 ); // bits_per_sample 109 | else 110 | bs_write( s, 2, 0x03 ); // bits_per_sample 111 | 112 | bs_write( s, 6, 0x3f ); // stuffing_bits 113 | 114 | } 115 | 116 | /**** In loop of SIT ****/ 117 | void write_partial_ts_descriptor( ts_writer_t *w, bs_t *s ) 118 | { 119 | bs_write( s, 8, HDMV_PARTIAL_TS_DESCRIPTOR_TAG ); // descriptor_tag 120 | bs_write( s, 8, 0x08 ); // descriptor_length 121 | bs_write( s, 2, 0x03 ); // DVB_reserved_future_use 122 | bs_write( s, 22, w->ts_muxrate / 400 ); // peak_rate 123 | bs_write( s, 2, 0x03 ); // DVB_reserved_future_use 124 | bs_write( s, 22, 0x3fffff ); // minimum_overall_smoothing_rate 125 | bs_write( s, 2, 0x03 ); // DVB_reserved_future_use 126 | bs_write( s, 14, 0x3fff ); // maximum_overall_smoothing_buffer 127 | } 128 | -------------------------------------------------------------------------------- /hdmv/hdmv.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * hdmv.h : HDMV specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_HDMV_H 22 | #define LIBMPEGTS_HDMV_H 23 | 24 | /* Blu-Ray specific stream types */ 25 | #define AUDIO_LPCM 0x80 26 | #define AUDIO_DTS 0x82 27 | #define AUDIO_DOLBY_LOSSLESS 0x83 28 | #define AUDIO_DTS_HD 0x85 29 | #define AUDIO_DTS_HD_XLL 0x86 30 | #define AUDIO_EAC3_SECONDARY 0xa1 31 | #define AUDIO_DTS_HD_SECONDARY 0xa2 32 | #define SUB_PRESENTATION_GRAPHICS 0x90 33 | #define SUB_INTERACTIVE_GRAPHICS 0x91 34 | #define SUB_TEXT 0x92 35 | 36 | /* Descriptor Tags */ 37 | #define HDMV_PARTIAL_TS_DESCRIPTOR_TAG 0x63 38 | #define HDMV_AC3_DESCRIPTOR_TAG 0x81 39 | #define HDMV_CAPTION_DESCRIPTOR_TAG 0x86 40 | #define HDMV_COPY_CTRL_DESCRIPTOR_TAG 0x88 41 | 42 | void write_hdmv_copy_control_descriptor( ts_writer_t *w, bs_t *s ); 43 | void write_hdmv_video_registration_descriptor( bs_t *s, ts_int_stream_t *stream ); 44 | void write_hdmv_lpcm_descriptor( bs_t *s, ts_int_stream_t *stream ); 45 | void write_partial_ts_descriptor( ts_writer_t *w, bs_t *s ); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /isdb/isdb.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * isdb.h : ISDB specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_ISDB_H 22 | #define LIBMPEGTS_ISDB_H 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /libmpegts.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * libmpegts.h : libmpegts public API 3 | ***************************************************************************** 4 | * Copyright (C) 2010-11 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_H 22 | #define LIBMPEGTS_H 23 | 24 | #if !defined(_STDINT_H) && !defined(_STDINT_H_) && \ 25 | !defined(_INTTYPES_H) && !defined(_INTTYPES_H_) 26 | # ifdef _MSC_VER 27 | # pragma message("You must include stdint.h or inttypes.h before libmpegts.h") 28 | # else 29 | # warning You must include stdint.h or inttypes.h before libmpegts.h 30 | # endif 31 | #endif 32 | 33 | /**** Version ****/ 34 | #define LIBMPEGTS_API_VERSION_MAJOR 0 35 | #define LIBMPEGTS_API_VERSION_MINOR 3 36 | 37 | /**** Stream Formats ****/ 38 | /* Generic */ 39 | #define LIBMPEGTS_VIDEO_MPEG2 1 40 | #define LIBMPEGTS_VIDEO_AVC 2 41 | #define LIBMPEGTS_VIDEO_DIRAC 3 42 | 43 | #define LIBMPEGTS_AUDIO_MPEG1 32 44 | #define LIBMPEGTS_AUDIO_MPEG2 33 45 | #define LIBMPEGTS_AUDIO_ADTS 34 /* Usually MPEG-2 AAC */ 46 | #define LIBMPEGTS_AUDIO_LATM 35 /* Usually MPEG-4 AAC */ 47 | #define LIBMPEGTS_AUDIO_AC3 36 48 | #define LIBMPEGTS_AUDIO_EAC3 37 49 | #define LIBMPEGTS_AUDIO_LPCM 38 /* Blu-Ray only */ 50 | #define LIBMPEGTS_AUDIO_DTS 39 51 | 52 | /* Blu-Ray Stream Formats */ 53 | #define LIBMPEGTS_AUDIO_DOLBY_LOSSLESS 40 /* "Dolby Lossless audio stream for Primary audio" */ 54 | #define LIBMPEGTS_AUDIO_DTS_HD 41 /* "DTS-HD audio stream except XLL for Primary audio" */ 55 | #define LIBMPEGTS_AUDIO_DTS_HD_XLL 42 /* "DTS-HD audio stream XLL for Primary audio" */ 56 | #define LIBMPEGTS_AUDIO_EAC3_SECONDARY 43 /* "Dolby Digital Plus audio stream for Secondary audio" */ 57 | #define LIBMPEGTS_AUDIO_DTS_HD_SECONDARY 44 /* "DTS-HD LBR audio stream for Secondary audio" */ 58 | #define LIBMPEGTS_SUB_PRESENTATION_GRAPHICS 45 59 | #define LIBMPEGTS_SUB_INTERACTIVE_GRAPHICS 46 60 | #define LIBMPEGTS_SUB_TEXT 47 61 | 62 | /* SMPTE Stream Formats */ 63 | #define LIBMPEGTS_AUDIO_302M 96 64 | #define LIBMPEGTS_ANCILLARY_RDD11 97 65 | #define LIBMPEGTS_ANCILLARY_2038 98 66 | 67 | /* DVB Stream Formats */ 68 | #define LIBMPEGTS_DVB_SUB 128 69 | #define LIBMPEGTS_DVB_TELETEXT 129 70 | #define LIBMPEGTS_DVB_VBI 130 71 | 72 | /* Misc */ 73 | #define LIBMPEGTS_AUDIO_OPUS 160 74 | #define LIBMPEGTS_DATA_SCTE35 161 75 | 76 | /**** Stream IDs ****/ 77 | /* SMPTE 302M, AC3, DVB subtitles and Teletext use Private Stream 1 */ 78 | #define LIBMPEGTS_STREAM_ID_PRIVATE_1 0xbd 79 | #define LIBMPEGTS_STREAM_ID_PRIVATE_2 0xbf 80 | 81 | /* MPEG Audio (all types): 0xc0-0xdf */ 82 | #define LIBMPEGTS_STREAM_ID_MPEGAUDIO 0xc0 83 | 84 | /* MPEG Video (all types): 0xe0-0xef */ 85 | #define LIBMPEGTS_STREAM_ID_MPEGVIDEO 0xe0 86 | 87 | /* Extended Stream-id */ 88 | #define LIBMPEGTS_STREAM_ID_EXTENDED 0xfd 89 | 90 | /**** Blu-Ray Information ****/ 91 | /* Blu-Ray Aspect Ratios */ 92 | #define LIBMPEGTS_HDMV_AR_4_3 2 93 | #define LIBMPEGTS_HDMV_AR_16_9 3 94 | 95 | /* Blu-Ray Video Formats */ 96 | #define LIBMPEGTS_HDMV_480I 1 97 | #define LIBMPEGTS_HDMV_576I 2 98 | #define LIBMPEGTS_HDMV_480P 3 99 | #define LIBMPEGTS_HDMV_1080I 4 100 | #define LIBMPEGTS_HDMV_720P 5 101 | #define LIBMPEGTS_HDMV_1080P 6 102 | #define LIBMPEGTS_HDMV_576P 7 103 | 104 | /* DVB-AU AND Blu-Ray Frame Rate */ 105 | #define LIBMPEGTS_DVB_AU_23_976_FPS 1 106 | #define LIBMPEGTS_DVB_AU_24_FPS 2 107 | #define LIBMPEGTS_DVB_AU_25_FPS 3 108 | #define LIBMPEGTS_DVB_AU_29_97_FPS 4 109 | #define LIBMPEGTS_DVB_AU_30_FPS 5 /* Not allowed in Blu-Ray */ 110 | #define LIBMPEGTS_DVB_AU_50_FPS 6 111 | #define LIBMPEGTS_DVB_AU_59_94_FPS 7 112 | #define LIBMPEGTS_DVB_AU_60_FPS 8 /* Not allowed in Blu-Ray */ 113 | 114 | /**** DVB AU_information ****/ 115 | /* DVB-AU Pic-Struct MPEG-2 */ 116 | #define LIBMPEGTS_DVB_AU_PIC_STRUCT_NONE 1 117 | #define LIBMPEGTS_DVB_AU_PIC_STRUCT_TOP_FIELD 2 118 | #define LIBMPEGTS_DVB_AU_PIC_STRUCT_BOT_FIELD 3 119 | 120 | /* DVB-AU Coding type MPEG-2 */ 121 | #define LIBMPEGTS_CODING_TYPE_I 1 122 | #define LIBMPEGTS_CODING_TYPE_P 2 123 | #define LIBMPEGTS_CODING_TYPE_B 3 124 | 125 | /* DVB-AU Coding type H.264 */ 126 | #define LIBMPEGTS_CODING_TYPE_SLICE_IDR (1<<3) 127 | #define LIBMPEGTS_CODING_TYPE_SLICE_I (1<<2) 128 | #define LIBMPEGTS_CODING_TYPE_SLICE_P (1<<1) 129 | #define LIBMPEGTS_CODING_TYPE_SLICE_B (1<<0) 130 | 131 | /**** Audio Service Type ****/ 132 | #define LIBMPEGTS_AUDIO_SERVICE_UNDEFINED 0 133 | #define LIBMPEGTS_AUDIO_SERVICE_CLEAN_EFFECTS 1 134 | #define LIBMPEGTS_AUDIO_SERVICE_HEARING_IMPAIRED 2 135 | #define LIBMPEGTS_AUDIO_SERVICE_VISUAL_IMPAIRED 3 136 | 137 | /* TS types: Packetised Elementary Stream, 138 | * Transport Stream, DVB, ATSC, CableLabs, ISDB, Generic (188 bytes), 139 | * Blu-Ray HDMV (192 bytes) */ 140 | enum ts_type_t 141 | { 142 | TS_TYPE_GENERIC, 143 | TS_TYPE_DVB, 144 | TS_TYPE_CABLELABS, 145 | TS_TYPE_ATSC, 146 | TS_TYPE_ISDB, 147 | TS_TYPE_BLU_RAY, 148 | }; 149 | 150 | /**** Levels and Profiles ****/ 151 | /* MPEG-2 Levels */ 152 | enum mpeg2_level_t 153 | { 154 | LIBMPEGTS_MPEG2_LEVEL_LOW = 1, 155 | LIBMPEGTS_MPEG2_LEVEL_MAIN, 156 | LIBMPEGTS_MPEG2_LEVEL_HIGH_1440, 157 | LIBMPEGTS_MPEG2_LEVEL_HIGH, 158 | LIBMPEGTS_MPEG2_LEVEL_HIGHP, 159 | }; 160 | 161 | /* MPEG-2 Profiles */ 162 | enum mpeg2_profile_t 163 | { 164 | LIBMPEGTS_MPEG2_PROFILE_SIMPLE, 165 | LIBMPEGTS_MPEG2_PROFILE_MAIN, 166 | LIBMPEGTS_MPEG2_PROFILE_422, 167 | }; 168 | 169 | /* AVC Profiles */ 170 | enum avc_profile_t 171 | { 172 | AVC_BASELINE, 173 | AVC_MAIN, 174 | AVC_HIGH, 175 | AVC_HIGH_10, 176 | AVC_HIGH_422, 177 | AVC_HIGH_444_PRED, 178 | AVC_HIGH_10_INTRA, 179 | AVC_HIGH_422_INTRA, 180 | AVC_HIGH_444_INTRA, 181 | AVC_CAVLC_444_INTRA, 182 | }; 183 | 184 | /* Opaque Structure */ 185 | typedef struct ts_writer_t ts_writer_t; 186 | 187 | // TODO make certain syntax elements updatable 188 | /* General Stream Information 189 | * 190 | * PID 191 | * stream_format - Use stream formats above 192 | * stream_id - See Table 2-22 in ISO 13818-1 193 | * 194 | * audio_frame_size - size of one audio frame in 90KHz ticks. (e.g. for ac3 1536 * 90000/samplerate ) 195 | * 196 | * write_lang_code - Write ISO 639 descriptor for audio 197 | * lang_code - ISO 639 Part 2 Language code (or non-standard codes) 198 | * audio_type - Audio service type 199 | * 200 | * has_stream_identifier - Set to 1 if stream identifier is present 201 | * stream_identifier - Stream identifier 202 | * 203 | * dvb_au - write DVB AU_information elements (video streams only) 204 | * dvb_au_frame_rate - DVB AU_information frame rate code (see above #defines) 205 | * 206 | * hdmv_frame_rate - For H.264 "Frame-rate = time_scale/num_units_in_tick/2" TODO MPEG-2 (see above #defines) 207 | * hdmv_aspect_ratio - either LIBMPEGTS_HDMV_AR_4_3 or LIBMPEGTS_HDMV_AR_16_9 208 | * hdmv_video_format - Video format (see above #defines) */ 209 | 210 | typedef struct 211 | { 212 | int pid; 213 | int stream_format; 214 | int stream_id; 215 | 216 | int audio_frame_size; 217 | 218 | int write_lang_code; 219 | char lang_code[4]; 220 | int audio_type; 221 | 222 | int has_stream_identifier; 223 | int stream_identifier; 224 | 225 | int dvb_au; 226 | int dvb_au_frame_rate; 227 | 228 | int hdmv_frame_rate; 229 | int hdmv_aspect_ratio; 230 | int hdmv_video_format; 231 | } ts_stream_t; 232 | 233 | /**** Stream attributes (DVB) ****/ 234 | 235 | #define DVB_SERVICE_TYPE_DIGITAL_TELEVISION 0x01 236 | #define DVB_SERVICE_TYPE_DIGITAL_RADIO_SOUND 0x02 237 | #define DVB_SERVICE_TYPE_TELETEXT 0x03 238 | #define DVB_SERVICE_TYPE_ADVANCED_CODEC_SD 0x16 239 | #define DVB_SERVICE_TYPE_ADVANCED_CODEC_HD 0x19 240 | 241 | /* SDT Stream Information 242 | * 243 | * service_type - See above 244 | * service_name - Self Explanatory 245 | * provider_name - Self Explanatory */ 246 | 247 | typedef struct 248 | { 249 | int service_type; 250 | char *service_name; 251 | char *provider_name; 252 | } sdt_program_ctx_t; 253 | 254 | /* Program attributes: 255 | * 256 | * PIDs must be between 33 and 8190 (DVB) 257 | * program_num must be between 1 and 8190 258 | * PCR PID can be the same as a stream in the program (video PID or separate PID recommended) 259 | * 260 | * is_3dtv - 261 | * Write 3d_MPEG2_descriptor in PMT (CableLabs OC-SP-CEP3.0-I01-100827). 262 | * Stream MUST have appropriate MPEG-2 user_data or AVC SEI with 3D information. 263 | * 264 | * Smoothing Buffer (Required for ATSC) - 265 | * sb_leak_rate - smoothing buffer leak rate (in units of 400 bits/s) 266 | * sb_size - in bytes 267 | */ 268 | typedef struct 269 | { 270 | int pmt_pid; 271 | int program_num; 272 | int pcr_pid; 273 | 274 | int num_streams; 275 | ts_stream_t *streams; 276 | 277 | int is_3dtv; 278 | 279 | /* ATSC */ 280 | int sb_leak_rate; 281 | int sb_size; 282 | 283 | /* DVB */ 284 | sdt_program_ctx_t sdt; 285 | } ts_program_t; 286 | 287 | /**** Functions ****/ 288 | 289 | /* Create Writer */ 290 | ts_writer_t *ts_create_writer( void ); 291 | 292 | /* 293 | * ts_id - Transport Stream ID 294 | * muxrate - Transport stream muxing rate 295 | * cbr - Pad to constant bitrate with null packets 296 | * ts_type - Type of transport stream to write 297 | * network_pid - PID of the network table (0 otherwise) 298 | * legacy_constraints - Comply with CableLabs legacy contraints in Section 7.3 of Content Encoding Profiles 3.0 Specification 299 | * 300 | * retransmit periods in milliseconds 301 | * 302 | * CURRENT LIMITATIONS 303 | * 304 | * Single Program Transport Streams only supported currently. 305 | * Only one video stream allowed. 306 | * 307 | * 308 | * */ 309 | 310 | typedef struct ts_main_t 311 | { 312 | int num_programs; 313 | ts_program_t *programs; 314 | 315 | int ts_id; 316 | int muxrate; 317 | int cbr; 318 | int ts_type; 319 | int lowlatency; 320 | 321 | int network_pid; 322 | 323 | int legacy_constraints; 324 | 325 | int pcr_period; 326 | int pat_period; 327 | 328 | // FIXME dvb land 329 | int network_id; 330 | int sdt_period; 331 | int nit_period; 332 | int tdt_period; 333 | int tot_period; 334 | } ts_main_t; 335 | 336 | int ts_setup_transport_stream( ts_writer_t *w, ts_main_t *params ); 337 | 338 | /* update transport stream 339 | * 340 | * muxrate is the only tested parameter 341 | * 342 | * TODO: implement versioning so other parameters can be updated 343 | * 344 | */ 345 | void ts_update_transport_stream( ts_writer_t *w, ts_main_t *params ); 346 | 347 | /**** Additional Codec-Specific functions ****/ 348 | /* Many formats require extra information. Setup the relevant information using the following functions */ 349 | 350 | /* Video */ 351 | /* Setup / Update MPEG Video 352 | * Mandatory before writing any MPEG Video Stream. 353 | * 354 | * MPEG-2 Video Stream 355 | * 356 | * level - MPEG-2 level 357 | * profile - MPEG-2 profile 358 | * vbv_maxrate - maximum bitrate into the vbv in bits/s 359 | * vbv_bufsize - vbv buffer size 360 | * frame_rate - MPEG-2 framerate code 361 | * 362 | * AVC Stream 363 | * 364 | * level_idc / profile_idc are as defined in the AVC Specification. 365 | * vbv_maxrate - maximum bitrate into the vbv in bits/s 366 | * vbv_bufsize - vbv buffer size 367 | * frame_rate - not used in AVC 368 | * 369 | * The only supported AVC files are those with a Buffering Period SEI at each keyframe but nal_hrd_parameters_present set to 0. 370 | * This is owing to bugs/inconsistencies in the TS specification. This does not apply to Blu-Ray. */ 371 | 372 | int ts_setup_mpegvideo_stream( ts_writer_t *w, int pid, int level, int profile, int vbv_maxrate, int vbv_bufsize, int frame_rate ); 373 | 374 | /* Audio */ 375 | #define LIBMPEGTS_MPEG2_AAC_MAIN_PROFILE 0 376 | #define LIBMPEGTS_MPEG2_AAC_LC_PROFILE 1 377 | 378 | #define LIBMPEGTS_MPEG2_AAC_1_CHANNEL 1 379 | #define LIBMPEGTS_MPEG2_AAC_2_CHANNEL 2 380 | #define LIBMPEGTS_MPEG2_AAC_3_CHANNEL 3 381 | #define LIBMPEGTS_MPEG2_AAC_4_CHANNEL 4 382 | #define LIBMPEGTS_MPEG2_AAC_5_CHANNEL 5 383 | #define LIBMPEGTS_MPEG2_AAC_5_POINT_1_CHANNEL 6 384 | #define LIBMPEGTS_MPEG2_AAC_7_POINT_1_CHANNEL 7 385 | 386 | /* Setup / Update MPEG-2 AAC Stream 387 | * 388 | */ 389 | 390 | int ts_setup_mpeg2_aac_stream( ts_writer_t *w, int pid, int profile, int channel_map ); 391 | 392 | #define LIBMPEGTS_MPEG4_AAC_MAIN_PROFILE_LEVEL_1 0x10 393 | #define LIBMPEGTS_MPEG4_AAC_MAIN_PROFILE_LEVEL_2 0x11 394 | #define LIBMPEGTS_MPEG4_AAC_MAIN_PROFILE_LEVEL_3 0x12 395 | #define LIBMPEGTS_MPEG4_AAC_MAIN_PROFILE_LEVEL_4 0x13 396 | #define LIBMPEGTS_MPEG4_AAC_PROFILE_LEVEL_1 0x50 397 | #define LIBMPEGTS_MPEG4_AAC_PROFILE_LEVEL_2 0x51 398 | #define LIBMPEGTS_MPEG4_AAC_PROFILE_LEVEL_4 0x52 399 | #define LIBMPEGTS_MPEG4_AAC_PROFILE_LEVEL_5 0x53 400 | #define LIBMPEGTS_MPEG4_HE_AAC_PROFILE_LEVEL_2 0x58 401 | #define LIBMPEGTS_MPEG4_HE_AAC_PROFILE_LEVEL_3 0x59 402 | #define LIBMPEGTS_MPEG4_HE_AAC_PROFILE_LEVEL_4 0x5a 403 | #define LIBMPEGTS_MPEG4_HE_AAC_PROFILE_LEVEL_5 0x5b 404 | #define LIBMPEGTS_MPEG4_HE_AAC_V2_PROFILE_LEVEL_2 0x60 405 | #define LIBMPEGTS_MPEG4_HE_AAC_V2_PROFILE_LEVEL_3 0x61 406 | #define LIBMPEGTS_MPEG4_HE_AAC_V2_PROFILE_LEVEL_4 0x62 407 | #define LIBMPEGTS_MPEG4_HE_AAC_V2_PROFILE_LEVEL_5 0x63 408 | 409 | /* Setup / Update MPEG-4 AAC Stream 410 | * profile_and_level - self explanatory 411 | * num_channels - number of channels (excluding LFE channel) 412 | * 413 | * It is the responsibility of the calling application to encapsulate using ADTS or LATM 414 | */ 415 | 416 | int ts_setup_mpeg4_aac_stream( ts_writer_t *w, int pid, int profile_and_level, int num_channels ); 417 | 418 | /* Setup / Update SMPTE 302M Stream 419 | * Mandatory before writing any 302M Stream. 420 | * 421 | * bit_depth - 16, 20 or 24 bits per sample. 422 | * num_channels - 2, 4, 6 or 8 channels. 423 | * 424 | * As per SMPTE 302M the sample rate can only be 48000Hz. 425 | * Notes: The PTS of a SMPTE 302M frame shall be within 2ms of the corresponding video frame 426 | * It is the responsibility of the calling application to encapsulate the SMPTE 302M data. */ 427 | 428 | int ts_setup_302m_stream( ts_writer_t *w, int pid, int bit_depth, int num_channels ); 429 | 430 | /* Opus */ 431 | 432 | #define LIBMPEGTS_CHANNEL_CONFIG_DUAL_MONO 0x00 433 | #define LIBMPEGTS_CHANNEL_CONFIG_MONO 0x01 434 | #define LIBMPEGTS_CHANNEL_CONFIG_STEREO 0x02 435 | 436 | int ts_setup_opus_stream( ts_writer_t *w, int pid, int channel_map ); 437 | 438 | 439 | /**** DVB Specific Information ****/ 440 | 441 | /* DVB Subtitles */ 442 | #define LIBMPEGTS_DVB_SUB_TYPE_EBU_TELETEXT 0x01 443 | #define LIBMPEGTS_DVB_SUB_TYPE_ASSOCIATED_EBU_TELETEXT 0x02 444 | #define LIBMPEGTS_DVB_SUB_TYPE_VBI_DATA 0x03 445 | #define LIBMPEGTS_DVB_SUB_TYPE_NORMAL_NO_AR 0x10 446 | #define LIBMPEGTS_DVB_SUB_TYPE_NORMAL_4_3_AR 0x11 447 | #define LIBMPEGTS_DVB_SUB_TYPE_NORMAL_2_21_1_AR 0x13 448 | #define LIBMPEGTS_DVB_SUB_TYPE_NORMAL_HD 0x14 449 | #define LIBMPEGTS_DVB_SUB_TYPE_HEARING_NO_AR 0x20 450 | #define LIBMPEGTS_DVB_SUB_TYPE_HEARING_4_3_AR 0x21 451 | #define LIBMPEGTS_DVB_SUB_TYPE_HEARING_16_9_AR 0x22 452 | #define LIBMPEGTS_DVB_SUB_TYPE_HEARING_HD 0x24 453 | 454 | /* ts_dvb_sub_t 455 | * 456 | * lang_code - ISO 639 Part 2 Language code 457 | * subtitling_type - see above #defines 458 | * composition_page_id - composition page 459 | * ancillary_page_id - optional ancillary page (should be set to composition page otherwise) 460 | */ 461 | 462 | typedef struct 463 | { 464 | char lang_code[4]; 465 | int subtitling_type; 466 | int composition_page_id; 467 | int ancillary_page_id; 468 | } ts_dvb_sub_t; 469 | 470 | /* ts_setup_dvb_subtitles 471 | * 472 | * has_dds - has display definition segment 473 | */ 474 | 475 | int ts_setup_dvb_subtitles( ts_writer_t *w, int pid, int has_dds, int num_subtitles, ts_dvb_sub_t *subtitles ); 476 | 477 | /* DVB Teletext */ 478 | #define LIBMPEGTS_DVB_TTX_TYPE_INITIAL 0x01 479 | #define LIBMPEGTS_DVB_TTX_TYPE_SUB 0x02 480 | #define LIBMPEGTS_DVB_TTX_TYPE_ADDITIONAL_INFO 0x03 481 | #define LIBMPEGTS_DVB_TTX_TYPE_SCHEDULE 0x04 482 | #define LIBMPEGTS_DVB_TTX_TYPE_SUB_HEARING_IMP 0x05 483 | 484 | /* ts_dvb_ttx_t 485 | * lang_code - ISO 639 Part 2 Language code 486 | * teletext_type - see above #defines 487 | * teletext_magazine_number - self explanatory 488 | * teletext_page_number - self explanatory 489 | */ 490 | 491 | typedef struct 492 | { 493 | char lang_code[4]; 494 | int teletext_type; 495 | int teletext_magazine_number; 496 | int teletext_page_number; 497 | } ts_dvb_ttx_t; 498 | 499 | int ts_setup_dvb_teletext( ts_writer_t *w, int pid, int num_teletexts, ts_dvb_ttx_t *teletexts ); 500 | 501 | /* ts_dvb_vbi_t 502 | * field_parity - 1 for first field (odd), 0 for second field (even) 503 | * line_offset - line number on which data is presented if it is transcoded into the VBI 504 | */ 505 | typedef struct 506 | { 507 | int field_parity; 508 | int line_offset; 509 | } ts_dvb_vbi_line_t; 510 | 511 | /* DVB service-ids */ 512 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_TTX 0x01 /* Requires call to ts_setup_dvb_teletext */ 513 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_INVERTED_TTX 0x02 514 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_VPS 0x04 515 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_WSS 0x05 516 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_CC 0x06 517 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_MONO_SAMPLES 0x07 518 | 519 | /* SCTE-127 service-ids */ 520 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_VITC 0xf7 521 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_COPY_PROTECTION 0xf9 522 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_TVG2X 0xfb 523 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_NABTS 0xfc 524 | #define LIBMPEGTS_DVB_VBI_DATA_SERVICE_ID_AMOL_48_96 0xfe 525 | 526 | /* ts_dvb_vbi_t 527 | * data_service_id - see above #defines 528 | * lines - one ts_dvb_vbi_line_t per line 529 | */ 530 | 531 | typedef struct 532 | { 533 | int data_service_id; 534 | int num_lines; 535 | ts_dvb_vbi_line_t *lines; 536 | } ts_dvb_vbi_t; 537 | 538 | int ts_setup_dvb_vbi( ts_writer_t *w, int pid, int num_vbis, ts_dvb_vbi_t *vbis ); 539 | 540 | /* Service Description Table 541 | * 542 | * ts_setup_sdt enables SDT 543 | * ts_remove_sdt disables SDT 544 | * 545 | */ 546 | 547 | int ts_setup_sdt( ts_writer_t *w ); 548 | void ts_remove_sdt( ts_writer_t *w ); 549 | 550 | /* Network Information Table */ 551 | 552 | typedef struct 553 | { 554 | 555 | } ts_dvb_nit_t; 556 | 557 | int ts_setup_nit( ts_writer_t *w ); 558 | void ts_update_nit( ts_writer_t *w ); 559 | void ts_remove_nit( ts_writer_t *w ); 560 | 561 | /* EIT 562 | * FIXME only now and next 563 | * */ 564 | 565 | int ts_setup_eit( ts_writer_t *w ); 566 | void ts_update_eit( ts_writer_t *w ); 567 | void ts_remove_eit( ts_writer_t *w ); 568 | 569 | /* TDT 570 | * 571 | * */ 572 | 573 | int ts_setup_tdt( ts_writer_t *w ); 574 | void ts_remove_tdt( ts_writer_t *w ); 575 | 576 | /* Time Offset Table 577 | * 578 | * */ 579 | 580 | int ts_setup_tot( ts_writer_t *w ); 581 | void ts_remove_tot( ts_writer_t *w ); 582 | 583 | /**** DVB / Blu-Ray Tables ****/ 584 | 585 | /* SIT 586 | * 587 | * */ 588 | 589 | int ts_setup_sit( ts_writer_t *w ); 590 | void ts_update_sit( ts_writer_t *w ); 591 | int ts_remove_sit( ts_writer_t *w ); 592 | 593 | /**** ATSC/CableLabs specific information ****/ 594 | 595 | /* ATSC Setup/Update AC3 stream 596 | * 597 | * Note: This channel status refers to channel map the current program being broadcast. 598 | * If the channel changes from 5.1 to 2.0 for an advertising break, this 599 | * need not be updated. On changing to a program with a different channel map, 600 | * this descriptor should be updated. 601 | */ 602 | 603 | //int ts_setup_atsc_ac3_stream( ts_writer_t *w, int pid, ts_atsc_ac3_info *ac3_info ); 604 | 605 | /**** Cablelabs specific information ****/ 606 | 607 | 608 | /**** Blu-Ray specific information ****/ 609 | 610 | /* Setup HDMV LPCM Stream 611 | * 612 | * num_channels - number of audio channels 613 | * sample_rate - sample rate in KHz 614 | * bits_per_sample - number of bits per sample 615 | * 616 | * NOTE: It is the responsibility of the calling application to write the appropriate LPCM headers 617 | */ 618 | int ts_setup_hdmv_lpcm_stream( ts_writer_t *w, int pid, int num_channels, int sample_rate, int bits_per_sample ); 619 | 620 | /* Digital Transmission Content Protection 621 | * 622 | * See Appendix B of DTCP Specification for information about DTCP_descriptor 623 | * byte_1 and byte_2 correspond to the two private_data_bytes in the DTCP_descriptor 624 | */ 625 | int ts_setup_dtcp( ts_writer_t *w, uint8_t byte_1, uint8_t byte_2 ); 626 | 627 | /* TODO: other relevant tables */ 628 | 629 | /* Writing frames to libmpegts 630 | * 631 | * The duration of a video frame and associated audio frames must be as close as possible. 632 | * The duration of audio frames can either be slighly less, equal to (rare), or slightly greater than 633 | * the video frame duration - libmpegts can handle all three conditions. 634 | * There should be no more than one frame with a DTS larger than that of the associated video stream. 635 | * 636 | * The DTS of a given PID must be monotonically increasing. Interleaving of frames from different streams is allowed. 637 | * Only a single video frame at a time must be written. */ 638 | 639 | /* ts_frame_t 640 | * 641 | * PID - Packet Identifier (i.e. which stream the payload is associated with) 642 | * 643 | * ** Video Only ** 644 | * 645 | * CPB Initial Arrival Time - initial arrival time of picture in CPB (in 27MHz clock ticks) 646 | * CPB Final Arrival Time - final arrival time of picture in CPB (in 27MHz clock ticks) 647 | * DTS - Decode Time Stamp (in 90kHz clock ticks - maximum 30 bits) 648 | * PTS - Presentation Time Stamp (in 90kHz clock ticks - maximum 30 bits) 649 | * (PTS and DTS may have codec-specific meanings. See ISO 13818-1 for more information) 650 | * Generally, non-video formats have PTS equal to DTS. 651 | * 652 | * This data does not need to be wrapped around ) 653 | * random_access - Data contains an "elementary stream access point" 654 | * priority - Indicate payload has priority 655 | * (random_access and priority can be codec specific. See ISO 13818-1 for more information.) 656 | * 657 | * DVB AU_information fields 658 | * frame_type - Single Value for MPEG-2, Bitfield for AVC (see above #defines) 659 | * ref_pic_idc - Set if frame is needed for reconstruction of other frames (MPEG-2), nal_ref_idc in AVC 660 | * write_pulldown_info - Write pulldown info in AU_Information 661 | * pic_struct - AVC pic_struct element - only used if write_pulldown_info set 662 | * 663 | * opaque - opaque pointer that libmpegts does nothing with 664 | */ 665 | 666 | typedef struct 667 | { 668 | uint8_t *data; 669 | int size; 670 | int pid; 671 | int64_t cpb_initial_arrival_time; 672 | int64_t cpb_final_arrival_time; 673 | int64_t dts; 674 | int64_t pts; 675 | int64_t duration; /* SMPTE 302M only */ 676 | int random_access; 677 | int priority; 678 | 679 | /* DVB AU_Information specific fields */ 680 | uint8_t frame_type; 681 | int ref_pic_idc; 682 | int write_pulldown_info; 683 | int pic_struct; 684 | 685 | void *opaque; 686 | } ts_frame_t; 687 | 688 | /* ts_write_frames 689 | * 690 | * libmpegts buffers one frame so the last set of packets can be output by setting num_frames = 0. 691 | * 692 | * pcr_list contains an array of pcr values, one for each output packet. The array length is len/188. 693 | * NOTE: This PCR list does not wrap around 694 | * 695 | */ 696 | 697 | int ts_write_frames( ts_writer_t *w, ts_frame_t *frames, int num_frames, uint8_t **out, int *len, int64_t **pcr_list ); 698 | 699 | /* INACTIVE 700 | * 701 | * */ 702 | int ts_delete_stream( ts_writer_t *w, int pid ); 703 | 704 | 705 | 706 | int ts_close_writer( ts_writer_t *w ); 707 | 708 | /* Examples TODO */ 709 | 710 | 711 | 712 | #endif 713 | -------------------------------------------------------------------------------- /smpte/smpte.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * smpte.c : SMPTE specific functions 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #include "../common.h" 22 | #include "smpte.h" 23 | 24 | void write_anc_data_descriptor( bs_t *s ) 25 | { 26 | bs_write( s, 8, USER_DEFINED_DESCRIPTOR_TAG ); // descriptor_tag 27 | bs_write( s, 8, 0 ); // descriptor_length 28 | 29 | /* Optional descriptors here */ 30 | } 31 | -------------------------------------------------------------------------------- /smpte/smpte.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * smpte.h : SMPTE specific headers 3 | ***************************************************************************** 4 | * Copyright (C) 2010 Kieran Kunhya 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. 19 | *****************************************************************************/ 20 | 21 | #ifndef LIBMPEGTS_SMPTE_H 22 | #define LIBMPEGTS_SMPTE_H 23 | 24 | void write_anc_data_descriptor( bs_t *s ); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /version.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git rev-list HEAD | sort > config.git-hash 3 | LOCALVER=`wc -l config.git-hash | awk '{print $1}'` 4 | if [ $LOCALVER \> 1 ] ; then 5 | VER=`git rev-list origin/master | sort | join config.git-hash - | wc -l | awk '{print $1}'` 6 | if [ $VER != $LOCALVER ] ; then 7 | VER="$VER+$(($LOCALVER-$VER))" 8 | fi 9 | if git status | grep -q "modified:" ; then 10 | VER="${VER}M" 11 | fi 12 | VER="$VER $(git rev-list HEAD -n 1 | cut -c 1-7)" 13 | echo "#define LIBMPEGTS_VERSION \" r$VER\"" 14 | else 15 | echo "#define LIBMPEGTS_VERSION \"\"" 16 | VER="x" 17 | fi 18 | rm -f config.git-hash 19 | API=`grep '#define LIBMPEGTS_API_VERSION_MAJOR' < libmpegts.h | sed -e 's/.* \([0-9]*\).*/\1/'` 20 | echo "#define LIBMPEGTS_POINTVER \"0.$API.$VER\"" 21 | --------------------------------------------------------------------------------