├── .auto ├── config.guess ├── config.sub ├── depcomp ├── install-sh ├── ltmain.sh └── missing ├── AUTHORS ├── COPYING ├── ChangeLog ├── CodingStyle ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── TODO ├── aclocal.m4 ├── bootstrap ├── configure ├── configure.ac ├── doc ├── Makefile.am ├── Makefile.in ├── libmpeg2.txt ├── sample1.c ├── sample2.c ├── sample3.c ├── sample4.c ├── sample5.c └── sample6.c ├── include ├── Makefile.am ├── Makefile.in ├── alpha_asm.h ├── attributes.h ├── config.h.in ├── mmx.h ├── mpeg2.h ├── mpeg2convert.h ├── tendra.h ├── video_out.h └── vis.h ├── libmpeg2 ├── Makefile.am ├── Makefile.in ├── alloc.c ├── convert │ ├── Makefile.am │ ├── Makefile.in │ ├── convert_internal.h │ ├── libmpeg2convert.pc.in │ ├── rgb.c │ ├── rgb_mmx.c │ ├── rgb_vis.c │ └── uyvy.c ├── cpu_accel.c ├── cpu_state.c ├── decode.c ├── header.c ├── idct.c ├── idct_alpha.c ├── idct_altivec.c ├── idct_mmx.c ├── libmpeg2.pc.in ├── motion_comp.c ├── motion_comp_alpha.c ├── motion_comp_altivec.c ├── motion_comp_arm.c ├── motion_comp_arm_s.S ├── motion_comp_mmx.c ├── motion_comp_vis.c ├── mpeg2_internal.h ├── slice.c └── vlc.h ├── libvo ├── Makefile.am ├── Makefile.in ├── video_out.c ├── video_out_dx.c ├── video_out_null.c ├── video_out_pgm.c ├── video_out_sdl.c ├── video_out_x11.c └── vo_internal.h ├── m4 ├── cflags.m4 ├── inttypes.m4 ├── keywords.m4 └── nonpic.m4 ├── packaging └── libmpeg2.spec ├── src ├── Makefile.am ├── Makefile.in ├── corrupt_mpeg2.c ├── dump_state.c ├── extract_mpeg2.1 ├── extract_mpeg2.c ├── getopt.c ├── getopt.h ├── gettimeofday.c ├── gettimeofday.h ├── mpeg2dec.1 └── mpeg2dec.c ├── test ├── Makefile.am ├── Makefile.in ├── README ├── compile ├── globals ├── regression ├── tek-525 ├── tek-625 └── tests └── vc++ ├── Makefile.am ├── Makefile.in ├── config.h ├── cpu_accel.obj ├── cpu_state.obj ├── idct_mmx.obj ├── inttypes.h ├── libmpeg2.dsp ├── libmpeg2convert.dsp ├── libvo.dsp ├── motion_comp_mmx.obj ├── mpeg2dec.dsp ├── mpeg2dec.dsw └── rgb_mmx.obj /AUTHORS: -------------------------------------------------------------------------------- 1 | Aaron Holtzman started the project and 2 | made the initial working implementation. 3 | 4 | Michel Lespinasse did major changes for speed and 5 | mpeg conformance and has been the maintainer for a long time. Most 6 | of the current code was (re)written by him. 7 | 8 | Sam Hocevar and Christophe Massiot 9 | are the current maintainers. 10 | 11 | Other contributors include: 12 | Koji Agawa - ARM code 13 | Bruno Barreyra - build fixes 14 | Gildas Bazin - mingw32 port 15 | Diego Biurrun - portability fixes 16 | Alexander W. Chin - progressive_seq fix 17 | Stephen Crowley - build fixes 18 | Didier Gautheron - bug fixes 19 | Ryan C. Gordon - SDL support 20 | Peter Gubanov - MMX IDCT scheduling 21 | Håkan Hjort - Solaris fixes, mlib code 22 | Petri Hintukainen - SSE2 IDCT 23 | Nicolas Joly - assorted bug fixes 24 | Gerd Knorr - Xv support 25 | David I. Lehn - motion_comp mmx code 26 | Olie Lho - MMX yuv2rgb routine 27 | David S. Miller - sparc VIS optimizations 28 | Rick Niles - build fixes 29 | Real Ouellet - g200 fixes 30 | Bajusz Peter - motion comp fixes 31 | Franck Sicard - x11 fixes 32 | Brion Vibber - x11 fixes 33 | Martin Vogt - reentrancy fixes 34 | Fredrik Vraalsen - general hackage and stuff 35 | 36 | (let me know if I forgot anyone) 37 | 38 | Thanks to David Schleef for creating me an account on his ppc g4 39 | machine and making it possible for me to work on the altivec code. 40 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | libmpeg2-0.5.1 Fri Jul 18 16:28:49 CEST 2008 2 | -fix broken installation of headers 3 | -put back /mpeg2dec in the .pc file's include path 4 | 5 | libmpeg2-0.5.0 Fri Jun 11 23:42:12 CET 2008 6 | -add STATE_SEQUENCE_MODIFIED 7 | -aspect ratio guessing functionality 8 | -support for ARM-specific optimizations 9 | -export repeat_first_field flag 10 | -add SSE2 IDCT 11 | -more tolerance for invalid streams 12 | -fix warnings triggered by recent GCC 13 | 14 | mpeg2dec-0.4.1 Wed Feb 15 17:08:28 CET 2006 15 | -fix build issues on X86-64, PowerPC, Alpha and Sparc 16 | -fix build issues on FreeBSD and OS X 17 | -fix memory leak with shm output on remote displays 18 | -fix incorrect 4:4:4 chroma handling 19 | -fix alignment issues in the documentation examples 20 | -more tolerance for invalid streams 21 | 22 | mpeg2dec-0.4.0 Tue Dec 23 03:04:35 PST 2003 23 | -support for 4:2:2-profile streams as well as 4:4:4 format 24 | -extra robustness with extensive test framework (including bad streams etc) 25 | -support for concatenated streams 26 | -helper library for common color conversion formats (currently rgb and uyvy) 27 | -sparc VIS MC optimizations from David Miller 28 | -new set-stride and decoder-reset functions 29 | -some code samples for (very basic) documentation 30 | 31 | mpeg2dec-0.3.1 Fri Dec 13 22:15:36 PST 2002 32 | -integrated CPU detection code 33 | -alpha IDCT/MC optimizations 34 | -C IDCT optimizations 35 | -fixed all known memory leaks 36 | -workarounds for HPPA/IA64/sparc build issues 37 | 38 | mpeg2dec-0.3.0 Wed Nov 27 23:23:23 PST 2002 39 | -first release using the new libmpeg2 API 40 | -improved error handling - does not seek to the next sequence header anymore 41 | -more minor optimizations (about 7% faster than 0.2.1) 42 | -support for streams higher than 2800 pixels 43 | -added SIMD optimizations to the VC++ port 44 | 45 | mpeg2dec-0.2.1 Sun Mar 17 23:24:04 PST 2002 46 | -altivec optimizations - provides 2.5x speedup for g4 processors 47 | -fixed MC code - should not crash on bad streams anymore 48 | -much higher tolerance to corrupted streams 49 | -support for high definition streams 50 | -support for VC++ compiler 51 | -various mpeg flags exported to libvo 52 | 53 | mpeg2dec-0.2.0 Thu Feb 15 20:12:34 PST 2001 54 | -support for field pictures 55 | -new 3Dnow/SSE accelerations for motion compensation and color conversion 56 | -full libmpeg2 and libvo reentrancy 57 | -various portability enhancements - from big iron to embedded to windows 58 | -major libvo rewrite - new API more adapted to synchro and speed enhancements 59 | -pgmpipe output for piping with other programs 60 | -make install actually installs 61 | -various cleanups - including removal of the infamous HACK_MODE 62 | 63 | mpeg2dec-0.1.7 Thu Nov 2 21:38:33 PST 2000 64 | -fix the solaris mlib code back bup 65 | -added Xv support 66 | -major cruft removal 67 | -cleanup on motion_comp 68 | -remove mb_buffer goofiness 69 | -new yuv2rgb code 70 | -SDL display code added 71 | -faster motion_comp_c code 72 | -moved codec, display code into separate libraries 73 | -test suite 74 | -lots of conformance fixes 75 | -rewrite of the parsing code 76 | -MMX/SSE runtime detection and support 77 | -new configuration code 78 | 79 | mpeg2dec-0.1.6 Wed Mar 22 09:45:44 PST 2000 80 | -enhanced g200 81 | -solaris fixes 82 | -inlined, rewritten bitstream code (much faster now) 83 | -moved colorspace conversion code into yuv2rgb.c 84 | 85 | mpeg2dec-0.1.5 Mon Dec 13 23:08:43 EST 1999 86 | -numerous bugfixes to mga_vid and x11 displays. 87 | -fix clipping in motion_comp 88 | -fix interlaced macroblocks in frame pictures 89 | -add preliminary MMX support 90 | 91 | mpeg2dec-0.1.4 Fri Dec 10 00:28:43 EST 1999 92 | -New bitstream interface 93 | -fixed screwy first macroblock 94 | -fixed mga_vid build problems 95 | -fixed pale x11 output 96 | 97 | mpeg2dec-0.1.3 Mon Dec 6 19:18:57 EST 1999 98 | -fixed Invalid macroblock type bug. 99 | -fixed Makefile for mga_vid 100 | 101 | mpeg2dec-0.1.2 Mon Dec 6 19:18:57 EST 1999 102 | -fixed AC coefficient bug. Output looks pretty 103 | now. 104 | -inv_quantize code moved into parse. 105 | 106 | mpeg2dec-0.1.1 Sun Dec 5 19:18:57 EST 1999 107 | -added X11 display interface 108 | -fixed minor bug mga_vid init bug 109 | 110 | mpeg2dec-0.1.0 Sun Dec 5 01:18:57 EST 1999 111 | -First release 112 | -------------------------------------------------------------------------------- /CodingStyle: -------------------------------------------------------------------------------- 1 | These are the formatting rules for mpeg2dec code. Please try to follow 2 | these for any new contributions: 3 | 4 | * Code should not be wider than 79 columns. 5 | 6 | * A tab character should be displayed as 8 columns wide. 7 | 8 | * Indentations are 4 columns wide. 9 | 10 | * Braces are never alone on a line, instead they are on the same line 11 | as their associated control flow (if/then/else/while/for) 12 | statement. Functions are a special case, their opening and ending 13 | braces are alone on their own line, in the leftmost column. This is 14 | all standard K&R coding style. 15 | 16 | * Braces are optional. It's ok to skip them if there is only one 17 | statement in the block you'd put the braces around. 18 | 19 | * There is always a space separating the function name and the 20 | associated argument list i.e. f () 21 | 22 | * There is always a space separating an if/while/for control flow 23 | statement and the associated conditions i.e. if (x) 24 | 25 | * Function argument lists are of the form f (a, b, c) i.e. there is 26 | always a space between the arguments. 27 | 28 | * Pointers are declared with spaces both before and after the star. 29 | 30 | * There are no parenthesis around a return expression i.e. return x; 31 | 32 | * Non-static functions have names of the form mpeg2_* 33 | 34 | Here is a short example for reference: 35 | 36 | static int foo (int bar, int baz, int * quux) 37 | { 38 | if (bar == baz) 39 | return *quux; 40 | else do { 41 | bar += *quux; 42 | quux++; 43 | } while (bar != baz); 44 | return *quux + bar; 45 | } 46 | 47 | * For xemacs users, this is what I use: 48 | 49 | (defconst mpeg2-c-style '("gnu" 50 | (c-basic-offset . 4) 51 | (c-label-minimum-indentation . 0) 52 | (c-offsets-alist . ( 53 | (knr-argdecl-intro . +) 54 | (topmost-intro-cont . +) 55 | )) 56 | )) 57 | (c-add-style "mpeg2" mpeg2-c-style) 58 | 59 | Then to use that coding style, type M-x c-set-style mpeg2 60 | 61 | * For emacs users, the following should work: 62 | 63 | (defun mpeg2-c-mode () 64 | "C mode with adjusted defaults for use with mpeg2dec." 65 | (interactive) 66 | (c-mode) 67 | (c-set-style "gnu") 68 | (setq c-basic-offset 4)) 69 | 70 | Then to use that coding style, type M-x mpeg2-c-mode 71 | 72 | * For vim users, the following might help: 73 | 74 | set noexpandtab 75 | set tabstop=8 76 | set shiftwidth=4 77 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Unix build instructions 2 | ----------------------- 3 | 4 | ./configure 5 | make 6 | make install 7 | 8 | If you install from Subversion you'll have to run ./bootstrap first 9 | 10 | 11 | Building for win32 12 | ------------------ 13 | 14 | There are at least three ways to do it: 15 | 16 | - natively on Windows using Microsoft VC++ and the vc++ project 17 | included in this distribution. 18 | 19 | - natively on Windows using MSYS + MINGW (www.mingw.org) (MSYS is a 20 | minimal build environnement to compile unixish projects under 21 | windows. It provides all the common unix tools like sh, gmake...) 22 | 23 | - or on Linux, using the mingw32 cross-compiler 24 | 25 | 26 | Building using MSYS + MINGW on windows 27 | -------------------------------------- 28 | 29 | First you will need to download and install the latest MSYS (version 30 | 1.0.7 as of now) and MINGW. The installation is really easy. Begin 31 | with the MSYS auto-installer and once this is done, extract MINGW into 32 | c:\msys\1.0\mingw. You also have to remember to remove the make 33 | utility included with MINGW as it conflicts with the one from MSYS 34 | (just rename or remove c:\msys\1.0\mingw\bin\make.exe). 35 | 36 | http://prdownloads.sourceforge.net/mingw/MSYS-1.0.7-i686-2002.04.24-1.exe 37 | http://prdownloads.sourceforge.net/mingw/MinGW-1.1.tar.gz 38 | 39 | Then you can build the package using: 40 | # ./configure 41 | # make 42 | 43 | 44 | Building using the mingw32 cross-compiler 45 | ----------------------------------------- 46 | 47 | You need to install mingw32 first. For Debian GNU/Linux users, there 48 | is a mingw32 package. Otherwise you might get it from the mingw site 49 | at http://www.mingw.org/download.shtml. 50 | 51 | The videolan project also keeps precompiled mingw32 binaries at 52 | http://www.videolan.org/vlc/windows.html . If you install these, 53 | you'll have to set your PATH accordingly to include 54 | /usr/local/cross-tools/bin too. 55 | 56 | The build should then proceed using something like: 57 | # CC=i586-mingw32msvc-gcc ./configure --host=i586-mingw32msvc 58 | # make 59 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = libmpeg2 include libvo src test vc++ 2 | DIST_SUBDIRS = doc $(SUBDIRS) 3 | 4 | EXTRA_DIST = bootstrap CodingStyle \ 5 | m4/cflags.m4 m4/inttypes.m4 m4/keywords.m4 m4/nonpic.m4 6 | ACLOCAL_AMFLAGS = -I m4 7 | 8 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | libmpeg2-0.5.1 Fri Jul 18 16:28:49 CEST 2008 2 | 3 | This bugfix release fixes issues with the installation of headers and 4 | pkgconfig files. 5 | 6 | 7 | libmpeg2-0.5.0 Fri Jun 11 23:42:12 CET 2008 8 | 9 | This release brings libmpeg2 up to date with recent contributions, 10 | compilers and systems. 11 | 12 | New optimizations have been provided for SSE2 and ARM instruction sets, 13 | while a lot of warnings triggered by recent compiler changes have been 14 | fixed. 15 | 16 | A new function has been added to guess the aspect ratio of streams where 17 | it is not properly coded. Also it is now possible to retrieve the value 18 | of the MPEG-2 repeat_first_field flag, and to be notified when the 19 | sequence header of a stream changes (eg. aspect ratio on-the-fly changes). 20 | 21 | 22 | mpeg2dec-0.4.1 Wed Feb 15 17:08:28 CET 2006 23 | 24 | This is a bugfix release. It is completely API and ABI compatible with 25 | version 0.4.0. 26 | 27 | The build system now supports newer versions of the autotools and can 28 | find them in weird places on FreeBSD and OS X systems. We also support 29 | x86 accelerations on the AMD64 CPU, including on FreeBSD. The AltiVec 30 | features are now better detected. 31 | 32 | Peter Gubanov found a bug in the 4:4:4 chroma handling, Nicolas Joly 33 | found a memory leak in the Xshm code on remote displays and Roberto 34 | Huelga found alignment issues in the sample3 and sample5 examples. 35 | Gildas Bazin contributed a patch for more tolerance for invalid sequence 36 | display extensions. 37 | 38 | There are also two new maintainers to help Michel in his task: Sam 39 | Hocevar and Christophe Massiot, from the VideoLAN project. 40 | 41 | 42 | mpeg2dec-0.4.0 Tue Dec 23 03:04:35 PST 2003 43 | 44 | Jeez, it's been way too long since the last release. 45 | 46 | The big functionality that warrants a 0.4.x version number is that we 47 | added support for 4:2:2 for 4:4:4 chroma formats. Thanks to Peter 48 | Gubanov for starting the effort there. 49 | 50 | A large part of the development effort has been to fix corner cases 51 | that happen with bad or corrupted streams, concatenated streams, 52 | etc... Regis Duchesne created test cases for this, which was a huge 53 | help. Right now the situation is that we don't know how to make 54 | libmpeg2 crash even when we try hard. 55 | 56 | There is a new helper library for color conversion to common format 57 | (currently rgb and uyvy). The ABI between libmpeg2 and libmpeg2convert 58 | might change in the future, but source code compatibility will be 59 | preserved. In the past people were supposed to write their own color 60 | conversion routines which was a pain since the API was messy. 61 | 62 | David S. Miller contributed some very nice sparc VIS optimizations for 63 | the motion compensation. There are no VIS optimizations for the IDCT 64 | yet but the plan is to get these in for a future 0.4.1 release. 65 | 66 | New functions have been added to set the buffer stride and to reset 67 | the decoder (typically after seeking thru a file). 68 | 69 | There is some very basic documentation in doc/* - it's still quite 70 | limited though. My good resolution for 2004 is to write better 71 | documentation :) In the mean time feel free to ask on mpeg2dec-devel 72 | or on irc.freenode.net channel #livid 73 | 74 | The speed has not changed much since last release - we tend to be 75 | about 1% faster. That's not too bad considering we have new features. 76 | 77 | 78 | mpeg2dec-0.3.1 Fri Dec 13 22:15:36 PST 2002 79 | 80 | This is mainly a maintainance release. On the API side, libmpeg2 now 81 | includes some CPU detection code - so it will by default automatically 82 | use whatever features are available on the CPU it runs on. There is a 83 | function to override this, mainly for testing purposes. 84 | 85 | There has been a few speed improvements too - there is now some alpha 86 | specific code that makes the library more than twice faster on these 87 | machines, and the C IDCT has also been improved which translates to 88 | about 6% speed improvement for people who use this code. 89 | 90 | Finally, a few bugs have been fixed, most notably some memory leaks 91 | and sparc/HPPA/IA64 build issues. 92 | 93 | 94 | mpeg2dec-0.3.0 Wed Nov 27 23:23:23 PST 2002 95 | 96 | The main goal of this release is to preview the new libmpeg2 API. The 97 | old API was not flexible enough for most users, as a result various 98 | projects (xine, mplayer etc...) ended up rewriting their own versions 99 | of decode.c. The goal with this new API is that it will be flexible 100 | enough for people to actually use it instead of rolling their own :) 101 | 102 | In many respects, this code is less mature than the 0.2.x codebase 103 | was. There will probably be a few changes in future versions regarding 104 | color conversion and CPU detection, to cite a few. The goal is to get 105 | a release out and then add the missing features in future 0.3.x 106 | releases. 107 | 108 | In addition to the new API, there are a few new features already too. 109 | For example, we now have improved the error handling, which should 110 | help applications who do seeking for example. Also a few minor speed 111 | improvements (about 7%) and SIMD optimizations now enabled in the VC++ 112 | port too. 113 | 114 | 115 | mpeg2dec-0.2.1 Sun Mar 17 23:24:04 PST 2002 116 | 117 | Two major new features: First, a much higher tolerance to corrupted 118 | streams. Instead of just segfaulting, we should now be able to keep 119 | going after errors. There is no test suite for this feature yet though. 120 | 121 | Second, the altivec optimizations provide a huge speedup (more than 122 | 2.5x) on ppc g4 machines. 123 | 124 | High definition video streams are now supported. 125 | 126 | There is also native support for compiling using VC++. 127 | 128 | And, the libvo interface has been slightly extended so people can more 129 | easily make use of the various mpeg flags. 130 | 131 | 132 | mpeg2dec-0.2.0 Thu Feb 15 20:12:34 PST 2001 133 | 134 | The most important new feature is the support for field 135 | pictures. mpeg2dec is now able to display any conformant 136 | "main profile @ main level" mpeg-2 stream. This means any 137 | stream you should actually encounter in practice :) 138 | 139 | We also added some more accelerations for motion compensation and 140 | color conversion - 3Dnow and SSE. Non-x86 accelerations would be 141 | welcome - patches anyone ? 142 | 143 | libmpeg2 and libvo are now fully reentrant. This will enable other 144 | projects to reuse the mpeg2dec codebase without patches. For the same 145 | reason we added support for "make install" 146 | 147 | Libvo has been switched to a new API. The immediate advantage is that 148 | it allowed us to get rid of the "HACK_MODE" setting - you really dont 149 | want to know. In the future this will also help a lot with the 150 | implementation of synchro. 151 | 152 | Portability enhancements - including support for win32 DLLs. This was 153 | done to get into the hearts of a few more developpers :) 154 | 155 | 156 | mpeg2dec-0.1.7 Thu Nov 2 21:38:33 PST 2000 157 | 158 | First release since march ! Lots of new features : improved 159 | performance, mpeg-1 and mpeg-2 support, integrated demuxer, standards 160 | compliance. 161 | 162 | The major missing feature is mpeg-2 field pictures, this is planned 163 | for mpeg2dec-0.2.0 164 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | 2 | 3 | ABOUT LIBMPEG2 4 | 5 | libmpeg2 is a free library for decoding mpeg-2 and mpeg-1 video 6 | streams. It is released under the terms of the GPL license. 7 | 8 | The main goals in libmpeg2 development are: 9 | 10 | * Conformance - libmpeg2 is able to decode all mpeg streams that 11 | conform to certain restrictions: "constrained parameters" for 12 | mpeg-1, and "main profile" for mpeg-2. In practice, this is 13 | what most people are using. For streams that follow these 14 | restrictions, we believe libmpeg2 is 100% conformant to the 15 | mpeg standards - and we have a pretty extensive test suite to 16 | check this. 17 | 18 | * Speed - there has been huge efforts there, and we believe 19 | libmpeg2 is the fastest library around for what it 20 | does. Please tell us if you find a faster one ! With typical 21 | video streams as found on DVD's, and doing only decoding with 22 | no display, you should be able to get about 110 fps on a 23 | PIII/666, or 150 fps on an Athlon/950. This is less than 20 24 | cycles per output pixel. In a real player program, the display 25 | routines will probably take as much time as the actual 26 | decoding ! 27 | 28 | * Portability - most of the code is written in C, and when we 29 | use platform-specific optimizations (typically assembly 30 | routines, currently used for the motion compensation and the 31 | inverse cosine transform stages) we always have a generic C 32 | routine to fall back on. This should be portable to all 33 | architectures - at least we have heard reports from people 34 | running this code on x86, ppc, sparc, arm and 35 | sh4. Assembly-optimized implementations are available on x86 36 | (MMX) and ppc (altivec) architectures. Ultrasparc (VIS) is 37 | probably the next on the list - we'll see. 38 | 39 | * Reuseability - we do not want libmpeg2 to include any 40 | project-specific code, but it should still include enough 41 | features to be used by very diverse projects. We are only 42 | starting to get there - the best way to help here is to give 43 | us some feedback ! 44 | 45 | The project homepage is at http://libmpeg2.sourceforge.net/ 46 | 47 | 48 | MPEG2DEC 49 | 50 | mpeg2dec is a test program for libmpeg2. It decodes mpeg-1 and mpeg-2 51 | video streams, and also includes a demultiplexer for mpeg-1 and mpeg-2 52 | program streams. It is purposely kept simple : it does not include 53 | features like reading files from a DVD, CSS, fullscreen output, 54 | navigation, etc... The main purpose of mpeg2dec is to have a simple 55 | test bed for libmpeg2. 56 | 57 | The libmpeg2 source code is always distributed in the mpeg2dec 58 | package, to make it easier for people to test it. 59 | 60 | The basic usage is to just type "mpeg2dec file" where file is a 61 | demultiplexed mpeg video file. 62 | 63 | The "-s" option must be used for multiplexed (audio and video) mpeg 64 | files using the "program stream" format. These files are usualy found 65 | on the internet or on unencrypted DVDs. 66 | 67 | The "-t" option must be used for multiplexed (audio and video) mpeg 68 | files using the "transport stream" format. These files are usualy 69 | found in digital TV applications. 70 | 71 | The "-o" option is used to select a given output module - for example 72 | to redirect the output to a file. This is also used for performance 73 | testing and conformance testing. 74 | 75 | The "-c" option is used to disable all optimizations. 76 | 77 | 78 | OTHER PROJECTS USING LIBMPEG2 79 | 80 | libmpeg2 is being used by various other projects, including: 81 | 82 | * xine (http://xine.sourceforge.net/) - started as a simple 83 | mpeg-2 audio and video decoder, but it since became a 84 | full-featured DVD and video media player. 85 | 86 | * VideoLAN (http://www.videolan.org/) - video streaming over an 87 | ethernet network, can also be used as a standalone player. 88 | 89 | * MPlayer (http://www.MPlayerHQ.hu) - another good player, it is 90 | also very robust against damaged streams. 91 | 92 | * movietime (http://movietime.sourceforge.net/) - still quite 93 | young, but it looks very promising ! 94 | 95 | * mpeg2decX (http://homepage1.nifty.com/~toku/software_en.html) - 96 | a graphical interface for mpeg2dec for macintosh osX. 97 | 98 | * TCVP (http://tcvp.sf.net) - video and music player for unix. 99 | 100 | * drip (http://drip.sourceforge.net/) - a DVD to DIVX transcoder. 101 | 102 | * PoMP 103 | (http://www.dmclab.hanyang.ac.kr/research/project/PoDS/PoDS_sw.htm) - 104 | a research player optimized to minimize disk power consumption. 105 | 106 | * OMS (http://www.linuxvideo.org/oms/) 107 | 108 | * XMPS (http://xmps.sourceforge.net/) 109 | 110 | * GStreamer (http://www.gstreamer.net/) - a framework for 111 | streaming media; it has an mpeg2 decoding plugin based on 112 | libmpeg2. 113 | 114 | * mpeglib (http://mpeglib.sourceforge.net/) - a video decoding 115 | library that usess libmpeg2 when decoding mpeg streams. 116 | 117 | * daphne (http://daphne.rulecity.com/) - a laserdisc arcade game 118 | simulator. 119 | 120 | * GOPchop (http://outflux.net/unix/software/GOPchop/) - a 121 | GOP-accurate editor for MPEG2 streams. 122 | 123 | If you use libmpeg2 in another project, let us know ! 124 | 125 | 126 | TASKS 127 | 128 | There are several places where we could easily use some help: 129 | 130 | * Documentation: libmpeg2 still has no documentation. Every 131 | project using it has had to figure things out by looking at 132 | the header files, at the mpeg2dec sample application, and by 133 | asking questions. Writing down a nice documentation would make 134 | the code more easily reuseable. 135 | 136 | * Testing: If you find any stream that does not decode right 137 | with libmpeg2, let us know ! The best thing would be to mail 138 | to the libmpeg2-devel mailing list. Also, it would be nice to 139 | build a stress test so we can make sure libmpeg2 never crashes 140 | on bad streams. 141 | 142 | * Coding: There is a small TODO list in the mpeg2dec package, 143 | you can have a look there ! Most items are pretty terse 144 | though. 145 | 146 | * Porting: If you're porting to a new architecture, you might 147 | want to experiment with the compile flags defined in 148 | configure.in . When you figure out whats fastest on your 149 | platform, send us a patch ! 150 | 151 | * Assembly optimizations: We only have x86 and altivec 152 | optimizations yet, it would be worthwhile writing routines for 153 | other architectures, especially those that have SIMD 154 | instruction set extensions ! Also the yuv2rgb x86 routines 155 | could probably be optimized a lot. 156 | 157 | 158 | SUBVERSION REPOSITORY 159 | 160 | The latest libmpeg2 and mpeg2dec source code can always be found by 161 | anonymous Subversion: 162 | 163 | $ svn checkout svn://svn.videolan.org/libmpeg2/trunk libmpeg2 164 | 165 | You can also browse the latest changes online at 166 | https://trac.videolan.org/libmpeg2/browser 167 | 168 | 169 | MAILING LISTS 170 | 171 | See the subscription information at http://libmpeg2.sourceforge.net/lists.html 172 | 173 | libmpeg2-devel 174 | 175 | This is the main mailing list for technical discussion about 176 | libmpeg2. Anyone wanting to work on libmpeg2, or maybe just stay 177 | informed about the development process, should probably subscribe to 178 | this list. 179 | 180 | libmpeg2-checkins 181 | 182 | All libmpeg2 checkins are announced there. This is a good way to keep 183 | track of what goes into CVS. 184 | 185 | libmpeg2-announce 186 | 187 | This is a very low traffic mailing list, only for announcements of new 188 | versions of libmpeg2. Only project administrators can post there. 189 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | * plain bugs 2 | * fix VIS IDCT code (handling of nonprogressive frame pictures) 3 | 4 | * things we dont implement yet 5 | * more verbose error reporting 6 | * export MC information (for XvMC or for error resilience) 7 | * export quantizer information (for postprocessing filters) 8 | * dont crash on bad streams, make sure we can resync after a while 9 | * possible chunk buffer overflow while reading bits 10 | * synchronization stuff (play at correct speed) 11 | * IDCT precision with sparse matrixes 12 | * sparc IDCT optimizations 13 | * support for still pictures (decode before receiving next startcode !) 14 | 15 | * structural optimizations 16 | * do yuv per sub-slice (probably big speed boost) 17 | * try different memory arrangements for pictures (yuyv, stride, ...) 18 | * once we have sync, call draw_frame before decoding I or P not after 19 | 20 | * local optimizations 21 | * put most common fields at start of decoder_t structure 22 | * fix code that uses multiples of the stride (use preshifted value ?) 23 | * avoid 8-bit accesses particularly on alpha 24 | * use 64-bit shift register for parsing on 64-bit arches 25 | * use restrict (__restrict__) pointers: int * restrict p; 26 | * try feig IDCT ? 27 | * review the use of static inline functions 28 | * improve MMX motion comp inner routines 29 | * optimize IDCT for very sparse input matrixes ? 30 | * optimize startcode search loop ? 31 | * bit parsing / DCT parsing optimizations 32 | 33 | * clean up 34 | * clean up header file usage 35 | * clean up yuv2rgb for interlaced pictures (handling of uv) 36 | * clean up decoder_t structure (some variables should be local ?) 37 | * clean up slice_init 38 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # $Id: bootstrap 2005 2008-07-16 20:51:50Z sam $ 3 | 4 | # bootstrap: generic bootstrap/autogen.sh script for autotools projects 5 | # 6 | # Copyright (c) 2002-2008 Sam Hocevar 7 | # 8 | # This program is free software. It comes without any warranty, to 9 | # the extent permitted by applicable law. You can redistribute it 10 | # and/or modify it under the terms of the Do What The Fuck You Want 11 | # To Public License, Version 2, as published by Sam Hocevar. See 12 | # http://sam.zoy.org/wtfpl/COPYING for more details. 13 | # 14 | # The latest version of this script can be found at the following place: 15 | # http://sam.zoy.org/autotools/ 16 | 17 | # Die if an error occurs 18 | set -e 19 | 20 | # Guess whether we are using configure.ac or configure.in 21 | if test -f configure.ac; then 22 | conffile="configure.ac" 23 | elif test -f configure.in; then 24 | conffile="configure.in" 25 | else 26 | echo "$0: could not find configure.ac or configure.in" 27 | exit 1 28 | fi 29 | 30 | # Check for needed features 31 | auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`" 32 | libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`" 33 | header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`" 34 | makefile="`[ -f Makefile.am ] && echo yes || echo no`" 35 | aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`" 36 | 37 | # Check for automake 38 | amvers="no" 39 | for v in 11 10 9 8 7 6 5; do 40 | if automake-1.${v} --version >/dev/null 2>&1; then 41 | amvers="-1.${v}" 42 | break 43 | elif automake1.${v} --version >/dev/null 2>&1; then 44 | amvers="1.${v}" 45 | break 46 | fi 47 | done 48 | 49 | if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then 50 | amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`" 51 | if expr "$amvers" "<" "1.5" > /dev/null 2>&1; then 52 | amvers="no" 53 | else 54 | amvers="" 55 | fi 56 | fi 57 | 58 | if test "$amvers" = "no"; then 59 | echo "$0: you need automake version 1.5 or later" 60 | exit 1 61 | fi 62 | 63 | # Check for autoconf 64 | acvers="no" 65 | for v in "" "259" "253"; do 66 | if autoconf${v} --version >/dev/null 2>&1; then 67 | acvers="${v}" 68 | break 69 | fi 70 | done 71 | 72 | if test "$acvers" = "no"; then 73 | echo "$0: you need autoconf" 74 | exit 1 75 | fi 76 | 77 | # Check for libtool 78 | if test "$libtool" = "yes"; then 79 | libtoolize="no" 80 | if glibtoolize --version >/dev/null 2>&1; then 81 | libtoolize="glibtoolize" 82 | else 83 | for v in "16" "15" "" "14"; do 84 | if libtoolize${v} --version >/dev/null 2>&1; then 85 | libtoolize="libtoolize${v}" 86 | break 87 | fi 88 | done 89 | fi 90 | 91 | if test "$libtoolize" = "no"; then 92 | echo "$0: you need libtool" 93 | exit 1 94 | fi 95 | fi 96 | 97 | # Remove old cruft 98 | for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done 99 | rm -Rf autom4te.cache 100 | if test -n "$auxdir"; then 101 | if test ! -d "$auxdir"; then 102 | mkdir "$auxdir" 103 | fi 104 | aclocalflags="${aclocalflags} -I $auxdir -I ." 105 | fi 106 | 107 | # Explain what we are doing from now 108 | set -x 109 | 110 | # Bootstrap package 111 | if test "$libtool" = "yes"; then 112 | ${libtoolize} --copy --force 113 | if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then 114 | echo "$0: working around a minor libtool issue" 115 | mv ltmain.sh "$auxdir/" 116 | fi 117 | fi 118 | 119 | aclocal${amvers} ${aclocalflags} 120 | autoconf${acvers} 121 | if test "$header" = "yes"; then 122 | autoheader${acvers} 123 | fi 124 | if test "$makefile" = "yes"; then 125 | #add --include-deps if you want to bootstrap with any other compiler than gcc 126 | #automake${amvers} --add-missing --copy --include-deps 127 | automake${amvers} --foreign --add-missing --copy 128 | fi 129 | 130 | # Remove cruft that we no longer want 131 | rm -Rf autom4te.cache 132 | 133 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Process this file with autoconf to produce a configure script. 2 | AC_PREREQ(2.54) 3 | AC_INIT([libmpeg2],[0.5.1],[]) 4 | 5 | AC_CONFIG_SRCDIR([src/mpeg2dec.c]) 6 | AC_CONFIG_AUX_DIR(.auto) 7 | AC_CONFIG_FILES([Makefile include/Makefile test/Makefile 8 | doc/Makefile src/Makefile libmpeg2/Makefile libmpeg2/convert/Makefile 9 | libvo/Makefile vc++/Makefile 10 | libmpeg2/libmpeg2.pc libmpeg2/convert/libmpeg2convert.pc]) 11 | AC_CONFIG_HEADERS([include/config.h]) 12 | AC_CANONICAL_HOST 13 | 14 | AM_INIT_AUTOMAKE([1.5 -Wall foreign]) 15 | AM_MAINTAINER_MODE 16 | 17 | dnl Checks for compiler 18 | AC_PROG_CC 19 | AC_PROG_GCC_TRADITIONAL 20 | AM_PROG_AS 21 | 22 | dnl Checks for headers. We do this before the CC-specific section because 23 | dnl autoconf generates tests for generic headers before the first header test. 24 | AC_CHECK_HEADERS([sys/time.h time.h sys/timeb.h io.h]) 25 | 26 | dnl CC-specific flags 27 | AC_SUBST([OPT_CFLAGS]) 28 | AC_SUBST([ARCH_OPT_CFLAGS]) 29 | if test x"$CC" = x"checkergcc"; then 30 | enable_sdl=no 31 | elif test x"$GCC" = x"yes"; then 32 | 33 | dnl GCC-specific flags 34 | 35 | dnl -Wall 36 | dnl -Werror moved to the end to not disturb the configure script 37 | TRY_CFLAGS="$OPT_CFLAGS -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs -Wsign-compare" 38 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]) 39 | 40 | dnl -O3 41 | changequote(<<,>>) 42 | TRY_CFLAGS=`echo "$OPT_CFLAGS $CFLAGS"|sed "s/-O[0-9]*//g"` 43 | changequote([,]) 44 | TRY_CFLAGS="$TRY_CFLAGS -O3" 45 | AC_TRY_CFLAGS([$TRY_CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]) 46 | 47 | AC_ARG_ENABLE([debug], 48 | [ --enable-debug debug mode configuration]) 49 | if test x"$enable_debug" = x"yes"; then 50 | AC_DEFINE([DEBUG],,[debug mode configuration]) 51 | else 52 | dnl -fomit-frame-pointer 53 | TRY_CFLAGS="$OPT_CFLAGS -fomit-frame-pointer" 54 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]) 55 | fi 56 | 57 | dnl -fno-common 58 | TRY_CFLAGS="$OPT_CFLAGS -fno-common" 59 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]) 60 | 61 | dnl arch-specific flags 62 | arm_conditional=false 63 | case "$host" in 64 | i?86-* | k?-* | x86_64-* | amd64-*) 65 | AC_DEFINE([ARCH_X86],,[x86 architecture]) 66 | case "$host" in 67 | i386-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i386";; 68 | i486-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=i486";; 69 | i586-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentium";; 70 | i686-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=pentiumpro";; 71 | k6-*) TRY_CFLAGS="$OPT_CFLAGS -mcpu=k6";; 72 | esac 73 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);; 74 | ppc-* | powerpc-*) 75 | have_altivec=no 76 | for TRY_CFLAGS in "-mpim-altivec -force_cpusubtype_ALL" -faltivec -maltivec -fvec; do 77 | AC_TRY_CFLAGS([$OPT_CFLAGS $TRY_CFLAGS $CFLAGS], 78 | [save_CFLAGS="$CFLAGS" 79 | CFLAGS="$OPT_CFLAGS $TRY_CFLAGS $CFLAGS" 80 | AC_MSG_CHECKING([if is needed]) 81 | AC_TRY_COMPILE([], 82 | [typedef vector int t; 83 | vec_ld(0, (unsigned char *)0);], 84 | [have_altivec=yes; AC_MSG_RESULT(no)], 85 | [AC_TRY_COMPILE([#include ], 86 | [typedef vector int t; vec_ld(0, (unsigned char *)0);], 87 | [AC_DEFINE([HAVE_ALTIVEC_H],, 88 | [Define to 1 if you have the header.]) 89 | have_altivec=yes; AC_MSG_RESULT(yes)], 90 | [AC_MSG_RESULT(unsupported)])]) 91 | CFLAGS="$save_CFLAGS"]) 92 | if test "$have_altivec" = "yes"; then 93 | ARCH_OPT_CFLAGS="$TRY_CFLAGS" 94 | AC_DEFINE([ARCH_PPC],,[ppc architecture]) 95 | break 96 | fi 97 | done;; 98 | sparc-* | sparc64-*) 99 | AC_DEFINE([ARCH_SPARC],,[sparc architecture]) 100 | TRY_CFLAGS="$OPT_CFLAGS -mcpu=ultrasparc -mvis" 101 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);; 102 | alpha*) 103 | AC_DEFINE([ARCH_ALPHA],,[alpha architecture]);; 104 | arm*) 105 | arm_conditional=: 106 | AC_DEFINE([ARCH_ARM],,[ARM architecture]);; 107 | esac 108 | elif test x"$CC" = x"tendracc"; then 109 | dnl TenDRA portability checking compiler 110 | TENDRA=yes 111 | OPT_CFLAGS="-Xp -Yansi -f`pwd`/include/tendra.h -DELIDE_CODE" 112 | no_x=yes 113 | enable_sdl=no 114 | elif test x"$CC" = x"icc" -a x"`$CC -V 2>&1 | grep Intel`" != x""; then 115 | dnl Intel C++ compiler 116 | OPT_CFLAGS="-g -O3 -unroll -ip" 117 | else 118 | dnl non-gcc flags - we probably need exact configuration triplets here. 119 | case "$host" in 120 | sparc-sun-solaris*) 121 | TRY_CFLAGS="$OPT_CFLAGS -xCC -fast -xO5" 122 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]);; 123 | esac 124 | fi 125 | 126 | AM_CONDITIONAL(ARCH_ARM, ${arm_conditional}) 127 | 128 | dnl Checks for libtool - this must be done after we set cflags 129 | AC_LIBTOOL_WIN32_DLL 130 | AC_PROG_LIBTOOL 131 | 132 | dnl Checks for libraries. 133 | 134 | dnl Checks for header files. 135 | AM_CPPFLAGS='-I$(top_srcdir)/include -I$(top_builddir)/include' 136 | AC_SUBST([AM_CPPFLAGS]) 137 | AC_HEADER_TIME 138 | AC_CHECK_TYPES([struct timeval], [], [], 139 | [#include 140 | #include ]) 141 | AC_CHECK_GENERATE_INTTYPES([include]) 142 | 143 | dnl Checks for typedefs, structures, and compiler characteristics. 144 | AC_C_CONST 145 | AC_C_ALWAYS_INLINE 146 | AC_C_RESTRICT 147 | AC_C_BUILTIN_EXPECT 148 | AC_C_BIGENDIAN 149 | AC_C_VOLATILE 150 | AC_TYPE_SIZE_T 151 | AC_TYPE_SIGNAL 152 | AC_SYS_LARGEFILE 153 | 154 | dnl Checks for library functions. 155 | AC_CHECK_FUNCS([gettimeofday ftime]) 156 | 157 | case "$target" in 158 | dnl avoid -fPIC on 32-bit x86 platforms 159 | i?86-*|k?-*) 160 | AC_LIBTOOL_NON_PIC([LIBMPEG2_CFLAGS="$LIBMPEG2_CFLAGS -prefer-non-pic"]) 161 | ;; 162 | esac 163 | AC_SUBST([LIBMPEG2_CFLAGS]) 164 | 165 | dnl check for cpudetect 166 | AC_ARG_ENABLE([accel-detect], 167 | [ --disable-accel-detect make a version without accel detection code]) 168 | if test x"$enable_accel_detect" != x"no"; then 169 | AC_DEFINE([ACCEL_DETECT],,[autodetect accelerations]) 170 | fi 171 | 172 | dnl check for X11 173 | AC_PATH_XTRA 174 | if test x"$no_x" != x"yes"; then 175 | dnl check for Xshm 176 | AC_CHECK_LIB([Xext],[XShmCreateImage], 177 | [AC_DEFINE([LIBVO_X11],,[libvo X11 support]) 178 | LIBVO_CFLAGS="$LIBVO_CFLAGS $X_CFLAGS" 179 | LIBVO_LIBS="$LIBVO_LIBS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lXext -lX11" 180 | dnl check for Xv 181 | AC_CHECK_LIB([Xv],[XvShmCreateImage], 182 | [AC_DEFINE([LIBVO_XV],,[libvo Xv support]) 183 | LIBVO_LIBS="$LIBVO_LIBS -lXv"],, 184 | [$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lXext -lX11])],, 185 | [$X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS -lX11]) 186 | fi 187 | 188 | dnl check for DirectX 189 | AC_ARG_ENABLE([directx], 190 | [ --enable-directx=DIR use Win32 DirectX headers in DIR]) 191 | case $enable_directx in 192 | ""|yes) AC_CHECK_HEADER([ddraw.h], 193 | [AC_DEFINE([LIBVO_DX],,[libvo DirectX support]) 194 | LIBVO_LIBS="$LIBVO_LIBS -lgdi32"]);; 195 | no) ;; 196 | *) if test -f "$enable_directx/ddraw.h"; then 197 | AC_DEFINE([LIBVO_DX],,[libvo DirectX support]) 198 | LIBVO_CFLAGS="$LIBVO_CFLAGS -I$enable_directx" 199 | LIBVO_LIBS="$LIBVO_LIBS -lgdi32" 200 | else 201 | AC_MSG_ERROR([Cannot find $enable_directx/ddraw.h]) 202 | fi;; 203 | esac 204 | 205 | dnl check for SDL 206 | AC_ARG_ENABLE([sdl],[ --disable-sdl make a version not using SDL]) 207 | if test x"$enable_sdl" != x"no"; then 208 | AC_CHECK_PROG([SDLCONFIG],[sdl-config],[yes]) 209 | if test x"$SDLCONFIG" = x"yes"; then 210 | AC_DEFINE([LIBVO_SDL],,[libvo SDL support]) 211 | LIBVO_CFLAGS="$LIBVO_CFLAGS `sdl-config --cflags`" 212 | LIBVO_LIBS="$LIBVO_LIBS `sdl-config --libs`" 213 | fi 214 | fi 215 | 216 | AC_SUBST([LIBVO_CFLAGS]) 217 | AC_SUBST([LIBVO_LIBS]) 218 | 219 | AC_ARG_ENABLE([warnings], 220 | [ --enable-warnings treat warnings as errors]) 221 | if test x"$enable_warnings" = x"yes" -a x"$GCC" = x"yes"; then 222 | dnl compiler warnings 223 | TRY_CFLAGS="$OPT_CFLAGS -Werror" 224 | AC_TRY_CFLAGS([$TRY_CFLAGS $CFLAGS],[OPT_CFLAGS="$TRY_CFLAGS"]) 225 | elif test x"$TENDRA" = x"yes"; then 226 | dnl TenDRA portability checking compiler 227 | OPT_CFLAGS="$OPT_CFLAGS -DTenDRA_check" 228 | fi 229 | 230 | MPEG2DEC_CFLAGS="$OPT_CFLAGS" 231 | 232 | AC_ARG_ENABLE([gprof],[ --enable-gprof make a version using gprof]) 233 | if test x"$enable_gprof" = x"yes"; then 234 | AC_DEFINE([MPEG2DEC_GPROF],,[mpeg2dec profiling]) 235 | MPEG2DEC_CFLAGS=`echo "$MPEG2DEC_CFLAGS"|sed "s/-fomit-frame-pointer//g"` 236 | MPEG2DEC_CFLAGS="$MPEG2DEC_CFLAGS -p" 237 | fi 238 | 239 | AC_SUBST([MPEG2DEC_CFLAGS]) 240 | 241 | AC_C_ATTRIBUTE_ALIGNED 242 | 243 | AC_OUTPUT 244 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = $(MPEG2DEC_CFLAGS) 2 | 3 | libmpeg2 = $(top_builddir)/libmpeg2/libmpeg2.la 4 | libmpeg2convert = $(top_builddir)/libmpeg2/convert/libmpeg2convert.la 5 | 6 | noinst_PROGRAMS = sample1 sample2 sample3 sample4 sample5 sample6 7 | sample1_SOURCES = sample1.c 8 | sample1_LDADD = $(libmpeg2) 9 | sample2_SOURCES = sample2.c 10 | sample2_LDADD = $(libmpeg2) $(libmpeg2convert) 11 | sample3_SOURCES = sample3.c 12 | sample3_LDADD = $(libmpeg2) 13 | sample4_SOURCES = sample4.c 14 | sample4_LDADD = $(libmpeg2) $(libmpeg2convert) 15 | sample5_SOURCES = sample5.c 16 | sample5_LDADD = $(libmpeg2) 17 | sample6_SOURCES = sample6.c 18 | sample6_LDADD = $(libmpeg2) $(libmpeg2convert) 19 | 20 | EXTRA_DIST = libmpeg2.txt 21 | -------------------------------------------------------------------------------- /doc/sample1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample1.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * 7 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 8 | * See http://libmpeg2.sourceforge.net/ for updates. 9 | * 10 | * mpeg2dec 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 | * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * This program reads a MPEG-2 stream, and saves each of its frames as 25 | * an image file using the PGM format (black and white). 26 | * 27 | * It demonstrates how to use the following features of libmpeg2: 28 | * - Output buffers use the YUV 4:2:0 planar format. 29 | * - Output buffers are allocated and managed by the library. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "mpeg2.h" 37 | 38 | static void save_pgm (int width, int height, 39 | int chroma_width, int chroma_height, 40 | uint8_t * const * buf, int num) 41 | { 42 | char filename[100]; 43 | FILE * pgmfile; 44 | int i; 45 | static uint8_t black[16384] = { 0 }; 46 | 47 | sprintf (filename, "%d.pgm", num); 48 | pgmfile = fopen (filename, "wb"); 49 | if (!pgmfile) { 50 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 51 | exit (1); 52 | } 53 | fprintf (pgmfile, "P5\n%d %d\n255\n", 54 | 2 * chroma_width, height + chroma_height); 55 | for (i = 0; i < height; i++) { 56 | fwrite (buf[0] + i * width, width, 1, pgmfile); 57 | fwrite (black, 2 * chroma_width - width, 1, pgmfile); 58 | } 59 | for (i = 0; i < chroma_height; i++) { 60 | fwrite (buf[1] + i * chroma_width, chroma_width, 1, pgmfile); 61 | fwrite (buf[2] + i * chroma_width, chroma_width, 1, pgmfile); 62 | } 63 | fclose (pgmfile); 64 | } 65 | 66 | static void sample1 (FILE * mpgfile) 67 | { 68 | #define BUFFER_SIZE 4096 69 | uint8_t buffer[BUFFER_SIZE]; 70 | mpeg2dec_t * decoder; 71 | const mpeg2_info_t * info; 72 | const mpeg2_sequence_t * sequence; 73 | mpeg2_state_t state; 74 | size_t size; 75 | int framenum = 0; 76 | 77 | decoder = mpeg2_init (); 78 | if (decoder == NULL) { 79 | fprintf (stderr, "Could not allocate a decoder object.\n"); 80 | exit (1); 81 | } 82 | info = mpeg2_info (decoder); 83 | 84 | size = (size_t)-1; 85 | do { 86 | state = mpeg2_parse (decoder); 87 | sequence = info->sequence; 88 | switch (state) { 89 | case STATE_BUFFER: 90 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 91 | mpeg2_buffer (decoder, buffer, buffer + size); 92 | break; 93 | case STATE_SLICE: 94 | case STATE_END: 95 | case STATE_INVALID_END: 96 | if (info->display_fbuf) 97 | save_pgm (sequence->width, sequence->height, 98 | sequence->chroma_width, sequence->chroma_height, 99 | info->display_fbuf->buf, framenum++); 100 | break; 101 | default: 102 | break; 103 | } 104 | } while (size); 105 | 106 | mpeg2_close (decoder); 107 | } 108 | 109 | int main (int argc, char ** argv) 110 | { 111 | FILE * mpgfile; 112 | 113 | if (argc > 1) { 114 | mpgfile = fopen (argv[1], "rb"); 115 | if (!mpgfile) { 116 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 117 | exit (1); 118 | } 119 | } else 120 | mpgfile = stdin; 121 | 122 | sample1 (mpgfile); 123 | 124 | return 0; 125 | } 126 | -------------------------------------------------------------------------------- /doc/sample2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample2.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * 7 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 8 | * See http://libmpeg2.sourceforge.net/ for updates. 9 | * 10 | * mpeg2dec 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 | * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * This program reads a MPEG-2 stream, and saves each of its frames as 25 | * an image file using the PPM format (color). 26 | * 27 | * It demonstrates how to use the following features of libmpeg2: 28 | * - Output buffers use the RGB 24-bit chunky format. 29 | * - Output buffers are allocated and managed by the library. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "mpeg2.h" 37 | #include "mpeg2convert.h" 38 | 39 | static void save_ppm (int width, int height, uint8_t * buf, int num) 40 | { 41 | char filename[100]; 42 | FILE * ppmfile; 43 | 44 | sprintf (filename, "%d.ppm", num); 45 | ppmfile = fopen (filename, "wb"); 46 | if (!ppmfile) { 47 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 48 | exit (1); 49 | } 50 | fprintf (ppmfile, "P6\n%d %d\n255\n", width, height); 51 | fwrite (buf, 3 * width, height, ppmfile); 52 | fclose (ppmfile); 53 | } 54 | 55 | static void sample2 (FILE * mpgfile) 56 | { 57 | #define BUFFER_SIZE 4096 58 | uint8_t buffer[BUFFER_SIZE]; 59 | mpeg2dec_t * decoder; 60 | const mpeg2_info_t * info; 61 | mpeg2_state_t state; 62 | size_t size; 63 | int framenum = 0; 64 | 65 | decoder = mpeg2_init (); 66 | if (decoder == NULL) { 67 | fprintf (stderr, "Could not allocate a decoder object.\n"); 68 | exit (1); 69 | } 70 | info = mpeg2_info (decoder); 71 | 72 | size = (size_t)-1; 73 | do { 74 | state = mpeg2_parse (decoder); 75 | switch (state) { 76 | case STATE_BUFFER: 77 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 78 | mpeg2_buffer (decoder, buffer, buffer + size); 79 | break; 80 | case STATE_SEQUENCE: 81 | mpeg2_convert (decoder, mpeg2convert_rgb24, NULL); 82 | break; 83 | case STATE_SLICE: 84 | case STATE_END: 85 | case STATE_INVALID_END: 86 | if (info->display_fbuf) 87 | save_ppm (info->sequence->width, info->sequence->height, 88 | info->display_fbuf->buf[0], framenum++); 89 | break; 90 | default: 91 | break; 92 | } 93 | } while (size); 94 | 95 | mpeg2_close (decoder); 96 | } 97 | 98 | int main (int argc, char ** argv) 99 | { 100 | FILE * mpgfile; 101 | 102 | if (argc > 1) { 103 | mpgfile = fopen (argv[1], "rb"); 104 | if (!mpgfile) { 105 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 106 | exit (1); 107 | } 108 | } else 109 | mpgfile = stdin; 110 | 111 | sample2 (mpgfile); 112 | 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /doc/sample3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample3.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * Copyright (C) 2006 Sam Hocevar 7 | * 8 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 9 | * See http://libmpeg2.sourceforge.net/ for updates. 10 | * 11 | * mpeg2dec is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * mpeg2dec is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * This program reads a MPEG-2 stream, and saves each of its frames as 26 | * an image file using the PGM format (black and white). 27 | * 28 | * It demonstrates how to use the following features of libmpeg2: 29 | * - Output buffers use the YUV 4:2:0 planar format. 30 | * - Output buffers must be 16-byte aligned. 31 | * - Output buffers are allocated by the caller but managed by the library. 32 | */ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "mpeg2.h" 39 | 40 | static void save_pgm (int width, int height, 41 | int chroma_width, int chroma_height, 42 | uint8_t * const * buf, int num) 43 | { 44 | char filename[100]; 45 | FILE * pgmfile; 46 | int i; 47 | static uint8_t black[16384] = { 0 }; 48 | 49 | sprintf (filename, "%d.pgm", num); 50 | pgmfile = fopen (filename, "wb"); 51 | if (!pgmfile) { 52 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 53 | exit (1); 54 | } 55 | fprintf (pgmfile, "P5\n%d %d\n255\n", 56 | 2 * chroma_width, height + chroma_height); 57 | for (i = 0; i < height; i++) { 58 | fwrite (buf[0] + i * width, width, 1, pgmfile); 59 | fwrite (black, 2 * chroma_width - width, 1, pgmfile); 60 | } 61 | for (i = 0; i < chroma_height; i++) { 62 | fwrite (buf[1] + i * chroma_width, chroma_width, 1, pgmfile); 63 | fwrite (buf[2] + i * chroma_width, chroma_width, 1, pgmfile); 64 | } 65 | fclose (pgmfile); 66 | } 67 | 68 | static void sample3 (FILE * mpgfile) 69 | { 70 | #define BUFFER_SIZE 4096 71 | #define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15))) 72 | uint8_t buffer[BUFFER_SIZE]; 73 | mpeg2dec_t * decoder; 74 | const mpeg2_info_t * info; 75 | const mpeg2_sequence_t * sequence; 76 | mpeg2_state_t state; 77 | size_t size; 78 | int framenum = 0; 79 | uint8_t * mbuf[3][3]; 80 | uint8_t * fbuf[3][3]; 81 | int i, j; 82 | 83 | decoder = mpeg2_init (); 84 | if (decoder == NULL) { 85 | fprintf (stderr, "Could not allocate a decoder object.\n"); 86 | exit (1); 87 | } 88 | info = mpeg2_info (decoder); 89 | 90 | size = (size_t)-1; 91 | do { 92 | state = mpeg2_parse (decoder); 93 | sequence = info->sequence; 94 | switch (state) { 95 | case STATE_BUFFER: 96 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 97 | mpeg2_buffer (decoder, buffer, buffer + size); 98 | break; 99 | case STATE_SEQUENCE: 100 | for (i = 0; i < 3; i++) { 101 | mbuf[i][0] = (uint8_t *) malloc (sequence->width * 102 | sequence->height + 15); 103 | mbuf[i][1] = (uint8_t *) malloc (sequence->chroma_width * 104 | sequence->chroma_height + 15); 105 | mbuf[i][2] = (uint8_t *) malloc (sequence->chroma_width * 106 | sequence->chroma_height + 15); 107 | if (!mbuf[i][0] || !mbuf[i][1] || !mbuf[i][2]) { 108 | fprintf (stderr, "Could not allocate an output buffer.\n"); 109 | exit (1); 110 | } 111 | for (j = 0; j < 3; j++) 112 | fbuf[i][j] = ALIGN_16 (mbuf[i][j]); 113 | mpeg2_set_buf (decoder, fbuf[i], NULL); 114 | } 115 | break; 116 | case STATE_SLICE: 117 | case STATE_END: 118 | case STATE_INVALID_END: 119 | if (info->display_fbuf) 120 | save_pgm (sequence->width, sequence->height, 121 | sequence->chroma_width, sequence->chroma_height, 122 | info->display_fbuf->buf, framenum++); 123 | if (state != STATE_SLICE) 124 | for (i = 0; i < 3; i++) 125 | for (j = 0; j < 3; j++) 126 | free (mbuf[i][j]); 127 | break; 128 | default: 129 | break; 130 | } 131 | } while (size); 132 | 133 | mpeg2_close (decoder); 134 | } 135 | 136 | int main (int argc, char ** argv) 137 | { 138 | FILE * mpgfile; 139 | 140 | if (argc > 1) { 141 | mpgfile = fopen (argv[1], "rb"); 142 | if (!mpgfile) { 143 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 144 | exit (1); 145 | } 146 | } else 147 | mpgfile = stdin; 148 | 149 | sample3 (mpgfile); 150 | 151 | return 0; 152 | } 153 | -------------------------------------------------------------------------------- /doc/sample4.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample4.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * 7 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 8 | * See http://libmpeg2.sourceforge.net/ for updates. 9 | * 10 | * mpeg2dec 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 | * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * This program reads a MPEG-2 stream, and saves each of its frames as 25 | * an image file using the PPM format (color). 26 | * 27 | * It demonstrates how to use the following features of libmpeg2: 28 | * - Output buffers use the RGB 24-bit chunky format. 29 | * - Output buffers are allocated by the caller but managed by the library. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "mpeg2.h" 37 | #include "mpeg2convert.h" 38 | 39 | static void save_ppm (int width, int height, uint8_t * buf, int num) 40 | { 41 | char filename[100]; 42 | FILE * ppmfile; 43 | 44 | sprintf (filename, "%d.ppm", num); 45 | ppmfile = fopen (filename, "wb"); 46 | if (!ppmfile) { 47 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 48 | exit (1); 49 | } 50 | fprintf (ppmfile, "P6\n%d %d\n255\n", width, height); 51 | fwrite (buf, 3 * width, height, ppmfile); 52 | fclose (ppmfile); 53 | } 54 | 55 | static void sample4 (FILE * mpgfile) 56 | { 57 | #define BUFFER_SIZE 4096 58 | uint8_t buffer[BUFFER_SIZE]; 59 | mpeg2dec_t * decoder; 60 | const mpeg2_info_t * info; 61 | mpeg2_state_t state; 62 | size_t size; 63 | int framenum = 0; 64 | int pixels; 65 | uint8_t * fbuf[3][3]; 66 | int i; 67 | 68 | decoder = mpeg2_init (); 69 | if (decoder == NULL) { 70 | fprintf (stderr, "Could not allocate a decoder object.\n"); 71 | exit (1); 72 | } 73 | info = mpeg2_info (decoder); 74 | 75 | size = (size_t)-1; 76 | do { 77 | state = mpeg2_parse (decoder); 78 | switch (state) { 79 | case STATE_BUFFER: 80 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 81 | mpeg2_buffer (decoder, buffer, buffer + size); 82 | break; 83 | case STATE_SEQUENCE: 84 | mpeg2_convert (decoder, mpeg2convert_rgb24, NULL); 85 | pixels = info->sequence->width * info->sequence->height; 86 | for (i = 0; i < 3; i++) { 87 | fbuf[i][0] = (uint8_t *) malloc (3 * pixels); 88 | fbuf[i][1] = fbuf[i][2] = NULL; 89 | if (!fbuf[i][0]) { 90 | fprintf (stderr, "Could not allocate an output buffer.\n"); 91 | exit (1); 92 | } 93 | mpeg2_set_buf (decoder, fbuf[i], NULL); 94 | } 95 | break; 96 | case STATE_SLICE: 97 | case STATE_END: 98 | case STATE_INVALID_END: 99 | if (info->display_fbuf) 100 | save_ppm (info->sequence->width, info->sequence->height, 101 | info->display_fbuf->buf[0], framenum++); 102 | if (state != STATE_SLICE) 103 | for (i = 0; i < 3; i++) 104 | free (fbuf[i][0]); 105 | break; 106 | default: 107 | break; 108 | } 109 | } while (size); 110 | 111 | mpeg2_close (decoder); 112 | } 113 | 114 | int main (int argc, char ** argv) 115 | { 116 | FILE * mpgfile; 117 | 118 | if (argc > 1) { 119 | mpgfile = fopen (argv[1], "rb"); 120 | if (!mpgfile) { 121 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 122 | exit (1); 123 | } 124 | } else 125 | mpgfile = stdin; 126 | 127 | sample4 (mpgfile); 128 | 129 | return 0; 130 | } 131 | -------------------------------------------------------------------------------- /doc/sample5.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample5.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * Copyright (C) 2006 Sam Hocevar 7 | * 8 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 9 | * See http://libmpeg2.sourceforge.net/ for updates. 10 | * 11 | * mpeg2dec is free software; you can redistribute it and/or modify 12 | * it under the terms of the GNU General Public License as published by 13 | * the Free Software Foundation; either version 2 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * mpeg2dec is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | * GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License 22 | * along with this program; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * This program reads a MPEG-2 stream, and saves each of its frames as 26 | * an image file using the PGM format (black and white). 27 | * 28 | * It demonstrates how to use the following features of libmpeg2: 29 | * - Output buffers use the YUV 4:2:0 planar format. 30 | * - Output buffers must be 16-byte aligned. 31 | * - Output buffers are allocated and managed by the caller. 32 | */ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | #include "mpeg2.h" 39 | 40 | static void save_pgm (int width, int height, 41 | int chroma_width, int chroma_height, 42 | uint8_t * const * buf, int num) 43 | { 44 | char filename[100]; 45 | FILE * pgmfile; 46 | int i; 47 | static uint8_t black[16384] = { 0 }; 48 | 49 | sprintf (filename, "%d.pgm", num); 50 | pgmfile = fopen (filename, "wb"); 51 | if (!pgmfile) { 52 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 53 | exit (1); 54 | } 55 | fprintf (pgmfile, "P5\n%d %d\n255\n", 56 | 2 * chroma_width, height + chroma_height); 57 | for (i = 0; i < height; i++) { 58 | fwrite (buf[0] + i * width, width, 1, pgmfile); 59 | fwrite (black, 2 * chroma_width - width, 1, pgmfile); 60 | } 61 | for (i = 0; i < chroma_height; i++) { 62 | fwrite (buf[1] + i * chroma_width, chroma_width, 1, pgmfile); 63 | fwrite (buf[2] + i * chroma_width, chroma_width, 1, pgmfile); 64 | } 65 | fclose (pgmfile); 66 | } 67 | 68 | static struct fbuf_s { 69 | uint8_t * mbuf[3]; 70 | uint8_t * yuv[3]; 71 | int used; 72 | } fbuf[3]; 73 | 74 | static struct fbuf_s * get_fbuf (void) 75 | { 76 | int i; 77 | 78 | for (i = 0; i < 3; i++) 79 | if (!fbuf[i].used) { 80 | fbuf[i].used = 1; 81 | return fbuf + i; 82 | } 83 | fprintf (stderr, "Could not find a free fbuf.\n"); 84 | exit (1); 85 | } 86 | 87 | static void sample5 (FILE * mpgfile) 88 | { 89 | #define BUFFER_SIZE 4096 90 | #define ALIGN_16(p) ((void *)(((uintptr_t)(p) + 15) & ~((uintptr_t)15))) 91 | uint8_t buffer[BUFFER_SIZE]; 92 | mpeg2dec_t * decoder; 93 | const mpeg2_info_t * info; 94 | const mpeg2_sequence_t * sequence; 95 | mpeg2_state_t state; 96 | size_t size; 97 | int framenum = 0; 98 | int i, j; 99 | struct fbuf_s * current_fbuf; 100 | 101 | decoder = mpeg2_init (); 102 | if (decoder == NULL) { 103 | fprintf (stderr, "Could not allocate a decoder object.\n"); 104 | exit (1); 105 | } 106 | info = mpeg2_info (decoder); 107 | 108 | size = (size_t)-1; 109 | do { 110 | state = mpeg2_parse (decoder); 111 | sequence = info->sequence; 112 | switch (state) { 113 | case STATE_BUFFER: 114 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 115 | mpeg2_buffer (decoder, buffer, buffer + size); 116 | break; 117 | case STATE_SEQUENCE: 118 | mpeg2_custom_fbuf (decoder, 1); 119 | for (i = 0; i < 3; i++) { 120 | fbuf[i].mbuf[0] = (uint8_t *) malloc (sequence->width * 121 | sequence->height + 15); 122 | fbuf[i].mbuf[1] = (uint8_t *) malloc (sequence->chroma_width * 123 | sequence->chroma_height + 15); 124 | fbuf[i].mbuf[2] = (uint8_t *) malloc (sequence->chroma_width * 125 | sequence->chroma_height + 15); 126 | if (!fbuf[i].mbuf[0] || !fbuf[i].mbuf[1] || !fbuf[i].mbuf[2]) { 127 | fprintf (stderr, "Could not allocate an output buffer.\n"); 128 | exit (1); 129 | } 130 | for (j = 0; j < 3; j++) 131 | fbuf[i].yuv[j] = ALIGN_16 (fbuf[i].mbuf[j]); 132 | fbuf[i].used = 0; 133 | } 134 | for (i = 0; i < 2; i++) { 135 | current_fbuf = get_fbuf (); 136 | mpeg2_set_buf (decoder, current_fbuf->yuv, current_fbuf); 137 | } 138 | break; 139 | case STATE_PICTURE: 140 | current_fbuf = get_fbuf (); 141 | mpeg2_set_buf (decoder, current_fbuf->yuv, current_fbuf); 142 | break; 143 | case STATE_SLICE: 144 | case STATE_END: 145 | case STATE_INVALID_END: 146 | if (info->display_fbuf) 147 | save_pgm (sequence->width, sequence->height, 148 | sequence->chroma_width, sequence->chroma_height, 149 | info->display_fbuf->buf, framenum++); 150 | if (info->discard_fbuf) 151 | ((struct fbuf_s *)info->discard_fbuf->id)->used = 0; 152 | if (state != STATE_SLICE) 153 | for (i = 0; i < 3; i++) 154 | for (j = 0; j < 3; j++) 155 | free (fbuf[i].mbuf[j]); 156 | break; 157 | default: 158 | break; 159 | } 160 | } while (size); 161 | 162 | mpeg2_close (decoder); 163 | } 164 | 165 | int main (int argc, char ** argv) 166 | { 167 | FILE * mpgfile; 168 | 169 | if (argc > 1) { 170 | mpgfile = fopen (argv[1], "rb"); 171 | if (!mpgfile) { 172 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 173 | exit (1); 174 | } 175 | } else 176 | mpgfile = stdin; 177 | 178 | sample5 (mpgfile); 179 | 180 | return 0; 181 | } 182 | -------------------------------------------------------------------------------- /doc/sample6.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sample6.c 3 | * Copyright (C) 2003 Regis Duchesne 4 | * Copyright (C) 2000-2003 Michel Lespinasse 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * 7 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 8 | * See http://libmpeg2.sourceforge.net/ for updates. 9 | * 10 | * mpeg2dec 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 | * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | * 24 | * This program reads a MPEG-2 stream, and saves each of its frames as 25 | * an image file using the PPM format (color). 26 | * 27 | * It demonstrates how to use the following features of libmpeg2: 28 | * - Output buffers use the RGB 24-bit chunky format. 29 | * - Output buffers are allocated and managed by the caller. 30 | */ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include "mpeg2.h" 37 | #include "mpeg2convert.h" 38 | 39 | static void save_ppm (int width, int height, uint8_t * buf, int num) 40 | { 41 | char filename[100]; 42 | FILE * ppmfile; 43 | 44 | sprintf (filename, "%d.ppm", num); 45 | ppmfile = fopen (filename, "wb"); 46 | if (!ppmfile) { 47 | fprintf (stderr, "Could not open file \"%s\".\n", filename); 48 | exit (1); 49 | } 50 | fprintf (ppmfile, "P6\n%d %d\n255\n", width, height); 51 | fwrite (buf, 3 * width, height, ppmfile); 52 | fclose (ppmfile); 53 | } 54 | 55 | static struct fbuf_s { 56 | uint8_t * rgb[3]; 57 | int used; 58 | } fbuf[3]; 59 | 60 | static struct fbuf_s * get_fbuf (void) 61 | { 62 | int i; 63 | 64 | for (i = 0; i < 3; i++) 65 | if (!fbuf[i].used) { 66 | fbuf[i].used = 1; 67 | return fbuf + i; 68 | } 69 | fprintf (stderr, "Could not find a free fbuf.\n"); 70 | exit (1); 71 | } 72 | 73 | static void sample6 (FILE * mpgfile) 74 | { 75 | #define BUFFER_SIZE 4096 76 | uint8_t buffer[BUFFER_SIZE]; 77 | mpeg2dec_t * decoder; 78 | const mpeg2_info_t * info; 79 | mpeg2_state_t state; 80 | size_t size; 81 | int framenum = 0; 82 | int pixels; 83 | int i; 84 | struct fbuf_s * current_fbuf; 85 | 86 | decoder = mpeg2_init (); 87 | if (decoder == NULL) { 88 | fprintf (stderr, "Could not allocate a decoder object.\n"); 89 | exit (1); 90 | } 91 | info = mpeg2_info (decoder); 92 | 93 | size = (size_t)-1; 94 | do { 95 | state = mpeg2_parse (decoder); 96 | switch (state) { 97 | case STATE_BUFFER: 98 | size = fread (buffer, 1, BUFFER_SIZE, mpgfile); 99 | mpeg2_buffer (decoder, buffer, buffer + size); 100 | break; 101 | case STATE_SEQUENCE: 102 | mpeg2_convert (decoder, mpeg2convert_rgb24, NULL); 103 | mpeg2_custom_fbuf (decoder, 1); 104 | pixels = info->sequence->width * info->sequence->height; 105 | for (i = 0; i < 3; i++) { 106 | fbuf[i].rgb[0] = (uint8_t *) malloc (3 * pixels); 107 | fbuf[i].rgb[1] = fbuf[i].rgb[2] = NULL; 108 | if (!fbuf[i].rgb[0]) { 109 | fprintf (stderr, "Could not allocate an output buffer.\n"); 110 | exit (1); 111 | } 112 | fbuf[i].used = 0; 113 | } 114 | for (i = 0; i < 2; i++) { 115 | current_fbuf = get_fbuf (); 116 | mpeg2_set_buf (decoder, current_fbuf->rgb, current_fbuf); 117 | } 118 | break; 119 | case STATE_PICTURE: 120 | current_fbuf = get_fbuf (); 121 | mpeg2_set_buf (decoder, current_fbuf->rgb, current_fbuf); 122 | break; 123 | case STATE_SLICE: 124 | case STATE_END: 125 | case STATE_INVALID_END: 126 | if (info->display_fbuf) 127 | save_ppm (info->sequence->width, info->sequence->height, 128 | info->display_fbuf->buf[0], framenum++); 129 | if (info->discard_fbuf) 130 | ((struct fbuf_s *)info->discard_fbuf->id)->used = 0; 131 | if (state != STATE_SLICE) 132 | for (i = 0; i < 3; i++) 133 | free (fbuf[i].rgb[0]); 134 | break; 135 | default: 136 | break; 137 | } 138 | } while (size); 139 | 140 | mpeg2_close (decoder); 141 | } 142 | 143 | int main (int argc, char ** argv) 144 | { 145 | FILE * mpgfile; 146 | 147 | if (argc > 1) { 148 | mpgfile = fopen (argv[1], "rb"); 149 | if (!mpgfile) { 150 | fprintf (stderr, "Could not open file \"%s\".\n", argv[1]); 151 | exit (1); 152 | } 153 | } else 154 | mpgfile = stdin; 155 | 156 | sample6 (mpgfile); 157 | 158 | return 0; 159 | } 160 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | libincludedir = $(includedir)/mpeg2dec 2 | libinclude_HEADERS = mpeg2.h mpeg2convert.h 3 | 4 | EXTRA_DIST = video_out.h mmx.h alpha_asm.h vis.h attributes.h tendra.h 5 | -------------------------------------------------------------------------------- /include/alpha_asm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Alpha assembly macros 3 | * Copyright (c) 2002-2003 Falk Hueffner 4 | * 5 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 6 | * See http://libmpeg2.sourceforge.net/ for updates. 7 | * 8 | * mpeg2dec is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * mpeg2dec is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #ifndef LIBMPEG2_ALPHA_ASM_H 24 | #define LIBMPEG2_ALPHA_ASM_H 25 | 26 | #include 27 | 28 | #if defined __GNUC__ 29 | # define GNUC_PREREQ(maj, min) \ 30 | ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) 31 | #else 32 | # define GNUC_PREREQ(maj, min) 0 33 | #endif 34 | 35 | #define AMASK_BWX (1 << 0) 36 | #define AMASK_FIX (1 << 1) 37 | #define AMASK_CIX (1 << 2) 38 | #define AMASK_MVI (1 << 8) 39 | 40 | #ifdef __alpha_bwx__ 41 | # define HAVE_BWX() 1 42 | #else 43 | # define HAVE_BWX() (amask(AMASK_BWX) == 0) 44 | #endif 45 | #ifdef __alpha_fix__ 46 | # define HAVE_FIX() 1 47 | #else 48 | # define HAVE_FIX() (amask(AMASK_FIX) == 0) 49 | #endif 50 | #ifdef __alpha_max__ 51 | # define HAVE_MVI() 1 52 | #else 53 | # define HAVE_MVI() (amask(AMASK_MVI) == 0) 54 | #endif 55 | #ifdef __alpha_cix__ 56 | # define HAVE_CIX() 1 57 | #else 58 | # define HAVE_CIX() (amask(AMASK_CIX) == 0) 59 | #endif 60 | 61 | inline static uint64_t BYTE_VEC(uint64_t x) 62 | { 63 | x |= x << 8; 64 | x |= x << 16; 65 | x |= x << 32; 66 | return x; 67 | } 68 | inline static uint64_t WORD_VEC(uint64_t x) 69 | { 70 | x |= x << 16; 71 | x |= x << 32; 72 | return x; 73 | } 74 | 75 | #define ldq(p) (*(const uint64_t *) (p)) 76 | #define ldl(p) (*(const int32_t *) (p)) 77 | #define stl(l, p) do { *(uint32_t *) (p) = (l); } while (0) 78 | #define stq(l, p) do { *(uint64_t *) (p) = (l); } while (0) 79 | #define sextw(x) ((int16_t) (x)) 80 | 81 | #ifdef __GNUC__ 82 | struct unaligned_long { uint64_t l; } __attribute__((packed)); 83 | #define ldq_u(p) (*(const uint64_t *) (((uint64_t) (p)) & ~7ul)) 84 | #define uldq(a) (((const struct unaligned_long *) (a))->l) 85 | 86 | #if GNUC_PREREQ(3,3) 87 | #define prefetch(p) __builtin_prefetch((p), 0, 1) 88 | #define prefetch_en(p) __builtin_prefetch((p), 0, 0) 89 | #define prefetch_m(p) __builtin_prefetch((p), 1, 1) 90 | #define prefetch_men(p) __builtin_prefetch((p), 1, 0) 91 | #define cmpbge __builtin_alpha_cmpbge 92 | /* Avoid warnings. */ 93 | #define extql(a, b) __builtin_alpha_extql(a, (uint64_t) (b)) 94 | #define extwl(a, b) __builtin_alpha_extwl(a, (uint64_t) (b)) 95 | #define extqh(a, b) __builtin_alpha_extqh(a, (uint64_t) (b)) 96 | #define zap __builtin_alpha_zap 97 | #define zapnot __builtin_alpha_zapnot 98 | #define amask __builtin_alpha_amask 99 | #define implver __builtin_alpha_implver 100 | #define rpcc __builtin_alpha_rpcc 101 | #else 102 | #define prefetch(p) asm volatile("ldl $31,%0" : : "m"(*(const char *) (p)) : "memory") 103 | #define prefetch_en(p) asm volatile("ldq $31,%0" : : "m"(*(const char *) (p)) : "memory") 104 | #define prefetch_m(p) asm volatile("lds $f31,%0" : : "m"(*(const char *) (p)) : "memory") 105 | #define prefetch_men(p) asm volatile("ldt $f31,%0" : : "m"(*(const char *) (p)) : "memory") 106 | #define cmpbge(a, b) ({ uint64_t __r; asm ("cmpbge %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 107 | #define extql(a, b) ({ uint64_t __r; asm ("extql %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 108 | #define extwl(a, b) ({ uint64_t __r; asm ("extwl %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 109 | #define extqh(a, b) ({ uint64_t __r; asm ("extqh %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 110 | #define zap(a, b) ({ uint64_t __r; asm ("zap %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 111 | #define zapnot(a, b) ({ uint64_t __r; asm ("zapnot %r1,%2,%0" : "=r" (__r) : "rJ" (a), "rI" (b)); __r; }) 112 | #define amask(a) ({ uint64_t __r; asm ("amask %1,%0" : "=r" (__r) : "rI" (a)); __r; }) 113 | #define implver() ({ uint64_t __r; asm ("implver %0" : "=r" (__r)); __r; }) 114 | #define rpcc() ({ uint64_t __r; asm volatile ("rpcc %0" : "=r" (__r)); __r; }) 115 | #endif 116 | #define wh64(p) asm volatile("wh64 (%0)" : : "r"(p) : "memory") 117 | 118 | #if GNUC_PREREQ(3,3) && defined(__alpha_max__) 119 | #define minub8 __builtin_alpha_minub8 120 | #define minsb8 __builtin_alpha_minsb8 121 | #define minuw4 __builtin_alpha_minuw4 122 | #define minsw4 __builtin_alpha_minsw4 123 | #define maxub8 __builtin_alpha_maxub8 124 | #define maxsb8 __builtin_alpha_maxsb8 125 | #define maxuw4 __builtin_alpha_maxuw4 126 | #define maxsw4 __builtin_alpha_maxsw4 127 | #define perr __builtin_alpha_perr 128 | #define pklb __builtin_alpha_pklb 129 | #define pkwb __builtin_alpha_pkwb 130 | #define unpkbl __builtin_alpha_unpkbl 131 | #define unpkbw __builtin_alpha_unpkbw 132 | #else 133 | #define minub8(a, b) ({ uint64_t __r; asm (".arch ev6; minub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 134 | #define minsb8(a, b) ({ uint64_t __r; asm (".arch ev6; minsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 135 | #define minuw4(a, b) ({ uint64_t __r; asm (".arch ev6; minuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 136 | #define minsw4(a, b) ({ uint64_t __r; asm (".arch ev6; minsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 137 | #define maxub8(a, b) ({ uint64_t __r; asm (".arch ev6; maxub8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 138 | #define maxsb8(a, b) ({ uint64_t __r; asm (".arch ev6; maxsb8 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 139 | #define maxuw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxuw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 140 | #define maxsw4(a, b) ({ uint64_t __r; asm (".arch ev6; maxsw4 %r1,%2,%0" : "=r" (__r) : "%rJ" (a), "rI" (b)); __r; }) 141 | #define perr(a, b) ({ uint64_t __r; asm (".arch ev6; perr %r1,%r2,%0" : "=r" (__r) : "%rJ" (a), "rJ" (b)); __r; }) 142 | #define pklb(a) ({ uint64_t __r; asm (".arch ev6; pklb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; }) 143 | #define pkwb(a) ({ uint64_t __r; asm (".arch ev6; pkwb %r1,%0" : "=r" (__r) : "rJ" (a)); __r; }) 144 | #define unpkbl(a) ({ uint64_t __r; asm (".arch ev6; unpkbl %r1,%0" : "=r" (__r) : "rJ" (a)); __r; }) 145 | #define unpkbw(a) ({ uint64_t __r; asm (".arch ev6; unpkbw %r1,%0" : "=r" (__r) : "rJ" (a)); __r; }) 146 | #endif 147 | 148 | #elif defined(__DECC) /* Digital/Compaq/hp "ccc" compiler */ 149 | 150 | #include 151 | #define ldq_u(a) asm ("ldq_u %v0,0(%a0)", a) 152 | #define uldq(a) (*(const __unaligned uint64_t *) (a)) 153 | #define cmpbge(a, b) asm ("cmpbge %a0,%a1,%v0", a, b) 154 | #define extql(a, b) asm ("extql %a0,%a1,%v0", a, b) 155 | #define extwl(a, b) asm ("extwl %a0,%a1,%v0", a, b) 156 | #define extqh(a, b) asm ("extqh %a0,%a1,%v0", a, b) 157 | #define zap(a, b) asm ("zap %a0,%a1,%v0", a, b) 158 | #define zapnot(a, b) asm ("zapnot %a0,%a1,%v0", a, b) 159 | #define amask(a) asm ("amask %a0,%v0", a) 160 | #define implver() asm ("implver %v0") 161 | #define rpcc() asm ("rpcc %v0") 162 | #define minub8(a, b) asm ("minub8 %a0,%a1,%v0", a, b) 163 | #define minsb8(a, b) asm ("minsb8 %a0,%a1,%v0", a, b) 164 | #define minuw4(a, b) asm ("minuw4 %a0,%a1,%v0", a, b) 165 | #define minsw4(a, b) asm ("minsw4 %a0,%a1,%v0", a, b) 166 | #define maxub8(a, b) asm ("maxub8 %a0,%a1,%v0", a, b) 167 | #define maxsb8(a, b) asm ("maxsb8 %a0,%a1,%v0", a, b) 168 | #define maxuw4(a, b) asm ("maxuw4 %a0,%a1,%v0", a, b) 169 | #define maxsw4(a, b) asm ("maxsw4 %a0,%a1,%v0", a, b) 170 | #define perr(a, b) asm ("perr %a0,%a1,%v0", a, b) 171 | #define pklb(a) asm ("pklb %a0,%v0", a) 172 | #define pkwb(a) asm ("pkwb %a0,%v0", a) 173 | #define unpkbl(a) asm ("unpkbl %a0,%v0", a) 174 | #define unpkbw(a) asm ("unpkbw %a0,%v0", a) 175 | #define wh64(a) asm ("wh64 %a0", a) 176 | 177 | #else 178 | #error "Unknown compiler!" 179 | #endif 180 | 181 | #endif /* LIBMPEG2_ALPHA_ASM_H */ 182 | -------------------------------------------------------------------------------- /include/attributes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * attributes.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_ATTRIBUTES_H 25 | #define LIBMPEG2_ATTRIBUTES_H 26 | 27 | /* use gcc attribs to align critical data structures */ 28 | #ifdef ATTRIBUTE_ALIGNED_MAX 29 | #define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) 30 | #else 31 | #define ATTR_ALIGN(align) 32 | #endif 33 | 34 | #ifdef HAVE_BUILTIN_EXPECT 35 | #define likely(x) __builtin_expect ((x) != 0, 1) 36 | #define unlikely(x) __builtin_expect ((x) != 0, 0) 37 | #else 38 | #define likely(x) (x) 39 | #define unlikely(x) (x) 40 | #endif 41 | 42 | #endif /* LIBMPEG2_ATTRIBUTES_H */ 43 | -------------------------------------------------------------------------------- /include/config.h.in: -------------------------------------------------------------------------------- 1 | /* include/config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* autodetect accelerations */ 4 | #undef ACCEL_DETECT 5 | 6 | /* alpha architecture */ 7 | #undef ARCH_ALPHA 8 | 9 | /* ARM architecture */ 10 | #undef ARCH_ARM 11 | 12 | /* ppc architecture */ 13 | #undef ARCH_PPC 14 | 15 | /* sparc architecture */ 16 | #undef ARCH_SPARC 17 | 18 | /* x86 architecture */ 19 | #undef ARCH_X86 20 | 21 | /* maximum supported data alignment */ 22 | #undef ATTRIBUTE_ALIGNED_MAX 23 | 24 | /* debug mode configuration */ 25 | #undef DEBUG 26 | 27 | /* Define to 1 if you have the header. */ 28 | #undef HAVE_ALTIVEC_H 29 | 30 | /* Define if you have the `__builtin_expect' function. */ 31 | #undef HAVE_BUILTIN_EXPECT 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_DLFCN_H 35 | 36 | /* Define to 1 if you have the `ftime' function. */ 37 | #undef HAVE_FTIME 38 | 39 | /* Define to 1 if you have the `gettimeofday' function. */ 40 | #undef HAVE_GETTIMEOFDAY 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_INTTYPES_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_IO_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_MEMORY_H 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_STDINT_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_STDLIB_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_STRINGS_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_STRING_H 62 | 63 | /* Define to 1 if the system has the type `struct timeval'. */ 64 | #undef HAVE_STRUCT_TIMEVAL 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #undef HAVE_SYS_STAT_H 68 | 69 | /* Define to 1 if you have the header file. */ 70 | #undef HAVE_SYS_TIMEB_H 71 | 72 | /* Define to 1 if you have the header file. */ 73 | #undef HAVE_SYS_TIME_H 74 | 75 | /* Define to 1 if you have the header file. */ 76 | #undef HAVE_SYS_TYPES_H 77 | 78 | /* Define to 1 if you have the header file. */ 79 | #undef HAVE_TIME_H 80 | 81 | /* Define to 1 if you have the header file. */ 82 | #undef HAVE_UNISTD_H 83 | 84 | /* libvo DirectX support */ 85 | #undef LIBVO_DX 86 | 87 | /* libvo SDL support */ 88 | #undef LIBVO_SDL 89 | 90 | /* libvo X11 support */ 91 | #undef LIBVO_X11 92 | 93 | /* libvo Xv support */ 94 | #undef LIBVO_XV 95 | 96 | /* mpeg2dec profiling */ 97 | #undef MPEG2DEC_GPROF 98 | 99 | /* Name of package */ 100 | #undef PACKAGE 101 | 102 | /* Define to the address where bug reports for this package should be sent. */ 103 | #undef PACKAGE_BUGREPORT 104 | 105 | /* Define to the full name of this package. */ 106 | #undef PACKAGE_NAME 107 | 108 | /* Define to the full name and version of this package. */ 109 | #undef PACKAGE_STRING 110 | 111 | /* Define to the one symbol short name of this package. */ 112 | #undef PACKAGE_TARNAME 113 | 114 | /* Define to the version of this package. */ 115 | #undef PACKAGE_VERSION 116 | 117 | /* Define as the return type of signal handlers (`int' or `void'). */ 118 | #undef RETSIGTYPE 119 | 120 | /* The size of `char', as computed by sizeof. */ 121 | #undef SIZEOF_CHAR 122 | 123 | /* The size of `int', as computed by sizeof. */ 124 | #undef SIZEOF_INT 125 | 126 | /* The size of `long', as computed by sizeof. */ 127 | #undef SIZEOF_LONG 128 | 129 | /* The size of `short', as computed by sizeof. */ 130 | #undef SIZEOF_SHORT 131 | 132 | /* The size of `void*', as computed by sizeof. */ 133 | #undef SIZEOF_VOIDP 134 | 135 | /* Define to 1 if you have the ANSI C header files. */ 136 | #undef STDC_HEADERS 137 | 138 | /* Define to 1 if you can safely include both and . */ 139 | #undef TIME_WITH_SYS_TIME 140 | 141 | /* Version number of package */ 142 | #undef VERSION 143 | 144 | /* Define to 1 if your processor stores words with the most significant byte 145 | first (like Motorola and SPARC, unlike Intel and VAX). */ 146 | #undef WORDS_BIGENDIAN 147 | 148 | /* Define to 1 if the X Window System is missing or not being used. */ 149 | #undef X_DISPLAY_MISSING 150 | 151 | /* Number of bits in a file offset, on hosts where this is settable. */ 152 | #undef _FILE_OFFSET_BITS 153 | 154 | /* Define for large files, on AIX-style hosts. */ 155 | #undef _LARGE_FILES 156 | 157 | /* Define to empty if `const' does not conform to ANSI C. */ 158 | #undef const 159 | 160 | /* Define to `__inline__' or `__inline' if that's what the C compiler 161 | calls it, or to nothing if 'inline' is not supported under any name. */ 162 | #ifndef __cplusplus 163 | #undef inline 164 | #endif 165 | 166 | /* Define as `__restrict' if that's what the C compiler calls it, or to 167 | nothing if it is not supported. */ 168 | #undef restrict 169 | 170 | /* Define to `unsigned int' if does not define. */ 171 | #undef size_t 172 | 173 | /* Define to empty if the keyword `volatile' does not work. Warning: valid 174 | code using `volatile' can become incorrect without. Disable with care. */ 175 | #undef volatile 176 | -------------------------------------------------------------------------------- /include/mpeg2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mpeg2.h 3 | * Copyright (C) 2000-2004 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_MPEG2_H 25 | #define LIBMPEG2_MPEG2_H 26 | 27 | #define MPEG2_VERSION(a,b,c) (((a)<<16)|((b)<<8)|(c)) 28 | #define MPEG2_RELEASE MPEG2_VERSION (0, 5, 1) /* 0.5.1 */ 29 | 30 | #define SEQ_FLAG_MPEG2 1 31 | #define SEQ_FLAG_CONSTRAINED_PARAMETERS 2 32 | #define SEQ_FLAG_PROGRESSIVE_SEQUENCE 4 33 | #define SEQ_FLAG_LOW_DELAY 8 34 | #define SEQ_FLAG_COLOUR_DESCRIPTION 16 35 | 36 | #define SEQ_MASK_VIDEO_FORMAT 0xe0 37 | #define SEQ_VIDEO_FORMAT_COMPONENT 0 38 | #define SEQ_VIDEO_FORMAT_PAL 0x20 39 | #define SEQ_VIDEO_FORMAT_NTSC 0x40 40 | #define SEQ_VIDEO_FORMAT_SECAM 0x60 41 | #define SEQ_VIDEO_FORMAT_MAC 0x80 42 | #define SEQ_VIDEO_FORMAT_UNSPECIFIED 0xa0 43 | 44 | typedef struct mpeg2_sequence_s { 45 | unsigned int width, height; 46 | unsigned int chroma_width, chroma_height; 47 | unsigned int byte_rate; 48 | unsigned int vbv_buffer_size; 49 | uint32_t flags; 50 | 51 | unsigned int picture_width, picture_height; 52 | unsigned int display_width, display_height; 53 | unsigned int pixel_width, pixel_height; 54 | unsigned int frame_period; 55 | 56 | uint8_t profile_level_id; 57 | uint8_t colour_primaries; 58 | uint8_t transfer_characteristics; 59 | uint8_t matrix_coefficients; 60 | } mpeg2_sequence_t; 61 | 62 | #define GOP_FLAG_DROP_FRAME 1 63 | #define GOP_FLAG_BROKEN_LINK 2 64 | #define GOP_FLAG_CLOSED_GOP 4 65 | 66 | typedef struct mpeg2_gop_s { 67 | uint8_t hours; 68 | uint8_t minutes; 69 | uint8_t seconds; 70 | uint8_t pictures; 71 | uint32_t flags; 72 | } mpeg2_gop_t; 73 | 74 | #define PIC_MASK_CODING_TYPE 7 75 | #define PIC_FLAG_CODING_TYPE_I 1 76 | #define PIC_FLAG_CODING_TYPE_P 2 77 | #define PIC_FLAG_CODING_TYPE_B 3 78 | #define PIC_FLAG_CODING_TYPE_D 4 79 | 80 | #define PIC_FLAG_TOP_FIELD_FIRST 8 81 | #define PIC_FLAG_PROGRESSIVE_FRAME 16 82 | #define PIC_FLAG_COMPOSITE_DISPLAY 32 83 | #define PIC_FLAG_SKIP 64 84 | #define PIC_FLAG_TAGS 128 85 | #define PIC_FLAG_REPEAT_FIRST_FIELD 256 86 | #define PIC_MASK_COMPOSITE_DISPLAY 0xfffff000 87 | 88 | typedef struct mpeg2_picture_s { 89 | unsigned int temporal_reference; 90 | unsigned int nb_fields; 91 | uint32_t tag, tag2; 92 | uint32_t flags; 93 | struct { 94 | int x, y; 95 | } display_offset[3]; 96 | } mpeg2_picture_t; 97 | 98 | typedef struct mpeg2_fbuf_s { 99 | uint8_t * buf[3]; 100 | void * id; 101 | } mpeg2_fbuf_t; 102 | 103 | typedef struct mpeg2_info_s { 104 | const mpeg2_sequence_t * sequence; 105 | const mpeg2_gop_t * gop; 106 | const mpeg2_picture_t * current_picture; 107 | const mpeg2_picture_t * current_picture_2nd; 108 | const mpeg2_fbuf_t * current_fbuf; 109 | const mpeg2_picture_t * display_picture; 110 | const mpeg2_picture_t * display_picture_2nd; 111 | const mpeg2_fbuf_t * display_fbuf; 112 | const mpeg2_fbuf_t * discard_fbuf; 113 | const uint8_t * user_data; 114 | unsigned int user_data_len; 115 | } mpeg2_info_t; 116 | 117 | typedef struct mpeg2dec_s mpeg2dec_t; 118 | typedef struct mpeg2_decoder_s mpeg2_decoder_t; 119 | 120 | typedef enum { 121 | STATE_BUFFER = 0, 122 | STATE_SEQUENCE = 1, 123 | STATE_SEQUENCE_REPEATED = 2, 124 | STATE_GOP = 3, 125 | STATE_PICTURE = 4, 126 | STATE_SLICE_1ST = 5, 127 | STATE_PICTURE_2ND = 6, 128 | STATE_SLICE = 7, 129 | STATE_END = 8, 130 | STATE_INVALID = 9, 131 | STATE_INVALID_END = 10, 132 | STATE_SEQUENCE_MODIFIED = 11 133 | } mpeg2_state_t; 134 | 135 | typedef struct mpeg2_convert_init_s { 136 | unsigned int id_size; 137 | unsigned int buf_size[3]; 138 | void (* start) (void * id, const mpeg2_fbuf_t * fbuf, 139 | const mpeg2_picture_t * picture, const mpeg2_gop_t * gop); 140 | void (* copy) (void * id, uint8_t * const * src, unsigned int v_offset); 141 | } mpeg2_convert_init_t; 142 | typedef enum { 143 | MPEG2_CONVERT_SET = 0, 144 | MPEG2_CONVERT_STRIDE = 1, 145 | MPEG2_CONVERT_START = 2 146 | } mpeg2_convert_stage_t; 147 | typedef int mpeg2_convert_t (int stage, void * id, 148 | const mpeg2_sequence_t * sequence, int stride, 149 | uint32_t accel, void * arg, 150 | mpeg2_convert_init_t * result); 151 | int mpeg2_convert (mpeg2dec_t * mpeg2dec, mpeg2_convert_t convert, void * arg); 152 | int mpeg2_stride (mpeg2dec_t * mpeg2dec, int stride); 153 | void mpeg2_set_buf (mpeg2dec_t * mpeg2dec, uint8_t * buf[3], void * id); 154 | void mpeg2_custom_fbuf (mpeg2dec_t * mpeg2dec, int custom_fbuf); 155 | 156 | #define MPEG2_ACCEL_X86_MMX 1 157 | #define MPEG2_ACCEL_X86_3DNOW 2 158 | #define MPEG2_ACCEL_X86_MMXEXT 4 159 | #define MPEG2_ACCEL_X86_SSE2 8 160 | #define MPEG2_ACCEL_X86_SSE3 16 161 | #define MPEG2_ACCEL_PPC_ALTIVEC 1 162 | #define MPEG2_ACCEL_ALPHA 1 163 | #define MPEG2_ACCEL_ALPHA_MVI 2 164 | #define MPEG2_ACCEL_SPARC_VIS 1 165 | #define MPEG2_ACCEL_SPARC_VIS2 2 166 | #define MPEG2_ACCEL_ARM 1 167 | #define MPEG2_ACCEL_DETECT 0x80000000 168 | 169 | uint32_t mpeg2_accel (uint32_t accel); 170 | mpeg2dec_t * mpeg2_init (void); 171 | const mpeg2_info_t * mpeg2_info (mpeg2dec_t * mpeg2dec); 172 | void mpeg2_close (mpeg2dec_t * mpeg2dec); 173 | 174 | void mpeg2_buffer (mpeg2dec_t * mpeg2dec, uint8_t * start, uint8_t * end); 175 | int mpeg2_getpos (mpeg2dec_t * mpeg2dec); 176 | mpeg2_state_t mpeg2_parse (mpeg2dec_t * mpeg2dec); 177 | 178 | void mpeg2_reset (mpeg2dec_t * mpeg2dec, int full_reset); 179 | void mpeg2_skip (mpeg2dec_t * mpeg2dec, int skip); 180 | void mpeg2_slice_region (mpeg2dec_t * mpeg2dec, int start, int end); 181 | 182 | void mpeg2_tag_picture (mpeg2dec_t * mpeg2dec, uint32_t tag, uint32_t tag2); 183 | 184 | void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3], 185 | uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3]); 186 | void mpeg2_slice (mpeg2_decoder_t * decoder, int code, const uint8_t * buffer); 187 | int mpeg2_guess_aspect (const mpeg2_sequence_t * sequence, 188 | unsigned int * pixel_width, 189 | unsigned int * pixel_height); 190 | 191 | typedef enum { 192 | MPEG2_ALLOC_MPEG2DEC = 0, 193 | MPEG2_ALLOC_CHUNK = 1, 194 | MPEG2_ALLOC_YUV = 2, 195 | MPEG2_ALLOC_CONVERT_ID = 3, 196 | MPEG2_ALLOC_CONVERTED = 4 197 | } mpeg2_alloc_t; 198 | 199 | void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason); 200 | void mpeg2_free (void * buf); 201 | void mpeg2_malloc_hooks (void * malloc (unsigned, mpeg2_alloc_t), 202 | int free (void *)); 203 | 204 | #endif /* LIBMPEG2_MPEG2_H */ 205 | -------------------------------------------------------------------------------- /include/mpeg2convert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * mpeg2convert.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_MPEG2CONVERT_H 25 | #define LIBMPEG2_MPEG2CONVERT_H 26 | 27 | mpeg2_convert_t mpeg2convert_rgb32; 28 | mpeg2_convert_t mpeg2convert_rgb24; 29 | mpeg2_convert_t mpeg2convert_rgb16; 30 | mpeg2_convert_t mpeg2convert_rgb15; 31 | mpeg2_convert_t mpeg2convert_rgb8; 32 | mpeg2_convert_t mpeg2convert_bgr32; 33 | mpeg2_convert_t mpeg2convert_bgr24; 34 | mpeg2_convert_t mpeg2convert_bgr16; 35 | mpeg2_convert_t mpeg2convert_bgr15; 36 | mpeg2_convert_t mpeg2convert_bgr8; 37 | 38 | typedef enum { 39 | MPEG2CONVERT_RGB = 0, 40 | MPEG2CONVERT_BGR = 1 41 | } mpeg2convert_rgb_order_t; 42 | 43 | mpeg2_convert_t * mpeg2convert_rgb (mpeg2convert_rgb_order_t order, 44 | unsigned int bpp); 45 | 46 | mpeg2_convert_t mpeg2convert_uyvy; 47 | 48 | #endif /* LIBMPEG2_MPEG2CONVERT_H */ 49 | -------------------------------------------------------------------------------- /include/tendra.h: -------------------------------------------------------------------------------- 1 | /* 2 | * tendra.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_TENDRA_H 25 | #define LIBMPEG2_TENDRA_H 26 | 27 | #pragma TenDRA begin 28 | #pragma TenDRA longlong type warning 29 | 30 | #ifdef TenDRA_check 31 | 32 | #pragma TenDRA conversion analysis (pointer-int explicit) off 33 | #pragma TenDRA implicit function declaration off 34 | 35 | /* avoid the "No declarations in translation unit" problem */ 36 | int TenDRA; 37 | 38 | #endif /* TenDRA_check */ 39 | 40 | #endif /* LIBMPEG2_TENDRA_H */ 41 | -------------------------------------------------------------------------------- /include/video_out.h: -------------------------------------------------------------------------------- 1 | /* 2 | * video_out.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_VIDEO_OUT_H 25 | #define LIBMPEG2_VIDEO_OUT_H 26 | 27 | struct mpeg2_sequence_s; 28 | struct mpeg2_convert_init_s; 29 | typedef struct { 30 | int (* convert) (int stage, void * id, 31 | const struct mpeg2_sequence_s * sequence, 32 | int stride, uint32_t accel, void * arg, 33 | struct mpeg2_convert_init_s * result); 34 | } vo_setup_result_t; 35 | 36 | typedef struct vo_instance_s vo_instance_t; 37 | struct vo_instance_s { 38 | int (* setup) (vo_instance_t * instance, unsigned int width, 39 | unsigned int height, unsigned int chroma_width, 40 | unsigned int chroma_height, vo_setup_result_t * result); 41 | void (* setup_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id); 42 | void (* set_fbuf) (vo_instance_t * instance, uint8_t ** buf, void ** id); 43 | void (* start_fbuf) (vo_instance_t * instance, 44 | uint8_t * const * buf, void * id); 45 | void (* draw) (vo_instance_t * instance, uint8_t * const * buf, void * id); 46 | void (* discard) (vo_instance_t * instance, 47 | uint8_t * const * buf, void * id); 48 | void (* close) (vo_instance_t * instance); 49 | }; 50 | 51 | typedef vo_instance_t * vo_open_t (void); 52 | 53 | typedef struct { 54 | const char * name; 55 | vo_open_t * open; 56 | } vo_driver_t; 57 | 58 | void vo_accel (uint32_t accel); 59 | 60 | /* return NULL terminated array of all drivers */ 61 | vo_driver_t const * vo_drivers (void); 62 | 63 | #endif /* LIBMPEG2_VIDEO_OUT_H */ 64 | -------------------------------------------------------------------------------- /libmpeg2/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = convert 2 | 3 | AM_CFLAGS = $(OPT_CFLAGS) $(LIBMPEG2_CFLAGS) 4 | 5 | lib_LTLIBRARIES = libmpeg2.la 6 | libmpeg2_la_SOURCES = alloc.c header.c decode.c slice.c motion_comp.c idct.c 7 | libmpeg2_la_LIBADD = libmpeg2arch.la 8 | libmpeg2_la_LDFLAGS = -no-undefined -version-info 1:0:1 9 | 10 | noinst_LTLIBRARIES = libmpeg2arch.la 11 | libmpeg2arch_la_SOURCES = motion_comp_mmx.c idct_mmx.c \ 12 | motion_comp_altivec.c idct_altivec.c \ 13 | motion_comp_alpha.c idct_alpha.c \ 14 | motion_comp_vis.c motion_comp_arm.c \ 15 | cpu_accel.c cpu_state.c 16 | if ARCH_ARM 17 | libmpeg2arch_la_SOURCES += motion_comp_arm_s.S 18 | endif 19 | libmpeg2arch_la_CFLAGS = $(OPT_CFLAGS) $(ARCH_OPT_CFLAGS) $(LIBMPEG2_CFLAGS) 20 | 21 | pkgconfigdir = $(libdir)/pkgconfig 22 | pkgconfig_DATA = libmpeg2.pc 23 | 24 | EXTRA_DIST = vlc.h mpeg2_internal.h 25 | -------------------------------------------------------------------------------- /libmpeg2/alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * alloc.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | #include "mpeg2.h" 28 | 29 | static void * (* malloc_hook) (unsigned size, mpeg2_alloc_t reason) = NULL; 30 | static int (* free_hook) (void * buf) = NULL; 31 | 32 | void * mpeg2_malloc (unsigned size, mpeg2_alloc_t reason) 33 | { 34 | char * buf; 35 | 36 | if (malloc_hook) { 37 | buf = (char *) malloc_hook (size, reason); 38 | if (buf) 39 | return buf; 40 | } 41 | 42 | if (size) { 43 | buf = (char *) malloc (size + 63 + sizeof (void **)); 44 | if (buf) { 45 | char * align_buf; 46 | 47 | align_buf = buf + 63 + sizeof (void **); 48 | align_buf -= (long)align_buf & 63; 49 | *(((void **)align_buf) - 1) = buf; 50 | return align_buf; 51 | } 52 | } 53 | return NULL; 54 | } 55 | 56 | void mpeg2_free (void * buf) 57 | { 58 | if (free_hook && free_hook (buf)) 59 | return; 60 | 61 | if (buf) 62 | free (*(((void **)buf) - 1)); 63 | } 64 | 65 | void mpeg2_malloc_hooks (void * alloc_func (unsigned, mpeg2_alloc_t), 66 | int free_func (void *)) 67 | { 68 | malloc_hook = alloc_func; 69 | free_hook = free_func; 70 | } 71 | -------------------------------------------------------------------------------- /libmpeg2/convert/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = $(OPT_CFLAGS) $(LIBMPEG2_CFLAGS) 2 | 3 | lib_LTLIBRARIES = libmpeg2convert.la 4 | libmpeg2convert_la_SOURCES = rgb.c uyvy.c 5 | libmpeg2convert_la_LIBADD = libmpeg2convertarch.la 6 | libmpeg2convert_la_LDFLAGS = -no-undefined 7 | 8 | noinst_LTLIBRARIES = libmpeg2convertarch.la 9 | libmpeg2convertarch_la_SOURCES = rgb_mmx.c rgb_vis.c 10 | libmpeg2convertarch_la_CFLAGS = $(OPT_CFLAGS) $(ARCH_OPT_CFLAGS) $(LIBMPEG2_CFLAGS) 11 | 12 | pkgconfigdir = $(libdir)/pkgconfig 13 | pkgconfig_DATA = libmpeg2convert.pc 14 | 15 | EXTRA_DIST = convert_internal.h 16 | -------------------------------------------------------------------------------- /libmpeg2/convert/convert_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * convert_internal.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | typedef struct { 25 | uint8_t * rgb_ptr; 26 | int width; 27 | int field; 28 | int y_stride, rgb_stride, y_increm, uv_increm, rgb_increm, rgb_slice; 29 | int chroma420, convert420; 30 | int dither_offset, dither_stride; 31 | int y_stride_frame, uv_stride_frame, rgb_stride_frame, rgb_stride_min; 32 | } convert_rgb_t; 33 | 34 | typedef void mpeg2convert_copy_t (void * id, uint8_t * const * src, 35 | unsigned int v_offset); 36 | 37 | mpeg2convert_copy_t * mpeg2convert_rgb_mmxext (int bpp, int mode, 38 | const mpeg2_sequence_t * seq); 39 | mpeg2convert_copy_t * mpeg2convert_rgb_mmx (int bpp, int mode, 40 | const mpeg2_sequence_t * seq); 41 | mpeg2convert_copy_t * mpeg2convert_rgb_vis (int bpp, int mode, 42 | const mpeg2_sequence_t * seq); 43 | -------------------------------------------------------------------------------- /libmpeg2/convert/libmpeg2convert.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libmpeg2convert 7 | Description: Image conversion library helper for libmpeg2 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lmpeg2convert 10 | Cflags: -I${includedir}/mpeg2dec 11 | -------------------------------------------------------------------------------- /libmpeg2/convert/uyvy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uyvy.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 2003 Regis Duchesne 5 | * Copyright (C) 1999-2000 Aaron Holtzman 6 | * 7 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 8 | * See http://libmpeg2.sourceforge.net/ for updates. 9 | * 10 | * mpeg2dec 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 | * mpeg2dec 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 | */ 24 | 25 | #include "config.h" 26 | 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "mpeg2convert.h" 31 | 32 | typedef struct { 33 | int width; 34 | int stride; 35 | int chroma420; 36 | uint8_t * out; 37 | } convert_uyvy_t; 38 | 39 | static void uyvy_start (void * _id, const mpeg2_fbuf_t * fbuf, 40 | const mpeg2_picture_t * picture, 41 | const mpeg2_gop_t * gop) 42 | { 43 | convert_uyvy_t * instance = (convert_uyvy_t *) _id; 44 | 45 | instance->out = fbuf->buf[0]; 46 | instance->stride = instance->width; 47 | if (picture->nb_fields == 1) { 48 | if (! (picture->flags & PIC_FLAG_TOP_FIELD_FIRST)) 49 | instance->out += 2 * instance->stride; 50 | instance->stride <<= 1; 51 | } 52 | } 53 | 54 | #ifdef WORDS_BIGENDIAN 55 | #define PACK(a,b,c,d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) 56 | #else 57 | #define PACK(a,b,c,d) (((d) << 24) | ((c) << 16) | ((b) << 8) | (a)) 58 | #endif 59 | 60 | static void uyvy_copy (void * const _id, uint8_t * const * src, 61 | const unsigned int v_offset) 62 | { 63 | const convert_uyvy_t * const id = (convert_uyvy_t *) _id; 64 | uint8_t * _dst; 65 | uint8_t * py, * pu, * pv; 66 | int i, j; 67 | 68 | _dst = id->out + 2 * id->stride * v_offset; 69 | py = src[0]; pu = src[1]; pv = src[2]; 70 | 71 | i = 16; 72 | do { 73 | uint32_t * dst = (uint32_t *) _dst; 74 | 75 | j = id->width >> 4; 76 | do { 77 | dst[0] = PACK (pu[0], py[0], pv[0], py[1]); 78 | dst[1] = PACK (pu[1], py[2], pv[1], py[3]); 79 | dst[2] = PACK (pu[2], py[4], pv[2], py[5]); 80 | dst[3] = PACK (pu[3], py[6], pv[3], py[7]); 81 | dst[4] = PACK (pu[4], py[8], pv[4], py[9]); 82 | dst[5] = PACK (pu[5], py[10], pv[5], py[11]); 83 | dst[6] = PACK (pu[6], py[12], pv[6], py[13]); 84 | dst[7] = PACK (pu[7], py[14], pv[7], py[15]); 85 | py += 16; 86 | pu += 8; 87 | pv += 8; 88 | dst += 8; 89 | } while (--j); 90 | py -= id->width; 91 | pu -= id->width >> 1; 92 | pv -= id->width >> 1; 93 | _dst += 2 * id->stride; 94 | py += id->stride; 95 | if (! (--i & id->chroma420)) { 96 | pu += id->stride >> 1; 97 | pv += id->stride >> 1; 98 | } 99 | } while (i); 100 | } 101 | 102 | int mpeg2convert_uyvy (int stage, void * _id, const mpeg2_sequence_t * seq, 103 | int stride, uint32_t accel, void * arg, 104 | mpeg2_convert_init_t * result) 105 | { 106 | convert_uyvy_t * instance = (convert_uyvy_t *) _id; 107 | 108 | if (seq->chroma_width == seq->width) 109 | return 1; 110 | 111 | if (instance) { 112 | instance->width = seq->width; 113 | instance->chroma420 = (seq->chroma_height < seq->height); 114 | result->buf_size[0] = seq->width * seq->height * 2; 115 | result->buf_size[1] = result->buf_size[2] = 0; 116 | result->start = uyvy_start; 117 | result->copy = uyvy_copy; 118 | } else { 119 | result->id_size = sizeof (convert_uyvy_t); 120 | } 121 | 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /libmpeg2/cpu_accel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cpu_accel.c 3 | * Copyright (C) 2000-2004 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | 28 | #include "mpeg2.h" 29 | #include "attributes.h" 30 | #include "mpeg2_internal.h" 31 | 32 | #if defined(ARCH_X86) || defined(ARCH_X86_64) 33 | static inline uint32_t arch_accel (uint32_t accel) 34 | { 35 | if (accel & (MPEG2_ACCEL_X86_3DNOW | MPEG2_ACCEL_X86_MMXEXT)) 36 | accel |= MPEG2_ACCEL_X86_MMX; 37 | 38 | if (accel & (MPEG2_ACCEL_X86_SSE2 | MPEG2_ACCEL_X86_SSE3)) 39 | accel |= MPEG2_ACCEL_X86_MMXEXT; 40 | 41 | if (accel & (MPEG2_ACCEL_X86_SSE3)) 42 | accel |= MPEG2_ACCEL_X86_SSE2; 43 | 44 | #ifdef ACCEL_DETECT 45 | if (accel & MPEG2_ACCEL_DETECT) { 46 | uint32_t eax, ebx, ecx, edx; 47 | int AMD; 48 | 49 | #if defined(__x86_64__) || (!defined(PIC) && !defined(__PIC__)) 50 | #define cpuid(op,eax,ebx,ecx,edx) \ 51 | __asm__ ("cpuid" \ 52 | : "=a" (eax), \ 53 | "=b" (ebx), \ 54 | "=c" (ecx), \ 55 | "=d" (edx) \ 56 | : "a" (op) \ 57 | : "cc") 58 | #else /* PIC version : save ebx (not needed on x86_64) */ 59 | #define cpuid(op,eax,ebx,ecx,edx) \ 60 | __asm__ ("pushl %%ebx\n\t" \ 61 | "cpuid\n\t" \ 62 | "movl %%ebx,%1\n\t" \ 63 | "popl %%ebx" \ 64 | : "=a" (eax), \ 65 | "=r" (ebx), \ 66 | "=c" (ecx), \ 67 | "=d" (edx) \ 68 | : "a" (op) \ 69 | : "cc") 70 | #endif 71 | 72 | #ifndef __x86_64__ /* x86_64 supports the cpuid op */ 73 | __asm__ ("pushf\n\t" 74 | "pushf\n\t" 75 | "pop %0\n\t" 76 | "movl %0,%1\n\t" 77 | "xorl $0x200000,%0\n\t" 78 | "push %0\n\t" 79 | "popf\n\t" 80 | "pushf\n\t" 81 | "pop %0\n\t" 82 | "popf" 83 | : "=r" (eax), 84 | "=r" (ebx) 85 | : 86 | : "cc"); 87 | 88 | if (eax == ebx) /* no cpuid */ 89 | return accel; 90 | #endif 91 | 92 | cpuid (0x00000000, eax, ebx, ecx, edx); 93 | if (!eax) /* vendor string only */ 94 | return accel; 95 | 96 | AMD = (ebx == 0x68747541 && ecx == 0x444d4163 && edx == 0x69746e65); 97 | 98 | cpuid (0x00000001, eax, ebx, ecx, edx); 99 | if (! (edx & 0x00800000)) /* no MMX */ 100 | return accel; 101 | 102 | accel |= MPEG2_ACCEL_X86_MMX; 103 | if (edx & 0x02000000) /* SSE - identical to AMD MMX ext. */ 104 | accel |= MPEG2_ACCEL_X86_MMXEXT; 105 | 106 | if (edx & 0x04000000) /* SSE2 */ 107 | accel |= MPEG2_ACCEL_X86_SSE2; 108 | 109 | if (ecx & 0x00000001) /* SSE3 */ 110 | accel |= MPEG2_ACCEL_X86_SSE3; 111 | 112 | cpuid (0x80000000, eax, ebx, ecx, edx); 113 | if (eax < 0x80000001) /* no extended capabilities */ 114 | return accel; 115 | 116 | cpuid (0x80000001, eax, ebx, ecx, edx); 117 | 118 | if (edx & 0x80000000) 119 | accel |= MPEG2_ACCEL_X86_3DNOW; 120 | 121 | if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */ 122 | accel |= MPEG2_ACCEL_X86_MMXEXT; 123 | } 124 | #endif /* ACCEL_DETECT */ 125 | 126 | return accel; 127 | } 128 | #endif /* ARCH_X86 || ARCH_X86_64 */ 129 | 130 | #if defined(ACCEL_DETECT) && (defined(ARCH_PPC) || defined(ARCH_SPARC)) 131 | #include 132 | #include 133 | 134 | static sigjmp_buf jmpbuf; 135 | static volatile sig_atomic_t canjump = 0; 136 | 137 | static RETSIGTYPE sigill_handler (int sig) 138 | { 139 | if (!canjump) { 140 | signal (sig, SIG_DFL); 141 | raise (sig); 142 | } 143 | 144 | canjump = 0; 145 | siglongjmp (jmpbuf, 1); 146 | } 147 | #endif /* ACCEL_DETECT && (ARCH_PPC || ARCH_SPARC) */ 148 | 149 | #ifdef ARCH_PPC 150 | static uint32_t arch_accel (uint32_t accel) 151 | { 152 | #ifdef ACCEL_DETECT 153 | if ((accel & (MPEG2_ACCEL_PPC_ALTIVEC | MPEG2_ACCEL_DETECT)) == 154 | MPEG2_ACCEL_DETECT) { 155 | static RETSIGTYPE (* oldsig) (int); 156 | 157 | oldsig = signal (SIGILL, sigill_handler); 158 | if (sigsetjmp (jmpbuf, 1)) { 159 | signal (SIGILL, oldsig); 160 | return accel; 161 | } 162 | 163 | canjump = 1; 164 | 165 | #if defined(__APPLE_CC__) /* apple */ 166 | #define VAND(a,b,c) "vand v" #a ",v" #b ",v" #c "\n\t" 167 | #else /* gnu */ 168 | #define VAND(a,b,c) "vand " #a "," #b "," #c "\n\t" 169 | #endif 170 | asm volatile ("mtspr 256, %0\n\t" 171 | VAND (0, 0, 0) 172 | : 173 | : "r" (-1)); 174 | 175 | canjump = 0; 176 | accel |= MPEG2_ACCEL_PPC_ALTIVEC; 177 | 178 | signal (SIGILL, oldsig); 179 | } 180 | #endif /* ACCEL_DETECT */ 181 | 182 | return accel; 183 | } 184 | #endif /* ARCH_PPC */ 185 | 186 | #ifdef ARCH_SPARC 187 | static uint32_t arch_accel (uint32_t accel) 188 | { 189 | if (accel & MPEG2_ACCEL_SPARC_VIS2) 190 | accel |= MPEG2_ACCEL_SPARC_VIS; 191 | 192 | #ifdef ACCEL_DETECT 193 | if ((accel & (MPEG2_ACCEL_SPARC_VIS2 | MPEG2_ACCEL_DETECT)) == 194 | MPEG2_ACCEL_DETECT) { 195 | static RETSIGTYPE (* oldsig) (int); 196 | 197 | oldsig = signal (SIGILL, sigill_handler); 198 | if (sigsetjmp (jmpbuf, 1)) { 199 | signal (SIGILL, oldsig); 200 | return accel; 201 | } 202 | 203 | canjump = 1; 204 | 205 | /* pdist %f0, %f0, %f0 */ 206 | __asm__ __volatile__(".word\t0x81b007c0"); 207 | 208 | canjump = 0; 209 | accel |= MPEG2_ACCEL_SPARC_VIS; 210 | 211 | if (sigsetjmp (jmpbuf, 1)) { 212 | signal (SIGILL, oldsig); 213 | return accel; 214 | } 215 | 216 | canjump = 1; 217 | 218 | /* edge8n %g0, %g0, %g0 */ 219 | __asm__ __volatile__(".word\t0x81b00020"); 220 | 221 | canjump = 0; 222 | accel |= MPEG2_ACCEL_SPARC_VIS2; 223 | 224 | signal (SIGILL, oldsig); 225 | } 226 | #endif /* ACCEL_DETECT */ 227 | 228 | return accel; 229 | } 230 | #endif /* ARCH_SPARC */ 231 | 232 | #ifdef ARCH_ALPHA 233 | static inline uint32_t arch_accel (uint32_t accel) 234 | { 235 | if (accel & MPEG2_ACCEL_ALPHA_MVI) 236 | accel |= MPEG2_ACCEL_ALPHA; 237 | 238 | #ifdef ACCEL_DETECT 239 | if (accel & MPEG2_ACCEL_DETECT) { 240 | uint64_t no_mvi; 241 | 242 | asm volatile ("amask %1, %0" 243 | : "=r" (no_mvi) 244 | : "rI" (256)); /* AMASK_MVI */ 245 | accel |= no_mvi ? MPEG2_ACCEL_ALPHA : (MPEG2_ACCEL_ALPHA | 246 | MPEG2_ACCEL_ALPHA_MVI); 247 | } 248 | #endif /* ACCEL_DETECT */ 249 | 250 | return accel; 251 | } 252 | #endif /* ARCH_ALPHA */ 253 | 254 | uint32_t mpeg2_detect_accel (uint32_t accel) 255 | { 256 | #if defined (ARCH_X86) || defined (ARCH_X86_64) || defined (ARCH_PPC) || defined (ARCH_ALPHA) || defined (ARCH_SPARC) 257 | accel = arch_accel (accel); 258 | #endif 259 | return accel; 260 | } 261 | -------------------------------------------------------------------------------- /libmpeg2/cpu_state.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cpu_state.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "attributes.h" 31 | #include "mpeg2_internal.h" 32 | #if defined(ARCH_X86) || defined(ARCH_X86_64) 33 | #include "mmx.h" 34 | #endif 35 | 36 | void (* mpeg2_cpu_state_save) (cpu_state_t * state) = NULL; 37 | void (* mpeg2_cpu_state_restore) (cpu_state_t * state) = NULL; 38 | 39 | #if defined(ARCH_X86) || defined(ARCH_X86_64) 40 | static void state_restore_mmx (cpu_state_t * state) 41 | { 42 | emms (); 43 | } 44 | #endif 45 | 46 | #ifdef ARCH_PPC 47 | #if defined(__APPLE_CC__) /* apple */ 48 | #define LI(a,b) "li r" #a "," #b "\n\t" 49 | #define STVX0(a,b,c) "stvx v" #a ",0,r" #c "\n\t" 50 | #define STVX(a,b,c) "stvx v" #a ",r" #b ",r" #c "\n\t" 51 | #define LVX0(a,b,c) "lvx v" #a ",0,r" #c "\n\t" 52 | #define LVX(a,b,c) "lvx v" #a ",r" #b ",r" #c "\n\t" 53 | #else /* gnu */ 54 | #define LI(a,b) "li " #a "," #b "\n\t" 55 | #define STVX0(a,b,c) "stvx " #a ",0," #c "\n\t" 56 | #define STVX(a,b,c) "stvx " #a "," #b "," #c "\n\t" 57 | #define LVX0(a,b,c) "lvx " #a ",0," #c "\n\t" 58 | #define LVX(a,b,c) "lvx " #a "," #b "," #c "\n\t" 59 | #endif 60 | 61 | static void state_save_altivec (cpu_state_t * state) 62 | { 63 | asm (LI (9, 16) 64 | STVX0 (20, 0, 3) 65 | LI (11, 32) 66 | STVX (21, 9, 3) 67 | LI (9, 48) 68 | STVX (22, 11, 3) 69 | LI (11, 64) 70 | STVX (23, 9, 3) 71 | LI (9, 80) 72 | STVX (24, 11, 3) 73 | LI (11, 96) 74 | STVX (25, 9, 3) 75 | LI (9, 112) 76 | STVX (26, 11, 3) 77 | LI (11, 128) 78 | STVX (27, 9, 3) 79 | LI (9, 144) 80 | STVX (28, 11, 3) 81 | LI (11, 160) 82 | STVX (29, 9, 3) 83 | LI (9, 176) 84 | STVX (30, 11, 3) 85 | STVX (31, 9, 3)); 86 | } 87 | 88 | static void state_restore_altivec (cpu_state_t * state) 89 | { 90 | asm (LI (9, 16) 91 | LVX0 (20, 0, 3) 92 | LI (11, 32) 93 | LVX (21, 9, 3) 94 | LI (9, 48) 95 | LVX (22, 11, 3) 96 | LI (11, 64) 97 | LVX (23, 9, 3) 98 | LI (9, 80) 99 | LVX (24, 11, 3) 100 | LI (11, 96) 101 | LVX (25, 9, 3) 102 | LI (9, 112) 103 | LVX (26, 11, 3) 104 | LI (11, 128) 105 | LVX (27, 9, 3) 106 | LI (9, 144) 107 | LVX (28, 11, 3) 108 | LI (11, 160) 109 | LVX (29, 9, 3) 110 | LI (9, 176) 111 | LVX (30, 11, 3) 112 | LVX (31, 9, 3)); 113 | } 114 | #endif 115 | 116 | void mpeg2_cpu_state_init (uint32_t accel) 117 | { 118 | #if defined(ARCH_X86) || defined(ARCH_X86_64) 119 | if (accel & MPEG2_ACCEL_X86_MMX) { 120 | mpeg2_cpu_state_restore = state_restore_mmx; 121 | } 122 | #endif 123 | #ifdef ARCH_PPC 124 | if (accel & MPEG2_ACCEL_PPC_ALTIVEC) { 125 | mpeg2_cpu_state_save = state_save_altivec; 126 | mpeg2_cpu_state_restore = state_restore_altivec; 127 | } 128 | #endif 129 | } 130 | -------------------------------------------------------------------------------- /libmpeg2/idct.c: -------------------------------------------------------------------------------- 1 | /* 2 | * idct.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "attributes.h" 31 | #include "mpeg2_internal.h" 32 | 33 | #define W1 2841 /* 2048 * sqrt (2) * cos (1 * pi / 16) */ 34 | #define W2 2676 /* 2048 * sqrt (2) * cos (2 * pi / 16) */ 35 | #define W3 2408 /* 2048 * sqrt (2) * cos (3 * pi / 16) */ 36 | #define W5 1609 /* 2048 * sqrt (2) * cos (5 * pi / 16) */ 37 | #define W6 1108 /* 2048 * sqrt (2) * cos (6 * pi / 16) */ 38 | #define W7 565 /* 2048 * sqrt (2) * cos (7 * pi / 16) */ 39 | 40 | /* idct main entry point */ 41 | void (* mpeg2_idct_copy) (int16_t * block, uint8_t * dest, int stride); 42 | void (* mpeg2_idct_add) (int last, int16_t * block, 43 | uint8_t * dest, int stride); 44 | 45 | /* 46 | * In legal streams, the IDCT output should be between -384 and +384. 47 | * In corrupted streams, it is possible to force the IDCT output to go 48 | * to +-3826 - this is the worst case for a column IDCT where the 49 | * column inputs are 16-bit values. 50 | */ 51 | uint8_t mpeg2_clip[3840 * 2 + 256]; 52 | #define CLIP(i) ((mpeg2_clip + 3840)[i]) 53 | 54 | #if 0 55 | #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ 56 | do { \ 57 | t0 = W0 * d0 + W1 * d1; \ 58 | t1 = W0 * d1 - W1 * d0; \ 59 | } while (0) 60 | #else 61 | #define BUTTERFLY(t0,t1,W0,W1,d0,d1) \ 62 | do { \ 63 | int tmp = W0 * (d0 + d1); \ 64 | t0 = tmp + (W1 - W0) * d1; \ 65 | t1 = tmp - (W1 + W0) * d0; \ 66 | } while (0) 67 | #endif 68 | 69 | static inline void idct_row (int16_t * const block) 70 | { 71 | int d0, d1, d2, d3; 72 | int a0, a1, a2, a3, b0, b1, b2, b3; 73 | int t0, t1, t2, t3; 74 | 75 | /* shortcut */ 76 | if (likely (!(block[1] | ((int32_t *)block)[1] | ((int32_t *)block)[2] | 77 | ((int32_t *)block)[3]))) { 78 | uint32_t tmp = (uint16_t) (block[0] >> 1); 79 | tmp |= tmp << 16; 80 | ((int32_t *)block)[0] = tmp; 81 | ((int32_t *)block)[1] = tmp; 82 | ((int32_t *)block)[2] = tmp; 83 | ((int32_t *)block)[3] = tmp; 84 | return; 85 | } 86 | 87 | d0 = (block[0] << 11) + 2048; 88 | d1 = block[1]; 89 | d2 = block[2] << 11; 90 | d3 = block[3]; 91 | t0 = d0 + d2; 92 | t1 = d0 - d2; 93 | BUTTERFLY (t2, t3, W6, W2, d3, d1); 94 | a0 = t0 + t2; 95 | a1 = t1 + t3; 96 | a2 = t1 - t3; 97 | a3 = t0 - t2; 98 | 99 | d0 = block[4]; 100 | d1 = block[5]; 101 | d2 = block[6]; 102 | d3 = block[7]; 103 | BUTTERFLY (t0, t1, W7, W1, d3, d0); 104 | BUTTERFLY (t2, t3, W3, W5, d1, d2); 105 | b0 = t0 + t2; 106 | b3 = t1 + t3; 107 | t0 -= t2; 108 | t1 -= t3; 109 | b1 = ((t0 + t1) >> 8) * 181; 110 | b2 = ((t0 - t1) >> 8) * 181; 111 | 112 | block[0] = (a0 + b0) >> 12; 113 | block[1] = (a1 + b1) >> 12; 114 | block[2] = (a2 + b2) >> 12; 115 | block[3] = (a3 + b3) >> 12; 116 | block[4] = (a3 - b3) >> 12; 117 | block[5] = (a2 - b2) >> 12; 118 | block[6] = (a1 - b1) >> 12; 119 | block[7] = (a0 - b0) >> 12; 120 | } 121 | 122 | static inline void idct_col (int16_t * const block) 123 | { 124 | int d0, d1, d2, d3; 125 | int a0, a1, a2, a3, b0, b1, b2, b3; 126 | int t0, t1, t2, t3; 127 | 128 | d0 = (block[8*0] << 11) + 65536; 129 | d1 = block[8*1]; 130 | d2 = block[8*2] << 11; 131 | d3 = block[8*3]; 132 | t0 = d0 + d2; 133 | t1 = d0 - d2; 134 | BUTTERFLY (t2, t3, W6, W2, d3, d1); 135 | a0 = t0 + t2; 136 | a1 = t1 + t3; 137 | a2 = t1 - t3; 138 | a3 = t0 - t2; 139 | 140 | d0 = block[8*4]; 141 | d1 = block[8*5]; 142 | d2 = block[8*6]; 143 | d3 = block[8*7]; 144 | BUTTERFLY (t0, t1, W7, W1, d3, d0); 145 | BUTTERFLY (t2, t3, W3, W5, d1, d2); 146 | b0 = t0 + t2; 147 | b3 = t1 + t3; 148 | t0 -= t2; 149 | t1 -= t3; 150 | b1 = ((t0 + t1) >> 8) * 181; 151 | b2 = ((t0 - t1) >> 8) * 181; 152 | 153 | block[8*0] = (a0 + b0) >> 17; 154 | block[8*1] = (a1 + b1) >> 17; 155 | block[8*2] = (a2 + b2) >> 17; 156 | block[8*3] = (a3 + b3) >> 17; 157 | block[8*4] = (a3 - b3) >> 17; 158 | block[8*5] = (a2 - b2) >> 17; 159 | block[8*6] = (a1 - b1) >> 17; 160 | block[8*7] = (a0 - b0) >> 17; 161 | } 162 | 163 | static void mpeg2_idct_copy_c (int16_t * block, uint8_t * dest, 164 | const int stride) 165 | { 166 | int i; 167 | 168 | for (i = 0; i < 8; i++) 169 | idct_row (block + 8 * i); 170 | for (i = 0; i < 8; i++) 171 | idct_col (block + i); 172 | do { 173 | dest[0] = CLIP (block[0]); 174 | dest[1] = CLIP (block[1]); 175 | dest[2] = CLIP (block[2]); 176 | dest[3] = CLIP (block[3]); 177 | dest[4] = CLIP (block[4]); 178 | dest[5] = CLIP (block[5]); 179 | dest[6] = CLIP (block[6]); 180 | dest[7] = CLIP (block[7]); 181 | 182 | ((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0; 183 | ((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0; 184 | 185 | dest += stride; 186 | block += 8; 187 | } while (--i); 188 | } 189 | 190 | static void mpeg2_idct_add_c (const int last, int16_t * block, 191 | uint8_t * dest, const int stride) 192 | { 193 | int i; 194 | 195 | if (last != 129 || (block[0] & (7 << 4)) == (4 << 4)) { 196 | for (i = 0; i < 8; i++) 197 | idct_row (block + 8 * i); 198 | for (i = 0; i < 8; i++) 199 | idct_col (block + i); 200 | do { 201 | dest[0] = CLIP (block[0] + dest[0]); 202 | dest[1] = CLIP (block[1] + dest[1]); 203 | dest[2] = CLIP (block[2] + dest[2]); 204 | dest[3] = CLIP (block[3] + dest[3]); 205 | dest[4] = CLIP (block[4] + dest[4]); 206 | dest[5] = CLIP (block[5] + dest[5]); 207 | dest[6] = CLIP (block[6] + dest[6]); 208 | dest[7] = CLIP (block[7] + dest[7]); 209 | 210 | ((int32_t *)block)[0] = 0; ((int32_t *)block)[1] = 0; 211 | ((int32_t *)block)[2] = 0; ((int32_t *)block)[3] = 0; 212 | 213 | dest += stride; 214 | block += 8; 215 | } while (--i); 216 | } else { 217 | int DC; 218 | 219 | DC = (block[0] + 64) >> 7; 220 | block[0] = block[63] = 0; 221 | i = 8; 222 | do { 223 | dest[0] = CLIP (DC + dest[0]); 224 | dest[1] = CLIP (DC + dest[1]); 225 | dest[2] = CLIP (DC + dest[2]); 226 | dest[3] = CLIP (DC + dest[3]); 227 | dest[4] = CLIP (DC + dest[4]); 228 | dest[5] = CLIP (DC + dest[5]); 229 | dest[6] = CLIP (DC + dest[6]); 230 | dest[7] = CLIP (DC + dest[7]); 231 | dest += stride; 232 | } while (--i); 233 | } 234 | } 235 | 236 | void mpeg2_idct_init (uint32_t accel) 237 | { 238 | #ifdef ARCH_X86 239 | if (accel & MPEG2_ACCEL_X86_SSE2) { 240 | mpeg2_idct_copy = mpeg2_idct_copy_sse2; 241 | mpeg2_idct_add = mpeg2_idct_add_sse2; 242 | mpeg2_idct_mmx_init (); 243 | } else if (accel & MPEG2_ACCEL_X86_MMXEXT) { 244 | mpeg2_idct_copy = mpeg2_idct_copy_mmxext; 245 | mpeg2_idct_add = mpeg2_idct_add_mmxext; 246 | mpeg2_idct_mmx_init (); 247 | } else if (accel & MPEG2_ACCEL_X86_MMX) { 248 | mpeg2_idct_copy = mpeg2_idct_copy_mmx; 249 | mpeg2_idct_add = mpeg2_idct_add_mmx; 250 | mpeg2_idct_mmx_init (); 251 | } else 252 | #endif 253 | #ifdef ARCH_PPC 254 | if (accel & MPEG2_ACCEL_PPC_ALTIVEC) { 255 | mpeg2_idct_copy = mpeg2_idct_copy_altivec; 256 | mpeg2_idct_add = mpeg2_idct_add_altivec; 257 | mpeg2_idct_altivec_init (); 258 | } else 259 | #endif 260 | #ifdef ARCH_ALPHA 261 | if (accel & MPEG2_ACCEL_ALPHA_MVI) { 262 | mpeg2_idct_copy = mpeg2_idct_copy_mvi; 263 | mpeg2_idct_add = mpeg2_idct_add_mvi; 264 | mpeg2_idct_alpha_init (); 265 | } else if (accel & MPEG2_ACCEL_ALPHA) { 266 | int i; 267 | 268 | mpeg2_idct_copy = mpeg2_idct_copy_alpha; 269 | mpeg2_idct_add = mpeg2_idct_add_alpha; 270 | mpeg2_idct_alpha_init (); 271 | for (i = -3840; i < 3840 + 256; i++) 272 | CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); 273 | } else 274 | #endif 275 | { 276 | int i, j; 277 | 278 | mpeg2_idct_copy = mpeg2_idct_copy_c; 279 | mpeg2_idct_add = mpeg2_idct_add_c; 280 | for (i = -3840; i < 3840 + 256; i++) 281 | CLIP(i) = (i < 0) ? 0 : ((i > 255) ? 255 : i); 282 | for (i = 0; i < 64; i++) { 283 | j = mpeg2_scan_norm[i]; 284 | mpeg2_scan_norm[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); 285 | j = mpeg2_scan_alt[i]; 286 | mpeg2_scan_alt[i] = ((j & 0x36) >> 1) | ((j & 0x09) << 2); 287 | } 288 | } 289 | } 290 | -------------------------------------------------------------------------------- /libmpeg2/libmpeg2.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: libmpeg2 7 | Description: MPEG-1 and MPEG-2 stream decoding library 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lmpeg2 10 | Cflags: -I${includedir}/mpeg2dec 11 | -------------------------------------------------------------------------------- /libmpeg2/motion_comp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * motion_comp.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | 28 | #include "mpeg2.h" 29 | #include "attributes.h" 30 | #include "mpeg2_internal.h" 31 | 32 | mpeg2_mc_t mpeg2_mc; 33 | 34 | void mpeg2_mc_init (uint32_t accel) 35 | { 36 | #ifdef ARCH_X86 37 | if (accel & MPEG2_ACCEL_X86_MMXEXT) 38 | mpeg2_mc = mpeg2_mc_mmxext; 39 | else if (accel & MPEG2_ACCEL_X86_3DNOW) 40 | mpeg2_mc = mpeg2_mc_3dnow; 41 | else if (accel & MPEG2_ACCEL_X86_MMX) 42 | mpeg2_mc = mpeg2_mc_mmx; 43 | else 44 | #endif 45 | #ifdef ARCH_PPC 46 | if (accel & MPEG2_ACCEL_PPC_ALTIVEC) 47 | mpeg2_mc = mpeg2_mc_altivec; 48 | else 49 | #endif 50 | #ifdef ARCH_ALPHA 51 | if (accel & MPEG2_ACCEL_ALPHA) 52 | mpeg2_mc = mpeg2_mc_alpha; 53 | else 54 | #endif 55 | #ifdef ARCH_SPARC 56 | if (accel & MPEG2_ACCEL_SPARC_VIS) 57 | mpeg2_mc = mpeg2_mc_vis; 58 | else 59 | #endif 60 | #ifdef ARCH_ARM 61 | if (accel & MPEG2_ACCEL_ARM) { 62 | mpeg2_mc = mpeg2_mc_arm; 63 | } else 64 | #endif 65 | mpeg2_mc = mpeg2_mc_c; 66 | } 67 | 68 | #define avg2(a,b) ((a+b+1)>>1) 69 | #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) 70 | 71 | #define predict_o(i) (ref[i]) 72 | #define predict_x(i) (avg2 (ref[i], ref[i+1])) 73 | #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) 74 | #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ 75 | (ref+stride)[i], (ref+stride)[i+1])) 76 | 77 | #define put(predictor,i) dest[i] = predictor (i) 78 | #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) 79 | 80 | /* mc function template */ 81 | 82 | #define MC_FUNC(op,xy) \ 83 | static void MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ 84 | const int stride, int height) \ 85 | { \ 86 | do { \ 87 | op (predict_##xy, 0); \ 88 | op (predict_##xy, 1); \ 89 | op (predict_##xy, 2); \ 90 | op (predict_##xy, 3); \ 91 | op (predict_##xy, 4); \ 92 | op (predict_##xy, 5); \ 93 | op (predict_##xy, 6); \ 94 | op (predict_##xy, 7); \ 95 | op (predict_##xy, 8); \ 96 | op (predict_##xy, 9); \ 97 | op (predict_##xy, 10); \ 98 | op (predict_##xy, 11); \ 99 | op (predict_##xy, 12); \ 100 | op (predict_##xy, 13); \ 101 | op (predict_##xy, 14); \ 102 | op (predict_##xy, 15); \ 103 | ref += stride; \ 104 | dest += stride; \ 105 | } while (--height); \ 106 | } \ 107 | static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ 108 | const int stride, int height) \ 109 | { \ 110 | do { \ 111 | op (predict_##xy, 0); \ 112 | op (predict_##xy, 1); \ 113 | op (predict_##xy, 2); \ 114 | op (predict_##xy, 3); \ 115 | op (predict_##xy, 4); \ 116 | op (predict_##xy, 5); \ 117 | op (predict_##xy, 6); \ 118 | op (predict_##xy, 7); \ 119 | ref += stride; \ 120 | dest += stride; \ 121 | } while (--height); \ 122 | } 123 | 124 | /* definitions of the actual mc functions */ 125 | 126 | MC_FUNC (put,o) 127 | MC_FUNC (avg,o) 128 | MC_FUNC (put,x) 129 | MC_FUNC (avg,x) 130 | MC_FUNC (put,y) 131 | MC_FUNC (avg,y) 132 | MC_FUNC (put,xy) 133 | MC_FUNC (avg,xy) 134 | 135 | MPEG2_MC_EXTERN (c) 136 | -------------------------------------------------------------------------------- /libmpeg2/motion_comp_alpha.c: -------------------------------------------------------------------------------- 1 | /* 2 | * motion_comp_alpha.c 3 | * Copyright (C) 2002-2003 Falk Hueffner 4 | * 5 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 6 | * See http://libmpeg2.sourceforge.net/ for updates. 7 | * 8 | * mpeg2dec is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * mpeg2dec is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #ifdef ARCH_ALPHA 26 | 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "attributes.h" 31 | #include "mpeg2_internal.h" 32 | #include "alpha_asm.h" 33 | 34 | static inline uint64_t avg2 (uint64_t a, uint64_t b) 35 | { 36 | return (a | b) - (((a ^ b) & BYTE_VEC (0xfe)) >> 1); 37 | } 38 | 39 | // Load two unaligned quadwords from addr. This macro only works if 40 | // addr is actually unaligned. 41 | #define ULOAD16(ret_l,ret_r,addr) \ 42 | do { \ 43 | uint64_t _l = ldq_u (addr + 0); \ 44 | uint64_t _m = ldq_u (addr + 8); \ 45 | uint64_t _r = ldq_u (addr + 16); \ 46 | ret_l = extql (_l, addr) | extqh (_m, addr); \ 47 | ret_r = extql (_m, addr) | extqh (_r, addr); \ 48 | } while (0) 49 | 50 | // Load two aligned quadwords from addr. 51 | #define ALOAD16(ret_l,ret_r,addr) \ 52 | do { \ 53 | ret_l = ldq (addr); \ 54 | ret_r = ldq (addr + 8); \ 55 | } while (0) 56 | 57 | #define OP8(LOAD,LOAD16,STORE) \ 58 | do { \ 59 | STORE (LOAD (pixels), block); \ 60 | pixels += line_size; \ 61 | block += line_size; \ 62 | } while (--h) 63 | 64 | #define OP16(LOAD,LOAD16,STORE) \ 65 | do { \ 66 | uint64_t l, r; \ 67 | LOAD16 (l, r, pixels); \ 68 | STORE (l, block); \ 69 | STORE (r, block + 8); \ 70 | pixels += line_size; \ 71 | block += line_size; \ 72 | } while (--h) 73 | 74 | #define OP8_X2(LOAD,LOAD16,STORE) \ 75 | do { \ 76 | uint64_t p0, p1; \ 77 | \ 78 | p0 = LOAD (pixels); \ 79 | p1 = p0 >> 8 | ((uint64_t) pixels[8] << 56); \ 80 | STORE (avg2 (p0, p1), block); \ 81 | pixels += line_size; \ 82 | block += line_size; \ 83 | } while (--h) 84 | 85 | #define OP16_X2(LOAD,LOAD16,STORE) \ 86 | do { \ 87 | uint64_t p0, p1; \ 88 | \ 89 | LOAD16 (p0, p1, pixels); \ 90 | STORE (avg2(p0, p0 >> 8 | p1 << 56), block); \ 91 | STORE (avg2(p1, p1 >> 8 | (uint64_t) pixels[16] << 56), \ 92 | block + 8); \ 93 | pixels += line_size; \ 94 | block += line_size; \ 95 | } while (--h) 96 | 97 | #define OP8_Y2(LOAD,LOAD16,STORE) \ 98 | do { \ 99 | uint64_t p0, p1; \ 100 | p0 = LOAD (pixels); \ 101 | pixels += line_size; \ 102 | p1 = LOAD (pixels); \ 103 | do { \ 104 | uint64_t av = avg2 (p0, p1); \ 105 | if (--h == 0) line_size = 0; \ 106 | pixels += line_size; \ 107 | p0 = p1; \ 108 | p1 = LOAD (pixels); \ 109 | STORE (av, block); \ 110 | block += line_size; \ 111 | } while (h); \ 112 | } while (0) 113 | 114 | #define OP16_Y2(LOAD,LOAD16,STORE) \ 115 | do { \ 116 | uint64_t p0l, p0r, p1l, p1r; \ 117 | LOAD16 (p0l, p0r, pixels); \ 118 | pixels += line_size; \ 119 | LOAD16 (p1l, p1r, pixels); \ 120 | do { \ 121 | uint64_t avl, avr; \ 122 | if (--h == 0) line_size = 0; \ 123 | avl = avg2 (p0l, p1l); \ 124 | avr = avg2 (p0r, p1r); \ 125 | p0l = p1l; \ 126 | p0r = p1r; \ 127 | pixels += line_size; \ 128 | LOAD16 (p1l, p1r, pixels); \ 129 | STORE (avl, block); \ 130 | STORE (avr, block + 8); \ 131 | block += line_size; \ 132 | } while (h); \ 133 | } while (0) 134 | 135 | #define OP8_XY2(LOAD,LOAD16,STORE) \ 136 | do { \ 137 | uint64_t pl, ph; \ 138 | uint64_t p1 = LOAD (pixels); \ 139 | uint64_t p2 = p1 >> 8 | ((uint64_t) pixels[8] << 56); \ 140 | \ 141 | ph = (((p1 & ~BYTE_VEC (0x03)) >> 2) + \ 142 | ((p2 & ~BYTE_VEC (0x03)) >> 2)); \ 143 | pl = ((p1 & BYTE_VEC (0x03)) + \ 144 | (p2 & BYTE_VEC (0x03))); \ 145 | \ 146 | do { \ 147 | uint64_t npl, nph; \ 148 | \ 149 | pixels += line_size; \ 150 | p1 = LOAD (pixels); \ 151 | p2 = (p1 >> 8) | ((uint64_t) pixels[8] << 56); \ 152 | nph = (((p1 & ~BYTE_VEC (0x03)) >> 2) + \ 153 | ((p2 & ~BYTE_VEC (0x03)) >> 2)); \ 154 | npl = ((p1 & BYTE_VEC (0x03)) + \ 155 | (p2 & BYTE_VEC (0x03))); \ 156 | \ 157 | STORE (ph + nph + \ 158 | (((pl + npl + BYTE_VEC (0x02)) >> 2) & \ 159 | BYTE_VEC (0x03)), block); \ 160 | \ 161 | block += line_size; \ 162 | pl = npl; \ 163 | ph = nph; \ 164 | } while (--h); \ 165 | } while (0) 166 | 167 | #define OP16_XY2(LOAD,LOAD16,STORE) \ 168 | do { \ 169 | uint64_t p0, p1, p2, p3, pl_l, ph_l, pl_r, ph_r; \ 170 | LOAD16 (p0, p2, pixels); \ 171 | p1 = p0 >> 8 | (p2 << 56); \ 172 | p3 = p2 >> 8 | ((uint64_t)pixels[16] << 56); \ 173 | \ 174 | ph_l = (((p0 & ~BYTE_VEC (0x03)) >> 2) + \ 175 | ((p1 & ~BYTE_VEC (0x03)) >> 2)); \ 176 | pl_l = ((p0 & BYTE_VEC (0x03)) + \ 177 | (p1 & BYTE_VEC(0x03))); \ 178 | ph_r = (((p2 & ~BYTE_VEC (0x03)) >> 2) + \ 179 | ((p3 & ~BYTE_VEC (0x03)) >> 2)); \ 180 | pl_r = ((p2 & BYTE_VEC (0x03)) + \ 181 | (p3 & BYTE_VEC (0x03))); \ 182 | \ 183 | do { \ 184 | uint64_t npl_l, nph_l, npl_r, nph_r; \ 185 | \ 186 | pixels += line_size; \ 187 | LOAD16 (p0, p2, pixels); \ 188 | p1 = p0 >> 8 | (p2 << 56); \ 189 | p3 = p2 >> 8 | ((uint64_t)pixels[16] << 56); \ 190 | nph_l = (((p0 & ~BYTE_VEC (0x03)) >> 2) + \ 191 | ((p1 & ~BYTE_VEC (0x03)) >> 2)); \ 192 | npl_l = ((p0 & BYTE_VEC (0x03)) + \ 193 | (p1 & BYTE_VEC (0x03))); \ 194 | nph_r = (((p2 & ~BYTE_VEC (0x03)) >> 2) + \ 195 | ((p3 & ~BYTE_VEC (0x03)) >> 2)); \ 196 | npl_r = ((p2 & BYTE_VEC (0x03)) + \ 197 | (p3 & BYTE_VEC (0x03))); \ 198 | \ 199 | STORE (ph_l + nph_l + \ 200 | (((pl_l + npl_l + BYTE_VEC (0x02)) >> 2) & \ 201 | BYTE_VEC(0x03)), block); \ 202 | STORE (ph_r + nph_r + \ 203 | (((pl_r + npl_r + BYTE_VEC (0x02)) >> 2) & \ 204 | BYTE_VEC(0x03)), block + 8); \ 205 | \ 206 | block += line_size; \ 207 | pl_l = npl_l; \ 208 | ph_l = nph_l; \ 209 | pl_r = npl_r; \ 210 | ph_r = nph_r; \ 211 | } while (--h); \ 212 | } while (0) 213 | 214 | #define MAKE_OP(OPNAME,SIZE,SUFF,OPKIND,STORE) \ 215 | static void MC_ ## OPNAME ## _ ## SUFF ## _ ## SIZE ## _alpha \ 216 | (uint8_t *restrict block, const uint8_t *restrict pixels, \ 217 | int line_size, int h) \ 218 | { \ 219 | if ((uint64_t) pixels & 0x7) { \ 220 | OPKIND (uldq, ULOAD16, STORE); \ 221 | } else { \ 222 | OPKIND (ldq, ALOAD16, STORE); \ 223 | } \ 224 | } 225 | 226 | #define PIXOP(OPNAME,STORE) \ 227 | MAKE_OP (OPNAME, 8, o, OP8, STORE); \ 228 | MAKE_OP (OPNAME, 8, x, OP8_X2, STORE); \ 229 | MAKE_OP (OPNAME, 8, y, OP8_Y2, STORE); \ 230 | MAKE_OP (OPNAME, 8, xy, OP8_XY2, STORE); \ 231 | MAKE_OP (OPNAME, 16, o, OP16, STORE); \ 232 | MAKE_OP (OPNAME, 16, x, OP16_X2, STORE); \ 233 | MAKE_OP (OPNAME, 16, y, OP16_Y2, STORE); \ 234 | MAKE_OP (OPNAME, 16, xy, OP16_XY2, STORE); 235 | 236 | #define STORE(l,b) stq (l, b) 237 | PIXOP (put, STORE); 238 | #undef STORE 239 | #define STORE(l,b) stq (avg2 (l, ldq (b)), b); 240 | PIXOP (avg, STORE); 241 | 242 | mpeg2_mc_t mpeg2_mc_alpha = { 243 | { MC_put_o_16_alpha, MC_put_x_16_alpha, 244 | MC_put_y_16_alpha, MC_put_xy_16_alpha, 245 | MC_put_o_8_alpha, MC_put_x_8_alpha, 246 | MC_put_y_8_alpha, MC_put_xy_8_alpha }, 247 | { MC_avg_o_16_alpha, MC_avg_x_16_alpha, 248 | MC_avg_y_16_alpha, MC_avg_xy_16_alpha, 249 | MC_avg_o_8_alpha, MC_avg_x_8_alpha, 250 | MC_avg_y_8_alpha, MC_avg_xy_8_alpha } 251 | }; 252 | 253 | #endif 254 | -------------------------------------------------------------------------------- /libmpeg2/motion_comp_arm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * motion_comp_arm.c 3 | * Copyright (C) 2004 AGAWA Koji 4 | * 5 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 6 | * See http://libmpeg2.sourceforge.net/ for updates. 7 | * 8 | * mpeg2dec is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * mpeg2dec is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with mpeg2dec; if not, write to the Free Software 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 | */ 22 | 23 | #include "config.h" 24 | 25 | #ifdef ARCH_ARM 26 | 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "attributes.h" 31 | #include "mpeg2_internal.h" 32 | 33 | #define avg2(a,b) ((a+b+1)>>1) 34 | #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) 35 | 36 | #define predict_o(i) (ref[i]) 37 | #define predict_x(i) (avg2 (ref[i], ref[i+1])) 38 | #define predict_y(i) (avg2 (ref[i], (ref+stride)[i])) 39 | #define predict_xy(i) (avg4 (ref[i], ref[i+1], \ 40 | (ref+stride)[i], (ref+stride)[i+1])) 41 | 42 | #define put(predictor,i) dest[i] = predictor (i) 43 | #define avg(predictor,i) dest[i] = avg2 (predictor (i), dest[i]) 44 | 45 | /* mc function template */ 46 | 47 | #define MC_FUNC(op,xy) \ 48 | static void inline MC_##op##_##xy##_16_c (uint8_t * dest, const uint8_t * ref, \ 49 | const int stride, int height) \ 50 | { \ 51 | do { \ 52 | op (predict_##xy, 0); \ 53 | op (predict_##xy, 1); \ 54 | op (predict_##xy, 2); \ 55 | op (predict_##xy, 3); \ 56 | op (predict_##xy, 4); \ 57 | op (predict_##xy, 5); \ 58 | op (predict_##xy, 6); \ 59 | op (predict_##xy, 7); \ 60 | op (predict_##xy, 8); \ 61 | op (predict_##xy, 9); \ 62 | op (predict_##xy, 10); \ 63 | op (predict_##xy, 11); \ 64 | op (predict_##xy, 12); \ 65 | op (predict_##xy, 13); \ 66 | op (predict_##xy, 14); \ 67 | op (predict_##xy, 15); \ 68 | ref += stride; \ 69 | dest += stride; \ 70 | } while (--height); \ 71 | } \ 72 | static void MC_##op##_##xy##_8_c (uint8_t * dest, const uint8_t * ref, \ 73 | const int stride, int height) \ 74 | { \ 75 | do { \ 76 | op (predict_##xy, 0); \ 77 | op (predict_##xy, 1); \ 78 | op (predict_##xy, 2); \ 79 | op (predict_##xy, 3); \ 80 | op (predict_##xy, 4); \ 81 | op (predict_##xy, 5); \ 82 | op (predict_##xy, 6); \ 83 | op (predict_##xy, 7); \ 84 | ref += stride; \ 85 | dest += stride; \ 86 | } while (--height); \ 87 | } \ 88 | /* definitions of the actual mc functions */ 89 | 90 | MC_FUNC (avg,o) 91 | MC_FUNC (avg,x) 92 | MC_FUNC (put,y) 93 | MC_FUNC (avg,y) 94 | MC_FUNC (put,xy) 95 | MC_FUNC (avg,xy) 96 | 97 | 98 | extern void MC_put_o_16_arm (uint8_t * dest, const uint8_t * ref, 99 | int stride, int height); 100 | 101 | extern void MC_put_x_16_arm (uint8_t * dest, const uint8_t * ref, 102 | int stride, int height); 103 | 104 | 105 | static void MC_put_y_16_arm (uint8_t * dest, const uint8_t * ref, 106 | int stride, int height) 107 | { 108 | MC_put_y_16_c(dest, ref, stride, height); 109 | } 110 | 111 | static void MC_put_xy_16_arm (uint8_t * dest, const uint8_t * ref, 112 | int stride, int height) 113 | { 114 | MC_put_xy_16_c(dest, ref, stride, height); 115 | } 116 | 117 | extern void MC_put_o_8_arm (uint8_t * dest, const uint8_t * ref, 118 | int stride, int height); 119 | 120 | extern void MC_put_x_8_arm (uint8_t * dest, const uint8_t * ref, 121 | int stride, int height); 122 | 123 | static void MC_put_y_8_arm (uint8_t * dest, const uint8_t * ref, 124 | int stride, int height) 125 | { 126 | MC_put_y_8_c(dest, ref, stride, height); 127 | } 128 | 129 | static void MC_put_xy_8_arm (uint8_t * dest, const uint8_t * ref, 130 | int stride, int height) 131 | { 132 | MC_put_xy_8_c(dest, ref, stride, height); 133 | } 134 | 135 | static void MC_avg_o_16_arm (uint8_t * dest, const uint8_t * ref, 136 | int stride, int height) 137 | { 138 | MC_avg_o_16_c(dest, ref, stride, height); 139 | } 140 | 141 | static void MC_avg_x_16_arm (uint8_t * dest, const uint8_t * ref, 142 | int stride, int height) 143 | { 144 | MC_avg_x_16_c(dest, ref, stride, height); 145 | } 146 | 147 | static void MC_avg_y_16_arm (uint8_t * dest, const uint8_t * ref, 148 | int stride, int height) 149 | { 150 | MC_avg_y_16_c(dest, ref, stride, height); 151 | } 152 | 153 | static void MC_avg_xy_16_arm (uint8_t * dest, const uint8_t * ref, 154 | int stride, int height) 155 | { 156 | MC_avg_xy_16_c(dest, ref, stride, height); 157 | } 158 | 159 | static void MC_avg_o_8_arm (uint8_t * dest, const uint8_t * ref, 160 | int stride, int height) 161 | { 162 | MC_avg_o_8_c(dest, ref, stride, height); 163 | } 164 | 165 | static void MC_avg_x_8_arm (uint8_t * dest, const uint8_t * ref, 166 | int stride, int height) 167 | { 168 | MC_avg_x_8_c(dest, ref, stride, height); 169 | } 170 | 171 | static void MC_avg_y_8_arm (uint8_t * dest, const uint8_t * ref, 172 | int stride, int height) 173 | { 174 | MC_avg_y_8_c(dest, ref, stride, height); 175 | } 176 | 177 | static void MC_avg_xy_8_arm (uint8_t * dest, const uint8_t * ref, 178 | int stride, int height) 179 | { 180 | MC_avg_xy_8_c(dest, ref, stride, height); 181 | } 182 | 183 | MPEG2_MC_EXTERN (arm) 184 | 185 | #endif 186 | -------------------------------------------------------------------------------- /libvo/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = $(OPT_CFLAGS) $(LIBVO_CFLAGS) 2 | 3 | noinst_LIBRARIES = libvo.a 4 | libvo_a_SOURCES = video_out.c video_out_x11.c video_out_dx.c video_out_sdl.c \ 5 | video_out_null.c video_out_pgm.c vo_internal.h 6 | -------------------------------------------------------------------------------- /libvo/video_out.c: -------------------------------------------------------------------------------- 1 | /* 2 | * video_out.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "video_out.h" 30 | #include "vo_internal.h" 31 | 32 | /* Externally visible list of all vo drivers */ 33 | 34 | static vo_driver_t video_out_drivers[] = { 35 | #ifdef LIBVO_XV 36 | {"xv", vo_xv_open}, 37 | {"xv2", vo_xv2_open}, 38 | #endif 39 | #ifdef LIBVO_X11 40 | {"x11", vo_x11_open}, 41 | #endif 42 | #ifdef LIBVO_DX 43 | {"dxrgb", vo_dxrgb_open}, 44 | {"dx", vo_dx_open}, 45 | #endif 46 | #ifdef LIBVO_SDL 47 | {"sdl", vo_sdl_open}, 48 | #endif 49 | {"null", vo_null_open}, 50 | {"nullslice", vo_nullslice_open}, 51 | {"nullskip", vo_nullskip_open}, 52 | {"nullrgb16", vo_nullrgb16_open}, 53 | {"nullrgb32", vo_nullrgb32_open}, 54 | {"pgm", vo_pgm_open}, 55 | {"pgmpipe", vo_pgmpipe_open}, 56 | {"md5", vo_md5_open}, 57 | {NULL, NULL} 58 | }; 59 | 60 | vo_driver_t const * vo_drivers (void) 61 | { 62 | return video_out_drivers; 63 | } 64 | -------------------------------------------------------------------------------- /libvo/video_out_null.c: -------------------------------------------------------------------------------- 1 | /* 2 | * video_out_null.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include 27 | #include 28 | 29 | #include "mpeg2.h" 30 | #include "video_out.h" 31 | #include "vo_internal.h" 32 | #include "mpeg2convert.h" 33 | 34 | static void null_draw_frame (vo_instance_t * instance, 35 | uint8_t * const * buf, void * id) 36 | { 37 | } 38 | 39 | static vo_instance_t * internal_open (int setup (vo_instance_t *, unsigned int, 40 | unsigned int, unsigned int, 41 | unsigned int, 42 | vo_setup_result_t *), 43 | void draw (vo_instance_t *, 44 | uint8_t * const *, void *)) 45 | { 46 | vo_instance_t * instance; 47 | 48 | instance = (vo_instance_t *) malloc (sizeof (vo_instance_t)); 49 | if (instance == NULL) 50 | return NULL; 51 | 52 | instance->setup = setup; 53 | instance->setup_fbuf = NULL; 54 | instance->set_fbuf = NULL; 55 | instance->start_fbuf = NULL; 56 | instance->draw = draw; 57 | instance->discard = NULL; 58 | instance->close = (void (*) (vo_instance_t *)) free; 59 | 60 | return instance; 61 | } 62 | 63 | static int null_setup (vo_instance_t * instance, unsigned int width, 64 | unsigned int height, unsigned int chroma_width, 65 | unsigned int chroma_height, vo_setup_result_t * result) 66 | { 67 | result->convert = NULL; 68 | return 0; 69 | } 70 | 71 | vo_instance_t * vo_null_open (void) 72 | { 73 | return internal_open (null_setup, null_draw_frame); 74 | } 75 | 76 | vo_instance_t * vo_nullskip_open (void) 77 | { 78 | return internal_open (null_setup, NULL); 79 | } 80 | 81 | static void nullslice_start (void * id, const mpeg2_fbuf_t * fbuf, 82 | const mpeg2_picture_t * picture, 83 | const mpeg2_gop_t * gop) 84 | { 85 | } 86 | 87 | static void nullslice_copy (void * id, uint8_t * const * src, 88 | unsigned int v_offset) 89 | { 90 | } 91 | 92 | static int nullslice_convert (int stage, void * id, 93 | const mpeg2_sequence_t * seq, 94 | int stride, uint32_t accel, void * arg, 95 | mpeg2_convert_init_t * result) 96 | { 97 | result->id_size = 0; 98 | result->buf_size[0] = result->buf_size[1] = result->buf_size[2] = 0; 99 | result->start = nullslice_start; 100 | result->copy = nullslice_copy; 101 | return 0; 102 | } 103 | 104 | static int nullslice_setup (vo_instance_t * instance, unsigned int width, 105 | unsigned int height, unsigned int chroma_width, 106 | unsigned int chroma_height, 107 | vo_setup_result_t * result) 108 | { 109 | result->convert = nullslice_convert; 110 | return 0; 111 | } 112 | 113 | vo_instance_t * vo_nullslice_open (void) 114 | { 115 | return internal_open (nullslice_setup, null_draw_frame); 116 | } 117 | 118 | static int nullrgb16_setup (vo_instance_t * instance, unsigned int width, 119 | unsigned int height, unsigned int chroma_width, 120 | unsigned int chroma_height, 121 | vo_setup_result_t * result) 122 | { 123 | result->convert = mpeg2convert_rgb16; 124 | return 0; 125 | } 126 | 127 | static int nullrgb32_setup (vo_instance_t * instance, unsigned int width, 128 | unsigned int height, unsigned int chroma_width, 129 | unsigned int chroma_height, 130 | vo_setup_result_t * result) 131 | { 132 | result->convert = mpeg2convert_rgb32; 133 | return 0; 134 | } 135 | 136 | vo_instance_t * vo_nullrgb16_open (void) 137 | { 138 | return internal_open (nullrgb16_setup, null_draw_frame); 139 | } 140 | 141 | vo_instance_t * vo_nullrgb32_open (void) 142 | { 143 | return internal_open (nullrgb32_setup, null_draw_frame); 144 | } 145 | -------------------------------------------------------------------------------- /libvo/video_out_sdl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * video_out_sdl.c 3 | * 4 | * Copyright (C) 2000-2003 Ryan C. Gordon and 5 | * Dominik Schnitzer 6 | * 7 | * SDL info, source, and binaries can be found at http://www.libsdl.org/ 8 | * 9 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 10 | * See http://libmpeg2.sourceforge.net/ for updates. 11 | * 12 | * mpeg2dec is free software; you can redistribute it and/or modify 13 | * it under the terms of the GNU General Public License as published by 14 | * the Free Software Foundation; either version 2 of the License, or 15 | * (at your option) any later version. 16 | * 17 | * mpeg2dec is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | * GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License 23 | * along with this program; if not, write to the Free Software 24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | */ 26 | 27 | #include "config.h" 28 | 29 | #ifdef LIBVO_SDL 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "video_out.h" 38 | #include "vo_internal.h" 39 | 40 | typedef struct { 41 | vo_instance_t vo; 42 | int width; 43 | int height; 44 | SDL_Surface * surface; 45 | Uint32 sdlflags; 46 | Uint8 bpp; 47 | } sdl_instance_t; 48 | 49 | static void sdl_setup_fbuf (vo_instance_t * _instance, 50 | uint8_t ** buf, void ** id) 51 | { 52 | sdl_instance_t * instance = (sdl_instance_t *) _instance; 53 | SDL_Overlay * overlay; 54 | 55 | *id = overlay = SDL_CreateYUVOverlay (instance->width, instance->height, 56 | SDL_YV12_OVERLAY, instance->surface); 57 | buf[0] = overlay->pixels[0]; 58 | buf[1] = overlay->pixels[2]; 59 | buf[2] = overlay->pixels[1]; 60 | if (((long)buf[0] & 15) || ((long)buf[1] & 15) || ((long)buf[2] & 15)) { 61 | fprintf (stderr, "Unaligned buffers. Anyone know how to fix this ?\n"); 62 | exit (1); 63 | } 64 | } 65 | 66 | static void sdl_start_fbuf (vo_instance_t * instance, 67 | uint8_t * const * buf, void * id) 68 | { 69 | SDL_LockYUVOverlay ((SDL_Overlay *) id); 70 | } 71 | 72 | static void sdl_draw_frame (vo_instance_t * _instance, 73 | uint8_t * const * buf, void * id) 74 | { 75 | sdl_instance_t * instance = (sdl_instance_t *) _instance; 76 | SDL_Overlay * overlay = (SDL_Overlay *) id; 77 | SDL_Event event; 78 | 79 | while (SDL_PollEvent (&event)) 80 | if (event.type == SDL_VIDEORESIZE) 81 | instance->surface = 82 | SDL_SetVideoMode (event.resize.w, event.resize.h, 83 | instance->bpp, instance->sdlflags); 84 | SDL_DisplayYUVOverlay (overlay, &(instance->surface->clip_rect)); 85 | } 86 | 87 | static void sdl_discard (vo_instance_t * _instance, 88 | uint8_t * const * buf, void * id) 89 | { 90 | SDL_UnlockYUVOverlay ((SDL_Overlay *) id); 91 | } 92 | 93 | #if 0 94 | static void sdl_close (vo_instance_t * _instance) 95 | { 96 | sdl_instance_t * instance; 97 | int i; 98 | 99 | instance = (sdl_instance_t *) _instance; 100 | for (i = 0; i < 3; i++) 101 | SDL_FreeYUVOverlay (instance->frame[i].overlay); 102 | SDL_FreeSurface (instance->surface); 103 | SDL_QuitSubSystem (SDL_INIT_VIDEO); 104 | } 105 | #endif 106 | 107 | static int sdl_setup (vo_instance_t * _instance, unsigned int width, 108 | unsigned int height, unsigned int chroma_width, 109 | unsigned int chroma_height, vo_setup_result_t * result) 110 | { 111 | sdl_instance_t * instance; 112 | 113 | instance = (sdl_instance_t *) _instance; 114 | 115 | instance->width = width; 116 | instance->height = height; 117 | instance->surface = SDL_SetVideoMode (width, height, instance->bpp, 118 | instance->sdlflags); 119 | if (! (instance->surface)) { 120 | fprintf (stderr, "sdl could not set the desired video mode\n"); 121 | return 1; 122 | } 123 | 124 | result->convert = NULL; 125 | return 0; 126 | } 127 | 128 | vo_instance_t * vo_sdl_open (void) 129 | { 130 | sdl_instance_t * instance; 131 | const SDL_VideoInfo * vidInfo; 132 | 133 | instance = (sdl_instance_t *) malloc (sizeof (sdl_instance_t)); 134 | if (instance == NULL) 135 | return NULL; 136 | 137 | instance->vo.setup = sdl_setup; 138 | instance->vo.setup_fbuf = sdl_setup_fbuf; 139 | instance->vo.set_fbuf = NULL; 140 | instance->vo.start_fbuf = sdl_start_fbuf; 141 | instance->vo.discard = sdl_discard; 142 | instance->vo.draw = sdl_draw_frame; 143 | instance->vo.close = NULL; /* sdl_close; */ 144 | instance->sdlflags = SDL_HWSURFACE | SDL_RESIZABLE; 145 | 146 | putenv((char *)"SDL_VIDEO_YUV_HWACCEL=1"); 147 | putenv((char *)"SDL_VIDEO_X11_NODIRECTCOLOR=1"); 148 | 149 | if (SDL_Init (SDL_INIT_VIDEO)) { 150 | fprintf (stderr, "sdl video initialization failed.\n"); 151 | return NULL; 152 | } 153 | 154 | vidInfo = SDL_GetVideoInfo (); 155 | if (!SDL_ListModes (vidInfo->vfmt, SDL_HWSURFACE | SDL_RESIZABLE)) { 156 | instance->sdlflags = SDL_RESIZABLE; 157 | if (!SDL_ListModes (vidInfo->vfmt, SDL_RESIZABLE)) { 158 | fprintf (stderr, "sdl couldn't get any acceptable video mode\n"); 159 | return NULL; 160 | } 161 | } 162 | instance->bpp = vidInfo->vfmt->BitsPerPixel; 163 | if (instance->bpp < 16) { 164 | fprintf(stderr, "sdl has to emulate a 16 bit surfaces, " 165 | "that will slow things down.\n"); 166 | instance->bpp = 16; 167 | } 168 | 169 | return (vo_instance_t *) instance; 170 | } 171 | #endif 172 | -------------------------------------------------------------------------------- /libvo/vo_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vo_internal.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | extern vo_open_t vo_xv_open; 25 | extern vo_open_t vo_xv2_open; 26 | extern vo_open_t vo_x11_open; 27 | extern vo_open_t vo_dxrgb_open; 28 | extern vo_open_t vo_dx_open; 29 | extern vo_open_t vo_sdl_open; 30 | extern vo_open_t vo_null_open; 31 | extern vo_open_t vo_nullslice_open; 32 | extern vo_open_t vo_nullskip_open; 33 | extern vo_open_t vo_nullrgb16_open; 34 | extern vo_open_t vo_nullrgb32_open; 35 | extern vo_open_t vo_pgm_open; 36 | extern vo_open_t vo_pgmpipe_open; 37 | extern vo_open_t vo_md5_open; 38 | 39 | -------------------------------------------------------------------------------- /m4/cflags.m4: -------------------------------------------------------------------------------- 1 | dnl AC_TRY_CFLAGS (CFLAGS, [ACTION-IF-WORKS], [ACTION-IF-FAILS]) 2 | dnl check if $CC supports a given set of cflags 3 | AC_DEFUN([AC_TRY_CFLAGS], 4 | [AC_MSG_CHECKING([if $CC supports $1 flags]) 5 | SAVE_CFLAGS="$CFLAGS" 6 | CFLAGS="$1" 7 | AC_TRY_COMPILE([],[],[ac_cv_try_cflags_ok=yes],[ac_cv_try_cflags_ok=no]) 8 | CFLAGS="$SAVE_CFLAGS" 9 | AC_MSG_RESULT([$ac_cv_try_cflags_ok]) 10 | if test x"$ac_cv_try_cflags_ok" = x"yes"; then 11 | ifelse([$2],[],[:],[$2]) 12 | else 13 | ifelse([$3],[],[:],[$3]) 14 | fi]) 15 | -------------------------------------------------------------------------------- /m4/keywords.m4: -------------------------------------------------------------------------------- 1 | dnl AC_C_RESTRICT 2 | dnl Do nothing if the compiler accepts the restrict keyword. 3 | dnl Otherwise define restrict to __restrict__ or __restrict if one of 4 | dnl those work, otherwise define restrict to be empty. 5 | AC_DEFUN([AC_C_RESTRICT], 6 | [AC_MSG_CHECKING([for restrict]) 7 | ac_cv_c_restrict=no 8 | for ac_kw in restrict __restrict__ __restrict; do 9 | AC_TRY_COMPILE([],[char * $ac_kw p;],[ac_cv_c_restrict=$ac_kw; break]) 10 | done 11 | AC_MSG_RESULT([$ac_cv_c_restrict]) 12 | case $ac_cv_c_restrict in 13 | restrict) ;; 14 | no) AC_DEFINE([restrict],, 15 | [Define as `__restrict' if that's what the C compiler calls 16 | it, or to nothing if it is not supported.]) ;; 17 | *) AC_DEFINE_UNQUOTED([restrict],$ac_cv_c_restrict) ;; 18 | esac]) 19 | 20 | dnl AC_C_BUILTIN_EXPECT 21 | dnl Check whether compiler understands __builtin_expect. 22 | AC_DEFUN([AC_C_BUILTIN_EXPECT], 23 | [AC_CACHE_CHECK([for __builtin_expect],[ac_cv_builtin_expect], 24 | [cat > conftest.c <&AC_FD_CC]); then 34 | ac_cv_builtin_expect=yes 35 | else 36 | ac_cv_builtin_expect=no 37 | fi 38 | rm -f conftest*]) 39 | if test x"$ac_cv_builtin_expect" = x"yes"; then 40 | AC_DEFINE(HAVE_BUILTIN_EXPECT,, 41 | [Define if you have the `__builtin_expect' function.]) 42 | fi]) 43 | 44 | dnl AC_C_ALWAYS_INLINE 45 | dnl Define inline to something appropriate, including the new always_inline 46 | dnl attribute from gcc 3.1 47 | AC_DEFUN([AC_C_ALWAYS_INLINE], 48 | [AC_C_INLINE 49 | if test x"$GCC" = x"yes" -a x"$ac_cv_c_inline" = x"inline"; then 50 | AC_MSG_CHECKING([for always_inline]) 51 | SAVE_CFLAGS="$CFLAGS" 52 | CFLAGS="$CFLAGS -Wall -Werror" 53 | AC_TRY_COMPILE([], 54 | [__attribute__ ((__always_inline__)) void f (void); 55 | #ifdef __cplusplus 56 | 42 = 42; // obviously illegal - we want c++ to fail here 57 | #endif], 58 | [ac_cv_always_inline=yes],[ac_cv_always_inline=no]) 59 | CFLAGS="$SAVE_CFLAGS" 60 | AC_MSG_RESULT([$ac_cv_always_inline]) 61 | if test x"$ac_cv_always_inline" = x"yes"; then 62 | AC_DEFINE_UNQUOTED([inline],[__attribute__ ((__always_inline__))]) 63 | fi 64 | fi]) 65 | 66 | dnl AC_C_ATTRIBUTE_ALIGNED 67 | dnl define ATTRIBUTE_ALIGNED_MAX to the maximum alignment if this is supported 68 | AC_DEFUN([AC_C_ATTRIBUTE_ALIGNED], 69 | [SAV_CFLAGS=$CFLAGS; 70 | if test x"$GCC" = xyes; then CFLAGS="$CFLAGS -Werror"; fi 71 | AC_CACHE_CHECK([__attribute__ ((aligned ())) support], 72 | [ac_cv_c_attribute_aligned], 73 | [ac_cv_c_attribute_aligned=0 74 | for ac_cv_c_attr_align_try in 2 4 8 16 32 64; do 75 | AC_TRY_COMPILE([], 76 | [static struct s { 77 | char a; 78 | char b __attribute__ ((aligned($ac_cv_c_attr_align_try))); 79 | } S = {0, 0}; 80 | switch (1) { 81 | case 0: 82 | case (long)(&((struct s *)0)->b) == $ac_cv_c_attr_align_try: 83 | return 0; 84 | } 85 | return (long)&S;], 86 | [ac_cv_c_attribute_aligned=$ac_cv_c_attr_align_try]) 87 | done]) 88 | if test x"$ac_cv_c_attribute_aligned" != x"0"; then 89 | AC_DEFINE_UNQUOTED([ATTRIBUTE_ALIGNED_MAX], 90 | [$ac_cv_c_attribute_aligned],[maximum supported data alignment]) 91 | fi 92 | CFLAGS=$SAV_CFLAGS]) 93 | 94 | -------------------------------------------------------------------------------- /m4/nonpic.m4: -------------------------------------------------------------------------------- 1 | dnl AC_LIBTOOL_NON_PIC ([ACTION-IF-WORKS], [ACTION-IF-FAILS]) 2 | dnl check for nonbuggy libtool -prefer-non-pic 3 | AC_DEFUN([AC_LIBTOOL_NON_PIC], 4 | [AC_MSG_CHECKING([if libtool supports -prefer-non-pic flag]) 5 | mkdir ac_test_libtool; cd ac_test_libtool; ac_cv_libtool_non_pic=no 6 | echo "int g (int i); static int h (int i) {return g (i);} int f (int i) {return h (i);}" >f.c 7 | echo "int (* hook) (int) = 0; int g (int i) {if (hook) i = hook (i); return i + 1;}" >g.c 8 | ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic \ 9 | -c f.c >/dev/null 2>&1 && \ 10 | ../libtool --mode=compile $CC $CFLAGS -prefer-non-pic \ 11 | -c g.c >/dev/null 2>&1 && \ 12 | ../libtool --mode=link $CC $CFLAGS -prefer-non-pic -o libfoo.la \ 13 | -rpath / f.lo g.lo >/dev/null 2>&1 && 14 | ac_cv_libtool_non_pic=yes 15 | cd ..; rm -fr ac_test_libtool; AC_MSG_RESULT([$ac_cv_libtool_non_pic]) 16 | if test x"$ac_cv_libtool_non_pic" = x"yes"; then 17 | ifelse([$1],[],[:],[$1]) 18 | else 19 | ifelse([$2],[],[:],[$2]) 20 | fi]) 21 | 22 | -------------------------------------------------------------------------------- /packaging/libmpeg2.spec: -------------------------------------------------------------------------------- 1 | Name: libmpeg2 2 | Version: 0.5.1 3 | Release: 1 4 | Summary: MPEG-2 decoder libraries 5 | 6 | Group: System Environment/Libraries 7 | License: GPLv2+ 8 | URL: http://libmpeg2.sourceforge.net/ 9 | Source0: libmpeg2-%{version}.tar.gz 10 | 11 | %description 12 | libmpeg2 is a free library for decoding mpeg-2 and mpeg-1 video 13 | streams. It is released under the terms of the GPL license. 14 | 15 | %package -n mpeg2dec 16 | Summary: MPEG-2 decoder program 17 | Group: Applications/Multimedia 18 | Requires: %{name} = %{version}-%{release} 19 | 20 | %description -n mpeg2dec 21 | The %{name}-devel package contains libraries and header files for 22 | developing applications that use %{name}. 23 | 24 | %package devel 25 | Summary: Development files for %{name} 26 | Group: Development/Libraries 27 | Requires: %{name} = %{version}-%{release} 28 | Requires: pkgconfig 29 | 30 | %description devel 31 | The %{name}-devel package contains libraries and header files for 32 | developing applications that use %{name}. 33 | 34 | 35 | %prep 36 | %setup -q 37 | 38 | %build 39 | %configure --disable-static \ 40 | %ifarch %{ix86} ppc 41 | --disable-accel-detect \ 42 | %endif 43 | 44 | # mpeg2dec have rpath 45 | # remove rpath from libtool 46 | sed -i.rpath 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool 47 | sed -i.rpath 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool 48 | 49 | make %{?_smp_mflags} \ 50 | %ifarch %{ix86} 51 | OPT_CFLAGS="-fPIC -DPIC" \ 52 | %else 53 | OPT_CFLAGS="" \ 54 | %endif 55 | 56 | 57 | %install 58 | rm -rf $RPM_BUILD_ROOT 59 | make install DESTDIR=$RPM_BUILD_ROOT INSTALL="install -p" 60 | find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';' 61 | 62 | 63 | #Fix datatype internal definitions 64 | install -pm 0644 libmpeg2/mpeg2_internal.h \ 65 | $RPM_BUILD_ROOT%{_includedir}/mpeg2dec/ 66 | 67 | 68 | 69 | %clean 70 | rm -rf $RPM_BUILD_ROOT 71 | 72 | 73 | %post -p /sbin/ldconfig 74 | 75 | %postun -p /sbin/ldconfig 76 | 77 | 78 | %files 79 | %defattr(-,root,root,-) 80 | %doc AUTHORS ChangeLog COPYING NEWS README TODO 81 | %{_libdir}/*.so.* 82 | 83 | %files -n mpeg2dec 84 | %defattr(-,root,root,-) 85 | %{_bindir}/corrupt_mpeg2 86 | %{_bindir}/extract_mpeg2 87 | %{_bindir}/mpeg2dec 88 | %{_mandir}/man1/*.1* 89 | 90 | %files devel 91 | %defattr(-,root,root,-) 92 | %doc CodingStyle doc/libmpeg2.txt doc/sample*.c 93 | %{_includedir}/mpeg2dec/ 94 | %{_libdir}/*.so 95 | %{_libdir}/pkgconfig/libmpeg2.pc 96 | %{_libdir}/pkgconfig/libmpeg2convert.pc 97 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | AM_CFLAGS = $(MPEG2DEC_CFLAGS) $(LIBVO_CFLAGS) 2 | 3 | libmpeg2 = $(top_builddir)/libmpeg2/libmpeg2.la 4 | libmpeg2convert = $(top_builddir)/libmpeg2/convert/libmpeg2convert.la 5 | libvo = $(top_builddir)/libvo/libvo.a $(LIBVO_LIBS) 6 | 7 | bin_PROGRAMS = mpeg2dec extract_mpeg2 corrupt_mpeg2 8 | mpeg2dec_SOURCES = mpeg2dec.c dump_state.c getopt.c gettimeofday.c 9 | mpeg2dec_LDADD = $(libvo) $(libmpeg2) $(libmpeg2convert) 10 | extract_mpeg2_SOURCES = extract_mpeg2.c getopt.c 11 | corrupt_mpeg2_SOURCES = corrupt_mpeg2.c getopt.c 12 | 13 | man_MANS = mpeg2dec.1 extract_mpeg2.1 14 | 15 | EXTRA_DIST = getopt.h gettimeofday.h $(man_MANS) 16 | -------------------------------------------------------------------------------- /src/extract_mpeg2.1: -------------------------------------------------------------------------------- 1 | .TH mpeg2dec "1" "extract_mpeg2" 2 | .SH NAME 3 | extract_mpeg2 \- extract MPEG video streams from a multiplexed stream. 4 | .SH SYNOPSIS 5 | .B extract_mpeg2 6 | [\fI-h\fR] [\fI-s [track]\fR] [\fI-t pid\fR] [\fIfile\fR] 7 | .SH DESCRIPTION 8 | `extract_mpeg2' extracts MPEG video streams from a multiplexed stream. 9 | Input is from stdin if no file is given. 10 | .TP 11 | \fB\-h\fR 12 | display help 13 | .TP 14 | \fB\-s track\fR 15 | set track number (0-0xf or 0xe0-0xef) 16 | .TP 17 | \fB\-t pid\fR 18 | use transport stream demultiplexer, pid 0x10-0x1ffe 19 | .SH AUTHORS 20 | Michel Lespinasse 21 | .br 22 | Aaron Holtzman 23 | .br 24 | And many others on the net. 25 | .SH "REPORTING BUGS" 26 | Report bugs to . 27 | .SH COPYRIGHT 28 | Copyright \(co 2000-2003 Michel Lespinasse 29 | .br 30 | Copyright \(co 1999-2000 Aaron Holtzman 31 | .br 32 | This is free software; see the source for copying conditions. There is NO 33 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 34 | .SH "SEE ALSO" 35 | .BR mpeg2dec "(1)" 36 | -------------------------------------------------------------------------------- /src/getopt.h: -------------------------------------------------------------------------------- 1 | /* Declarations for getopt. 2 | Copyright (C) 1989,90,91,92,93,94,96,97,98 Free Software Foundation, Inc. 3 | This file is part of the GNU C Library. 4 | 5 | The GNU C Library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public License as 7 | published by the Free Software Foundation; either version 2 of the 8 | License, or (at your option) any later version. 9 | 10 | The GNU C Library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with the GNU C Library; see the file COPYING.LIB. If not, 17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 | Boston, MA 02111-1307, USA. */ 19 | 20 | #ifndef _GETOPT_H 21 | 22 | #ifndef __need_getopt 23 | # define _GETOPT_H 1 24 | #endif 25 | 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | /* For communication from `getopt' to the caller. 31 | When `getopt' finds an option that takes an argument, 32 | the argument value is returned here. 33 | Also, when `ordering' is RETURN_IN_ORDER, 34 | each non-option ARGV-element is returned here. */ 35 | 36 | extern char *optarg; 37 | 38 | /* Index in ARGV of the next element to be scanned. 39 | This is used for communication to and from the caller 40 | and for communication between successive calls to `getopt'. 41 | 42 | On entry to `getopt', zero means this is the first call; initialize. 43 | 44 | When `getopt' returns -1, this is the index of the first of the 45 | non-option elements that the caller should itself scan. 46 | 47 | Otherwise, `optind' communicates from one call to the next 48 | how much of ARGV has been scanned so far. */ 49 | 50 | extern int optind; 51 | 52 | /* Callers store zero here to inhibit the error message `getopt' prints 53 | for unrecognized options. */ 54 | 55 | extern int opterr; 56 | 57 | /* Set to an option character which was unrecognized. */ 58 | 59 | extern int optopt; 60 | 61 | #ifndef __need_getopt 62 | /* Describe the long-named options requested by the application. 63 | The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector 64 | of `struct option' terminated by an element containing a name which is 65 | zero. 66 | 67 | The field `has_arg' is: 68 | no_argument (or 0) if the option does not take an argument, 69 | required_argument (or 1) if the option requires an argument, 70 | optional_argument (or 2) if the option takes an optional argument. 71 | 72 | If the field `flag' is not NULL, it points to a variable that is set 73 | to the value given in the field `val' when the option is found, but 74 | left unchanged if the option is not found. 75 | 76 | To have a long-named option do something other than set an `int' to 77 | a compiled-in constant, such as set a value from `optarg', set the 78 | option's `flag' field to zero and its `val' field to a nonzero 79 | value (the equivalent single-letter option character, if there is 80 | one). For long options that have a zero `flag' field, `getopt' 81 | returns the contents of the `val' field. */ 82 | 83 | struct option 84 | { 85 | # if defined __STDC__ && __STDC__ 86 | const char *name; 87 | # else 88 | char *name; 89 | # endif 90 | /* has_arg can't be an enum because some compilers complain about 91 | type mismatches in all the code that assumes it is an int. */ 92 | int has_arg; 93 | int *flag; 94 | int val; 95 | }; 96 | 97 | /* Names for the values of the `has_arg' field of `struct option'. */ 98 | 99 | # define no_argument 0 100 | # define required_argument 1 101 | # define optional_argument 2 102 | #endif /* need getopt */ 103 | 104 | 105 | /* Get definitions and prototypes for functions to process the 106 | arguments in ARGV (ARGC of them, minus the program name) for 107 | options given in OPTS. 108 | 109 | Return the option character from OPTS just read. Return -1 when 110 | there are no more options. For unrecognized options, or options 111 | missing arguments, `optopt' is set to the option letter, and '?' is 112 | returned. 113 | 114 | The OPTS string is a list of characters which are recognized option 115 | letters, optionally followed by colons, specifying that that letter 116 | takes an argument, to be placed in `optarg'. 117 | 118 | If a letter in OPTS is followed by two colons, its argument is 119 | optional. This behavior is specific to the GNU `getopt'. 120 | 121 | The argument `--' causes premature termination of argument 122 | scanning, explicitly telling `getopt' that there are no more 123 | options. 124 | 125 | If OPTS begins with `--', then non-option arguments are treated as 126 | arguments to the option '\0'. This behavior is specific to the GNU 127 | `getopt'. */ 128 | 129 | #if defined __STDC__ && __STDC__ 130 | # ifdef __GNU_LIBRARY__ 131 | /* Many other libraries have conflicting prototypes for getopt, with 132 | differences in the consts, in stdlib.h. To avoid compilation 133 | errors, only prototype getopt for the GNU C library. */ 134 | extern int getopt (int __argc, char *const *__argv, const char *__shortopts); 135 | # else /* not __GNU_LIBRARY__ */ 136 | extern int getopt (); 137 | # endif /* __GNU_LIBRARY__ */ 138 | 139 | # ifndef __need_getopt 140 | extern int getopt_long (int __argc, char *const *__argv, const char *__shortopts, 141 | const struct option *__longopts, int *__longind); 142 | extern int getopt_long_only (int __argc, char *const *__argv, 143 | const char *__shortopts, 144 | const struct option *__longopts, int *__longind); 145 | 146 | /* Internal only. Users should not call this directly. */ 147 | extern int _getopt_internal (int __argc, char *const *__argv, 148 | const char *__shortopts, 149 | const struct option *__longopts, int *__longind, 150 | int __long_only); 151 | # endif 152 | #else /* not __STDC__ */ 153 | extern int getopt (); 154 | # ifndef __need_getopt 155 | extern int getopt_long (); 156 | extern int getopt_long_only (); 157 | 158 | extern int _getopt_internal (); 159 | # endif 160 | #endif /* __STDC__ */ 161 | 162 | #ifdef __cplusplus 163 | } 164 | #endif 165 | 166 | /* Make sure we later can get all the definitions and declarations. */ 167 | #undef __need_getopt 168 | 169 | #endif /* getopt.h */ 170 | -------------------------------------------------------------------------------- /src/gettimeofday.c: -------------------------------------------------------------------------------- 1 | /* 2 | * gettimeofday.c 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #include "config.h" 25 | 26 | #include "gettimeofday.h" 27 | 28 | #ifdef CUSTOM_GETTIMEOFDAY 29 | 30 | #include 31 | 32 | void gettimeofday (struct timeval * tp, void * dummy) 33 | { 34 | struct timeb tm; 35 | ftime (&tm); 36 | tp->tv_sec = tm.time; 37 | tp->tv_usec = tm.millitm * 1000; 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/gettimeofday.h: -------------------------------------------------------------------------------- 1 | /* 2 | * gettimeofday.h 3 | * Copyright (C) 2000-2003 Michel Lespinasse 4 | * Copyright (C) 1999-2000 Aaron Holtzman 5 | * 6 | * This file is part of mpeg2dec, a free MPEG-2 video stream decoder. 7 | * See http://libmpeg2.sourceforge.net/ for updates. 8 | * 9 | * mpeg2dec is free software; you can redistribute it and/or modify 10 | * it 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 | * mpeg2dec is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 | */ 23 | 24 | #ifndef LIBMPEG2_GETTIMEOFDAY_H 25 | #define LIBMPEG2_GETTIMEOFDAY_H 26 | 27 | #if defined(HAVE_STRUCT_TIMEVAL) && defined(HAVE_GETTIMEOFDAY) 28 | #if defined(TIME_WITH_SYS_TIME) 29 | #include 30 | #include 31 | #elif defined(HAVE_SYS_TIME_H) 32 | #include 33 | #else 34 | #include 35 | #endif 36 | #elif defined(HAVE_SYS_TIMEB_H) && defined(HAVE_FTIME) 37 | 38 | #define HAVE_GETTIMEOFDAY 1 39 | #define CUSTOM_GETTIMEOFDAY 1 40 | 41 | struct timeval { 42 | long tv_sec; 43 | long tv_usec; 44 | }; 45 | 46 | void gettimeofday (struct timeval * tp, void * dummy); 47 | 48 | #else 49 | #undef HAVE_GETTIMEOFDAY 50 | #endif 51 | 52 | #endif /* LIBMPEG2_GETTIMEOFDAY_H */ 53 | -------------------------------------------------------------------------------- /src/mpeg2dec.1: -------------------------------------------------------------------------------- 1 | .TH mpeg2dec "1" "mpeg2dec" 2 | .SH NAME 3 | mpeg2dec \- decode MPEG and MPEG2 video streams 4 | .SH SYNOPSIS 5 | .B mpeg2dec 6 | [\fI-h\fR] [\fI-s [track]\fR] [\fI-t pid\fR] [\fI-c\fR] [\fI-o mode\fR] [\fIfile\fR] 7 | .SH DESCRIPTION 8 | `mpeg2dec' displays MPEG1 and MPEG2 video stream. 9 | Input is from stdin if no file is given. 10 | .TP 11 | \fB\-h\fR 12 | display help and available video modes 13 | .TP 14 | \fB\-s\fR 15 | use program stream demultiplexer, track 0-0xf or 0xe0-0xef 16 | .TP 17 | \fB\-t pid\fR 18 | use transport stream demultiplexer, pid 0x10-0x1ffe 19 | .TP 20 | \fB\-c\fR 21 | use c implementation, disables all accelerations 22 | .TP 23 | \fB\-o\fR \fImode\fR 24 | use video output driver `mode'. 25 | .br 26 | A list of modes is available using the \fB\-h\fR option. 27 | .SH AUTHORS 28 | Michel Lespinasse 29 | .br 30 | Aaron Holtzman 31 | .br 32 | And many others on the net. 33 | .SH "REPORTING BUGS" 34 | Report bugs to . 35 | .SH COPYRIGHT 36 | Copyright \(co 2000-2003 Michel Lespinasse 37 | .br 38 | Copyright \(co 1999-2000 Aaron Holtzman 39 | .br 40 | This is free software; see the source for copying conditions. There is NO 41 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 42 | .SH "SEE ALSO" 43 | .BR extract_mpeg2 "(1)" 44 | -------------------------------------------------------------------------------- /test/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = regression tests tek-525 tek-625 compile globals 2 | TESTS = regression compile globals 3 | -------------------------------------------------------------------------------- /test/README: -------------------------------------------------------------------------------- 1 | Please do use these tests if you do some libmpeg2 changes. 2 | 3 | * get the official suite of mpeg2 torture tests at 4 | http://libmpeg2.sourceforge.net/files/mpeg2dec-streams.tar.gz 5 | 6 | or using SVN : 7 | 8 | # svn co svn://svn.videolan.org/libmpeg2/streams 9 | 10 | (OK, I did some reorganization work on the archive, so it is not really the 11 | official suite anymore) 12 | 13 | Then, 14 | 15 | * extract this archive at the same level as your mpeg2dec directory : 16 | in your working directory you should have subdirectories mpeg2dec 17 | and streams. 18 | 19 | * or, extract this archive where you want, but change the first line 20 | of the "tests" file to reflect that location. Do _not_ remove the 21 | pound (#) sign at the beginning of the line. 22 | 23 | Now run test/regression 24 | 25 | is the name of the test suite you want to use. For the official 26 | mpeg video conformance tests, just use "tests". 27 | 28 | is the type of IDCT you are using. If your machine supports MMX, 29 | choose "mmx". If your machine uses the c idct, choose "c" 30 | 31 | That's it... 32 | 33 | walken 34 | -------------------------------------------------------------------------------- /test/compile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test x"$srcdir" != x""; then 4 | builddir="." # running from make check, but it does not define that 5 | else 6 | srcdir=`echo "$0" | sed s,[^/]*$,,` 7 | test "$srcdir" = "$0" && srcdir=. 8 | test -z "$srcdir" && srcdir=. 9 | builddir="$srcdir" # running manually, have to assume 10 | fi 11 | 12 | srcdir=`cd $srcdir;pwd` 13 | builddir=`cd $builddir;pwd` 14 | 15 | basedir=".." 16 | cd $srcdir; if [ ! -d $basedir -o ! -f $basedir/src/mpeg2dec.c -o \ 17 | ! -f $basedir/mpeg2dec-*.tar.gz ]; then 18 | cd ..; if [ ! -d $basedir -o ! -f $basedir/src/mpeg2dec.c -o \ 19 | ! -f $basedir/mpeg2dec-*.tar.gz ]; then 20 | exit 77 21 | fi 22 | fi 23 | basedir=`cd $basedir;pwd` 24 | 25 | cd $builddir 26 | rm -fr compile_test 27 | 28 | for compiler in cc gcc gcc272 gcc-2.95 gcc-3.0 gcc-3.1 gcc-3.2 gcc-3.3 \ 29 | gcc-3.4 gcc-4.0 gcc-4.1 gcc-4.2 c89 \ 30 | c++ g++ g++-2.95 g++-3.0 g++-3.1 g++-3.2 g++-3.3 g++-3.4 \ 31 | g++-4.0 g++-4.1 g++-4.2 \ 32 | ccmalloc-gcc bgcc checkergcc tendracc icc \ 33 | i586-mingw32msvc-gcc; do 34 | compiler_path=`which $compiler` 35 | if test x"$compiler_path" = x""; then continue; fi 36 | 37 | mkdir compile_test 38 | cd compile_test; tar xzpf $basedir/mpeg2dec-*.tar.gz; cd mpeg2dec-* 39 | case "$compiler" in 40 | i586-mingw32msvc-gcc) 41 | opts="--host=i586-mingw32msvc --enable-warnings --disable-sdl" 42 | if test -f "/usr/local/opt/ddraw/ddraw.h"; then 43 | opts="$opts --with-directx=/usr/local/opt/ddraw" 44 | fi;; 45 | c89) opts="";; 46 | ccmalloc-gcc) opts="--enable-warnings --enable-debug";; 47 | tcc-*) opts="--enable-warnings --disable-sdl";; 48 | checkergcc) opts="--disable-largefile";; 49 | gcc272|*-2.95) opts="";; 50 | *) opts="--enable-warnings";; 51 | esac 52 | error=1; CC=$compiler ./configure $opts && make && error=0 53 | if test x"$error" != x"0"; then exit 1; fi 54 | cd ../.. 55 | rm -fr compile_test 56 | done 57 | 58 | exit 0 59 | -------------------------------------------------------------------------------- /test/globals: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test x"$srcdir" != x""; then 4 | builddir="." # running from make check, but it does not define that 5 | else 6 | srcdir=`echo "$0" | sed s,[^/]*$,,` 7 | test "$srcdir" = "$0" && srcdir=. 8 | test -z "$srcdir" && srcdir=. 9 | builddir="$srcdir" # running manually, have to assume 10 | fi 11 | 12 | srcdir=`cd $srcdir;pwd` 13 | builddir=`cd $builddir;pwd` 14 | 15 | error=0 16 | 17 | bad_globals=`nm -g --defined-only $builddir/../libmpeg2/*.o |\ 18 | awk '{if ($3) print $3}' | grep -v '^_\?mpeg2_'` 19 | 20 | if test x"$bad_globals" != x""; then 21 | echo BAD GLOBAL SYMBOLS: 22 | for s in $bad_globals; do echo $s; done 23 | error=1 24 | fi 25 | 26 | bad_globals=`nm -g --defined-only $builddir/../libmpeg2/convert/*.o |\ 27 | awk '{if ($3) print $3}' | grep -v '^_\?mpeg2convert_'` 28 | 29 | if test x"$bad_globals" != x""; then 30 | echo BAD GLOBAL SYMBOLS: 31 | for s in $bad_globals; do echo $s; done 32 | error=1 33 | fi 34 | 35 | exit $error 36 | -------------------------------------------------------------------------------- /test/regression: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if test x"$srcdir" != x""; then 4 | builddir="." # running from make check, but it does not define that 5 | else 6 | srcdir=`echo "$0" | sed 's,[^/]*$,,'` 7 | test "$srcdir" = "$0" && srcdir=. 8 | test -z "$srcdir" && srcdir=. 9 | builddir="$srcdir" # running manually, have to assume 10 | fi 11 | 12 | srcdir=`cd $srcdir;pwd` 13 | builddir=`cd $builddir;pwd` 14 | 15 | testfile="$srcdir/tests" 16 | if [ $# -ge 1 ]; then testfile="$1"; fi 17 | 18 | dirs=`cut -d '#' -f 1 $testfile` 19 | 20 | basedir=`head -n 1 $testfile | awk '{print $2}'` 21 | cd $srcdir; if [ ! -d $basedir ]; then 22 | cd ..; if [ ! -d $basedir ]; then exit 77; fi # for make distcheck 23 | fi 24 | basedir=`cd $basedir;pwd` 25 | 26 | # choose between c_md5 and mmx_md5 (based on the idct you use) 27 | md5=c.md5 28 | accel="-c" 29 | if [ $# -ge 2 -a x"$2" != x"c" ]; then md5="$2.md5"; accel=""; fi 30 | 31 | cd $builddir 32 | error=0 33 | 34 | rm -fr data 35 | mkdir data 36 | cd data 37 | 38 | mpeg2dec="../../src/mpeg2dec"; if [ ! -x $mpeg2dec ]; then 39 | if [ -x ../../vc++/Release/mpeg2dec.exe ]; then 40 | mpeg2dec="../../vc++/Release/mpeg2dec.exe" 41 | basedir=`echo "$basedir" | sed "s,/cygdrive/\(.\)/,\1:/,"` 42 | elif [ -x ../../vc++/Debug/mpeg2dec.exe ]; then 43 | mpeg2dec="../../vc++/Debug/mpeg2dec.exe" 44 | basedir=`echo "$basedir" | sed "s,/cygdrive/\(.\)/,\1:/,"` 45 | else 46 | echo "Can not find mpeg2dec executable"; exit 1 47 | fi 48 | fi 49 | 50 | for dir in $dirs; do 51 | if [ -f $basedir/$dir/stream ]; then 52 | echo $dir 53 | $mpeg2dec -vvvv $accel -o md5 $basedir/$dir/stream >dump 2>&1 >md5 54 | if [ ! -f $basedir/$dir/$md5 ]; then 55 | echo MISSING FILE $dir/$md5 56 | elif [ ! -f $basedir/$dir/IGNORE-MD5 ]; then 57 | diff -wu md5 $basedir/$dir/$md5 || error=1 58 | fi 59 | if [ ! -f $basedir/$dir/dump ]; then 60 | echo MISSING FILE $dir/dump 61 | else 62 | sed '1d' dump | diff -wu - $basedir/$dir/dump || error=1 63 | fi 64 | rm -f md5 dump core 65 | else 66 | echo missing file $dir/stream 67 | fi 68 | done 69 | 70 | cd .. 71 | rmdir data 72 | 73 | exit $error 74 | -------------------------------------------------------------------------------- /test/tek-525: -------------------------------------------------------------------------------- 1 | #basedir ../../streams/tek/525 2 | 3 | 100b/015 # OK 4 | 100b/040 # OK 5 | 100b/060 # OK 6 | 100b/080 # OK 7 | 100b/120 # OK 8 | #100b/180 # FAIL - 4:2:2 chroma 9 | #100b/400 # FAIL - 4:2:2 chroma 10 | 11 | bbc3/015 # OK 12 | bbc3/040 # OK 13 | bbc3/060 # OK 14 | bbc3/080 # OK 15 | bbc3/120 # OK 16 | #bbc3/180 # FAIL - 4:2:2 chroma 17 | #bbc3/400 # FAIL - 4:2:2 chroma 18 | 19 | cact/015 # OK 20 | cact/040 # OK 21 | cact/060 # OK 22 | cact/080 # OK 23 | cact/120 # OK 24 | #cact/180 # FAIL - 4:2:2 chroma 25 | #cact/400 # FAIL - 4:2:2 chroma 26 | 27 | flwr/015 # OK 28 | flwr/040 # OK 29 | flwr/060 # OK 30 | flwr/080 # OK 31 | flwr/120 # OK 32 | #flwr/180 # FAIL - 4:2:2 chroma 33 | #flwr/400 # FAIL - 4:2:2 chroma 34 | 35 | mobl/015 # OK 36 | mobl/040 # OK 37 | mobl/060 # OK 38 | mobl/080 # OK 39 | mobl/120 # OK 40 | #mobl/180 # FAIL - 4:2:2 chroma 41 | #mobl/400 # FAIL - 4:2:2 chroma 42 | 43 | mulb/015 # OK 44 | mulb/040 # OK 45 | mulb/060 # OK 46 | mulb/080 # OK 47 | mulb/120 # OK 48 | #mulb/180 # FAIL - 4:2:2 chroma 49 | #mulb/400 # FAIL - 4:2:2 chroma 50 | 51 | pulb/015 # OK 52 | pulb/040 # OK 53 | pulb/060 # OK 54 | pulb/080 # OK 55 | pulb/120 # OK 56 | #pulb/180 # FAIL - 4:2:2 chroma 57 | #pulb/400 # FAIL - 4:2:2 chroma 58 | 59 | susi/015 # OK 60 | susi/040 # OK 61 | susi/060 # OK 62 | susi/080 # OK 63 | susi/120 # OK 64 | #susi/180 # FAIL - 4:2:2 chroma 65 | #susi/400 # FAIL - 4:2:2 chroma 66 | 67 | tens/015 # OK 68 | tens/040 # OK 69 | tens/060 # OK 70 | tens/080 # OK 71 | tens/120 # OK 72 | #tens/180 # FAIL - 4:2:2 chroma 73 | #tens/400 # FAIL - 4:2:2 chroma 74 | 75 | time/015 # OK 76 | time/040 # OK 77 | time/060 # OK 78 | time/080 # OK 79 | time/120 # OK 80 | #time/180 # FAIL - 4:2:2 chroma 81 | #time/400 # FAIL - 4:2:2 chroma 82 | 83 | v700/015 # OK 84 | v700/040 # OK 85 | v700/060 # OK 86 | v700/080 # OK 87 | v700/120 # OK 88 | #v700/180 # FAIL - 4:2:2 chroma 89 | #v700/400 # FAIL - 4:2:2 chroma 90 | -------------------------------------------------------------------------------- /test/tek-625: -------------------------------------------------------------------------------- 1 | #basedir ../../streams/tek/625 2 | 3 | 100b/015 # OK 4 | 100b/040 # OK 5 | 100b/060 # OK 6 | 100b/080 # OK 7 | 100b/120 # OK 8 | #100b/180 # FAIL - 4:2:2 chroma 9 | #100b/400 # FAIL - 4:2:2 chroma 10 | 11 | bbc3/015 # OK 12 | bbc3/040 # OK 13 | bbc3/060 # OK 14 | bbc3/080 # OK 15 | bbc3/120 # OK 16 | #bbc3/180 # FAIL - 4:2:2 chroma 17 | #bbc3/400 # FAIL - 4:2:2 chroma 18 | 19 | cact/015 # OK 20 | cact/040 # OK 21 | cact/060 # OK 22 | cact/080 # OK 23 | cact/120 # OK 24 | #cact/180 # FAIL - 4:2:2 chroma 25 | #cact/400 # FAIL - 4:2:2 chroma 26 | 27 | flwr/015 # OK 28 | flwr/040 # OK 29 | flwr/060 # OK 30 | flwr/080 # OK 31 | flwr/120 # OK 32 | #flwr/180 # FAIL - 4:2:2 chroma 33 | #flwr/400 # FAIL - 4:2:2 chroma 34 | 35 | mobl/015 # OK 36 | mobl/040 # OK 37 | mobl/060 # OK 38 | mobl/080 # OK 39 | mobl/120 # OK 40 | #mobl/180 # FAIL - 4:2:2 chroma 41 | #mobl/400 # FAIL - 4:2:2 chroma 42 | 43 | mulb/015 # OK 44 | mulb/040 # OK 45 | mulb/060 # OK 46 | mulb/080 # OK 47 | mulb/120 # OK 48 | #mulb/180 # FAIL - 4:2:2 chroma 49 | #mulb/400 # FAIL - 4:2:2 chroma 50 | 51 | pulb/015 # OK 52 | pulb/040 # OK 53 | pulb/060 # OK 54 | pulb/080 # OK 55 | pulb/120 # OK 56 | #pulb/180 # FAIL - 4:2:2 chroma 57 | #pulb/400 # FAIL - 4:2:2 chroma 58 | 59 | susi/015 # OK 60 | susi/040 # OK 61 | susi/060 # OK 62 | susi/080 # OK 63 | susi/120 # OK 64 | #susi/180 # FAIL - 4:2:2 chroma 65 | #susi/400 # FAIL - 4:2:2 chroma 66 | 67 | tens/015 # OK 68 | tens/040 # OK 69 | tens/060 # OK 70 | tens/080 # OK 71 | tens/120 # OK 72 | #tens/180 # FAIL - 4:2:2 chroma 73 | #tens/400 # FAIL - 4:2:2 chroma 74 | 75 | time/015 # OK 76 | time/040 # OK 77 | time/060 # OK 78 | time/080 # OK 79 | time/120 # OK 80 | #time/180 # FAIL - 4:2:2 chroma 81 | #time/400 # FAIL - 4:2:2 chroma 82 | 83 | v700/015 # OK 84 | v700/040 # OK 85 | v700/060 # OK 86 | v700/080 # OK 87 | v700/120 # OK 88 | #v700/180 # FAIL - 4:2:2 chroma 89 | #v700/400 # FAIL - 4:2:2 chroma 90 | -------------------------------------------------------------------------------- /test/tests: -------------------------------------------------------------------------------- 1 | #basedir ../../streams 2 | 3 | teracom/teracom_vlc4 # OK - test all VLC tables 4 | att/att_mismatch # OK - IDCT accuracy 5 | compcore/ccm1 # OK - IDCT overflow 6 | tek/Tek-5-long # OK - all macroblock types 7 | tek/Tek-5.2 # OK - all macroblock types 8 | ccett/mcp10ccett # OK - MC accuracy 9 | tcela/tcela-17-dots # OK - long-range motion vectors 10 | ti/TI_c1_2 # OK - field MC, interp 11 | lep/bits_conf_lep_11 # OK - parser performance 12 | sony/sony-ct1 # OK - field pictures, parsing flags 13 | sony/sony-ct2 # OK - field pictures, parsing flags 14 | sony/sony-ct3 # OK - field pictures, parsing flags 15 | sony/sony-ct4 # OK - field pictures, parsing flags 16 | hhi/hhi_burst_long # OK - field pictures, burst 17 | hhi/hhi_burst_short # OK - field pictures, burst 18 | tcela/tcela-10-killer # OK - field pictures, 16x8 MC bandwidth 19 | tcela/tcela-8-fp-dp # OK - field pictures, DMV MC bandwidth 20 | tcela/tcela-9-fp-dp # OK - field pictures, DMV MC bandwidth 21 | tcela/tcela-16-matrices # OK - mpeg1 - quant matrixes transposition 22 | tcela/tcela-19-wide # OK - mpeg1 - wide picture size 23 | tcela/tcela-18-d-pict # OK - mpeg1 - D pictures 24 | mei/MEI.stream16.long # OK - mpeg1 25 | mei/MEI.stream16v2 # OK - mpeg1 26 | ibm/ibm-bw-v3 # OK - DMV, decoder bandwidth, skipped MB 27 | tcela/tcela-14-bff-dp # OK - DMV bottom first, MC bandwidth 28 | tcela/tcela-14-bff-dp-short # OK - DMV bottom first, MC bandwidth 29 | nokia/nokia6-60 # OK - DMV, MC bandwidth 30 | nokia/nokia6 # OK - DMV, MC bandwidth 31 | nokia/nokia_7 # OK - DMV, MC bandwidth 32 | ntr/ntr_skipped_v3 # OK - DMV, low delay, skipped pictures 33 | toshiba/toshiba_DPall-0 # OK - DMV, MC bandwidth 34 | gi/gi4 # OK - intra dc precision, MC bandwidth 35 | gi/gi6 # OK - intra dc precision, MC bandwidth 36 | gi/gi7 # OK - intra dc precision, MC bandwidth 37 | gi/gi_9 # OK - intra dc precision, MC bandwidth 38 | gi/gi_from_tape # OK - intra dc precision, MC bandwidth 39 | mei/mei.2conftest.4f # OK - vbv buffer size 40 | mei/mei.2conftest.60f.new # OK - vbv buffer size 41 | tceh/tceh_conf2 # OK - vbv buffer size 42 | tcela/tcela-6-slices # OK - short slices 43 | tcela/tcela-7-slices # OK - short slices 44 | tcela/tcela-15-stuffing # OK - huge amounts of stuffing 45 | 46 | # 4:2:2 profile test suite 47 | 422-profile/Tek6-422-bigBpic-long # OK - 4:2:2 48 | 422-profile/Tek6-422-bigBpic # OK - 4:2:2 49 | 422-profile/Tek7-422-smallSlices-long # OK - 4:2:2 - 4 quant matrix 50 | 422-profile/Tek7-422-smallSlices # OK - 4:2:2 - 4 quant matrix 51 | 422-profile/Tek8-422-16x8inBpics-long # OK - 4:2:2 - 4 quant matrix 52 | 422-profile/Tek8-422-16x8inBpics # OK - 4:2:2 - 4 quant matrix 53 | 422-profile/hhi_burst_422-long # OK - 4:2:2 - 4 quant matrix 54 | 422-profile/hhi_burst_422 # OK - 4:2:2 - 4 quant matrix 55 | 422-profile/ibm_dp_intra_422 # OK - 4:2:2 56 | 422-profile/sony_422_id01-1 # OK - 4:2:2 - 4 quant matrix 57 | 422-profile/sony_422_id03-1 # OK - 4:2:2 - 4 quant matrix 58 | 422-profile/sony_422_id13-1 # OK - 4:2:2 - 4 quant matrix 59 | 422-profile/Tek9-422-uniformVLC-long # IGNORE - 4:2:2 - IDCT overflow 60 | 422-profile/Tek9-422-uniformVLC # IGNORE - 4:2:2 - IDCT overflow 61 | 62 | # The twilight zone streams are not part of the official mpeg2 test suite 63 | twilight_zone/walken/chroma_444 # OK - 4:4:4 chroma format 64 | twilight_zone/walken/mpeg1_full_pix # OK - mpeg1 full pixel MC 65 | twilight_zone/walken/mpeg1_stuffing # OK - mpeg1 macroblk stuffing 66 | twilight_zone/walken/mpeg1_start_slice # IGNORE - bad slice start mba 67 | twilight_zone/walken/mpeg1_slice # IGNORE - general slice struct 68 | twilight_zone/walken/repeat_sequence_bitrate # OK - variable bitrate value 69 | twilight_zone/walken/repeat_sequence_aspect # OK - variable aspect ratio 70 | twilight_zone/walken/progressive_12x12 # OK - progressive sequence 71 | twilight_zone/walken/interlaced_12x12 # OK - nonprogressive sequence 72 | twilight_zone/walken/very_high # OK - very high picture 73 | twilight_zone/walken/very_wide # OK - very wide picture 74 | twilight_zone/anonymous/anonymous # OK 75 | twilight_zone/chromatic/chroma_dct_type-1 # OK 76 | twilight_zone/tcela/tcela-12 # OK - IDCT drift - see 7.4.4 77 | twilight_zone/mei/MEI.stream17.long # OK - different img sizes 78 | twilight_zone/mei/MEI2.stream17 # OK - different img sizes 79 | twilight_zone/tcela/tcela-11v2 # IGNORE - IDCT overflow 80 | # We're actually doing better than the reference decoder on tcela-11v2 81 | -------------------------------------------------------------------------------- /vc++/Makefile.am: -------------------------------------------------------------------------------- 1 | DISTCLEANFILES = cpu_accel.obj rgb_mmx.obj cpu_state.obj \ 2 | idct_mmx.obj motion_comp_mmx.obj 3 | 4 | EXTRA_DIST = config.h inttypes.h libmpeg2.dsp libmpeg2convert.dsp \ 5 | libvo.dsp mpeg2dec.dsp mpeg2dec.dsw $(DISTCLEANFILES) 6 | 7 | WIN_GCC = i586-mingw32msvc-gcc \ 8 | -I$(top_srcdir)/include -I$(top_builddir)/include \ 9 | -Wall -Werror -O3 -fomit-frame-pointer -mcpu=pentiumpro 10 | 11 | cpu_accel.obj: FORCE 12 | $(WIN_GCC) -c $(top_srcdir)/libmpeg2/cpu_accel.c -o cpu_accel.obj 13 | 14 | cpu_state.obj: FORCE 15 | $(WIN_GCC) -c $(top_srcdir)/libmpeg2/cpu_state.c -o cpu_state.obj 16 | 17 | idct_mmx.obj: FORCE 18 | $(WIN_GCC) -c $(top_srcdir)/libmpeg2/idct_mmx.c -o idct_mmx.obj 19 | 20 | motion_comp_mmx.obj: FORCE 21 | $(WIN_GCC) -c $(top_srcdir)/libmpeg2/motion_comp_mmx.c -o motion_comp_mmx.obj 22 | 23 | rgb_mmx.obj: FORCE 24 | $(WIN_GCC) -c $(top_srcdir)/libmpeg2/convert/rgb_mmx.c -o rgb_mmx.obj 25 | 26 | FORCE: 27 | -------------------------------------------------------------------------------- /vc++/config.h: -------------------------------------------------------------------------------- 1 | /* vc++/config.h - manually adapted from include/config.h.in */ 2 | 3 | /* Suppress warnings relating to mismatched declarations */ 4 | #pragma warning (disable:4028) 5 | 6 | /* autodetect accelerations */ 7 | #define ACCEL_DETECT 8 | 9 | /* alpha architecture */ 10 | /* #undef ARCH_ALPHA */ 11 | 12 | /* ppc architecture */ 13 | /* #undef ARCH_PPC */ 14 | 15 | /* sparc architecture */ 16 | /* #undef ARCH_SPARC */ 17 | 18 | /* x86 architecture */ 19 | #define ARCH_X86 20 | 21 | /* maximum supported data alignment */ 22 | /* #undef ATTRIBUTE_ALIGNED_MAX */ 23 | 24 | /* debug mode configuration */ 25 | /* #undef DEBUG */ 26 | 27 | /* Define to 1 if you have the header file. */ 28 | /* #undef HAVE_ALTIVEC_H */ 29 | 30 | /* Define if you have the `__builtin_expect' function. */ 31 | /* #undef HAVE_BUILTIN_EXPECT */ 32 | 33 | /* Define to 1 if you have the header file. */ 34 | /* #undef HAVE_DLFCN_H */ 35 | 36 | /* Define to 1 if you have the `ftime' function. */ 37 | #define HAVE_FTIME 1 38 | 39 | /* Define to 1 if you have the `gettimeofday' function. */ 40 | /* #undef HAVE_GETTIMEOFDAY */ 41 | 42 | /* Define to 1 if you have the header file. */ 43 | /* #undef HAVE_INTTYPES_H */ 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #define HAVE_IO_H 1 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #define HAVE_MEMORY_H 1 50 | 51 | /* Define to 1 if you have the header file. */ 52 | /* #undef HAVE_STDINT_H */ 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #define HAVE_STDLIB_H 1 56 | 57 | /* Define to 1 if you have the header file. */ 58 | /* #undef HAVE_STRINGS_H */ 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #define HAVE_STRING_H 1 62 | 63 | /* Define to 1 if the system has the type `struct timeval'. */ 64 | /* #undef HAVE_STRUCT_TIMEVAL */ 65 | 66 | /* Define to 1 if you have the header file. */ 67 | #define HAVE_SYS_STAT_H 1 68 | 69 | /* Define to 1 if you have the header file. */ 70 | #define HAVE_SYS_TIMEB_H 1 71 | 72 | /* Define to 1 if you have the header file. */ 73 | /* #undef HAVE_SYS_TIME_H */ 74 | 75 | /* Define to 1 if you have the header file. */ 76 | #define HAVE_SYS_TYPES_H 1 77 | 78 | /* Define to 1 if you have the header file. */ 79 | /* #undef HAVE_TIME_H */ 80 | 81 | /* Define to 1 if you have the header file. */ 82 | /* #undef HAVE_UNISTD_H */ 83 | 84 | /* libvo DirectX support */ 85 | #define LIBVO_DX 86 | 87 | /* libvo SDL support */ 88 | /* #undef LIBVO_SDL */ 89 | 90 | /* libvo X11 support */ 91 | /* #undef LIBVO_X11 */ 92 | 93 | /* libvo Xv support */ 94 | /* #undef LIBVO_XV */ 95 | 96 | /* mpeg2dec profiling */ 97 | /* #undef MPEG2DEC_GPROF */ 98 | 99 | /* Name of package */ 100 | #define PACKAGE "mpeg2dec" 101 | 102 | /* Define to the address where bug reports for this package should be sent. */ 103 | #define PACKAGE_BUGREPORT "" 104 | 105 | /* Define to the full name of this package. */ 106 | #define PACKAGE_NAME "" 107 | 108 | /* Define to the full name and version of this package. */ 109 | #define PACKAGE_STRING "" 110 | 111 | /* Define to the one symbol short name of this package. */ 112 | #define PACKAGE_TARNAME "" 113 | 114 | /* Define to the version of this package. */ 115 | #define PACKAGE_VERSION "" 116 | 117 | /* Define as the return type of signal handlers (`int' or `void'). */ 118 | #define RETSIGTYPE void 119 | 120 | /* The size of a `char', as computed by sizeof. */ 121 | #define SIZEOF_CHAR 1 122 | 123 | /* The size of a `int', as computed by sizeof. */ 124 | #define SIZEOF_INT 4 125 | 126 | /* The size of a `long', as computed by sizeof. */ 127 | #define SIZEOF_LONG 4 128 | 129 | /* The size of a `short', as computed by sizeof. */ 130 | #define SIZEOF_SHORT 2 131 | 132 | /* The size of a `void*', as computed by sizeof. */ 133 | #define SIZEOF_VOIDP 4 134 | 135 | /* Define to 1 if you have the ANSI C header files. */ 136 | #define STDC_HEADERS 1 137 | 138 | /* Define to 1 if you can safely include both and . */ 139 | /* #undef TIME_WITH_SYS_TIME */ 140 | 141 | /* Version number of package */ 142 | #define VERSION "0.5.1" 143 | 144 | /* Define to 1 if your processor stores words with the most significant byte 145 | first (like Motorola and SPARC, unlike Intel and VAX). */ 146 | /* #undef WORDS_BIGENDIAN */ 147 | 148 | /* Define to 1 if the X Window System is missing or not being used. */ 149 | #define X_DISPLAY_MISSING 1 150 | 151 | /* Number of bits in a file offset, on hosts where this is settable. */ 152 | /* #undef _FILE_OFFSET_BITS */ 153 | 154 | /* Define for large files, on AIX-style hosts. */ 155 | /* #undef _LARGE_FILES */ 156 | 157 | /* Define to empty if `const' does not conform to ANSI C. */ 158 | /* #undef const */ 159 | 160 | /* Define to `__inline__' or `__inline' if that's what the C compiler 161 | calls it, or to nothing if 'inline' is not supported under any name. */ 162 | #ifndef __cplusplus 163 | #define inline __inline 164 | #endif 165 | 166 | /* Define as `__restrict' if that's what the C compiler calls it, or to 167 | nothing if it is not supported. */ 168 | #define restrict __restrict 169 | 170 | /* Define to `unsigned' if does not define. */ 171 | /* #undef size_t */ 172 | 173 | /* Define to empty if the keyword `volatile' does not work. Warning: valid 174 | code using `volatile' can become incorrect without. Disable with care. */ 175 | /* #undef volatile */ 176 | -------------------------------------------------------------------------------- /vc++/cpu_accel.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco-open-source/libmpeg2/5e8464c4011985d31a4042acea23f1023d8c7a75/vc++/cpu_accel.obj -------------------------------------------------------------------------------- /vc++/cpu_state.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco-open-source/libmpeg2/5e8464c4011985d31a4042acea23f1023d8c7a75/vc++/cpu_state.obj -------------------------------------------------------------------------------- /vc++/idct_mmx.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco-open-source/libmpeg2/5e8464c4011985d31a4042acea23f1023d8c7a75/vc++/idct_mmx.obj -------------------------------------------------------------------------------- /vc++/inttypes.h: -------------------------------------------------------------------------------- 1 | typedef signed char int8_t; 2 | typedef signed short int16_t; 3 | typedef signed int int32_t; 4 | 5 | typedef unsigned char uint8_t; 6 | typedef unsigned short uint16_t; 7 | typedef unsigned int uint32_t; 8 | -------------------------------------------------------------------------------- /vc++/libmpeg2.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libmpeg2" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libmpeg2 - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libmpeg2.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libmpeg2.mak" CFG="libmpeg2 - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libmpeg2 - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libmpeg2 - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libmpeg2 - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "." /I "../include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "libmpeg2 - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "libmpeg2 - Win32 Release" 82 | # Name "libmpeg2 - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\libmpeg2\alloc.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=..\libmpeg2\decode.c 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=..\libmpeg2\header.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\libmpeg2\idct.c 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=..\libmpeg2\motion_comp.c 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=..\libmpeg2\slice.c 109 | # End Source File 110 | # Begin Source File 111 | 112 | SOURCE=.\cpu_accel.obj 113 | # End Source File 114 | # Begin Source File 115 | 116 | SOURCE=.\cpu_state.obj 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=.\idct_mmx.obj 121 | # End Source File 122 | # Begin Source File 123 | 124 | SOURCE=.\motion_comp_mmx.obj 125 | # End Source File 126 | # End Group 127 | # Begin Group "Header Files" 128 | 129 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 130 | # Begin Source File 131 | 132 | SOURCE=..\include\mpeg2.h 133 | # End Source File 134 | # Begin Source File 135 | 136 | SOURCE=..\libmpeg2\mpeg2_internal.h 137 | # End Source File 138 | # Begin Source File 139 | 140 | SOURCE=..\libmpeg2\vlc.h 141 | # End Source File 142 | # End Group 143 | # End Target 144 | # End Project 145 | -------------------------------------------------------------------------------- /vc++/libmpeg2convert.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libmpeg2convert" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libmpeg2convert - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libmpeg2convert.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libmpeg2convert.mak" CFG="libmpeg2convert - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libmpeg2convert - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libmpeg2convert - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libmpeg2convert - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "." /I "../include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "libmpeg2convert - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "libmpeg2convert - Win32 Release" 82 | # Name "libmpeg2convert - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\libmpeg2\convert\rgb.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=.\rgb_mmx.obj 93 | # End Source File 94 | # End Group 95 | # Begin Group "Header Files" 96 | 97 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 98 | # Begin Source File 99 | 100 | SOURCE=..\include\mpeg2.h 101 | # End Source File 102 | # End Group 103 | # End Target 104 | # End Project 105 | -------------------------------------------------------------------------------- /vc++/libvo.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="libvo" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Static Library" 0x0104 6 | 7 | CFG=libvo - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "libvo.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "libvo.mak" CFG="libvo - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "libvo - Win32 Release" (based on "Win32 (x86) Static Library") 21 | !MESSAGE "libvo - Win32 Debug" (based on "Win32 (x86) Static Library") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "libvo - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "." /I "../include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LIB32=link.exe -lib 51 | # ADD BASE LIB32 /nologo 52 | # ADD LIB32 /nologo 53 | 54 | !ELSEIF "$(CFG)" == "libvo - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../include" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LIB32=link.exe -lib 74 | # ADD BASE LIB32 /nologo 75 | # ADD LIB32 /nologo 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "libvo - Win32 Release" 82 | # Name "libvo - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\libvo\video_out.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=..\libvo\video_out_dx.c 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=..\libvo\video_out_null.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\libvo\video_out_pgm.c 101 | # End Source File 102 | # Begin Source File 103 | 104 | SOURCE=..\libvo\video_out_sdl.c 105 | # End Source File 106 | # Begin Source File 107 | 108 | SOURCE=..\libvo\video_out_x11.c 109 | # End Source File 110 | # End Group 111 | # Begin Group "Header Files" 112 | 113 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 114 | # Begin Source File 115 | 116 | SOURCE=..\include\video_out.h 117 | # End Source File 118 | # Begin Source File 119 | 120 | SOURCE=..\libvo\video_out_internal.h 121 | # End Source File 122 | # End Group 123 | # End Target 124 | # End Project 125 | -------------------------------------------------------------------------------- /vc++/motion_comp_mmx.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco-open-source/libmpeg2/5e8464c4011985d31a4042acea23f1023d8c7a75/vc++/motion_comp_mmx.obj -------------------------------------------------------------------------------- /vc++/mpeg2dec.dsp: -------------------------------------------------------------------------------- 1 | # Microsoft Developer Studio Project File - Name="mpeg2dec" - Package Owner=<4> 2 | # Microsoft Developer Studio Generated Build File, Format Version 6.00 3 | # ** DO NOT EDIT ** 4 | 5 | # TARGTYPE "Win32 (x86) Console Application" 0x0103 6 | 7 | CFG=mpeg2dec - Win32 Debug 8 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, 9 | !MESSAGE use the Export Makefile command and run 10 | !MESSAGE 11 | !MESSAGE NMAKE /f "mpeg2dec.mak". 12 | !MESSAGE 13 | !MESSAGE You can specify a configuration when running NMAKE 14 | !MESSAGE by defining the macro CFG on the command line. For example: 15 | !MESSAGE 16 | !MESSAGE NMAKE /f "mpeg2dec.mak" CFG="mpeg2dec - Win32 Debug" 17 | !MESSAGE 18 | !MESSAGE Possible choices for configuration are: 19 | !MESSAGE 20 | !MESSAGE "mpeg2dec - Win32 Release" (based on "Win32 (x86) Console Application") 21 | !MESSAGE "mpeg2dec - Win32 Debug" (based on "Win32 (x86) Console Application") 22 | !MESSAGE 23 | 24 | # Begin Project 25 | # PROP AllowPerConfigDependencies 0 26 | # PROP Scc_ProjName "" 27 | # PROP Scc_LocalPath "" 28 | CPP=cl.exe 29 | RSC=rc.exe 30 | 31 | !IF "$(CFG)" == "mpeg2dec - Win32 Release" 32 | 33 | # PROP BASE Use_MFC 0 34 | # PROP BASE Use_Debug_Libraries 0 35 | # PROP BASE Output_Dir "Release" 36 | # PROP BASE Intermediate_Dir "Release" 37 | # PROP BASE Target_Dir "" 38 | # PROP Use_MFC 0 39 | # PROP Use_Debug_Libraries 0 40 | # PROP Output_Dir "Release" 41 | # PROP Intermediate_Dir "Release" 42 | # PROP Target_Dir "" 43 | # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c 44 | # ADD CPP /nologo /W3 /GX /O2 /I "." /I "../include" /I "../src" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /YX /FD /c 45 | # ADD BASE RSC /l 0x409 /d "NDEBUG" 46 | # ADD RSC /l 0x409 /d "NDEBUG" 47 | BSC32=bscmake.exe 48 | # ADD BASE BSC32 /nologo 49 | # ADD BSC32 /nologo 50 | LINK32=link.exe 51 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 52 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 53 | 54 | !ELSEIF "$(CFG)" == "mpeg2dec - Win32 Debug" 55 | 56 | # PROP BASE Use_MFC 0 57 | # PROP BASE Use_Debug_Libraries 1 58 | # PROP BASE Output_Dir "Debug" 59 | # PROP BASE Intermediate_Dir "Debug" 60 | # PROP BASE Target_Dir "" 61 | # PROP Use_MFC 0 62 | # PROP Use_Debug_Libraries 1 63 | # PROP Output_Dir "Debug" 64 | # PROP Intermediate_Dir "Debug" 65 | # PROP Target_Dir "" 66 | # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c 67 | # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "." /I "../include" /I "../src" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "HAVE_CONFIG_H" /YX /FD /GZ /c 68 | # ADD BASE RSC /l 0x409 /d "_DEBUG" 69 | # ADD RSC /l 0x409 /d "_DEBUG" 70 | BSC32=bscmake.exe 71 | # ADD BASE BSC32 /nologo 72 | # ADD BSC32 /nologo 73 | LINK32=link.exe 74 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 75 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept 76 | 77 | !ENDIF 78 | 79 | # Begin Target 80 | 81 | # Name "mpeg2dec - Win32 Release" 82 | # Name "mpeg2dec - Win32 Debug" 83 | # Begin Group "Source Files" 84 | 85 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" 86 | # Begin Source File 87 | 88 | SOURCE=..\src\dump_state.c 89 | # End Source File 90 | # Begin Source File 91 | 92 | SOURCE=..\src\getopt.c 93 | # End Source File 94 | # Begin Source File 95 | 96 | SOURCE=..\src\gettimeofday.c 97 | # End Source File 98 | # Begin Source File 99 | 100 | SOURCE=..\src\mpeg2dec.c 101 | # End Source File 102 | # End Group 103 | # Begin Group "Header Files" 104 | 105 | # PROP Default_Filter "h;hpp;hxx;hm;inl" 106 | # Begin Source File 107 | 108 | SOURCE=..\src\getopt.h 109 | # End Source File 110 | # End Group 111 | # Begin Group "Resource Files" 112 | 113 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" 114 | # End Group 115 | # End Target 116 | # End Project 117 | -------------------------------------------------------------------------------- /vc++/mpeg2dec.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "libmpeg2"=".\libmpeg2.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Project: "libmpeg2convert"=".\libmpeg2convert.dsp" - Package Owner=<4> 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<4> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | Project: "libvo"=".\libvo.dsp" - Package Owner=<4> 31 | 32 | Package=<5> 33 | {{{ 34 | }}} 35 | 36 | Package=<4> 37 | {{{ 38 | }}} 39 | 40 | ############################################################################### 41 | 42 | Project: "mpeg2dec"=".\mpeg2dec.dsp" - Package Owner=<4> 43 | 44 | Package=<5> 45 | {{{ 46 | }}} 47 | 48 | Package=<4> 49 | {{{ 50 | Begin Project Dependency 51 | Project_Dep_Name libmpeg2 52 | End Project Dependency 53 | Begin Project Dependency 54 | Project_Dep_Name libmpeg2convert 55 | End Project Dependency 56 | Begin Project Dependency 57 | Project_Dep_Name libvo 58 | End Project Dependency 59 | }}} 60 | 61 | ############################################################################### 62 | 63 | Global: 64 | 65 | Package=<5> 66 | {{{ 67 | }}} 68 | 69 | Package=<3> 70 | {{{ 71 | }}} 72 | 73 | ############################################################################### 74 | 75 | -------------------------------------------------------------------------------- /vc++/rgb_mmx.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cisco-open-source/libmpeg2/5e8464c4011985d31a4042acea23f1023d8c7a75/vc++/rgb_mmx.obj --------------------------------------------------------------------------------