summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmpeg3
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmpeg3') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmpeg3/.cvsignore5
-rw-r--r--core/multimedia/opieplayer/libmpeg3/COPYING340
-rw-r--r--core/multimedia/opieplayer/libmpeg3/Makefile.in774
-rw-r--r--core/multimedia/opieplayer/libmpeg3/README35
-rw-r--r--core/multimedia/opieplayer/libmpeg3/VERSION1
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/Makefile35
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/ac3.c691
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/ac3.h308
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/bit_allocation.c586
-rwxr-xr-xcore/multimedia/opieplayer/libmpeg3/audio/c_flags1
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/dct.c1135
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/exponents.c141
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/fptables.h1556
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/header.c163
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/huffman.h355
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/layer1.c6
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/layer2.c418
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/layer3.c1254
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/mantissa.c387
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.c536
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.h144
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h232
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/pcm.c51
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/synthesizers.c174
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/tables.c554
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/tables.h88
-rw-r--r--core/multimedia/opieplayer/libmpeg3/audio/uncouple.c135
-rw-r--r--core/multimedia/opieplayer/libmpeg3/bitstream.c167
-rw-r--r--core/multimedia/opieplayer/libmpeg3/bitstream.h207
-rwxr-xr-xcore/multimedia/opieplayer/libmpeg3/c_flags4
-rwxr-xr-xcore/multimedia/opieplayer/libmpeg3/configure102
-rw-r--r--core/multimedia/opieplayer/libmpeg3/docs/index.html306
-rw-r--r--core/multimedia/opieplayer/libmpeg3/dump.c79
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3.c672
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3.h175
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3.pro42
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.cpp105
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h113
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp70
-rw-r--r--core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h53
-rwxr-xr-xcore/multimedia/opieplayer/libmpeg3/make_package10
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3atrack.c36
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3atrack.h36
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3cat.c225
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3css.c32
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3css.h29
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.c19
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.h29
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3demux.c1849
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3demux.h118
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3io.c127
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3io.h74
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3private.h62
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3private.inc110
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3protos.h278
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3title.c63
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3title.h47
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3toc.c81
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.c33
-rw-r--r--core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.h39
-rw-r--r--core/multimedia/opieplayer/libmpeg3/ronin_narrow.toc26
-rw-r--r--core/multimedia/opieplayer/libmpeg3/ronin_wide.toc47
-rw-r--r--core/multimedia/opieplayer/libmpeg3/timecode.h31
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/Makefile32
-rwxr-xr-xcore/multimedia/opieplayer/libmpeg3/video/c_flags1
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/getpicture.c767
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/headers.c492
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/idct.c160
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/idct.h24
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/layerdata.h35
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/macroblocks.c338
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/mmxidct.S675
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/mmxtest.c35
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/motion.c230
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/mpeg3video.c597
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/mpeg3video.h180
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/mpeg3videoprotos.h26
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/output.c993
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/reconmmx.s301
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/reconstruct.c1290
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/seek.c233
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/slice.c702
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/slice.h194
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/vlc.c421
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/vlc.h164
-rw-r--r--core/multimedia/opieplayer/libmpeg3/video/worksheet.c30
86 files changed, 23521 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libmpeg3/.cvsignore b/core/multimedia/opieplayer/libmpeg3/.cvsignore
new file mode 100644
index 0000000..d7bb3c1
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/.cvsignore
@@ -0,0 +1,5 @@
1global_config
2dump
3mpeg3toc
4mpeg3cat
5Makefile
diff --git a/core/multimedia/opieplayer/libmpeg3/COPYING b/core/multimedia/opieplayer/libmpeg3/COPYING
new file mode 100644
index 0000000..60549be
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/COPYING
@@ -0,0 +1,340 @@
1 GNU GENERAL PUBLIC LICENSE
2 Version 2, June 1991
3
4 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6 Everyone is permitted to copy and distribute verbatim copies
7 of this license document, but changing it is not allowed.
8
9 Preamble
10
11 The licenses for most software are designed to take away your
12freedom to share and change it. By contrast, the GNU General Public
13License is intended to guarantee your freedom to share and change free
14software--to make sure the software is free for all its users. This
15General Public License applies to most of the Free Software
16Foundation's software and to any other program whose authors commit to
17using it. (Some other Free Software Foundation software is covered by
18the GNU Library General Public License instead.) You can apply it to
19your programs, too.
20
21 When we speak of free software, we are referring to freedom, not
22price. Our General Public Licenses are designed to make sure that you
23have the freedom to distribute copies of free software (and charge for
24this service if you wish), that you receive source code or can get it
25if you want it, that you can change the software or use pieces of it
26in new free programs; and that you know you can do these things.
27
28 To protect your rights, we need to make restrictions that forbid
29anyone to deny you these rights or to ask you to surrender the rights.
30These restrictions translate to certain responsibilities for you if you
31distribute copies of the software, or if you modify it.
32
33 For example, if you distribute copies of such a program, whether
34gratis or for a fee, you must give the recipients all the rights that
35you have. You must make sure that they, too, receive or can get the
36source code. And you must show them these terms so they know their
37rights.
38
39 We protect your rights with two steps: (1) copyright the software, and
40(2) offer you this license which gives you legal permission to copy,
41distribute and/or modify the software.
42
43 Also, for each author's protection and ours, we want to make certain
44that everyone understands that there is no warranty for this free
45software. If the software is modified by someone else and passed on, we
46want its recipients to know that what they have is not the original, so
47that any problems introduced by others will not reflect on the original
48authors' reputations.
49
50 Finally, any free program is threatened constantly by software
51patents. We wish to avoid the danger that redistributors of a free
52program will individually obtain patent licenses, in effect making the
53program proprietary. To prevent this, we have made it clear that any
54patent must be licensed for everyone's free use or not licensed at all.
55
56 The precise terms and conditions for copying, distribution and
57modification follow.
58
59 GNU GENERAL PUBLIC LICENSE
60 TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62 0. This License applies to any program or other work which contains
63a notice placed by the copyright holder saying it may be distributed
64under the terms of this General Public License. The "Program", below,
65refers to any such program or work, and a "work based on the Program"
66means either the Program or any derivative work under copyright law:
67that is to say, a work containing the Program or a portion of it,
68either verbatim or with modifications and/or translated into another
69language. (Hereinafter, translation is included without limitation in
70the term "modification".) Each licensee is addressed as "you".
71
72Activities other than copying, distribution and modification are not
73covered by this License; they are outside its scope. The act of
74running the Program is not restricted, and the output from the Program
75is covered only if its contents constitute a work based on the
76Program (independent of having been made by running the Program).
77Whether that is true depends on what the Program does.
78
79 1. You may copy and distribute verbatim copies of the Program's
80source code as you receive it, in any medium, provided that you
81conspicuously and appropriately publish on each copy an appropriate
82copyright notice and disclaimer of warranty; keep intact all the
83notices that refer to this License and to the absence of any warranty;
84and give any other recipients of the Program a copy of this License
85along with the Program.
86
87You may charge a fee for the physical act of transferring a copy, and
88you may at your option offer warranty protection in exchange for a fee.
89
90 2. You may modify your copy or copies of the Program or any portion
91of it, thus forming a work based on the Program, and copy and
92distribute such modifications or work under the terms of Section 1
93above, provided that you also meet all of these conditions:
94
95 a) You must cause the modified files to carry prominent notices
96 stating that you changed the files and the date of any change.
97
98 b) You must cause any work that you distribute or publish, that in
99 whole or in part contains or is derived from the Program or any
100 part thereof, to be licensed as a whole at no charge to all third
101 parties under the terms of this License.
102
103 c) If the modified program normally reads commands interactively
104 when run, you must cause it, when started running for such
105 interactive use in the most ordinary way, to print or display an
106 announcement including an appropriate copyright notice and a
107 notice that there is no warranty (or else, saying that you provide
108 a warranty) and that users may redistribute the program under
109 these conditions, and telling the user how to view a copy of this
110 License. (Exception: if the Program itself is interactive but
111 does not normally print such an announcement, your work based on
112 the Program is not required to print an announcement.)
113
114These requirements apply to the modified work as a whole. If
115identifiable sections of that work are not derived from the Program,
116and can be reasonably considered independent and separate works in
117themselves, then this License, and its terms, do not apply to those
118sections when you distribute them as separate works. But when you
119distribute the same sections as part of a whole which is a work based
120on the Program, the distribution of the whole must be on the terms of
121this License, whose permissions for other licensees extend to the
122entire whole, and thus to each and every part regardless of who wrote it.
123
124Thus, it is not the intent of this section to claim rights or contest
125your rights to work written entirely by you; rather, the intent is to
126exercise the right to control the distribution of derivative or
127collective works based on the Program.
128
129In addition, mere aggregation of another work not based on the Program
130with the Program (or with a work based on the Program) on a volume of
131a storage or distribution medium does not bring the other work under
132the scope of this License.
133
134 3. You may copy and distribute the Program (or a work based on it,
135under Section 2) in object code or executable form under the terms of
136Sections 1 and 2 above provided that you also do one of the following:
137
138 a) Accompany it with the complete corresponding machine-readable
139 source code, which must be distributed under the terms of Sections
140 1 and 2 above on a medium customarily used for software interchange; or,
141
142 b) Accompany it with a written offer, valid for at least three
143 years, to give any third party, for a charge no more than your
144 cost of physically performing source distribution, a complete
145 machine-readable copy of the corresponding source code, to be
146 distributed under the terms of Sections 1 and 2 above on a medium
147 customarily used for software interchange; or,
148
149 c) Accompany it with the information you received as to the offer
150 to distribute corresponding source code. (This alternative is
151 allowed only for noncommercial distribution and only if you
152 received the program in object code or executable form with such
153 an offer, in accord with Subsection b above.)
154
155The source code for a work means the preferred form of the work for
156making modifications to it. For an executable work, complete source
157code means all the source code for all modules it contains, plus any
158associated interface definition files, plus the scripts used to
159control compilation and installation of the executable. However, as a
160special exception, the source code distributed need not include
161anything that is normally distributed (in either source or binary
162form) with the major components (compiler, kernel, and so on) of the
163operating system on which the executable runs, unless that component
164itself accompanies the executable.
165
166If distribution of executable or object code is made by offering
167access to copy from a designated place, then offering equivalent
168access to copy the source code from the same place counts as
169distribution of the source code, even though third parties are not
170compelled to copy the source along with the object code.
171
172 4. You may not copy, modify, sublicense, or distribute the Program
173except as expressly provided under this License. Any attempt
174otherwise to copy, modify, sublicense or distribute the Program is
175void, and will automatically terminate your rights under this License.
176However, parties who have received copies, or rights, from you under
177this License will not have their licenses terminated so long as such
178parties remain in full compliance.
179
180 5. You are not required to accept this License, since you have not
181signed it. However, nothing else grants you permission to modify or
182distribute the Program or its derivative works. These actions are
183prohibited by law if you do not accept this License. Therefore, by
184modifying or distributing the Program (or any work based on the
185Program), you indicate your acceptance of this License to do so, and
186all its terms and conditions for copying, distributing or modifying
187the Program or works based on it.
188
189 6. Each time you redistribute the Program (or any work based on the
190Program), the recipient automatically receives a license from the
191original licensor to copy, distribute or modify the Program subject to
192these terms and conditions. You may not impose any further
193restrictions on the recipients' exercise of the rights granted herein.
194You are not responsible for enforcing compliance by third parties to
195this License.
196
197 7. If, as a consequence of a court judgment or allegation of patent
198infringement or for any other reason (not limited to patent issues),
199conditions are imposed on you (whether by court order, agreement or
200otherwise) that contradict the conditions of this License, they do not
201excuse you from the conditions of this License. If you cannot
202distribute so as to satisfy simultaneously your obligations under this
203License and any other pertinent obligations, then as a consequence you
204may not distribute the Program at all. For example, if a patent
205license would not permit royalty-free redistribution of the Program by
206all those who receive copies directly or indirectly through you, then
207the only way you could satisfy both it and this License would be to
208refrain entirely from distribution of the Program.
209
210If any portion of this section is held invalid or unenforceable under
211any particular circumstance, the balance of the section is intended to
212apply and the section as a whole is intended to apply in other
213circumstances.
214
215It is not the purpose of this section to induce you to infringe any
216patents or other property right claims or to contest validity of any
217such claims; this section has the sole purpose of protecting the
218integrity of the free software distribution system, which is
219implemented by public license practices. Many people have made
220generous contributions to the wide range of software distributed
221through that system in reliance on consistent application of that
222system; it is up to the author/donor to decide if he or she is willing
223to distribute software through any other system and a licensee cannot
224impose that choice.
225
226This section is intended to make thoroughly clear what is believed to
227be a consequence of the rest of this License.
228
229 8. If the distribution and/or use of the Program is restricted in
230certain countries either by patents or by copyrighted interfaces, the
231original copyright holder who places the Program under this License
232may add an explicit geographical distribution limitation excluding
233those countries, so that distribution is permitted only in or among
234countries not thus excluded. In such case, this License incorporates
235the limitation as if written in the body of this License.
236
237 9. The Free Software Foundation may publish revised and/or new versions
238of the General Public License from time to time. Such new versions will
239be similar in spirit to the present version, but may differ in detail to
240address new problems or concerns.
241
242Each version is given a distinguishing version number. If the Program
243specifies a version number of this License which applies to it and "any
244later version", you have the option of following the terms and conditions
245either of that version or of any later version published by the Free
246Software Foundation. If the Program does not specify a version number of
247this License, you may choose any version ever published by the Free Software
248Foundation.
249
250 10. If you wish to incorporate parts of the Program into other free
251programs whose distribution conditions are different, write to the author
252to ask for permission. For software which is copyrighted by the Free
253Software Foundation, write to the Free Software Foundation; we sometimes
254make exceptions for this. Our decision will be guided by the two goals
255of preserving the free status of all derivatives of our free software and
256of promoting the sharing and reuse of software generally.
257
258 NO WARRANTY
259
260 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268REPAIR OR CORRECTION.
269
270 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278POSSIBILITY OF SUCH DAMAGES.
279
280 END OF TERMS AND CONDITIONS
281
282 How to Apply These Terms to Your New Programs
283
284 If you develop a new program, and you want it to be of the greatest
285possible use to the public, the best way to achieve this is to make it
286free software which everyone can redistribute and change under these terms.
287
288 To do so, attach the following notices to the program. It is safest
289to attach them to the start of each source file to most effectively
290convey the exclusion of warranty; and each file should have at least
291the "copyright" line and a pointer to where the full notice is found.
292
293 <one line to give the program's name and a brief idea of what it does.>
294 Copyright (C) 19yy <name of author>
295
296 This program is free software; you can redistribute it and/or modify
297 it under the terms of the GNU General Public License as published by
298 the Free Software Foundation; either version 2 of the License, or
299 (at your option) any later version.
300
301 This program is distributed in the hope that it will be useful,
302 but WITHOUT ANY WARRANTY; without even the implied warranty of
303 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 GNU General Public License for more details.
305
306 You should have received a copy of the GNU General Public License
307 along with this program; if not, write to the Free Software
308 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
310
311Also add information on how to contact you by electronic and paper mail.
312
313If the program is interactive, make it output a short notice like this
314when it starts in an interactive mode:
315
316 Gnomovision version 69, Copyright (C) 19yy name of author
317 Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318 This is free software, and you are welcome to redistribute it
319 under certain conditions; type `show c' for details.
320
321The hypothetical commands `show w' and `show c' should show the appropriate
322parts of the General Public License. Of course, the commands you use may
323be called something other than `show w' and `show c'; they could even be
324mouse-clicks or menu items--whatever suits your program.
325
326You should also get your employer (if you work as a programmer) or your
327school, if any, to sign a "copyright disclaimer" for the program, if
328necessary. Here is a sample; alter the names:
329
330 Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331 `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333 <signature of Ty Coon>, 1 April 1989
334 Ty Coon, President of Vice
335
336This General Public License does not permit incorporating your program into
337proprietary programs. If your program is a subroutine library, you may
338consider it more useful to permit linking proprietary applications with the
339library. If this is what you want to do, use the GNU Library General
340Public License instead of this License.
diff --git a/core/multimedia/opieplayer/libmpeg3/Makefile.in b/core/multimedia/opieplayer/libmpeg3/Makefile.in
new file mode 100644
index 0000000..1817902
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/Makefile.in
@@ -0,0 +1,774 @@
1#############################################################################
2
3####### Compiler, tools and options
4
5 CXX =$(SYSCONF_CXX) $(QT_CXX_MT)
6 CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) $(SYSCONF_CXXFLAGS_LIB) -DQCONFIG=\"qpe\"
7 CC =$(SYSCONF_CC) $(QT_C_MT)
8 CFLAGS =$(SYSCONF_CFLAGS) $(SYSCONF_CFLAGS_LIB) -DQCONFIG=\"qpe\"
9 INCPATH =-I$(QPEDIR)/include -I..
10 LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT)
11 LIBS =$(SUBLIBS) -lqpe -lpthread -lm $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS_QTAPP)
12 MOC =$(SYSCONF_MOC)
13 UIC =$(SYSCONF_UIC)
14
15####### Target
16
17DESTDIR = ../../plugins/codecs/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= mpeg3plugin
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =libmpeg3plugin.h \
27 libmpeg3pluginimpl.h
28 SOURCES =libmpeg3plugin.cpp \
29 libmpeg3pluginimpl.cpp \
30 bitstream.c \
31 libmpeg3.c \
32 mpeg3atrack.c \
33 mpeg3css.c \
34 mpeg3demux.c \
35 mpeg3io.c \
36 mpeg3title.c \
37 mpeg3vtrack.c \
38 audio/ac3.c \
39 audio/bit_allocation.c \
40 audio/dct.c \
41 audio/exponents.c \
42 audio/header.c \
43 audio/layer2.c \
44 audio/layer3.c \
45 audio/mantissa.c \
46 audio/mpeg3audio.c \
47 audio/pcm.c \
48 audio/synthesizers.c \
49 audio/tables.c \
50 video/getpicture.c \
51 video/headers.c \
52 video/idct.c \
53 video/macroblocks.c \
54 video/mmxtest.c \
55 video/motion.c \
56 video/mpeg3video.c \
57 video/output.c \
58 video/reconstruct.c \
59 video/seek.c \
60 video/slice.c \
61 video/vlc.c
62 OBJECTS =libmpeg3plugin.o \
63 libmpeg3pluginimpl.o \
64 bitstream.o \
65 libmpeg3.o \
66 mpeg3atrack.o \
67 mpeg3css.o \
68 mpeg3demux.o \
69 mpeg3io.o \
70 mpeg3title.o \
71 mpeg3vtrack.o \
72 audio/ac3.o \
73 audio/bit_allocation.o \
74 audio/dct.o \
75 audio/exponents.o \
76 audio/header.o \
77 audio/layer2.o \
78 audio/layer3.o \
79 audio/mantissa.o \
80 audio/mpeg3audio.o \
81 audio/pcm.o \
82 audio/synthesizers.o \
83 audio/tables.o \
84 video/getpicture.o \
85 video/headers.o \
86 video/idct.o \
87 video/macroblocks.o \
88 video/mmxtest.o \
89 video/motion.o \
90 video/mpeg3video.o \
91 video/output.o \
92 video/reconstruct.o \
93 video/seek.o \
94 video/slice.o \
95 video/vlc.o
96INTERFACES =
97UICDECLS =
98UICIMPLS =
99 SRCMOC =
100 OBJMOC =
101
102
103####### Implicit rules
104
105.SUFFIXES: .cpp .cxx .cc .C .c
106
107.cpp.o:
108 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
109
110.cxx.o:
111 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
112
113.cc.o:
114 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
115
116.C.o:
117 $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
118
119.c.o:
120 $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
121
122####### Build rules
123
124
125all: $(DESTDIR)$(SYSCONF_LINK_TARGET)
126
127$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
128 $(SYSCONF_LINK_LIB)
129
130moc: $(SRCMOC)
131
132tmake:
133 tmake libmpeg3.pro
134
135clean:
136 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
137 -rm -f *~ core
138 -rm -f allmoc.cpp
139
140####### Extension Modules
141
142listpromodules:
143 @echo
144
145listallmodules:
146 @echo
147
148listaddonpromodules:
149 @echo
150
151listaddonentmodules:
152 @echo
153
154
155REQUIRES=
156
157####### Sub-libraries
158
159
160###### Combined headers
161
162
163
164####### Compile
165
166libmpeg3plugin.o: libmpeg3plugin.cpp \
167 libmpeg3plugin.h \
168 libmpeg3.h \
169 mpeg3private.h \
170 mpeg3atrack.h \
171 mpeg3demux.h \
172 mpeg3title.h \
173 mpeg3io.h \
174 mpeg3css.h \
175 mpeg3private.inc \
176 audio/mpeg3audio.h \
177 mpeg3vtrack.h \
178 video/mpeg3video.h \
179 mpeg3protos.h \
180 ../mediaplayerplugininterface.h
181
182libmpeg3pluginimpl.o: libmpeg3pluginimpl.cpp \
183 libmpeg3plugin.h \
184 libmpeg3.h \
185 mpeg3private.h \
186 mpeg3atrack.h \
187 mpeg3demux.h \
188 mpeg3title.h \
189 mpeg3io.h \
190 mpeg3css.h \
191 mpeg3private.inc \
192 audio/mpeg3audio.h \
193 mpeg3vtrack.h \
194 video/mpeg3video.h \
195 mpeg3protos.h \
196 ../mediaplayerplugininterface.h \
197 libmpeg3pluginimpl.h \
198 ../mediaplayerplugininterface.h
199
200bitstream.o: bitstream.c \
201 mpeg3private.h \
202 mpeg3atrack.h \
203 mpeg3demux.h \
204 mpeg3title.h \
205 mpeg3io.h \
206 mpeg3css.h \
207 mpeg3private.inc \
208 audio/mpeg3audio.h \
209 mpeg3vtrack.h \
210 video/mpeg3video.h \
211 mpeg3protos.h
212
213libmpeg3.o: libmpeg3.c \
214 libmpeg3.h \
215 mpeg3private.h \
216 mpeg3atrack.h \
217 mpeg3demux.h \
218 mpeg3title.h \
219 mpeg3io.h \
220 mpeg3css.h \
221 mpeg3private.inc \
222 audio/mpeg3audio.h \
223 mpeg3vtrack.h \
224 video/mpeg3video.h \
225 mpeg3protos.h
226
227mpeg3atrack.o: mpeg3atrack.c \
228 libmpeg3.h \
229 mpeg3private.h \
230 mpeg3atrack.h \
231 mpeg3demux.h \
232 mpeg3title.h \
233 mpeg3io.h \
234 mpeg3css.h \
235 mpeg3private.inc \
236 audio/mpeg3audio.h \
237 mpeg3vtrack.h \
238 video/mpeg3video.h \
239 mpeg3protos.h
240
241mpeg3css.o: mpeg3css.c \
242 mpeg3css.h \
243 mpeg3private.h \
244 mpeg3atrack.h \
245 mpeg3demux.h \
246 mpeg3title.h \
247 mpeg3io.h \
248 mpeg3private.inc \
249 audio/mpeg3audio.h \
250 mpeg3vtrack.h \
251 video/mpeg3video.h
252
253mpeg3demux.o: mpeg3demux.c \
254 libmpeg3.h \
255 mpeg3private.h \
256 mpeg3atrack.h \
257 mpeg3demux.h \
258 mpeg3title.h \
259 mpeg3io.h \
260 mpeg3css.h \
261 mpeg3private.inc \
262 audio/mpeg3audio.h \
263 mpeg3vtrack.h \
264 video/mpeg3video.h \
265 mpeg3protos.h
266
267mpeg3io.o: mpeg3io.c \
268 mpeg3private.h \
269 mpeg3atrack.h \
270 mpeg3demux.h \
271 mpeg3title.h \
272 mpeg3io.h \
273 mpeg3css.h \
274 mpeg3private.inc \
275 audio/mpeg3audio.h \
276 mpeg3vtrack.h \
277 video/mpeg3video.h \
278 mpeg3protos.h
279
280mpeg3title.o: mpeg3title.c \
281 mpeg3private.h \
282 mpeg3atrack.h \
283 mpeg3demux.h \
284 mpeg3title.h \
285 mpeg3io.h \
286 mpeg3css.h \
287 mpeg3private.inc \
288 audio/mpeg3audio.h \
289 mpeg3vtrack.h \
290 video/mpeg3video.h \
291 mpeg3protos.h
292
293mpeg3vtrack.o: mpeg3vtrack.c \
294 libmpeg3.h \
295 mpeg3private.h \
296 mpeg3atrack.h \
297 mpeg3demux.h \
298 mpeg3title.h \
299 mpeg3io.h \
300 mpeg3css.h \
301 mpeg3private.inc \
302 audio/mpeg3audio.h \
303 mpeg3vtrack.h \
304 video/mpeg3video.h \
305 mpeg3protos.h
306
307audio/ac3.o: audio/ac3.c \
308 audio/mpeg3audio.h \
309 audio/ac3.h \
310 audio/mpeg3real.h \
311 audio/../bitstream.h \
312 mpeg3demux.h \
313 mpeg3title.h \
314 mpeg3io.h \
315 mpeg3css.h \
316 mpeg3private.inc \
317 audio/../libmpeg3.h \
318 mpeg3private.h \
319 mpeg3atrack.h \
320 audio/mpeg3audio.h \
321 mpeg3vtrack.h \
322 video/mpeg3video.h \
323 audio/../mpeg3protos.h
324
325audio/bit_allocation.o: audio/bit_allocation.c \
326 audio/mpeg3audio.h \
327 audio/ac3.h \
328 audio/mpeg3real.h \
329 audio/../bitstream.h \
330 mpeg3demux.h \
331 mpeg3title.h \
332 mpeg3io.h \
333 mpeg3css.h \
334 mpeg3private.inc \
335 audio/../libmpeg3.h \
336 mpeg3private.h \
337 mpeg3atrack.h \
338 audio/mpeg3audio.h \
339 mpeg3vtrack.h \
340 video/mpeg3video.h \
341 audio/../mpeg3protos.h
342
343audio/dct.o: audio/dct.c \
344 audio/mpeg3audio.h \
345 audio/ac3.h \
346 audio/mpeg3real.h \
347 audio/../bitstream.h \
348 mpeg3demux.h \
349 mpeg3title.h \
350 mpeg3io.h \
351 mpeg3css.h \
352 mpeg3private.inc \
353 audio/../libmpeg3.h \
354 mpeg3private.h \
355 mpeg3atrack.h \
356 audio/mpeg3audio.h \
357 mpeg3vtrack.h \
358 video/mpeg3video.h \
359 audio/../mpeg3protos.h \
360 audio/tables.h \
361 audio/fptables.h
362
363audio/exponents.o: audio/exponents.c \
364 audio/mpeg3audio.h \
365 audio/ac3.h \
366 audio/mpeg3real.h \
367 audio/../bitstream.h \
368 mpeg3demux.h \
369 mpeg3title.h \
370 mpeg3io.h \
371 mpeg3css.h \
372 mpeg3private.inc \
373 audio/../libmpeg3.h \
374 mpeg3private.h \
375 mpeg3atrack.h \
376 audio/mpeg3audio.h \
377 mpeg3vtrack.h \
378 video/mpeg3video.h \
379 audio/../mpeg3protos.h
380
381audio/header.o: audio/header.c \
382 audio/mpeg3audio.h \
383 audio/ac3.h \
384 audio/mpeg3real.h \
385 audio/../bitstream.h \
386 mpeg3demux.h \
387 mpeg3title.h \
388 mpeg3io.h \
389 mpeg3css.h \
390 mpeg3private.inc \
391 audio/tables.h \
392 audio/../libmpeg3.h \
393 mpeg3private.h \
394 mpeg3atrack.h \
395 audio/mpeg3audio.h \
396 mpeg3vtrack.h \
397 video/mpeg3video.h \
398 audio/../mpeg3protos.h
399
400audio/layer2.o: audio/layer2.c \
401 audio/mpeg3audio.h \
402 audio/ac3.h \
403 audio/mpeg3real.h \
404 audio/../bitstream.h \
405 mpeg3demux.h \
406 mpeg3title.h \
407 mpeg3io.h \
408 mpeg3css.h \
409 mpeg3private.inc \
410 audio/../libmpeg3.h \
411 mpeg3private.h \
412 mpeg3atrack.h \
413 audio/mpeg3audio.h \
414 mpeg3vtrack.h \
415 video/mpeg3video.h \
416 audio/../mpeg3protos.h \
417 audio/tables.h
418
419audio/layer3.o: audio/layer3.c \
420 audio/huffman.h \
421 audio/mpeg3audio.h \
422 audio/ac3.h \
423 audio/mpeg3real.h \
424 audio/../bitstream.h \
425 mpeg3demux.h \
426 mpeg3title.h \
427 mpeg3io.h \
428 mpeg3css.h \
429 mpeg3private.inc \
430 audio/../libmpeg3.h \
431 mpeg3private.h \
432 mpeg3atrack.h \
433 audio/mpeg3audio.h \
434 mpeg3vtrack.h \
435 video/mpeg3video.h \
436 audio/../mpeg3protos.h \
437 audio/tables.h
438
439audio/mantissa.o: audio/mantissa.c \
440 audio/mpeg3audio.h \
441 audio/ac3.h \
442 audio/mpeg3real.h \
443 audio/../bitstream.h \
444 mpeg3demux.h \
445 mpeg3title.h \
446 mpeg3io.h \
447 mpeg3css.h \
448 mpeg3private.inc \
449 audio/../libmpeg3.h \
450 mpeg3private.h \
451 mpeg3atrack.h \
452 audio/mpeg3audio.h \
453 mpeg3vtrack.h \
454 video/mpeg3video.h \
455 audio/../mpeg3protos.h
456
457audio/mpeg3audio.o: audio/mpeg3audio.c \
458 audio/../libmpeg3.h \
459 mpeg3private.h \
460 mpeg3atrack.h \
461 mpeg3demux.h \
462 mpeg3title.h \
463 mpeg3io.h \
464 mpeg3css.h \
465 mpeg3private.inc \
466 audio/mpeg3audio.h \
467 audio/ac3.h \
468 audio/mpeg3real.h \
469 audio/../bitstream.h \
470 mpeg3vtrack.h \
471 video/mpeg3video.h \
472 audio/../mpeg3protos.h \
473 audio/mpeg3audio.h \
474 audio/tables.h
475
476audio/pcm.o: audio/pcm.c \
477 audio/mpeg3audio.h \
478 audio/ac3.h \
479 audio/mpeg3real.h \
480 audio/../bitstream.h \
481 mpeg3demux.h \
482 mpeg3title.h \
483 mpeg3io.h \
484 mpeg3css.h \
485 mpeg3private.inc \
486 audio/../libmpeg3.h \
487 mpeg3private.h \
488 mpeg3atrack.h \
489 audio/mpeg3audio.h \
490 mpeg3vtrack.h \
491 video/mpeg3video.h \
492 audio/../mpeg3protos.h
493
494audio/synthesizers.o: audio/synthesizers.c \
495 audio/mpeg3audio.h \
496 audio/ac3.h \
497 audio/mpeg3real.h \
498 audio/../bitstream.h \
499 mpeg3demux.h \
500 mpeg3title.h \
501 mpeg3io.h \
502 mpeg3css.h \
503 mpeg3private.inc \
504 audio/../libmpeg3.h \
505 mpeg3private.h \
506 mpeg3atrack.h \
507 audio/mpeg3audio.h \
508 mpeg3vtrack.h \
509 video/mpeg3video.h \
510 audio/../mpeg3protos.h \
511 audio/tables.h
512
513audio/tables.o: audio/tables.c \
514 audio/mpeg3audio.h \
515 audio/ac3.h \
516 audio/mpeg3real.h \
517 audio/../bitstream.h \
518 mpeg3demux.h \
519 mpeg3title.h \
520 mpeg3io.h \
521 mpeg3css.h \
522 mpeg3private.inc \
523 audio/../libmpeg3.h \
524 mpeg3private.h \
525 mpeg3atrack.h \
526 audio/mpeg3audio.h \
527 mpeg3vtrack.h \
528 video/mpeg3video.h \
529 audio/../mpeg3protos.h \
530 audio/tables.h \
531 audio/fptables.h
532
533video/getpicture.o: video/getpicture.c \
534 audio/../libmpeg3.h \
535 mpeg3private.h \
536 mpeg3atrack.h \
537 mpeg3demux.h \
538 mpeg3title.h \
539 mpeg3io.h \
540 mpeg3css.h \
541 mpeg3private.inc \
542 audio/mpeg3audio.h \
543 audio/ac3.h \
544 audio/mpeg3real.h \
545 audio/../bitstream.h \
546 mpeg3vtrack.h \
547 video/mpeg3video.h \
548 video/../mpeg3private.inc \
549 video/idct.h \
550 video/slice.h \
551 video/../timecode.h \
552 video/../mpeg3protos.h \
553 video/mpeg3video.h \
554 video/vlc.h
555
556video/headers.o: video/headers.c \
557 video/../mpeg3demux.h \
558 mpeg3title.h \
559 mpeg3io.h \
560 mpeg3css.h \
561 mpeg3private.inc \
562 audio/../libmpeg3.h \
563 mpeg3private.h \
564 mpeg3atrack.h \
565 mpeg3demux.h \
566 audio/mpeg3audio.h \
567 audio/ac3.h \
568 audio/mpeg3real.h \
569 audio/../bitstream.h \
570 mpeg3vtrack.h \
571 video/mpeg3video.h \
572 video/../mpeg3private.inc \
573 video/idct.h \
574 video/slice.h \
575 video/../timecode.h \
576 video/../mpeg3protos.h \
577 video/mpeg3video.h
578
579video/idct.o: video/idct.c \
580 video/idct.h
581
582video/macroblocks.o: video/macroblocks.c \
583 audio/../libmpeg3.h \
584 mpeg3private.h \
585 mpeg3atrack.h \
586 mpeg3demux.h \
587 mpeg3title.h \
588 mpeg3io.h \
589 mpeg3css.h \
590 mpeg3private.inc \
591 audio/mpeg3audio.h \
592 audio/ac3.h \
593 audio/mpeg3real.h \
594 audio/../bitstream.h \
595 mpeg3vtrack.h \
596 video/mpeg3video.h \
597 video/../mpeg3private.inc \
598 video/idct.h \
599 video/slice.h \
600 video/../timecode.h \
601 video/../mpeg3protos.h \
602 video/mpeg3video.h \
603 video/vlc.h
604
605video/mmxtest.o: video/mmxtest.c \
606 audio/../libmpeg3.h \
607 mpeg3private.h \
608 mpeg3atrack.h \
609 mpeg3demux.h \
610 mpeg3title.h \
611 mpeg3io.h \
612 mpeg3css.h \
613 mpeg3private.inc \
614 audio/mpeg3audio.h \
615 audio/ac3.h \
616 audio/mpeg3real.h \
617 audio/../bitstream.h \
618 mpeg3vtrack.h \
619 video/mpeg3video.h \
620 video/../mpeg3private.inc \
621 video/idct.h \
622 video/slice.h \
623 video/../timecode.h \
624 video/../mpeg3protos.h
625
626video/motion.o: video/motion.c \
627 video/mpeg3video.h \
628 audio/../bitstream.h \
629 mpeg3demux.h \
630 mpeg3title.h \
631 mpeg3io.h \
632 mpeg3css.h \
633 mpeg3private.inc \
634 video/../mpeg3private.inc \
635 video/idct.h \
636 video/slice.h \
637 video/../timecode.h \
638 audio/../libmpeg3.h \
639 mpeg3private.h \
640 mpeg3atrack.h \
641 audio/mpeg3audio.h \
642 audio/ac3.h \
643 audio/mpeg3real.h \
644 mpeg3vtrack.h \
645 video/mpeg3video.h \
646 video/../mpeg3protos.h \
647 video/vlc.h
648
649video/mpeg3video.o: video/mpeg3video.c \
650 audio/../libmpeg3.h \
651 mpeg3private.h \
652 mpeg3atrack.h \
653 mpeg3demux.h \
654 mpeg3title.h \
655 mpeg3io.h \
656 mpeg3css.h \
657 mpeg3private.inc \
658 audio/mpeg3audio.h \
659 audio/ac3.h \
660 audio/mpeg3real.h \
661 audio/../bitstream.h \
662 mpeg3vtrack.h \
663 video/mpeg3video.h \
664 video/../mpeg3private.inc \
665 video/idct.h \
666 video/slice.h \
667 video/../timecode.h \
668 video/../mpeg3protos.h \
669 video/mpeg3video.h \
670 video/mpeg3videoprotos.h
671
672video/output.o: video/output.c \
673 audio/../libmpeg3.h \
674 mpeg3private.h \
675 mpeg3atrack.h \
676 mpeg3demux.h \
677 mpeg3title.h \
678 mpeg3io.h \
679 mpeg3css.h \
680 mpeg3private.inc \
681 audio/mpeg3audio.h \
682 audio/ac3.h \
683 audio/mpeg3real.h \
684 audio/../bitstream.h \
685 mpeg3vtrack.h \
686 video/mpeg3video.h \
687 video/../mpeg3private.inc \
688 video/idct.h \
689 video/slice.h \
690 video/../timecode.h \
691 video/../mpeg3protos.h \
692 video/mpeg3video.h
693
694video/reconstruct.o: video/reconstruct.c \
695 audio/../libmpeg3.h \
696 mpeg3private.h \
697 mpeg3atrack.h \
698 mpeg3demux.h \
699 mpeg3title.h \
700 mpeg3io.h \
701 mpeg3css.h \
702 mpeg3private.inc \
703 audio/mpeg3audio.h \
704 audio/ac3.h \
705 audio/mpeg3real.h \
706 audio/../bitstream.h \
707 mpeg3vtrack.h \
708 video/mpeg3video.h \
709 video/../mpeg3private.inc \
710 video/idct.h \
711 video/slice.h \
712 video/../timecode.h \
713 video/../mpeg3protos.h \
714 video/mpeg3video.h
715
716video/seek.o: video/seek.c \
717 video/../mpeg3private.h \
718 mpeg3atrack.h \
719 mpeg3demux.h \
720 mpeg3title.h \
721 mpeg3io.h \
722 mpeg3css.h \
723 mpeg3private.inc \
724 audio/mpeg3audio.h \
725 audio/ac3.h \
726 audio/mpeg3real.h \
727 audio/../bitstream.h \
728 mpeg3vtrack.h \
729 video/mpeg3video.h \
730 video/../mpeg3private.inc \
731 video/idct.h \
732 video/slice.h \
733 video/../timecode.h \
734 video/../mpeg3protos.h \
735 video/mpeg3video.h
736
737video/slice.o: video/slice.c \
738 audio/../libmpeg3.h \
739 mpeg3private.h \
740 mpeg3atrack.h \
741 mpeg3demux.h \
742 mpeg3title.h \
743 mpeg3io.h \
744 mpeg3css.h \
745 mpeg3private.inc \
746 audio/mpeg3audio.h \
747 audio/ac3.h \
748 audio/mpeg3real.h \
749 audio/../bitstream.h \
750 mpeg3vtrack.h \
751 video/mpeg3video.h \
752 video/../mpeg3private.inc \
753 video/idct.h \
754 video/slice.h \
755 video/../timecode.h \
756 video/../mpeg3protos.h \
757 video/mpeg3video.h \
758 video/mpeg3videoprotos.h
759
760video/vlc.o: video/vlc.c \
761 video/mpeg3video.h \
762 audio/../bitstream.h \
763 mpeg3demux.h \
764 mpeg3title.h \
765 mpeg3io.h \
766 mpeg3css.h \
767 mpeg3private.inc \
768 video/../mpeg3private.inc \
769 video/idct.h \
770 video/slice.h \
771 video/../timecode.h \
772 video/vlc.h
773
774
diff --git a/core/multimedia/opieplayer/libmpeg3/README b/core/multimedia/opieplayer/libmpeg3/README
new file mode 100644
index 0000000..7a2a061
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/README
@@ -0,0 +1,35 @@
1/********************************************************
2 * LibMPEG3
3 * Author: Adam Williams <broadcast@earthling.net>
4 * Page: heroine.linuxbox.com
5 *
6 * libmpeg3 is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * libmpeg3 is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Make; see the file COPYING. If not, write to
18 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 *******************************************************/
21
22
23/**********************************************************
24 * Credits:
25 *********************************************************/
26
27AC3 decoder:
28
29 Written by Aaron Holtzman (aholtzma@engr.uvic.ca)
30
31
32
33Problems:
34
35 Streams where the multiplexing packet size changes at random.
diff --git a/core/multimedia/opieplayer/libmpeg3/VERSION b/core/multimedia/opieplayer/libmpeg3/VERSION
new file mode 100644
index 0000000..55772e2
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/VERSION
@@ -0,0 +1 @@
libmpeg3-1.2.1
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/Makefile b/core/multimedia/opieplayer/libmpeg3/audio/Makefile
new file mode 100644
index 0000000..eaa0e0b
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/Makefile
@@ -0,0 +1,35 @@
1include ../global_config
2export CFLAGS
3export CFLAGS_lessopt
4
5OBJS = \
6 ac3.o \
7 bit_allocation.o \
8 dct.o \
9 exponents.o \
10 header.o \
11 layer2.o \
12 layer3.o \
13 mantissa.o \
14 mpeg3audio.o \
15 pcm.o \
16 synthesizers.o \
17 tables.o
18
19all: $(OBJS)
20
21dct.o: dct.c
22 $(CC) -c `./c_flags dct.c` -o $@ $<
23
24synthesizers.o: synthesizers.c
25 $(CC) -c `./c_flags synthesizers.c` -o $@ $<
26
27
28.c.o:
29 $(CC) -c `./c_flags` -o $@ $<
30
31.s.o:
32 $(CC) -f elf $*.s
33
34clean:
35 rm -f *.o
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/ac3.c b/core/multimedia/opieplayer/libmpeg3/audio/ac3.c
new file mode 100644
index 0000000..7a3b664
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/ac3.c
@@ -0,0 +1,691 @@
1/*
2 *
3 *ac3.c Copyright (C) Aaron Holtzman - May 1999
4 *
5 *
6 * This file is part of libmpeg3
7 *
8 * libmpeg3 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, or (at your option)
11 * any later version.
12 *
13 * libmpeg3 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 GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#include "mpeg3audio.h"
25#include "../libmpeg3.h"
26#include "../mpeg3protos.h"
27
28#include <math.h>
29#include <stdlib.h>
30#include <stdio.h>
31#include <string.h>
32
33#define MPEG3AC3_MAGIC_NUMBER 0xdeadbeef
34
35
36int mpeg3_ac3_samplerates[] = { 48000, 44100, 32000 };
37
38struct mpeg3_framesize_s
39{
40 unsigned short bit_rate;
41 unsigned short frm_size[3];
42};
43
44struct mpeg3_framesize_s framesize_codes[] =
45{
46 { 32 ,{64 ,69 ,96 } },
47 { 32 ,{64 ,70 ,96 } },
48 { 40 ,{80 ,87 ,120 } },
49 { 40 ,{80 ,88 ,120 } },
50 { 48 ,{96 ,104 ,144 } },
51 { 48 ,{96 ,105 ,144 } },
52 { 56 ,{112 ,121 ,168 } },
53 { 56 ,{112 ,122 ,168 } },
54 { 64 ,{128 ,139 ,192 } },
55 { 64 ,{128 ,140 ,192 } },
56 { 80 ,{160 ,174 ,240 } },
57 { 80 ,{160 ,175 ,240 } },
58 { 96 ,{192 ,208 ,288 } },
59 { 96 ,{192 ,209 ,288 } },
60 { 112 ,{224 ,243 ,336 } },
61 { 112 ,{224 ,244 ,336 } },
62 { 128 ,{256 ,278 ,384 } },
63 { 128 ,{256 ,279 ,384 } },
64 { 160 ,{320 ,348 ,480 } },
65 { 160 ,{320 ,349 ,480 } },
66 { 192 ,{384 ,417 ,576 } },
67 { 192 ,{384 ,418 ,576 } },
68 { 224 ,{448 ,487 ,672 } },
69 { 224 ,{448 ,488 ,672 } },
70 { 256 ,{512 ,557 ,768 } },
71 { 256 ,{512 ,558 ,768 } },
72 { 320 ,{640 ,696 ,960 } },
73 { 320 ,{640 ,697 ,960 } },
74 { 384 ,{768 ,835 ,1152 } },
75 { 384 ,{768 ,836 ,1152 } },
76 { 448 ,{896 ,975 ,1344 } },
77 { 448 ,{896 ,976 ,1344 } },
78 { 512 ,{1024 ,1114 ,1536 } },
79 { 512 ,{1024 ,1115 ,1536 } },
80 { 576 ,{1152 ,1253 ,1728 } },
81 { 576 ,{1152 ,1254 ,1728 } },
82 { 640 ,{1280 ,1393 ,1920 } },
83 { 640 ,{1280 ,1394 ,1920 } }
84};
85
86/* Audio channel modes */
87short mpeg3_ac3_acmodes[] = {2, 1, 2, 3, 3, 4, 4, 5};
88
89/* Rematrix tables */
90struct rematrix_band_s
91{
92 int start;
93 int end;
94};
95
96struct rematrix_band_s mpeg3_rematrix_band[] =
97{
98 {13, 24},
99 {25, 36},
100 {37, 60},
101 {61, 252}
102};
103
104int mpeg3_min(int x, int y)
105{
106 return (x < y) ? x : y;
107}
108
109int mpeg3_max(int x, int y)
110{
111 return (x > y) ? x : y;
112}
113
114int mpeg3audio_read_ac3_header(mpeg3audio_t *audio)
115{
116 unsigned int code, crc;
117 unsigned int i;
118 mpeg3_ac3bsi_t *bsi = &(audio->ac3_bsi);
119
120/* Get the sync code */
121 code = mpeg3bits_getbits(audio->astream, 16);
122 while(!mpeg3bits_eof(audio->astream) && code != MPEG3_AC3_START_CODE)
123 {
124 code <<= 8;
125 code &= 0xffff;
126 code |= mpeg3bits_getbits(audio->astream, 8);
127 }
128
129 if(mpeg3bits_eof(audio->astream)) return 1;
130
131/* Get crc1 - we don't actually use this data though */
132/* The crc can be the same as the sync code or come after a sync code repeated twice */
133 crc = mpeg3bits_getbits(audio->astream, 16);
134
135/* Got the sync code. Read the entire frame into a buffer if possible. */
136 if(audio->avg_framesize > 0)
137 {
138 if(mpeg3bits_read_buffer(audio->astream, audio->ac3_buffer, audio->framesize - 4))
139 return 1;
140 mpeg3bits_use_ptr(audio->astream, audio->ac3_buffer);
141 }
142
143/* Get the sampling rate code */
144 audio->sampling_frequency_code = mpeg3bits_getbits(audio->astream, 2);
145
146/* Get the frame size code */
147 audio->ac3_framesize_code = mpeg3bits_getbits(audio->astream, 6);
148
149 audio->bitrate = framesize_codes[audio->ac3_framesize_code].bit_rate;
150 audio->avg_framesize = audio->framesize = 2 * framesize_codes[audio->ac3_framesize_code].frm_size[audio->sampling_frequency_code];
151
152/* Check the AC-3 version number */
153 bsi->bsid = mpeg3bits_getbits(audio->astream, 5);
154
155/* Get the audio service provided by the steram */
156 bsi->bsmod = mpeg3bits_getbits(audio->astream, 3);
157
158/* Get the audio coding mode (ie how many channels)*/
159 bsi->acmod = mpeg3bits_getbits(audio->astream, 3);
160
161/* Predecode the number of full bandwidth channels as we use this
162 * number a lot */
163 bsi->nfchans = mpeg3_ac3_acmodes[bsi->acmod];
164 audio->channels = bsi->nfchans;
165
166/* If it is in use, get the centre channel mix level */
167 if((bsi->acmod & 0x1) && (bsi->acmod != 0x1))
168 bsi->cmixlev = mpeg3bits_getbits(audio->astream, 2);
169
170/* If it is in use, get the surround channel mix level */
171 if(bsi->acmod & 0x4)
172 bsi->surmixlev = mpeg3bits_getbits(audio->astream, 2);
173
174/* Get the dolby surround mode if in 2/0 mode */
175 if(bsi->acmod == 0x2)
176 bsi->dsurmod= mpeg3bits_getbits(audio->astream, 2);
177
178/* Is the low frequency effects channel on? */
179 bsi->lfeon = mpeg3bits_getbits(audio->astream, 1);
180
181/* Get the dialogue normalization level */
182 bsi->dialnorm = mpeg3bits_getbits(audio->astream, 5);
183
184/* Does compression gain exist? */
185 bsi->compre = mpeg3bits_getbits(audio->astream, 1);
186 if (bsi->compre)
187 {
188/* Get compression gain */
189 bsi->compr = mpeg3bits_getbits(audio->astream, 8);
190 }
191
192/* Does language code exist? */
193 bsi->langcode = mpeg3bits_getbits(audio->astream, 1);
194 if (bsi->langcode)
195 {
196/* Get langauge code */
197 bsi->langcod = mpeg3bits_getbits(audio->astream, 8);
198 }
199
200/* Does audio production info exist? */
201 bsi->audprodie = mpeg3bits_getbits(audio->astream, 1);
202 if (bsi->audprodie)
203 {
204/* Get mix level */
205 bsi->mixlevel = mpeg3bits_getbits(audio->astream, 5);
206
207/* Get room type */
208 bsi->roomtyp = mpeg3bits_getbits(audio->astream, 2);
209 }
210
211/* If we're in dual mono mode then get some extra info */
212 if (bsi->acmod == 0)
213 {
214/* Get the dialogue normalization level two */
215 bsi->dialnorm2 = mpeg3bits_getbits(audio->astream, 5);
216
217/* Does compression gain two exist? */
218 bsi->compr2e = mpeg3bits_getbits(audio->astream, 1);
219 if (bsi->compr2e)
220 {
221/* Get compression gain two */
222 bsi->compr2 = mpeg3bits_getbits(audio->astream, 8);
223 }
224
225/* Does language code two exist? */
226 bsi->langcod2e = mpeg3bits_getbits(audio->astream, 1);
227 if (bsi->langcod2e)
228 {
229/* Get langauge code two */
230 bsi->langcod2 = mpeg3bits_getbits(audio->astream, 8);
231 }
232
233/* Does audio production info two exist? */
234 bsi->audprodi2e = mpeg3bits_getbits(audio->astream, 1);
235 if (bsi->audprodi2e)
236 {
237/* Get mix level two */
238 bsi->mixlevel2 = mpeg3bits_getbits(audio->astream, 5);
239
240/* Get room type two */
241 bsi->roomtyp2 = mpeg3bits_getbits(audio->astream, 2);
242 }
243 }
244
245/* Get the copyright bit */
246 bsi->copyrightb = mpeg3bits_getbits(audio->astream, 1);
247
248/* Get the original bit */
249 bsi->origbs = mpeg3bits_getbits(audio->astream, 1);
250
251/* Does timecode one exist? */
252 bsi->timecod1e = mpeg3bits_getbits(audio->astream, 1);
253
254 if(bsi->timecod1e)
255 bsi->timecod1 = mpeg3bits_getbits(audio->astream, 14);
256
257/* Does timecode two exist? */
258 bsi->timecod2e = mpeg3bits_getbits(audio->astream, 1);
259
260 if(bsi->timecod2e)
261 bsi->timecod2 = mpeg3bits_getbits(audio->astream, 14);
262
263/* Does addition info exist? */
264 bsi->addbsie = mpeg3bits_getbits(audio->astream, 1);
265
266 if(bsi->addbsie)
267 {
268/* Get how much info is there */
269 bsi->addbsil = mpeg3bits_getbits(audio->astream, 6);
270
271/* Get the additional info */
272 for(i = 0; i < (bsi->addbsil + 1); i++)
273 bsi->addbsi[i] = mpeg3bits_getbits(audio->astream, 8);
274 }
275
276 if(mpeg3bits_eof(audio->astream))
277 {
278 mpeg3bits_use_demuxer(audio->astream);
279 return 1;
280 }
281 //return mpeg3bits_error(audio->astream);
282}
283
284int mpeg3audio_read_ac3_audblk(mpeg3audio_t *audio)
285{
286 int i, j;
287 mpeg3_ac3bsi_t *bsi = &(audio->ac3_bsi);
288 mpeg3_ac3audblk_t *audblk = &(audio->ac3_audblk);
289
290 for(i = 0; i < bsi->nfchans; i++)
291 {
292/* Is this channel an interleaved 256 + 256 block ? */
293 audblk->blksw[i] = mpeg3bits_getbits(audio->astream, 1);
294 }
295
296 for(i = 0; i < bsi->nfchans; i++)
297 {
298/* Should we dither this channel? */
299 audblk->dithflag[i] = mpeg3bits_getbits(audio->astream, 1);
300 }
301
302/* Does dynamic range control exist? */
303 audblk->dynrnge = mpeg3bits_getbits(audio->astream, 1);
304 if(audblk->dynrnge)
305 {
306/* Get dynamic range info */
307 audblk->dynrng = mpeg3bits_getbits(audio->astream, 8);
308 }
309
310/* If we're in dual mono mode then get the second channel DR info */
311 if(bsi->acmod == 0)
312 {
313/* Does dynamic range control two exist? */
314 audblk->dynrng2e = mpeg3bits_getbits(audio->astream, 1);
315 if (audblk->dynrng2e)
316 {
317/* Get dynamic range info */
318 audblk->dynrng2 = mpeg3bits_getbits(audio->astream, 8);
319 }
320 }
321
322/* Does coupling strategy exist? */
323 audblk->cplstre = mpeg3bits_getbits(audio->astream, 1);
324 if(audblk->cplstre)
325 {
326/* Is coupling turned on? */
327 audblk->cplinu = mpeg3bits_getbits(audio->astream, 1);
328 if(audblk->cplinu)
329 {
330 for(i = 0; i < bsi->nfchans; i++)
331 audblk->chincpl[i] = mpeg3bits_getbits(audio->astream, 1);
332
333 if(bsi->acmod == 0x2)
334 audblk->phsflginu = mpeg3bits_getbits(audio->astream, 1);
335
336 audblk->cplbegf = mpeg3bits_getbits(audio->astream, 4);
337 audblk->cplendf = mpeg3bits_getbits(audio->astream, 4);
338 audblk->ncplsubnd = (audblk->cplendf + 2) - audblk->cplbegf + 1;
339
340/* Calculate the start and end bins of the coupling channel */
341 audblk->cplstrtmant = (audblk->cplbegf * 12) + 37 ;
342 audblk->cplendmant = ((audblk->cplendf + 3) * 12) + 37;
343
344/* The number of combined subbands is ncplsubnd minus each combined band */
345 audblk->ncplbnd = audblk->ncplsubnd;
346
347 for(i = 1; i < audblk->ncplsubnd; i++)
348 {
349 audblk->cplbndstrc[i] = mpeg3bits_getbits(audio->astream, 1);
350 audblk->ncplbnd -= audblk->cplbndstrc[i];
351 }
352 }
353 }
354
355 if(audblk->cplinu)
356 {
357 /* Loop through all the channels and get their coupling co-ords */
358 for(i = 0; i < bsi->nfchans; i++)
359 {
360 if(!audblk->chincpl[i])
361 continue;
362
363/* Is there new coupling co-ordinate info? */
364 audblk->cplcoe[i] = mpeg3bits_getbits(audio->astream, 1);
365
366 if(audblk->cplcoe[i])
367 {
368 audblk->mstrcplco[i] = mpeg3bits_getbits(audio->astream, 2);
369 for(j = 0; j < audblk->ncplbnd; j++)
370 {
371 audblk->cplcoexp[i][j] = mpeg3bits_getbits(audio->astream, 4);
372 audblk->cplcomant[i][j] = mpeg3bits_getbits(audio->astream, 4);
373 }
374 }
375 }
376
377/* If we're in dual mono mode, there's going to be some phase info */
378 if((bsi->acmod == 0x2) && audblk->phsflginu &&
379 (audblk->cplcoe[0] || audblk->cplcoe[1]))
380 {
381 for(j = 0; j < audblk->ncplbnd; j++)
382 {
383 audblk->phsflg[j] = mpeg3bits_getbits(audio->astream, 1);
384 }
385 }
386 }
387
388/* If we're in dual mono mode, there may be a rematrix strategy */
389 if(bsi->acmod == 0x2)
390 {
391 audblk->rematstr = mpeg3bits_getbits(audio->astream, 1);
392 if(audblk->rematstr)
393 {
394 if (audblk->cplinu == 0)
395 {
396 for(i = 0; i < 4; i++)
397 audblk->rematflg[i] = mpeg3bits_getbits(audio->astream, 1);
398 }
399 if((audblk->cplbegf > 2) && audblk->cplinu)
400 {
401 for(i = 0; i < 4; i++)
402 audblk->rematflg[i] = mpeg3bits_getbits(audio->astream, 1);
403 }
404 if((audblk->cplbegf <= 2) && audblk->cplinu)
405 {
406 for(i = 0; i < 3; i++)
407 audblk->rematflg[i] = mpeg3bits_getbits(audio->astream, 1);
408 }
409 if((audblk->cplbegf == 0) && audblk->cplinu)
410 for(i = 0; i < 2; i++)
411 audblk->rematflg[i] = mpeg3bits_getbits(audio->astream, 1);
412
413 }
414 }
415
416 if (audblk->cplinu)
417 {
418/* Get the coupling channel exponent strategy */
419 audblk->cplexpstr = mpeg3bits_getbits(audio->astream, 2);
420
421 if(audblk->cplexpstr == 0)
422 audblk->ncplgrps = 0;
423 else
424 audblk->ncplgrps = (audblk->cplendmant - audblk->cplstrtmant) /
425 (3 << (audblk->cplexpstr - 1));
426
427 }
428
429 for(i = 0; i < bsi->nfchans; i++)
430 {
431 audblk->chexpstr[i] = mpeg3bits_getbits(audio->astream, 2);
432 }
433
434/* Get the exponent strategy for lfe channel */
435 if(bsi->lfeon)
436 audblk->lfeexpstr = mpeg3bits_getbits(audio->astream, 1);
437
438/* Determine the bandwidths of all the fbw channels */
439 for(i = 0; i < bsi->nfchans; i++)
440 {
441 unsigned short grp_size;
442
443 if(audblk->chexpstr[i] != MPEG3_EXP_REUSE)
444 {
445 if (audblk->cplinu && audblk->chincpl[i])
446 {
447 audblk->endmant[i] = audblk->cplstrtmant;
448 }
449 else
450 {
451 audblk->chbwcod[i] = mpeg3bits_getbits(audio->astream, 6);
452 audblk->endmant[i] = ((audblk->chbwcod[i] + 12) * 3) + 37;
453 }
454
455/* Calculate the number of exponent groups to fetch */
456 grp_size = 3 * (1 << (audblk->chexpstr[i] - 1));
457 audblk->nchgrps[i] = (audblk->endmant[i] - 1 + (grp_size - 3)) / grp_size;
458 }
459 }
460
461/* Get the coupling exponents if they exist */
462 if(audblk->cplinu && (audblk->cplexpstr != MPEG3_EXP_REUSE))
463 {
464 audblk->cplabsexp = mpeg3bits_getbits(audio->astream, 4);
465 for(i = 0; i< audblk->ncplgrps; i++)
466 audblk->cplexps[i] = mpeg3bits_getbits(audio->astream, 7);
467 }
468
469/* Get the fwb channel exponents */
470 for(i = 0; i < bsi->nfchans; i++)
471 {
472 if(audblk->chexpstr[i] != MPEG3_EXP_REUSE)
473 {
474 audblk->exps[i][0] = mpeg3bits_getbits(audio->astream, 4);
475 for(j = 1; j <= audblk->nchgrps[i]; j++)
476 audblk->exps[i][j] = mpeg3bits_getbits(audio->astream, 7);
477 audblk->gainrng[i] = mpeg3bits_getbits(audio->astream, 2);
478 }
479 }
480
481/* Get the lfe channel exponents */
482 if(bsi->lfeon && (audblk->lfeexpstr != MPEG3_EXP_REUSE))
483 {
484 audblk->lfeexps[0] = mpeg3bits_getbits(audio->astream, 4);
485 audblk->lfeexps[1] = mpeg3bits_getbits(audio->astream, 7);
486 audblk->lfeexps[2] = mpeg3bits_getbits(audio->astream, 7);
487 }
488
489/* Get the parametric bit allocation parameters */
490 audblk->baie = mpeg3bits_getbits(audio->astream, 1);
491
492 if(audblk->baie)
493 {
494 audblk->sdcycod = mpeg3bits_getbits(audio->astream, 2);
495 audblk->fdcycod = mpeg3bits_getbits(audio->astream, 2);
496 audblk->sgaincod = mpeg3bits_getbits(audio->astream, 2);
497 audblk->dbpbcod = mpeg3bits_getbits(audio->astream, 2);
498 audblk->floorcod = mpeg3bits_getbits(audio->astream, 3);
499 }
500
501
502/* Get the SNR off set info if it exists */
503 audblk->snroffste = mpeg3bits_getbits(audio->astream, 1);
504
505 if(audblk->snroffste)
506 {
507 audblk->csnroffst = mpeg3bits_getbits(audio->astream, 6);
508
509 if(audblk->cplinu)
510 {
511 audblk->cplfsnroffst = mpeg3bits_getbits(audio->astream, 4);
512 audblk->cplfgaincod = mpeg3bits_getbits(audio->astream, 3);
513 }
514
515 for(i = 0; i < bsi->nfchans; i++)
516 {
517 audblk->fsnroffst[i] = mpeg3bits_getbits(audio->astream, 4);
518 audblk->fgaincod[i] = mpeg3bits_getbits(audio->astream, 3);
519 }
520 if(bsi->lfeon)
521 {
522
523 audblk->lfefsnroffst = mpeg3bits_getbits(audio->astream, 4);
524 audblk->lfefgaincod = mpeg3bits_getbits(audio->astream, 3);
525 }
526 }
527
528/* Get coupling leakage info if it exists */
529 if(audblk->cplinu)
530 {
531 audblk->cplleake = mpeg3bits_getbits(audio->astream, 1);
532
533 if(audblk->cplleake)
534 {
535 audblk->cplfleak = mpeg3bits_getbits(audio->astream, 3);
536 audblk->cplsleak = mpeg3bits_getbits(audio->astream, 3);
537 }
538 }
539
540/* Get the delta bit alloaction info */
541 audblk->deltbaie = mpeg3bits_getbits(audio->astream, 1);
542
543 if(audblk->deltbaie)
544 {
545 if(audblk->cplinu)
546 audblk->cpldeltbae = mpeg3bits_getbits(audio->astream, 2);
547
548 for(i = 0; i < bsi->nfchans; i++)
549 audblk->deltbae[i] = mpeg3bits_getbits(audio->astream, 2);
550
551 if (audblk->cplinu && (audblk->cpldeltbae == DELTA_BIT_NEW))
552 {
553 audblk->cpldeltnseg = mpeg3bits_getbits(audio->astream, 3);
554 for(i = 0; i < audblk->cpldeltnseg + 1; i++)
555 {
556 audblk->cpldeltoffst[i] = mpeg3bits_getbits(audio->astream, 5);
557 audblk->cpldeltlen[i] = mpeg3bits_getbits(audio->astream, 4);
558 audblk->cpldeltba[i] = mpeg3bits_getbits(audio->astream, 3);
559 }
560 }
561
562 for(i = 0; i < bsi->nfchans; i++)
563 {
564 if (audblk->deltbae[i] == DELTA_BIT_NEW)
565 {
566 audblk->deltnseg[i] = mpeg3bits_getbits(audio->astream, 3);
567 for(j = 0; j < audblk->deltnseg[i] + 1; j++)
568 {
569 audblk->deltoffst[i][j] = mpeg3bits_getbits(audio->astream, 5);
570 audblk->deltlen[i][j] = mpeg3bits_getbits(audio->astream, 4);
571 audblk->deltba[i][j] = mpeg3bits_getbits(audio->astream, 3);
572 }
573 }
574 }
575 }
576
577/* Check to see if there's any dummy info to get */
578 if((audblk->skiple = mpeg3bits_getbits(audio->astream, 1)))
579 {
580 unsigned int skip_data;
581 audblk->skipl = mpeg3bits_getbits(audio->astream, 9);
582 for(i = 0; i < audblk->skipl ; i++)
583 {
584 skip_data = mpeg3bits_getbits(audio->astream, 8);
585 }
586 }
587
588 return mpeg3bits_error(audio->astream);
589}
590
591
592/* This routine simply does stereo rematrixing for the 2 channel
593 * stereo mode */
594int mpeg3audio_ac3_rematrix(mpeg3_ac3audblk_t *audblk,
595 mpeg3ac3_stream_samples_t samples)
596{
597 int num_bands;
598 int start;
599 int end;
600 int i, j;
601 mpeg3_real_t left, right;
602
603 if(audblk->cplinu || audblk->cplbegf > 2)
604 num_bands = 4;
605 else if (audblk->cplbegf > 0)
606 num_bands = 3;
607 else
608 num_bands = 2;
609
610 for(i = 0; i < num_bands; i++)
611 {
612 if(!audblk->rematflg[i])
613 continue;
614
615 start = mpeg3_rematrix_band[i].start;
616 end = mpeg3_min(mpeg3_rematrix_band[i].end, 12 * audblk->cplbegf + 36);
617
618 for(j = start; j < end; j++)
619 {
620 left = samples[0][j] + samples[1][j];
621 right = samples[0][j] - samples[1][j];
622 samples[0][j] = left;
623 samples[1][j] = right;
624 }
625 }
626 return 0;
627}
628
629
630int mpeg3audio_ac3_reset_frame(mpeg3audio_t *audio)
631{
632 memset(&audio->ac3_bit_allocation, 0, sizeof(mpeg3_ac3_bitallocation_t));
633 memset(&audio->ac3_mantissa, 0, sizeof(mpeg3_ac3_mantissa_t));
634 memset(&audio->ac3_audblk, 0, sizeof(mpeg3_ac3audblk_t));
635
636 return 0;
637}
638
639int mpeg3audio_do_ac3(mpeg3audio_t *audio)
640{
641 int result = 0, i;
642
643/* Reset the coefficients and exponents */
644 mpeg3audio_ac3_reset_frame(audio);
645
646 for(i = 0; i < 6 && !result; i++)
647 {
648 memset(audio->ac3_samples, 0, sizeof(mpeg3_real_t) * 256 * (audio->ac3_bsi.nfchans + audio->ac3_bsi.lfeon));
649/* Extract most of the audblk info from the bitstream
650 * (minus the mantissas */
651 result |= mpeg3audio_read_ac3_audblk(audio);
652
653/* Take the differential exponent data and turn it into
654 * absolute exponents */
655 if(!result) result |= mpeg3audio_ac3_exponent_unpack(audio,
656 &(audio->ac3_bsi),
657 &(audio->ac3_audblk));
658
659/* Figure out how many bits per mantissa */
660 if(!result) result |= mpeg3audio_ac3_bit_allocate(audio,
661 audio->sampling_frequency_code,
662 &(audio->ac3_bsi),
663 &(audio->ac3_audblk));
664
665/* Extract the mantissas from the data stream */
666 if(!result) result |= mpeg3audio_ac3_coeff_unpack(audio,
667 &(audio->ac3_bsi),
668 &(audio->ac3_audblk),
669 audio->ac3_samples);
670
671 if(audio->ac3_bsi.acmod == 0x2)
672 if(!result) result |= mpeg3audio_ac3_rematrix(&(audio->ac3_audblk),
673 audio->ac3_samples);
674
675/* Convert the frequency data into time samples */
676 if(!result) result |= mpeg3audio_ac3_imdct(audio,
677 &(audio->ac3_bsi),
678 &(audio->ac3_audblk),
679 audio->ac3_samples);
680
681 if(audio->pcm_point / audio->channels >= audio->pcm_allocated - MPEG3AUDIO_PADDING * audio->channels)
682 {
683/* Need more room */
684 mpeg3audio_replace_buffer(audio, audio->pcm_allocated + MPEG3AUDIO_PADDING * audio->channels);
685 }
686 }
687
688 mpeg3bits_use_demuxer(audio->astream);
689
690 return result;
691}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/ac3.h b/core/multimedia/opieplayer/libmpeg3/audio/ac3.h
new file mode 100644
index 0000000..9161c36
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/ac3.h
@@ -0,0 +1,308 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef AC3_H
21#define AC3_H
22
23#include "mpeg3real.h"
24
25#define MAX_AC3_FRAMESIZE 1920 * 2 + 512
26
27extern int mpeg3_ac3_samplerates[3];
28
29/* Exponent strategy constants */
30#define MPEG3_EXP_REUSE (0)
31#define MPEG3_EXP_D15 (1)
32#define MPEG3_EXP_D25 (2)
33#define MPEG3_EXP_D45 (3)
34
35/* Delta bit allocation constants */
36#define DELTA_BIT_REUSE (0)
37#define DELTA_BIT_NEW (1)
38#define DELTA_BIT_NONE (2)
39#define DELTA_BIT_RESERVED (3)
40
41
42typedef mpeg3_real_t mpeg3ac3_stream_samples_t[6][256];
43
44typedef struct
45{
46/* Bit stream identification == 0x8 */
47 int bsid;
48/* Bit stream mode */
49 int bsmod;
50/* Audio coding mode */
51 int acmod;
52/* If we're using the centre channel then */
53/* centre mix level */
54 int cmixlev;
55/* If we're using the surround channel then */
56/* surround mix level */
57 int surmixlev;
58/* If we're in 2/0 mode then */
59/* Dolby surround mix level - NOT USED - */
60 int dsurmod;
61/* Low frequency effects on */
62 int lfeon;
63/* Dialogue Normalization level */
64 int dialnorm;
65/* Compression exists */
66 int compre;
67/* Compression level */
68 int compr;
69/* Language code exists */
70 int langcode;
71/* Language code */
72 int langcod;
73/* Audio production info exists*/
74 unsigned int audprodie;
75 int mixlevel;
76 int roomtyp;
77/* If we're in dual mono mode (acmod == 0) then extra stuff */
78 int dialnorm2;
79 int compr2e;
80 int compr2;
81 int langcod2e;
82 int langcod2;
83 int audprodi2e;
84 int mixlevel2;
85 int roomtyp2;
86/* Copyright bit */
87 int copyrightb;
88/* Original bit */
89 int origbs;
90/* Timecode 1 exists */
91 int timecod1e;
92/* Timecode 1 */
93 unsigned int timecod1;
94/* Timecode 2 exists */
95 int timecod2e;
96/* Timecode 2 */
97 unsigned int timecod2;
98/* Additional bit stream info exists */
99 int addbsie;
100/* Additional bit stream length - 1 (in bytes) */
101 int addbsil;
102/* Additional bit stream information (max 64 bytes) */
103 unsigned char addbsi[64];
104
105/* Information not in the AC-3 bitstream, but derived */
106/* Number of channels (excluding LFE)
107 * Derived from acmod */
108 int nfchans;
109} mpeg3_ac3bsi_t;
110
111typedef struct
112{
113/* block switch bit indexed by channel num */
114 unsigned short blksw[5];
115/* dither enable bit indexed by channel num */
116 unsigned short dithflag[5];
117/* dynamic range gain exists */
118 int dynrnge;
119/* dynamic range gain */
120 int dynrng;
121/* if acmod==0 then */
122/* dynamic range 2 gain exists */
123 int dynrng2e;
124/* dynamic range 2 gain */
125 int dynrng2;
126/* coupling strategy exists */
127 int cplstre;
128/* coupling in use */
129 int cplinu;
130/* channel coupled */
131 unsigned short chincpl[5];
132/* if acmod==2 then */
133/* Phase flags in use */
134 int phsflginu;
135/* coupling begin frequency code */
136 int cplbegf;
137/* coupling end frequency code */
138 int cplendf;
139/* coupling band structure bits */
140 unsigned short cplbndstrc[18];
141/* Do coupling co-ords exist for this channel? */
142 unsigned short cplcoe[5];
143/* Master coupling co-ordinate */
144 unsigned short mstrcplco[5];
145/* Per coupling band coupling co-ordinates */
146 unsigned short cplcoexp[5][18];
147 unsigned short cplcomant[5][18];
148/* Phase flags for dual mono */
149 unsigned short phsflg[18];
150/* Is there a rematrixing strategy */
151 unsigned int rematstr;
152/* Rematrixing bits */
153 unsigned short rematflg[4];
154/* Coupling exponent strategy */
155 int cplexpstr;
156/* Exponent strategy for full bandwidth channels */
157 unsigned short chexpstr[5];
158/* Exponent strategy for lfe channel */
159 int lfeexpstr;
160/* Channel bandwidth for independent channels */
161 unsigned short chbwcod[5];
162/* The absolute coupling exponent */
163 int cplabsexp;
164/* Coupling channel exponents (D15 mode gives 18 * 12 /3 encoded exponents */
165 unsigned short cplexps[18 * 12 / 3];
166/* fbw channel exponents */
167 unsigned short exps[5][252 / 3];
168/* channel gain range */
169 unsigned short gainrng[5];
170/* low frequency exponents */
171 unsigned short lfeexps[3];
172
173/* Bit allocation info */
174 int baie;
175/* Slow decay code */
176 int sdcycod;
177/* Fast decay code */
178 int fdcycod;
179/* Slow gain code */
180 int sgaincod;
181/* dB per bit code */
182 int dbpbcod;
183/* masking floor code */
184 int floorcod;
185
186/* SNR offset info */
187 int snroffste;
188/* coarse SNR offset */
189 int csnroffst;
190/* coupling fine SNR offset */
191 int cplfsnroffst;
192/* coupling fast gain code */
193 int cplfgaincod;
194/* fbw fine SNR offset */
195 unsigned short fsnroffst[5];
196/* fbw fast gain code */
197 unsigned short fgaincod[5];
198/* lfe fine SNR offset */
199 int lfefsnroffst;
200/* lfe fast gain code */
201 int lfefgaincod;
202
203/* Coupling leak info */
204 int cplleake;
205/* coupling fast leak initialization */
206 int cplfleak;
207/* coupling slow leak initialization */
208 int cplsleak;
209
210/* delta bit allocation info */
211 int deltbaie;
212/* coupling delta bit allocation exists */
213 int cpldeltbae;
214/* fbw delta bit allocation exists */
215 unsigned short deltbae[5];
216/* number of cpl delta bit segments */
217 int cpldeltnseg;
218/* coupling delta bit allocation offset */
219 short cpldeltoffst[8];
220/* coupling delta bit allocation length */
221 short cpldeltlen[8];
222/* coupling delta bit allocation length */
223 short cpldeltba[8];
224/* number of delta bit segments */
225 unsigned short deltnseg[5];
226/* fbw delta bit allocation offset */
227 short deltoffst[5][8];
228/* fbw delta bit allocation length */
229 short deltlen[5][8];
230/* fbw delta bit allocation length */
231 short deltba[5][8];
232
233/* skip length exists */
234 int skiple;
235/* skip length */
236 int skipl;
237
238/* channel mantissas */
239 short chmant[5][256];
240
241/* coupling mantissas */
242 unsigned short cplmant[256];
243
244/* coupling mantissas */
245 unsigned short lfemant[7];
246
247/* -- Information not in the bitstream, but derived thereof -- */
248
249/* Number of coupling sub-bands */
250 int ncplsubnd;
251
252/* Number of combined coupling sub-bands
253 * Derived from ncplsubnd and cplbndstrc */
254 int ncplbnd;
255
256/* Number of exponent groups by channel
257 * Derived from strmant, endmant */
258 int nchgrps[5];
259
260/* Number of coupling exponent groups
261 * Derived from cplbegf, cplendf, cplexpstr */
262 int ncplgrps;
263
264/* End mantissa numbers of fbw channels */
265 unsigned short endmant[5];
266
267/* Start and end mantissa numbers for the coupling channel */
268 int cplstrtmant;
269 int cplendmant;
270
271/* Decoded exponent info */
272 unsigned short fbw_exp[5][256];
273 unsigned short cpl_exp[256];
274 unsigned short lfe_exp[7];
275
276/* Bit allocation pointer results */
277 short fbw_bap[5][256];
278/*FIXME figure out exactly how many entries there should be (253-37?) */
279 short cpl_bap[256];
280 short lfe_bap[7];
281} mpeg3_ac3audblk_t;
282
283/* Bit allocation data */
284typedef struct
285{
286 int sdecay;
287 int fdecay;
288 int sgain;
289 int dbknee;
290 int floor;
291 short psd[256];
292 short bndpsd[256];
293 short excite[256];
294 short mask[256];
295} mpeg3_ac3_bitallocation_t;
296
297/* Mantissa data */
298typedef struct
299{
300 unsigned short m_1[3];
301 unsigned short m_2[3];
302 unsigned short m_4[2];
303 unsigned short m_1_pointer;
304 unsigned short m_2_pointer;
305 unsigned short m_4_pointer;
306} mpeg3_ac3_mantissa_t;
307
308#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/bit_allocation.c b/core/multimedia/opieplayer/libmpeg3/audio/bit_allocation.c
new file mode 100644
index 0000000..29df7d7
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/bit_allocation.c
@@ -0,0 +1,586 @@
1/*
2 *
3 *Copyright (C) Aaron Holtzman - May 1999
4 *
5 *
6 * This file is part of libmpeg3
7 *
8 * libmpeg3 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, or (at your option)
11 * any later version.
12 *
13 * libmpeg3 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 GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#include "mpeg3audio.h"
25#include "../libmpeg3.h"
26#include "../mpeg3protos.h"
27#include <string.h>
28#include <stdlib.h>
29
30/* Bit allocation tables */
31
32static short mpeg3_slowdec[] = { 0x0f, 0x11, 0x13, 0x15 };
33static short mpeg3_fastdec[] = { 0x3f, 0x53, 0x67, 0x7b };
34static short mpeg3_slowgain[] = { 0x540, 0x4d8, 0x478, 0x410 };
35static short mpeg3_dbpbtab[] = { 0x000, 0x700, 0x900, 0xb00 };
36
37static unsigned short mpeg3_floortab[] = { 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800 };
38static short mpeg3_fastgain[] = { 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400 };
39
40
41static short mpeg3_bndtab[] =
42{
43 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
44 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
45 20, 21, 22, 23, 24, 25, 26, 27, 28, 31,
46 34, 37, 40, 43, 46, 49, 55, 61, 67, 73,
47 79, 85, 97, 109, 121, 133, 157, 181, 205, 229
48};
49
50static short mpeg3_bndsz[] =
51{
52 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
53 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
54 1, 1, 1, 1, 1, 1, 1, 1, 3, 3,
55 3, 3, 3, 3, 3, 6, 6, 6, 6, 6,
56 6, 12, 12, 12, 12, 24, 24, 24, 24, 24
57};
58
59static short mpeg3_masktab[] =
60{
61 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
62 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 28, 28, 29,
63 29, 29, 30, 30, 30, 31, 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
64 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36, 36, 36, 37, 37, 37,
65 37, 37, 37, 38, 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, 39, 40,
66 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41,
67 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43, 43, 43,
68 43, 43, 43, 43, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 44, 44,
69 44, 44, 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
70 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 46, 46, 46,
71 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
72 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
73 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 48, 48, 48,
74 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48,
75 48, 48, 48, 48, 48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
76 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 0, 0, 0
77};
78
79
80static short mpeg3_latab[] =
81{
82 0x0040, 0x003f, 0x003e, 0x003d, 0x003c, 0x003b, 0x003a, 0x0039,
83 0x0038, 0x0037, 0x0036, 0x0035, 0x0034, 0x0034, 0x0033, 0x0032,
84 0x0031, 0x0030, 0x002f, 0x002f, 0x002e, 0x002d, 0x002c, 0x002c,
85 0x002b, 0x002a, 0x0029, 0x0029, 0x0028, 0x0027, 0x0026, 0x0026,
86 0x0025, 0x0024, 0x0024, 0x0023, 0x0023, 0x0022, 0x0021, 0x0021,
87 0x0020, 0x0020, 0x001f, 0x001e, 0x001e, 0x001d, 0x001d, 0x001c,
88 0x001c, 0x001b, 0x001b, 0x001a, 0x001a, 0x0019, 0x0019, 0x0018,
89 0x0018, 0x0017, 0x0017, 0x0016, 0x0016, 0x0015, 0x0015, 0x0015,
90 0x0014, 0x0014, 0x0013, 0x0013, 0x0013, 0x0012, 0x0012, 0x0012,
91 0x0011, 0x0011, 0x0011, 0x0010, 0x0010, 0x0010, 0x000f, 0x000f,
92 0x000f, 0x000e, 0x000e, 0x000e, 0x000d, 0x000d, 0x000d, 0x000d,
93 0x000c, 0x000c, 0x000c, 0x000c, 0x000b, 0x000b, 0x000b, 0x000b,
94 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x0009, 0x0009, 0x0009,
95 0x0009, 0x0009, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
96 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0007, 0x0006, 0x0006,
97 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0006, 0x0005, 0x0005,
98 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0005, 0x0004, 0x0004,
99 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004, 0x0004,
100 0x0004, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003,
101 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0003, 0x0002,
102 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
103 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
104 0x0002, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
105 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
106 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
107 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
108 0x0001, 0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
109 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
110 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
111 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
112 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
113 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
114 0x0000, 0x0000, 0x0000, 0x0000
115};
116
117static short mpeg3_hth[][50] =
118{
119 {
120 0x04d0, 0x04d0, 0x0440, 0x0400, 0x03e0, 0x03c0, 0x03b0, 0x03b0,
121 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390,
122 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360, 0x0350, 0x0350,
123 0x0340, 0x0340, 0x0330, 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0,
124 0x02f0, 0x02f0, 0x0300, 0x0310, 0x0340, 0x0390, 0x03e0, 0x0420,
125 0x0460, 0x0490, 0x04a0, 0x0460, 0x0440, 0x0440, 0x0520, 0x0800,
126 0x0840, 0x0840
127 },
128
129 {
130 0x04f0, 0x04f0, 0x0460, 0x0410, 0x03e0, 0x03d0, 0x03c0, 0x03b0,
131 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390,
132 0x0390, 0x0380, 0x0380, 0x0380, 0x0370, 0x0370, 0x0360, 0x0360,
133 0x0350, 0x0350, 0x0340, 0x0340, 0x0320, 0x0310, 0x0300, 0x02f0,
134 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0320, 0x0350, 0x0390, 0x03e0,
135 0x0420, 0x0450, 0x04a0, 0x0490, 0x0460, 0x0440, 0x0480, 0x0630,
136 0x0840, 0x0840
137 },
138
139 {
140 0x0580, 0x0580, 0x04b0, 0x0450, 0x0420, 0x03f0, 0x03e0, 0x03d0,
141 0x03c0, 0x03b0, 0x03b0, 0x03b0, 0x03a0, 0x03a0, 0x03a0, 0x03a0,
142 0x03a0, 0x03a0, 0x03a0, 0x03a0, 0x0390, 0x0390, 0x0390, 0x0390,
143 0x0380, 0x0380, 0x0380, 0x0370, 0x0360, 0x0350, 0x0340, 0x0330,
144 0x0320, 0x0310, 0x0300, 0x02f0, 0x02f0, 0x02f0, 0x0300, 0x0310,
145 0x0330, 0x0350, 0x03c0, 0x0410, 0x0470, 0x04a0, 0x0460, 0x0440,
146 0x0450, 0x04e0
147 }
148};
149
150
151static short mpeg3_baptab[] =
152{
153 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6,
154 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10,
155 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14,
156 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15
157};
158
159
160inline int logadd(int a, int b)
161{
162 int c;
163 int address;
164
165 c = a - b;
166 address = mpeg3_min((abs(c) >> 1), 255);
167
168 if(c >= 0)
169 return(a + mpeg3_latab[address]);
170 else
171 return(b + mpeg3_latab[address]);
172}
173
174
175int mpeg3audio_ac3_calc_lowcomp(int a, int b0, int b1, int bin)
176{
177 if(bin < 7)
178 {
179 if((b0 + 256) == b1)
180 a = 384;
181 else
182 if(b0 > b1)
183 a = mpeg3_max(0, a - 64);
184 }
185 else if(bin < 20)
186 {
187 if((b0 + 256) == b1)
188 a = 320;
189 else if(b0 > b1)
190 a = mpeg3_max(0, a - 64) ;
191 }
192 else
193 a = mpeg3_max(0, a - 128);
194
195 return(a);
196}
197
198void mpeg3audio_ac3_ba_compute_psd(int start,
199 int end,
200 unsigned short exps[],
201 short psd[],
202 short bndpsd[])
203{
204 int bin,i,j,k;
205 int lastbin = 0;
206
207/* Map the exponents into dBs */
208 for (bin = start; bin < end; bin++)
209 {
210 psd[bin] = (3072 - (exps[bin] << 7));
211 }
212
213/* Integrate the psd function over each bit allocation band */
214 j = start;
215 k = mpeg3_masktab[start];
216
217 do
218 {
219 lastbin = mpeg3_min(mpeg3_bndtab[k] + mpeg3_bndsz[k], end);
220 bndpsd[k] = psd[j];
221 j++;
222
223 for(i = j; i < lastbin; i++)
224 {
225 bndpsd[k] = logadd(bndpsd[k], psd[j]);
226 j++;
227 }
228
229 k++;
230 }while(end > lastbin);
231}
232
233void mpeg3audio_ac3_ba_compute_excitation(mpeg3audio_t *audio,
234 int start,
235 int end,
236 int fgain,
237 int fastleak,
238 int slowleak,
239 int is_lfe,
240 short bndpsd[],
241 short excite[])
242{
243 int bin;
244 int bndstrt;
245 int bndend;
246 int lowcomp = 0;
247 int begin = 0;
248
249/* Compute excitation function */
250 bndstrt = mpeg3_masktab[start];
251 bndend = mpeg3_masktab[end - 1] + 1;
252
253 if(bndstrt == 0) /* For fbw and lfe channels */
254 {
255 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[0], bndpsd[1], 0);
256 excite[0] = bndpsd[0] - fgain - lowcomp;
257 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[1], bndpsd[2], 1);
258 excite[1] = bndpsd[1] - fgain - lowcomp;
259 begin = 7 ;
260
261/* Note: Do not call mpeg3audio_ac3_calc_lowcomp() for the last band of the lfe channel, (bin = 6) */
262 for (bin = 2; bin < 7; bin++)
263 {
264 if(!(is_lfe && (bin == 6)))
265 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
266 fastleak = bndpsd[bin] - fgain;
267 slowleak = bndpsd[bin] - audio->ac3_bit_allocation.sgain;
268 excite[bin] = fastleak - lowcomp;
269
270 if(!(is_lfe && (bin == 6)))
271 {
272 if(bndpsd[bin] <= bndpsd[bin+1])
273 {
274 begin = bin + 1 ;
275 break;
276 }
277 }
278 }
279
280 for (bin = begin; bin < mpeg3_min(bndend, 22); bin++)
281 {
282 if (!(is_lfe && (bin == 6)))
283 lowcomp = mpeg3audio_ac3_calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin);
284 fastleak -= audio->ac3_bit_allocation.fdecay;
285 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
286 slowleak -= audio->ac3_bit_allocation.sdecay;
287 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
288 excite[bin] = mpeg3_max(fastleak - lowcomp, slowleak);
289 }
290 begin = 22;
291 }
292 else /* For coupling channel */
293 {
294 begin = bndstrt;
295 }
296
297 for (bin = begin; bin < bndend; bin++)
298 {
299 fastleak -= audio->ac3_bit_allocation.fdecay;
300 fastleak = mpeg3_max(fastleak, bndpsd[bin] - fgain);
301 slowleak -= audio->ac3_bit_allocation.sdecay;
302 slowleak = mpeg3_max(slowleak, bndpsd[bin] - audio->ac3_bit_allocation.sgain);
303 excite[bin] = mpeg3_max(fastleak, slowleak) ;
304 }
305}
306
307void mpeg3audio_ac3_ba_compute_mask(mpeg3audio_t *audio,
308 int start,
309 int end,
310 int fscod,
311 int deltbae,
312 int deltnseg,
313 short deltoffst[],
314 short deltba[],
315 short deltlen[],
316 short excite[],
317 short mask[])
318{
319 int bin, k;
320 int bndstrt;
321 int bndend;
322 int delta;
323
324 bndstrt = mpeg3_masktab[start];
325 bndend = mpeg3_masktab[end - 1] + 1;
326
327/* Compute the masking curve */
328
329 for (bin = bndstrt; bin < bndend; bin++)
330 {
331 if (audio->ac3_bit_allocation.bndpsd[bin] < audio->ac3_bit_allocation.dbknee)
332 {
333 excite[bin] += ((audio->ac3_bit_allocation.dbknee - audio->ac3_bit_allocation.bndpsd[bin]) >> 2);
334 }
335 mask[bin] = mpeg3_max(excite[bin], mpeg3_hth[fscod][bin]);
336 }
337
338/* Perform delta bit modulation if necessary */
339 if ((deltbae == DELTA_BIT_REUSE) || (deltbae == DELTA_BIT_NEW))
340 {
341 int band = 0;
342 int seg = 0;
343
344 for (seg = 0; seg < deltnseg + 1; seg++)
345 {
346 band += deltoffst[seg];
347 if (deltba[seg] >= 4)
348 {
349 delta = (deltba[seg] - 3) << 7;
350 }
351 else
352 {
353 delta = (deltba[seg] - 4) << 7;
354 }
355
356 for (k = 0; k < deltlen[seg]; k++)
357 {
358 mask[band] += delta;
359 band++;
360 }
361 }
362 }
363}
364
365void mpeg3audio_ac3_ba_compute_bap(mpeg3audio_t *audio,
366 int start,
367 int end,
368 int snroffset,
369 short psd[],
370 short mask[],
371 short bap[])
372{
373 int i, j, k;
374 short lastbin = 0;
375 short address = 0;
376
377/* Compute the bit allocation pointer for each bin */
378 i = start;
379 j = mpeg3_masktab[start];
380
381 do
382 {
383 lastbin = mpeg3_min(mpeg3_bndtab[j] + mpeg3_bndsz[j], end);
384 mask[j] -= snroffset;
385 mask[j] -= audio->ac3_bit_allocation.floor;
386
387 if(mask[j] < 0)
388 mask[j] = 0;
389
390 mask[j] &= 0x1fe0;
391 mask[j] += audio->ac3_bit_allocation.floor;
392 for(k = i; k < lastbin; k++)
393 {
394 address = (psd[i] - mask[j]) >> 5;
395 address = mpeg3_min(63, mpeg3_max(0, address));
396 bap[i] = mpeg3_baptab[address];
397 i++;
398 }
399 j++;
400 }while (end > lastbin);
401}
402
403int mpeg3audio_ac3_bit_allocate(mpeg3audio_t *audio,
404 unsigned int fscod,
405 mpeg3_ac3bsi_t *bsi,
406 mpeg3_ac3audblk_t *audblk)
407{
408 int result = 0;
409 int i;
410 int fgain;
411 int snroffset;
412 int start;
413 int end;
414 int fastleak;
415 int slowleak;
416
417/*printf("mpeg3audio_ac3_bit_allocate %d %d %d %d %d\n", audblk->sdcycod, audblk->fdcycod, audblk->sgaincod, audblk->dbpbcod, audblk->floorcod); */
418/* Only perform bit_allocation if the exponents have changed or we
419 * have new sideband information */
420 if(audblk->chexpstr[0] == 0 && audblk->chexpstr[1] == 0 &&
421 audblk->chexpstr[2] == 0 && audblk->chexpstr[3] == 0 &&
422 audblk->chexpstr[4] == 0 && audblk->cplexpstr == 0 &&
423 audblk->lfeexpstr == 0 && audblk->baie == 0 &&
424 audblk->snroffste == 0 && audblk->deltbaie == 0)
425 return 0;
426
427/* Do some setup before we do the bit alloc */
428 audio->ac3_bit_allocation.sdecay = mpeg3_slowdec[audblk->sdcycod];
429 audio->ac3_bit_allocation.fdecay = mpeg3_fastdec[audblk->fdcycod];
430 audio->ac3_bit_allocation.sgain = mpeg3_slowgain[audblk->sgaincod];
431 audio->ac3_bit_allocation.dbknee = mpeg3_dbpbtab[audblk->dbpbcod];
432 audio->ac3_bit_allocation.floor = mpeg3_floortab[audblk->floorcod];
433
434/* if all the SNR offset constants are zero then the whole block is zero */
435 if(!audblk->csnroffst && !audblk->fsnroffst[0] &&
436 !audblk->fsnroffst[1] && !audblk->fsnroffst[2] &&
437 !audblk->fsnroffst[3] && !audblk->fsnroffst[4] &&
438 !audblk->cplfsnroffst && !audblk->lfefsnroffst)
439 {
440 memset(audblk->fbw_bap, 0, sizeof(short) * 256 * 5);
441 memset(audblk->cpl_bap, 0, sizeof(short) * 256);
442 memset(audblk->lfe_bap, 0, sizeof(short) * 7);
443 return 0;
444 }
445
446 for(i = 0; i < bsi->nfchans; i++)
447 {
448 start = 0;
449 end = audblk->endmant[i];
450 fgain = mpeg3_fastgain[audblk->fgaincod[i]];
451 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->fsnroffst[i]) << 2 ;
452 fastleak = 0;
453 slowleak = 0;
454
455 mpeg3audio_ac3_ba_compute_psd(start,
456 end,
457 audblk->fbw_exp[i],
458 audio->ac3_bit_allocation.psd,
459 audio->ac3_bit_allocation.bndpsd);
460
461 mpeg3audio_ac3_ba_compute_excitation(audio,
462 start,
463 end ,
464 fgain,
465 fastleak,
466 slowleak,
467 0,
468 audio->ac3_bit_allocation.bndpsd,
469 audio->ac3_bit_allocation.excite);
470
471 mpeg3audio_ac3_ba_compute_mask(audio,
472 start,
473 end,
474 fscod,
475 audblk->deltbae[i],
476 audblk->deltnseg[i],
477 audblk->deltoffst[i],
478 audblk->deltba[i],
479 audblk->deltlen[i],
480 audio->ac3_bit_allocation.excite,
481 audio->ac3_bit_allocation.mask);
482
483 mpeg3audio_ac3_ba_compute_bap(audio,
484 start,
485 end,
486 snroffset,
487 audio->ac3_bit_allocation.psd,
488 audio->ac3_bit_allocation.mask,
489 audblk->fbw_bap[i]);
490 }
491
492 if(audblk->cplinu)
493 {
494 start = audblk->cplstrtmant;
495 end = audblk->cplendmant;
496 fgain = mpeg3_fastgain[audblk->cplfgaincod];
497 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->cplfsnroffst) << 2 ;
498 fastleak = (audblk->cplfleak << 8) + 768;
499 slowleak = (audblk->cplsleak << 8) + 768;
500
501 mpeg3audio_ac3_ba_compute_psd(start,
502 end,
503 audblk->cpl_exp,
504 audio->ac3_bit_allocation.psd,
505 audio->ac3_bit_allocation.bndpsd);
506
507 mpeg3audio_ac3_ba_compute_excitation(audio,
508 start,
509 end ,
510 fgain,
511 fastleak,
512 slowleak,
513 0,
514 audio->ac3_bit_allocation.bndpsd,
515 audio->ac3_bit_allocation.excite);
516
517 mpeg3audio_ac3_ba_compute_mask(audio,
518 start,
519 end,
520 fscod,
521 audblk->cpldeltbae,
522 audblk->cpldeltnseg,
523 audblk->cpldeltoffst,
524 audblk->cpldeltba,
525 audblk->cpldeltlen,
526 audio->ac3_bit_allocation.excite,
527 audio->ac3_bit_allocation.mask);
528
529 mpeg3audio_ac3_ba_compute_bap(audio,
530 start,
531 end,
532 snroffset,
533 audio->ac3_bit_allocation.psd,
534 audio->ac3_bit_allocation.mask,
535 audblk->cpl_bap);
536 }
537
538 if(bsi->lfeon)
539 {
540 start = 0;
541 end = 7;
542 fgain = mpeg3_fastgain[audblk->lfefgaincod];
543 snroffset = (((audblk->csnroffst - 15) << 4) + audblk->lfefsnroffst) << 2 ;
544 fastleak = 0;
545 slowleak = 0;
546
547 mpeg3audio_ac3_ba_compute_psd(start,
548 end,
549 audblk->lfe_exp,
550 audio->ac3_bit_allocation.psd,
551 audio->ac3_bit_allocation.bndpsd);
552
553 mpeg3audio_ac3_ba_compute_excitation(audio,
554 start,
555 end ,
556 fgain,
557 fastleak,
558 slowleak,
559 1,
560 audio->ac3_bit_allocation.bndpsd,
561 audio->ac3_bit_allocation.excite);
562
563/* Perform no delta bit allocation for lfe */
564 mpeg3audio_ac3_ba_compute_mask(audio,
565 start,
566 end,
567 fscod,
568 2,
569 0,
570 0,
571 0,
572 0,
573 audio->ac3_bit_allocation.excite,
574 audio->ac3_bit_allocation.mask);
575
576 mpeg3audio_ac3_ba_compute_bap(audio,
577 start,
578 end,
579 snroffset,
580 audio->ac3_bit_allocation.psd,
581 audio->ac3_bit_allocation.mask,
582 audblk->lfe_bap);
583 }
584
585 return result;
586}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/c_flags b/core/multimedia/opieplayer/libmpeg3/audio/c_flags
new file mode 100755
index 0000000..d7943d0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/c_flags
@@ -0,0 +1 @@
echo $CFLAGS
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/dct.c b/core/multimedia/opieplayer/libmpeg3/audio/dct.c
new file mode 100644
index 0000000..1fd52ce
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/dct.c
@@ -0,0 +1,1135 @@
1/*
2 *
3 * This file is part of libmpeg3
4 *
5 * libmpeg3 is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * libmpeg3 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 */
20
21/*
22 * Discrete Cosine Tansform (DCT) for subband synthesis
23 * optimized for machines with no auto-increment.
24 * The performance is highly compiler dependend. Maybe
25 * the dct64.c version for 'normal' processor may be faster
26 * even for Intel processors.
27 */
28
29#include "mpeg3audio.h"
30#include "../libmpeg3.h"
31#include "../mpeg3protos.h"
32#include "tables.h"
33
34#include <math.h>
35
36int mpeg3audio_dct64_1(mpeg3_real_t *out0, mpeg3_real_t *out1, mpeg3_real_t *b1, mpeg3_real_t *b2, mpeg3_real_t *samples)
37{
38 register mpeg3_real_t *costab = mpeg3_pnts[0];
39
40 b1[0x00] = samples[0x00] + samples[0x1F];
41 b1[0x01] = samples[0x01] + samples[0x1E];
42 b1[0x1F] = (samples[0x00] - samples[0x1F]) * costab[0x0];
43 b1[0x1E] = (samples[0x01] - samples[0x1E]) * costab[0x1];
44
45 b1[0x02] = samples[0x02] + samples[0x1D];
46 b1[0x03] = samples[0x03] + samples[0x1C];
47 b1[0x1D] = (samples[0x02] - samples[0x1D]) * costab[0x2];
48 b1[0x1C] = (samples[0x03] - samples[0x1C]) * costab[0x3];
49
50 b1[0x04] = samples[0x04] + samples[0x1B];
51 b1[0x05] = samples[0x05] + samples[0x1A];
52 b1[0x1B] = (samples[0x04] - samples[0x1B]) * costab[0x4];
53 b1[0x1A] = (samples[0x05] - samples[0x1A]) * costab[0x5];
54
55 b1[0x06] = samples[0x06] + samples[0x19];
56 b1[0x07] = samples[0x07] + samples[0x18];
57 b1[0x19] = (samples[0x06] - samples[0x19]) * costab[0x6];
58 b1[0x18] = (samples[0x07] - samples[0x18]) * costab[0x7];
59
60 b1[0x08] = samples[0x08] + samples[0x17];
61 b1[0x09] = samples[0x09] + samples[0x16];
62 b1[0x17] = (samples[0x08] - samples[0x17]) * costab[0x8];
63 b1[0x16] = (samples[0x09] - samples[0x16]) * costab[0x9];
64
65 b1[0x0A] = samples[0x0A] + samples[0x15];
66 b1[0x0B] = samples[0x0B] + samples[0x14];
67 b1[0x15] = (samples[0x0A] - samples[0x15]) * costab[0xA];
68 b1[0x14] = (samples[0x0B] - samples[0x14]) * costab[0xB];
69
70 b1[0x0C] = samples[0x0C] + samples[0x13];
71 b1[0x0D] = samples[0x0D] + samples[0x12];
72 b1[0x13] = (samples[0x0C] - samples[0x13]) * costab[0xC];
73 b1[0x12] = (samples[0x0D] - samples[0x12]) * costab[0xD];
74
75 b1[0x0E] = samples[0x0E] + samples[0x11];
76 b1[0x0F] = samples[0x0F] + samples[0x10];
77 b1[0x11] = (samples[0x0E] - samples[0x11]) * costab[0xE];
78 b1[0x10] = (samples[0x0F] - samples[0x10]) * costab[0xF];
79
80 costab = mpeg3_pnts[1];
81
82 b2[0x00] = b1[0x00] + b1[0x0F];
83 b2[0x01] = b1[0x01] + b1[0x0E];
84 b2[0x0F] = (b1[0x00] - b1[0x0F]) * costab[0];
85 b2[0x0E] = (b1[0x01] - b1[0x0E]) * costab[1];
86
87 b2[0x02] = b1[0x02] + b1[0x0D];
88 b2[0x03] = b1[0x03] + b1[0x0C];
89 b2[0x0D] = (b1[0x02] - b1[0x0D]) * costab[2];
90 b2[0x0C] = (b1[0x03] - b1[0x0C]) * costab[3];
91
92 b2[0x04] = b1[0x04] + b1[0x0B];
93 b2[0x05] = b1[0x05] + b1[0x0A];
94 b2[0x0B] = (b1[0x04] - b1[0x0B]) * costab[4];
95 b2[0x0A] = (b1[0x05] - b1[0x0A]) * costab[5];
96
97 b2[0x06] = b1[0x06] + b1[0x09];
98 b2[0x07] = b1[0x07] + b1[0x08];
99 b2[0x09] = (b1[0x06] - b1[0x09]) * costab[6];
100 b2[0x08] = (b1[0x07] - b1[0x08]) * costab[7];
101
102 /* */
103
104 b2[0x10] = b1[0x10] + b1[0x1F];
105 b2[0x11] = b1[0x11] + b1[0x1E];
106 b2[0x1F] = (b1[0x1F] - b1[0x10]) * costab[0];
107 b2[0x1E] = (b1[0x1E] - b1[0x11]) * costab[1];
108
109 b2[0x12] = b1[0x12] + b1[0x1D];
110 b2[0x13] = b1[0x13] + b1[0x1C];
111 b2[0x1D] = (b1[0x1D] - b1[0x12]) * costab[2];
112 b2[0x1C] = (b1[0x1C] - b1[0x13]) * costab[3];
113
114 b2[0x14] = b1[0x14] + b1[0x1B];
115 b2[0x15] = b1[0x15] + b1[0x1A];
116 b2[0x1B] = (b1[0x1B] - b1[0x14]) * costab[4];
117 b2[0x1A] = (b1[0x1A] - b1[0x15]) * costab[5];
118
119 b2[0x16] = b1[0x16] + b1[0x19];
120 b2[0x17] = b1[0x17] + b1[0x18];
121 b2[0x19] = (b1[0x19] - b1[0x16]) * costab[6];
122 b2[0x18] = (b1[0x18] - b1[0x17]) * costab[7];
123
124 costab = mpeg3_pnts[2];
125
126 b1[0x00] = b2[0x00] + b2[0x07];
127 b1[0x07] = (b2[0x00] - b2[0x07]) * costab[0];
128 b1[0x01] = b2[0x01] + b2[0x06];
129 b1[0x06] = (b2[0x01] - b2[0x06]) * costab[1];
130 b1[0x02] = b2[0x02] + b2[0x05];
131 b1[0x05] = (b2[0x02] - b2[0x05]) * costab[2];
132 b1[0x03] = b2[0x03] + b2[0x04];
133 b1[0x04] = (b2[0x03] - b2[0x04]) * costab[3];
134
135 b1[0x08] = b2[0x08] + b2[0x0F];
136 b1[0x0F] = (b2[0x0F] - b2[0x08]) * costab[0];
137 b1[0x09] = b2[0x09] + b2[0x0E];
138 b1[0x0E] = (b2[0x0E] - b2[0x09]) * costab[1];
139 b1[0x0A] = b2[0x0A] + b2[0x0D];
140 b1[0x0D] = (b2[0x0D] - b2[0x0A]) * costab[2];
141 b1[0x0B] = b2[0x0B] + b2[0x0C];
142 b1[0x0C] = (b2[0x0C] - b2[0x0B]) * costab[3];
143
144 b1[0x10] = b2[0x10] + b2[0x17];
145 b1[0x17] = (b2[0x10] - b2[0x17]) * costab[0];
146 b1[0x11] = b2[0x11] + b2[0x16];
147 b1[0x16] = (b2[0x11] - b2[0x16]) * costab[1];
148 b1[0x12] = b2[0x12] + b2[0x15];
149 b1[0x15] = (b2[0x12] - b2[0x15]) * costab[2];
150 b1[0x13] = b2[0x13] + b2[0x14];
151 b1[0x14] = (b2[0x13] - b2[0x14]) * costab[3];
152
153 b1[0x18] = b2[0x18] + b2[0x1F];
154 b1[0x1F] = (b2[0x1F] - b2[0x18]) * costab[0];
155 b1[0x19] = b2[0x19] + b2[0x1E];
156 b1[0x1E] = (b2[0x1E] - b2[0x19]) * costab[1];
157 b1[0x1A] = b2[0x1A] + b2[0x1D];
158 b1[0x1D] = (b2[0x1D] - b2[0x1A]) * costab[2];
159 b1[0x1B] = b2[0x1B] + b2[0x1C];
160 b1[0x1C] = (b2[0x1C] - b2[0x1B]) * costab[3];
161
162 {
163 register mpeg3_real_t const cos0 = mpeg3_pnts[3][0];
164 register mpeg3_real_t const cos1 = mpeg3_pnts[3][1];
165
166 b2[0x00] = b1[0x00] + b1[0x03];
167 b2[0x03] = (b1[0x00] - b1[0x03]) * cos0;
168 b2[0x01] = b1[0x01] + b1[0x02];
169 b2[0x02] = (b1[0x01] - b1[0x02]) * cos1;
170
171 b2[0x04] = b1[0x04] + b1[0x07];
172 b2[0x07] = (b1[0x07] - b1[0x04]) * cos0;
173 b2[0x05] = b1[0x05] + b1[0x06];
174 b2[0x06] = (b1[0x06] - b1[0x05]) * cos1;
175
176 b2[0x08] = b1[0x08] + b1[0x0B];
177 b2[0x0B] = (b1[0x08] - b1[0x0B]) * cos0;
178 b2[0x09] = b1[0x09] + b1[0x0A];
179 b2[0x0A] = (b1[0x09] - b1[0x0A]) * cos1;
180
181 b2[0x0C] = b1[0x0C] + b1[0x0F];
182 b2[0x0F] = (b1[0x0F] - b1[0x0C]) * cos0;
183 b2[0x0D] = b1[0x0D] + b1[0x0E];
184 b2[0x0E] = (b1[0x0E] - b1[0x0D]) * cos1;
185
186 b2[0x10] = b1[0x10] + b1[0x13];
187 b2[0x13] = (b1[0x10] - b1[0x13]) * cos0;
188 b2[0x11] = b1[0x11] + b1[0x12];
189 b2[0x12] = (b1[0x11] - b1[0x12]) * cos1;
190
191 b2[0x14] = b1[0x14] + b1[0x17];
192 b2[0x17] = (b1[0x17] - b1[0x14]) * cos0;
193 b2[0x15] = b1[0x15] + b1[0x16];
194 b2[0x16] = (b1[0x16] - b1[0x15]) * cos1;
195
196 b2[0x18] = b1[0x18] + b1[0x1B];
197 b2[0x1B] = (b1[0x18] - b1[0x1B]) * cos0;
198 b2[0x19] = b1[0x19] + b1[0x1A];
199 b2[0x1A] = (b1[0x19] - b1[0x1A]) * cos1;
200
201 b2[0x1C] = b1[0x1C] + b1[0x1F];
202 b2[0x1F] = (b1[0x1F] - b1[0x1C]) * cos0;
203 b2[0x1D] = b1[0x1D] + b1[0x1E];
204 b2[0x1E] = (b1[0x1E] - b1[0x1D]) * cos1;
205 }
206
207 {
208 register mpeg3_real_t const cos0 = mpeg3_pnts[4][0];
209
210 b1[0x00] = b2[0x00] + b2[0x01];
211 b1[0x01] = (b2[0x00] - b2[0x01]) * cos0;
212 b1[0x02] = b2[0x02] + b2[0x03];
213 b1[0x03] = (b2[0x03] - b2[0x02]) * cos0;
214 b1[0x02] += b1[0x03];
215
216 b1[0x04] = b2[0x04] + b2[0x05];
217 b1[0x05] = (b2[0x04] - b2[0x05]) * cos0;
218 b1[0x06] = b2[0x06] + b2[0x07];
219 b1[0x07] = (b2[0x07] - b2[0x06]) * cos0;
220 b1[0x06] += b1[0x07];
221 b1[0x04] += b1[0x06];
222 b1[0x06] += b1[0x05];
223 b1[0x05] += b1[0x07];
224
225 b1[0x08] = b2[0x08] + b2[0x09];
226 b1[0x09] = (b2[0x08] - b2[0x09]) * cos0;
227 b1[0x0A] = b2[0x0A] + b2[0x0B];
228 b1[0x0B] = (b2[0x0B] - b2[0x0A]) * cos0;
229 b1[0x0A] += b1[0x0B];
230
231 b1[0x0C] = b2[0x0C] + b2[0x0D];
232 b1[0x0D] = (b2[0x0C] - b2[0x0D]) * cos0;
233 b1[0x0E] = b2[0x0E] + b2[0x0F];
234 b1[0x0F] = (b2[0x0F] - b2[0x0E]) * cos0;
235 b1[0x0E] += b1[0x0F];
236 b1[0x0C] += b1[0x0E];
237 b1[0x0E] += b1[0x0D];
238 b1[0x0D] += b1[0x0F];
239
240 b1[0x10] = b2[0x10] + b2[0x11];
241 b1[0x11] = (b2[0x10] - b2[0x11]) * cos0;
242 b1[0x12] = b2[0x12] + b2[0x13];
243 b1[0x13] = (b2[0x13] - b2[0x12]) * cos0;
244 b1[0x12] += b1[0x13];
245
246 b1[0x14] = b2[0x14] + b2[0x15];
247 b1[0x15] = (b2[0x14] - b2[0x15]) * cos0;
248 b1[0x16] = b2[0x16] + b2[0x17];
249 b1[0x17] = (b2[0x17] - b2[0x16]) * cos0;
250 b1[0x16] += b1[0x17];
251 b1[0x14] += b1[0x16];
252 b1[0x16] += b1[0x15];
253 b1[0x15] += b1[0x17];
254
255 b1[0x18] = b2[0x18] + b2[0x19];
256 b1[0x19] = (b2[0x18] - b2[0x19]) * cos0;
257 b1[0x1A] = b2[0x1A] + b2[0x1B];
258 b1[0x1B] = (b2[0x1B] - b2[0x1A]) * cos0;
259 b1[0x1A] += b1[0x1B];
260
261 b1[0x1C] = b2[0x1C] + b2[0x1D];
262 b1[0x1D] = (b2[0x1C] - b2[0x1D]) * cos0;
263 b1[0x1E] = b2[0x1E] + b2[0x1F];
264 b1[0x1F] = (b2[0x1F] - b2[0x1E]) * cos0;
265 b1[0x1E] += b1[0x1F];
266 b1[0x1C] += b1[0x1E];
267 b1[0x1E] += b1[0x1D];
268 b1[0x1D] += b1[0x1F];
269 }
270
271 out0[0x10*16] = b1[0x00];
272 out0[0x10*12] = b1[0x04];
273 out0[0x10* 8] = b1[0x02];
274 out0[0x10* 4] = b1[0x06];
275 out0[0x10* 0] = b1[0x01];
276 out1[0x10* 0] = b1[0x01];
277 out1[0x10* 4] = b1[0x05];
278 out1[0x10* 8] = b1[0x03];
279 out1[0x10*12] = b1[0x07];
280
281 out0[0x10*14] = b1[0x08] + b1[0x0C];
282 out0[0x10*10] = b1[0x0C] + b1[0x0a];
283 out0[0x10* 6] = b1[0x0A] + b1[0x0E];
284 out0[0x10* 2] = b1[0x0E] + b1[0x09];
285 out1[0x10* 2] = b1[0x09] + b1[0x0D];
286 out1[0x10* 6] = b1[0x0D] + b1[0x0B];
287 out1[0x10*10] = b1[0x0B] + b1[0x0F];
288 out1[0x10*14] = b1[0x0F];
289
290 {
291 register mpeg3_real_t tmp;
292 tmp = b1[0x18] + b1[0x1C];
293 out0[0x10*15] = tmp + b1[0x10];
294 out0[0x10*13] = tmp + b1[0x14];
295 tmp = b1[0x1C] + b1[0x1A];
296 out0[0x10*11] = tmp + b1[0x14];
297 out0[0x10* 9] = tmp + b1[0x12];
298 tmp = b1[0x1A] + b1[0x1E];
299 out0[0x10* 7] = tmp + b1[0x12];
300 out0[0x10* 5] = tmp + b1[0x16];
301 tmp = b1[0x1E] + b1[0x19];
302 out0[0x10* 3] = tmp + b1[0x16];
303 out0[0x10* 1] = tmp + b1[0x11];
304 tmp = b1[0x19] + b1[0x1D];
305 out1[0x10* 1] = tmp + b1[0x11];
306 out1[0x10* 3] = tmp + b1[0x15];
307 tmp = b1[0x1D] + b1[0x1B];
308 out1[0x10* 5] = tmp + b1[0x15];
309 out1[0x10* 7] = tmp + b1[0x13];
310 tmp = b1[0x1B] + b1[0x1F];
311 out1[0x10* 9] = tmp + b1[0x13];
312 out1[0x10*11] = tmp + b1[0x17];
313 out1[0x10*13] = b1[0x17] + b1[0x1F];
314 out1[0x10*15] = b1[0x1F];
315 }
316 return 0;
317}
318
319/*
320 * the call via dct64 is a trick to force GCC to use
321 * (new) registers for the b1,b2 pointer to the bufs[xx] field
322 */
323int mpeg3audio_dct64(mpeg3_real_t *a, mpeg3_real_t *b, mpeg3_real_t *c)
324{
325 mpeg3_real_t bufs[0x40];
326 return mpeg3audio_dct64_1(a, b, bufs, bufs + 0x20, c);
327}
328
329/*//////////////////////////////////////////////////////////////// */
330/* */
331/* 9 Point Inverse Discrete Cosine Transform */
332/* */
333/* This piece of code is Copyright 1997 Mikko Tommila and is freely usable */
334/* by anybody. The algorithm itself is of course in the public domain. */
335/* */
336/* Again derived heuristically from the 9-point WFTA. */
337/* */
338/* The algorithm is optimized (?) for speed, not for small rounding errors or */
339/* good readability. */
340/* */
341/* 36 additions, 11 multiplications */
342/* */
343/* Again this is very likely sub-optimal. */
344/* */
345/* The code is optimized to use a minimum number of temporary variables, */
346/* so it should compile quite well even on 8-register Intel x86 processors. */
347/* This makes the code quite obfuscated and very difficult to understand. */
348/* */
349/* References: */
350/* [1] S. Winograd: "On Computing the Discrete Fourier Transform", */
351/* Mathematics of Computation, Volume 32, Number 141, January 1978, */
352/* Pages 175-199 */
353
354
355/*------------------------------------------------------------------*/
356/* */
357/* Function: Calculation of the inverse MDCT */
358/* */
359/*------------------------------------------------------------------*/
360
361int mpeg3audio_dct36(mpeg3_real_t *inbuf, mpeg3_real_t *o1, mpeg3_real_t *o2, mpeg3_real_t *wintab, mpeg3_real_t *tsbuf)
362{
363 mpeg3_real_t tmp[18];
364
365 {
366 register mpeg3_real_t *in = inbuf;
367
368 in[17]+=in[16]; in[16]+=in[15]; in[15]+=in[14];
369 in[14]+=in[13]; in[13]+=in[12]; in[12]+=in[11];
370 in[11]+=in[10]; in[10]+=in[9]; in[9] +=in[8];
371 in[8] +=in[7]; in[7] +=in[6]; in[6] +=in[5];
372 in[5] +=in[4]; in[4] +=in[3]; in[3] +=in[2];
373 in[2] +=in[1]; in[1] +=in[0];
374
375 in[17]+=in[15]; in[15]+=in[13]; in[13]+=in[11]; in[11]+=in[9];
376 in[9] +=in[7]; in[7] +=in[5]; in[5] +=in[3]; in[3] +=in[1];
377
378
379 {
380 mpeg3_real_t t3;
381 {
382 mpeg3_real_t t0, t1, t2;
383
384 t0 = mpeg3_COS6_2 * (in[8] + in[16] - in[4]);
385 t1 = mpeg3_COS6_2 * in[12];
386
387 t3 = in[0];
388 t2 = t3 - t1 - t1;
389 tmp[1] = tmp[7] = t2 - t0;
390 tmp[4] = t2 + t0 + t0;
391 t3 += t1;
392
393 t2 = mpeg3_COS6_1 * (in[10] + in[14] - in[2]);
394 tmp[1] -= t2;
395 tmp[7] += t2;
396 }
397 {
398 mpeg3_real_t t0, t1, t2;
399
400 t0 = mpeg3_cos9[0] * (in[4] + in[8] );
401 t1 = mpeg3_cos9[1] * (in[8] - in[16]);
402 t2 = mpeg3_cos9[2] * (in[4] + in[16]);
403
404 tmp[2] = tmp[6] = t3 - t0 - t2;
405 tmp[0] = tmp[8] = t3 + t0 + t1;
406 tmp[3] = tmp[5] = t3 - t1 + t2;
407 }
408 }
409 {
410 mpeg3_real_t t1, t2, t3;
411
412 t1 = mpeg3_cos18[0] * (in[2] + in[10]);
413 t2 = mpeg3_cos18[1] * (in[10] - in[14]);
414 t3 = mpeg3_COS6_1 * in[6];
415
416 {
417 mpeg3_real_t t0 = t1 + t2 + t3;
418 tmp[0] += t0;
419 tmp[8] -= t0;
420 }
421
422 t2 -= t3;
423 t1 -= t3;
424
425 t3 = mpeg3_cos18[2] * (in[2] + in[14]);
426
427 t1 += t3;
428 tmp[3] += t1;
429 tmp[5] -= t1;
430
431 t2 -= t3;
432 tmp[2] += t2;
433 tmp[6] -= t2;
434 }
435
436
437 {
438 mpeg3_real_t t0, t1, t2, t3, t4, t5, t6, t7;
439
440 t1 = mpeg3_COS6_2 * in[13];
441 t2 = mpeg3_COS6_2 * (in[9] + in[17] - in[5]);
442
443 t3 = in[1] + t1;
444 t4 = in[1] - t1 - t1;
445 t5 = t4 - t2;
446
447 t0 = mpeg3_cos9[0] * (in[5] + in[9]);
448 t1 = mpeg3_cos9[1] * (in[9] - in[17]);
449
450 tmp[13] = (t4 + t2 + t2) * mpeg3_tfcos36[17-13];
451 t2 = mpeg3_cos9[2] * (in[5] + in[17]);
452
453 t6 = t3 - t0 - t2;
454 t0 += t3 + t1;
455 t3 += t2 - t1;
456
457 t2 = mpeg3_cos18[0] * (in[3] + in[11]);
458 t4 = mpeg3_cos18[1] * (in[11] - in[15]);
459 t7 = mpeg3_COS6_1 * in[7];
460
461 t1 = t2 + t4 + t7;
462 tmp[17] = (t0 + t1) * mpeg3_tfcos36[17-17];
463 tmp[9] = (t0 - t1) * mpeg3_tfcos36[17-9];
464 t1 = mpeg3_cos18[2] * (in[3] + in[15]);
465 t2 += t1 - t7;
466
467 tmp[14] = (t3 + t2) * mpeg3_tfcos36[17-14];
468 t0 = mpeg3_COS6_1 * (in[11] + in[15] - in[3]);
469 tmp[12] = (t3 - t2) * mpeg3_tfcos36[17-12];
470
471 t4 -= t1 + t7;
472
473 tmp[16] = (t5 - t0) * mpeg3_tfcos36[17-16];
474 tmp[10] = (t5 + t0) * mpeg3_tfcos36[17-10];
475 tmp[15] = (t6 + t4) * mpeg3_tfcos36[17-15];
476 tmp[11] = (t6 - t4) * mpeg3_tfcos36[17-11];
477 }
478
479#define MACRO(v) \
480 { \
481 mpeg3_real_t tmpval; \
482 tmpval = tmp[(v)] + tmp[17-(v)]; \
483 out2[9+(v)] = tmpval * w[27+(v)]; \
484 out2[8-(v)] = tmpval * w[26-(v)]; \
485 tmpval = tmp[(v)] - tmp[17-(v)]; \
486 ts[SBLIMIT*(8-(v))] = out1[8-(v)] + tmpval * w[8-(v)]; \
487 ts[SBLIMIT*(9+(v))] = out1[9+(v)] + tmpval * w[9+(v)]; \
488 }
489
490 {
491 register mpeg3_real_t *out2 = o2;
492 register mpeg3_real_t *w = wintab;
493 register mpeg3_real_t *out1 = o1;
494 register mpeg3_real_t *ts = tsbuf;
495
496 MACRO(0);
497 MACRO(1);
498 MACRO(2);
499 MACRO(3);
500 MACRO(4);
501 MACRO(5);
502 MACRO(6);
503 MACRO(7);
504 MACRO(8);
505 }
506 }
507 return 0;
508}
509
510/*
511 * new DCT12
512 */
513int mpeg3audio_dct12(mpeg3_real_t *in,mpeg3_real_t *rawout1,mpeg3_real_t *rawout2,register mpeg3_real_t *wi,register mpeg3_real_t *ts)
514{
515#define DCT12_PART1 \
516 in5 = in[5*3]; \
517 in5 += (in4 = in[4*3]); \
518 in4 += (in3 = in[3*3]); \
519 in3 += (in2 = in[2*3]); \
520 in2 += (in1 = in[1*3]); \
521 in1 += (in0 = in[0*3]); \
522 \
523 in5 += in3; in3 += in1; \
524 \
525 in2 *= mpeg3_COS6_1; \
526 in3 *= mpeg3_COS6_1; \
527
528#define DCT12_PART2 \
529 in0 += in4 * mpeg3_COS6_2; \
530 \
531 in4 = in0 + in2; \
532 in0 -= in2; \
533 \
534 in1 += in5 * mpeg3_COS6_2; \
535 \
536 in5 = (in1 + in3) * mpeg3_tfcos12[0]; \
537 in1 = (in1 - in3) * mpeg3_tfcos12[2]; \
538 \
539 in3 = in4 + in5; \
540 in4 -= in5; \
541 \
542 in2 = in0 + in1; \
543 in0 -= in1;
544
545
546 {
547 mpeg3_real_t in0,in1,in2,in3,in4,in5;
548 register mpeg3_real_t *out1 = rawout1;
549 ts[SBLIMIT*0] = out1[0]; ts[SBLIMIT*1] = out1[1]; ts[SBLIMIT*2] = out1[2];
550 ts[SBLIMIT*3] = out1[3]; ts[SBLIMIT*4] = out1[4]; ts[SBLIMIT*5] = out1[5];
551
552 DCT12_PART1
553
554 {
555 mpeg3_real_t tmp0,tmp1 = (in0 - in4);
556 {
557 mpeg3_real_t tmp2 = (in1 - in5) * mpeg3_tfcos12[1];
558 tmp0 = tmp1 + tmp2;
559 tmp1 -= tmp2;
560 }
561 ts[(17-1)*SBLIMIT] = out1[17-1] + tmp0 * wi[11-1];
562 ts[(12+1)*SBLIMIT] = out1[12+1] + tmp0 * wi[6+1];
563 ts[(6 +1)*SBLIMIT] = out1[6 +1] + tmp1 * wi[1];
564 ts[(11-1)*SBLIMIT] = out1[11-1] + tmp1 * wi[5-1];
565 }
566
567 DCT12_PART2
568
569 ts[(17-0)*SBLIMIT] = out1[17-0] + in2 * wi[11-0];
570 ts[(12+0)*SBLIMIT] = out1[12+0] + in2 * wi[6+0];
571 ts[(12+2)*SBLIMIT] = out1[12+2] + in3 * wi[6+2];
572 ts[(17-2)*SBLIMIT] = out1[17-2] + in3 * wi[11-2];
573
574 ts[(6+0)*SBLIMIT] = out1[6+0] + in0 * wi[0];
575 ts[(11-0)*SBLIMIT] = out1[11-0] + in0 * wi[5-0];
576 ts[(6+2)*SBLIMIT] = out1[6+2] + in4 * wi[2];
577 ts[(11-2)*SBLIMIT] = out1[11-2] + in4 * wi[5-2];
578 }
579
580 in++;
581
582 {
583 mpeg3_real_t in0,in1,in2,in3,in4,in5;
584 register mpeg3_real_t *out2 = rawout2;
585
586 DCT12_PART1
587
588 {
589 mpeg3_real_t tmp0,tmp1 = (in0 - in4);
590 {
591 mpeg3_real_t tmp2 = (in1 - in5) * mpeg3_tfcos12[1];
592 tmp0 = tmp1 + tmp2;
593 tmp1 -= tmp2;
594 }
595 out2[5-1] = tmp0 * wi[11-1];
596 out2[0+1] = tmp0 * wi[6+1];
597 ts[(12+1)*SBLIMIT] += tmp1 * wi[1];
598 ts[(17-1)*SBLIMIT] += tmp1 * wi[5-1];
599 }
600
601 DCT12_PART2
602
603 out2[5-0] = in2 * wi[11-0];
604 out2[0+0] = in2 * wi[6+0];
605 out2[0+2] = in3 * wi[6+2];
606 out2[5-2] = in3 * wi[11-2];
607
608 ts[(12+0)*SBLIMIT] += in0 * wi[0];
609 ts[(17-0)*SBLIMIT] += in0 * wi[5-0];
610 ts[(12+2)*SBLIMIT] += in4 * wi[2];
611 ts[(17-2)*SBLIMIT] += in4 * wi[5-2];
612 }
613
614 in++;
615
616 {
617 mpeg3_real_t in0,in1,in2,in3,in4,in5;
618 register mpeg3_real_t *out2 = rawout2;
619 out2[12]=out2[13]=out2[14]=out2[15]=out2[16]=out2[17]=0.0;
620
621 DCT12_PART1
622
623 {
624 mpeg3_real_t tmp0,tmp1 = (in0 - in4);
625 {
626 mpeg3_real_t tmp2 = (in1 - in5) * mpeg3_tfcos12[1];
627 tmp0 = tmp1 + tmp2;
628 tmp1 -= tmp2;
629 }
630 out2[11-1] = tmp0 * wi[11-1];
631 out2[6 +1] = tmp0 * wi[6+1];
632 out2[0+1] += tmp1 * wi[1];
633 out2[5-1] += tmp1 * wi[5-1];
634 }
635
636 DCT12_PART2
637
638 out2[11-0] = in2 * wi[11-0];
639 out2[6 +0] = in2 * wi[6+0];
640 out2[6 +2] = in3 * wi[6+2];
641 out2[11-2] = in3 * wi[11-2];
642
643 out2[0+0] += in0 * wi[0];
644 out2[5-0] += in0 * wi[5-0];
645 out2[0+2] += in4 * wi[2];
646 out2[5-2] += in4 * wi[5-2];
647 }
648 return 0;
649}
650
651/* AC3 IMDCT tables */
652
653/* Twiddle factors for IMDCT */
654#if !defined(USE_FIXED_POINT) || defined(PRINT_FIXED_POINT_TABLES)
655static mpeg3_real_t mpeg3_xcos1[AC3_N / 4];
656static mpeg3_real_t mpeg3_xsin1[AC3_N / 4];
657static mpeg3_real_t mpeg3_xcos2[AC3_N / 8];
658static mpeg3_real_t mpeg3_xsin2[AC3_N / 8];
659#else
660#define USE_FP_TABLES
661#include "fptables.h"
662#endif
663
664/* 128 point bit-reverse LUT */
665static unsigned char mpeg3_bit_reverse_512[] =
666{
667 0x00, 0x40, 0x20, 0x60, 0x10, 0x50, 0x30, 0x70,
668 0x08, 0x48, 0x28, 0x68, 0x18, 0x58, 0x38, 0x78,
669 0x04, 0x44, 0x24, 0x64, 0x14, 0x54, 0x34, 0x74,
670 0x0c, 0x4c, 0x2c, 0x6c, 0x1c, 0x5c, 0x3c, 0x7c,
671 0x02, 0x42, 0x22, 0x62, 0x12, 0x52, 0x32, 0x72,
672 0x0a, 0x4a, 0x2a, 0x6a, 0x1a, 0x5a, 0x3a, 0x7a,
673 0x06, 0x46, 0x26, 0x66, 0x16, 0x56, 0x36, 0x76,
674 0x0e, 0x4e, 0x2e, 0x6e, 0x1e, 0x5e, 0x3e, 0x7e,
675 0x01, 0x41, 0x21, 0x61, 0x11, 0x51, 0x31, 0x71,
676 0x09, 0x49, 0x29, 0x69, 0x19, 0x59, 0x39, 0x79,
677 0x05, 0x45, 0x25, 0x65, 0x15, 0x55, 0x35, 0x75,
678 0x0d, 0x4d, 0x2d, 0x6d, 0x1d, 0x5d, 0x3d, 0x7d,
679 0x03, 0x43, 0x23, 0x63, 0x13, 0x53, 0x33, 0x73,
680 0x0b, 0x4b, 0x2b, 0x6b, 0x1b, 0x5b, 0x3b, 0x7b,
681 0x07, 0x47, 0x27, 0x67, 0x17, 0x57, 0x37, 0x77,
682 0x0f, 0x4f, 0x2f, 0x6f, 0x1f, 0x5f, 0x3f, 0x7f
683};
684
685static unsigned char mpeg3_bit_reverse_256[] =
686{
687 0x00, 0x20, 0x10, 0x30, 0x08, 0x28, 0x18, 0x38,
688 0x04, 0x24, 0x14, 0x34, 0x0c, 0x2c, 0x1c, 0x3c,
689 0x02, 0x22, 0x12, 0x32, 0x0a, 0x2a, 0x1a, 0x3a,
690 0x06, 0x26, 0x16, 0x36, 0x0e, 0x2e, 0x1e, 0x3e,
691 0x01, 0x21, 0x11, 0x31, 0x09, 0x29, 0x19, 0x39,
692 0x05, 0x25, 0x15, 0x35, 0x0d, 0x2d, 0x1d, 0x3d,
693 0x03, 0x23, 0x13, 0x33, 0x0b, 0x2b, 0x1b, 0x3b,
694 0x07, 0x27, 0x17, 0x37, 0x0f, 0x2f, 0x1f, 0x3f
695};
696
697/* Windowing function for Modified DCT - Thank you acroread */
698static mpeg3_real_t mpeg3_window[] =
699{
700 0.00014, 0.00024, 0.00037, 0.00051, 0.00067, 0.00086, 0.00107, 0.00130,
701 0.00157, 0.00187, 0.00220, 0.00256, 0.00297, 0.00341, 0.00390, 0.00443,
702 0.00501, 0.00564, 0.00632, 0.00706, 0.00785, 0.00871, 0.00962, 0.01061,
703 0.01166, 0.01279, 0.01399, 0.01526, 0.01662, 0.01806, 0.01959, 0.02121,
704 0.02292, 0.02472, 0.02662, 0.02863, 0.03073, 0.03294, 0.03527, 0.03770,
705 0.04025, 0.04292, 0.04571, 0.04862, 0.05165, 0.05481, 0.05810, 0.06153,
706 0.06508, 0.06878, 0.07261, 0.07658, 0.08069, 0.08495, 0.08935, 0.09389,
707 0.09859, 0.10343, 0.10842, 0.11356, 0.11885, 0.12429, 0.12988, 0.13563,
708 0.14152, 0.14757, 0.15376, 0.16011, 0.16661, 0.17325, 0.18005, 0.18699,
709 0.19407, 0.20130, 0.20867, 0.21618, 0.22382, 0.23161, 0.23952, 0.24757,
710 0.25574, 0.26404, 0.27246, 0.28100, 0.28965, 0.29841, 0.30729, 0.31626,
711 0.32533, 0.33450, 0.34376, 0.35311, 0.36253, 0.37204, 0.38161, 0.39126,
712 0.40096, 0.41072, 0.42054, 0.43040, 0.44030, 0.45023, 0.46020, 0.47019,
713 0.48020, 0.49022, 0.50025, 0.51028, 0.52031, 0.53033, 0.54033, 0.55031,
714 0.56026, 0.57019, 0.58007, 0.58991, 0.59970, 0.60944, 0.61912, 0.62873,
715 0.63827, 0.64774, 0.65713, 0.66643, 0.67564, 0.68476, 0.69377, 0.70269,
716 0.71150, 0.72019, 0.72877, 0.73723, 0.74557, 0.75378, 0.76186, 0.76981,
717 0.77762, 0.78530, 0.79283, 0.80022, 0.80747, 0.81457, 0.82151, 0.82831,
718 0.83496, 0.84145, 0.84779, 0.85398, 0.86001, 0.86588, 0.87160, 0.87716,
719 0.88257, 0.88782, 0.89291, 0.89785, 0.90264, 0.90728, 0.91176, 0.91610,
720 0.92028, 0.92432, 0.92822, 0.93197, 0.93558, 0.93906, 0.94240, 0.94560,
721 0.94867, 0.95162, 0.95444, 0.95713, 0.95971, 0.96217, 0.96451, 0.96674,
722 0.96887, 0.97089, 0.97281, 0.97463, 0.97635, 0.97799, 0.97953, 0.98099,
723 0.98236, 0.98366, 0.98488, 0.98602, 0.98710, 0.98811, 0.98905, 0.98994,
724 0.99076, 0.99153, 0.99225, 0.99291, 0.99353, 0.99411, 0.99464, 0.99513,
725 0.99558, 0.99600, 0.99639, 0.99674, 0.99706, 0.99736, 0.99763, 0.99788,
726 0.99811, 0.99831, 0.99850, 0.99867, 0.99882, 0.99895, 0.99908, 0.99919,
727 0.99929, 0.99938, 0.99946, 0.99953, 0.99959, 0.99965, 0.99969, 0.99974,
728 0.99978, 0.99981, 0.99984, 0.99986, 0.99988, 0.99990, 0.99992, 0.99993,
729 0.99994, 0.99995, 0.99996, 0.99997, 0.99998, 0.99998, 0.99998, 0.99999,
730 0.99999, 0.99999, 0.99999, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000,
731 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000, 1.00000
732};
733
734mpeg3_complex_t cmplx_mult(mpeg3_complex_t a, mpeg3_complex_t b)
735{
736 mpeg3_complex_t ret;
737
738 ret.real = a.real * b.real - a.imag * b.imag;
739 ret.imag = a.real * b.imag + a.imag * b.real;
740
741 return ret;
742}
743
744int mpeg3audio_imdct_init(mpeg3audio_t *audio)
745{
746 int i, k;
747 mpeg3_complex_t angle_step;
748 mpeg3_complex_t current_angle;
749
750/* Twiddle factors to turn IFFT into IMDCT */
751 for(i = 0; i < AC3_N / 4; i++)
752 {
753 mpeg3_xcos1[i] = -cos(2.0f * M_PI * (8 * i + 1 ) / ( 8 * AC3_N));
754 mpeg3_xsin1[i] = -sin(2.0f * M_PI * (8 * i + 1 ) / ( 8 * AC3_N));
755 }
756
757/* More twiddle factors to turn IFFT into IMDCT */
758 for(i = 0; i < AC3_N / 8; i++)
759 {
760 mpeg3_xcos2[i] = -cos(2.0f * M_PI * (8 * i + 1 ) / ( 4 * AC3_N));
761 mpeg3_xsin2[i] = -sin(2.0f * M_PI * (8 * i + 1 ) / ( 4 * AC3_N));
762 }
763
764/* Canonical twiddle factors for FFT */
765#if defined(USE_FIXED_POINT) && !defined(PRINT_FIXED_POINT_TABLES)
766 for(i = 0; i < 7; i++)
767 {
768 audio->ac3_w[i] = (mpeg3_complex_t*)ac3_w_fixedpoints[i];
769 }
770#else
771 audio->ac3_w[0] = audio->ac3_w_1;
772 audio->ac3_w[1] = audio->ac3_w_2;
773 audio->ac3_w[2] = audio->ac3_w_4;
774 audio->ac3_w[3] = audio->ac3_w_8;
775 audio->ac3_w[4] = audio->ac3_w_16;
776 audio->ac3_w[5] = audio->ac3_w_32;
777 audio->ac3_w[6] = audio->ac3_w_64;
778
779 for(i = 0; i < 7; i++)
780 {
781 angle_step.real = cos(-2.0f * M_PI / (1 << (i + 1)));
782 angle_step.imag = sin(-2.0f * M_PI / (1 << (i + 1)));
783
784 current_angle.real = 1.0f;
785 current_angle.imag = 0.0f;
786
787 for (k = 0; k < 1 << i; k++)
788 {
789 audio->ac3_w[i][k] = current_angle;
790 current_angle = cmplx_mult(current_angle, angle_step);
791 }
792 }
793
794#ifdef PRINT_FIXED_POINT_TABLES
795 printf("#ifdef USE_FP_TABLES\n");
796 printf("static long mpeg3_xcos1_fixedpoints[] = {");
797 for(i = 0; i < AC3_N / 4; i++) {
798 printf("%c0x%08x,", i%8?' ':'\n', mpeg3_xcos1[i].fixedPoint());
799 }
800 printf("\n};\nstatic mpeg3_real_t *mpeg3_xcos1 = \n"
801 "(mpeg3_real_t*)mpeg3_xcos1_fixedpoints;\n");
802
803 printf("static long mpeg3_xsin1_fixedpoints[] = {");
804 for(i = 0; i < AC3_N / 4; i++) {
805 printf("%c0x%08x,", i%8?' ':'\n', mpeg3_xsin1[i].fixedPoint());
806 }
807 printf("\n};\nstatic mpeg3_real_t *mpeg3_xsin1 = \n"
808 "(mpeg3_real_t*)mpeg3_xsin1_fixedpoints;\n");
809
810
811 printf("static long mpeg3_xcos2_fixedpoints[] = {");
812 for(i = 0; i < AC3_N / 4; i++) {
813 printf("%c0x%08x,", i%8?' ':'\n', mpeg3_xcos2[i].fixedPoint());
814 }
815 printf("\n};\nstatic mpeg3_real_t *mpeg3_xcos2 = \n"
816 "(mpeg3_real_t*)mpeg3_xcos2_fixedpoints;\n");
817
818 printf("static long mpeg3_xsin2_fixedpoints[] = {");
819 for(i = 0; i < AC3_N / 4; i++) {
820 printf("%c0x%08x,", i%8?' ':'\n', mpeg3_xsin2[i].fixedPoint());
821 }
822 printf("\n};\nstatic mpeg3_real_t *mpeg3_xsin2 = \n"
823 "(mpeg3_real_t*)mpeg3_xsin2_fixedpoints;\n");
824
825
826 printf("typedef struct { long r, i; } fixed_cmplx;\n");
827 for(i = 0; i < 7; i++)
828 {
829 printf("fixed_cmplx ac3_w_d%d[] = { ", 1<<i);
830 for (k = 0; k < 1 << i; k++)
831 {
832 printf("%s{ 0x%08x, 0x%08x },", k%4?" ":"\n ",
833 audio->ac3_w[i][k].real.fixedPoint(),
834 audio->ac3_w[i][k].imag.fixedPoint());
835 }
836 printf("};\n");
837 }
838
839 printf("fixed_cmplx *ac3_w_fixedpoints[] = {\n");
840 for(i = 0; i < 7; i++)
841 {
842 printf("ac3_w_d%d, ", 1<<i);
843 }
844 printf("};\n");
845 printf("#endif\n");
846#endif
847#endif
848
849 return 0;
850}
851
852
853inline void swap_cmplx(mpeg3_complex_t *a, mpeg3_complex_t *b)
854{
855 mpeg3_complex_t tmp;
856
857 tmp = *a;
858 *a = *b;
859 *b = tmp;
860}
861
862void mpeg3audio_ac3_imdct_do_512(mpeg3audio_t *audio,
863 mpeg3_real_t data[],
864 mpeg3_real_t *y,
865 int step,
866 mpeg3_real_t *delay)
867{
868 int i, k;
869 int p, q;
870 int m;
871 int two_m;
872 int two_m_plus_one;
873
874 mpeg3_real_t tmp_a_i;
875 mpeg3_real_t tmp_a_r;
876 mpeg3_real_t tmp_b_i;
877 mpeg3_real_t tmp_b_r;
878
879 mpeg3_real_t *y_ptr;
880 mpeg3_real_t *delay_ptr;
881 mpeg3_real_t *window_ptr;
882 mpeg3_complex_t *buf = audio->ac3_imdct_buf;
883
884/* Pre IFFT complex multiply plus IFFT cmplx conjugate */
885 for(i = 0; i < AC3_N / 4; i++)
886 {
887 buf[i].real = (data[AC3_N / 2 - 2 * i - 1] * mpeg3_xcos1[i]) - (data[2 * i] * mpeg3_xsin1[i]);
888 buf[i].imag = -((data[2 * i] * mpeg3_xcos1[i]) + (data[AC3_N / 2 - 2 * i - 1] * mpeg3_xsin1[i]));
889 }
890
891/* Bit reversed shuffling */
892 for(i = 0; i < AC3_N / 4; i++)
893 {
894 k = mpeg3_bit_reverse_512[i];
895 if(k < i)
896 swap_cmplx(&buf[i], &buf[k]);
897 }
898
899/* FFT Merge */
900 for(m = 0; m < 7; m++)
901 {
902 if(m)
903 two_m = (1 << m);
904 else
905 two_m = 1;
906
907 two_m_plus_one = (1 << (m + 1));
908
909 for(k = 0; k < two_m; k++)
910 {
911 for(i = 0; i < AC3_N / 4; i += two_m_plus_one)
912 {
913 p = k + i;
914 q = p + two_m;
915 tmp_a_r = buf[p].real;
916 tmp_a_i = buf[p].imag;
917 tmp_b_r = buf[q].real * audio->ac3_w[m][k].real - buf[q].imag * audio->ac3_w[m][k].imag;
918 tmp_b_i = buf[q].imag * audio->ac3_w[m][k].real + buf[q].real * audio->ac3_w[m][k].imag;
919 buf[p].real = tmp_a_r + tmp_b_r;
920 buf[p].imag = tmp_a_i + tmp_b_i;
921 buf[q].real = tmp_a_r - tmp_b_r;
922 buf[q].imag = tmp_a_i - tmp_b_i;
923 }
924 }
925 }
926
927/* Post IFFT complex multiply plus IFFT complex conjugate*/
928 for(i = 0; i < AC3_N / 4; i++)
929 {
930 tmp_a_r = buf[i].real;
931 tmp_a_i = -buf[i].imag;
932 buf[i].real = (tmp_a_r * mpeg3_xcos1[i]) - (tmp_a_i * mpeg3_xsin1[i]);
933 buf[i].imag = (tmp_a_r * mpeg3_xsin1[i]) + (tmp_a_i * mpeg3_xcos1[i]);
934 }
935
936 y_ptr = y;
937 delay_ptr = delay;
938 window_ptr = mpeg3_window;
939
940/* Window and convert to real valued signal */
941 for(i = 0; i < AC3_N / 8; i++)
942 {
943 *y_ptr = -buf[AC3_N / 8 + i].imag * *window_ptr++ + *delay_ptr++;
944 y_ptr += step;
945 *y_ptr = buf[AC3_N / 8 - i - 1].real * *window_ptr++ + *delay_ptr++;
946 y_ptr += step;
947 }
948
949 for(i = 0; i < AC3_N / 8; i++)
950 {
951 *y_ptr = -buf[i].real * *window_ptr++ + *delay_ptr++;
952 y_ptr += step;
953 *y_ptr = buf[AC3_N / 4 - i - 1].imag * *window_ptr++ + *delay_ptr++;
954 y_ptr += step;
955 }
956
957/* The trailing edge of the window goes into the delay line */
958 delay_ptr = delay;
959
960 for(i = 0; i < AC3_N / 8; i++)
961 {
962 *delay_ptr++ = -buf[AC3_N / 8 + i].real * *--window_ptr;
963 *delay_ptr++ = buf[AC3_N / 8 - i - 1].imag * *--window_ptr;
964 }
965
966 for(i = 0; i < AC3_N / 8; i++)
967 {
968 *delay_ptr++ = buf[i].imag * *--window_ptr;
969 *delay_ptr++ = -buf[AC3_N / 4 - i - 1].real * *--window_ptr;
970 }
971}
972
973void mpeg3audio_ac3_imdct_do_256(mpeg3audio_t *audio,
974 mpeg3_real_t data[],
975 mpeg3_real_t *y,
976 int step,
977 mpeg3_real_t *delay)
978{
979 int i, k;
980 int p, q;
981 int m;
982 int two_m;
983 int two_m_plus_one;
984 mpeg3_complex_t *buf = audio->ac3_imdct_buf;
985 mpeg3_real_t *y_ptr;
986 mpeg3_real_t *delay_ptr;
987 mpeg3_real_t *window_ptr;
988
989 mpeg3_real_t tmp_a_i;
990 mpeg3_real_t tmp_a_r;
991 mpeg3_real_t tmp_b_i;
992 mpeg3_real_t tmp_b_r;
993
994 mpeg3_complex_t *buf_1, *buf_2;
995
996 buf_1 = &buf[0];
997 buf_2 = &buf[64];
998
999/* Pre IFFT complex multiply plus IFFT cmplx conjugate */
1000 for(k = 0; k < AC3_N / 8; k++)
1001 {
1002 p = 2 * (AC3_N / 4 - 2 * k - 1);
1003 q = 2 * (2 * k);
1004
1005 buf_1[k].real = data[p] * mpeg3_xcos2[k] - data[q] * mpeg3_xsin2[k];
1006 buf_1[k].imag = - (data[q] * mpeg3_xcos2[k] + data[p] * mpeg3_xsin2[k]);
1007 buf_2[k].real = data[p + 1] * mpeg3_xcos2[k] - data[q + 1] * mpeg3_xsin2[k];
1008 buf_2[k].imag = - (data[q + 1] * mpeg3_xcos2[k] + data[p + 1] * mpeg3_xsin2[k]);
1009 }
1010
1011/* IFFT Bit reversed shuffling */
1012 for(i = 0; i < AC3_N / 8; i++)
1013 {
1014 k = mpeg3_bit_reverse_256[i];
1015 if(k < i)
1016 {
1017 swap_cmplx(&buf_1[i], &buf_1[k]);
1018 swap_cmplx(&buf_2[i], &buf_2[k]);
1019 }
1020 }
1021
1022/* FFT Merge */
1023 for(m = 0; m < 6; m++)
1024 {
1025 if(m)
1026 two_m = (1 << m);
1027 else
1028 two_m = 1;
1029
1030 two_m_plus_one = (1 << (m + 1));
1031
1032 for(k = 0; k < two_m; k++)
1033 {
1034 for(i = 0; i < AC3_N / 8; i += two_m_plus_one)
1035 {
1036 p = k + i;
1037 q = p + two_m;
1038/* Do block 1 */
1039 tmp_a_r = buf_1[p].real;
1040 tmp_a_i = buf_1[p].imag;
1041 tmp_b_r = buf_1[q].real * audio->ac3_w[m][k].real - buf_1[q].imag * audio->ac3_w[m][k].imag;
1042 tmp_b_i = buf_1[q].imag * audio->ac3_w[m][k].real + buf_1[q].real * audio->ac3_w[m][k].imag;
1043 buf_1[p].real = tmp_a_r + tmp_b_r;
1044 buf_1[p].imag = tmp_a_i + tmp_b_i;
1045 buf_1[q].real = tmp_a_r - tmp_b_r;
1046 buf_1[q].imag = tmp_a_i - tmp_b_i;
1047
1048/* Do block 2 */
1049 tmp_a_r = buf_2[p].real;
1050 tmp_a_i = buf_2[p].imag;
1051 tmp_b_r = buf_2[q].real * audio->ac3_w[m][k].real - buf_2[q].imag * audio->ac3_w[m][k].imag;
1052 tmp_b_i = buf_2[q].imag * audio->ac3_w[m][k].real + buf_2[q].real * audio->ac3_w[m][k].imag;
1053 buf_2[p].real = tmp_a_r + tmp_b_r;
1054 buf_2[p].imag = tmp_a_i + tmp_b_i;
1055 buf_2[q].real = tmp_a_r - tmp_b_r;
1056 buf_2[q].imag = tmp_a_i - tmp_b_i;
1057 }
1058 }
1059 }
1060
1061/* Post IFFT complex multiply */
1062 for(i = 0; i < AC3_N / 8; i++)
1063 {
1064 tmp_a_r = buf_1[i].real;
1065 tmp_a_i = -buf_1[i].imag;
1066 buf_1[i].real = (tmp_a_r * mpeg3_xcos2[i]) - (tmp_a_i * mpeg3_xsin2[i]);
1067 buf_1[i].imag = (tmp_a_r * mpeg3_xsin2[i]) + (tmp_a_i * mpeg3_xcos2[i]);
1068 tmp_a_r = buf_2[i].real;
1069 tmp_a_i = -buf_2[i].imag;
1070 buf_2[i].real = (tmp_a_r * mpeg3_xcos2[i]) - (tmp_a_i * mpeg3_xsin2[i]);
1071 buf_2[i].imag = (tmp_a_r * mpeg3_xsin2[i]) + (tmp_a_i * mpeg3_xcos2[i]);
1072 }
1073
1074/* Window and convert to real valued signal */
1075 y_ptr = y;
1076 delay_ptr = delay;
1077 window_ptr = mpeg3_window;
1078
1079 for(i = 0; i < AC3_N / 8; i++)
1080 {
1081 *y_ptr = -buf[AC3_N / 8 + i].imag * *window_ptr++ + *delay_ptr++;
1082 y_ptr += step;
1083 *y_ptr = buf[AC3_N / 8 - i - 1].real * *window_ptr++ + *delay_ptr++;
1084 y_ptr += step;
1085 }
1086
1087 for(i = 0; i < AC3_N / 8; i++)
1088 {
1089 *y_ptr = -buf[i].real * *window_ptr++ + *delay_ptr++;
1090 y_ptr += step;
1091 *y_ptr = buf[AC3_N / 4 - i - 1].imag * *window_ptr++ + *delay_ptr++;
1092 y_ptr += step;
1093 }
1094
1095/* The trailing edge of the window goes into the delay line */
1096 delay_ptr = delay;
1097
1098 for(i = 0; i < AC3_N / 8; i++)
1099 {
1100 *delay_ptr++ = -buf[AC3_N / 8 + i].real * *--window_ptr;
1101 *delay_ptr++ = buf[AC3_N / 8 - i - 1].imag * *--window_ptr;
1102 }
1103
1104 for(i = 0; i < AC3_N / 8; i++)
1105 {
1106 *delay_ptr++ = buf[i].imag * *--window_ptr;
1107 *delay_ptr++ = -buf[AC3_N / 4 - i - 1].real * *--window_ptr;
1108 }
1109}
1110
1111int mpeg3audio_ac3_imdct(mpeg3audio_t *audio,
1112 mpeg3_ac3bsi_t *bsi,
1113 mpeg3_ac3audblk_t *audblk,
1114 mpeg3ac3_stream_samples_t samples)
1115{
1116 int i;
1117
1118 for(i = 0; i < bsi->nfchans; i++)
1119 {
1120 if(audblk->blksw[i])
1121 mpeg3audio_ac3_imdct_do_256(audio,
1122 samples[i],
1123 audio->pcm_sample + audio->pcm_point + i,
1124 bsi->nfchans,
1125 audio->ac3_delay[i]);
1126 else
1127 mpeg3audio_ac3_imdct_do_512(audio,
1128 samples[i],
1129 audio->pcm_sample + audio->pcm_point + i,
1130 bsi->nfchans,
1131 audio->ac3_delay[i]);
1132 }
1133 audio->pcm_point += AC3_N / 2 * bsi->nfchans;
1134 return 0;
1135}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/exponents.c b/core/multimedia/opieplayer/libmpeg3/audio/exponents.c
new file mode 100644
index 0000000..deda9b9
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/exponents.c
@@ -0,0 +1,141 @@
1/*
2 *
3 *exponents.c Copyright (C) Aaron Holtzman - May 1999
4 *
5 * This file is part of libmpeg3
6 *
7 * libmpeg3 is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * libmpeg3 is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include "mpeg3audio.h"
24#include "../libmpeg3.h"
25#include "../mpeg3protos.h"
26#include <stdio.h>
27
28/* Exponent defines */
29#define UNPACK_FBW 1
30#define UNPACK_CPL 2
31#define UNPACK_LFE 4
32
33static inline int mpeg3audio_ac3_exp_unpack_ch(unsigned int type,
34 unsigned int expstr,
35 unsigned int ngrps,
36 unsigned int initial_exp,
37 unsigned short exps[],
38 unsigned short *dest)
39{
40 int i, j;
41 int exp_acc;
42 int exp_1, exp_2, exp_3;
43
44 if(expstr == MPEG3_EXP_REUSE)
45 return 0;
46
47/* Handle the initial absolute exponent */
48 exp_acc = initial_exp;
49 j = 0;
50
51/* In the case of a fbw channel then the initial absolute value is
52 * also an exponent */
53 if(type != UNPACK_CPL)
54 dest[j++] = exp_acc;
55
56/* Loop through the groups and fill the dest array appropriately */
57 for(i = 0; i < ngrps; i++)
58 {
59 if(exps[i] > 124)
60 {
61 fprintf(stderr, "mpeg3audio_ac3_exp_unpack_ch: Invalid exponent %d\n", exps[i]);
62 return 1;
63 }
64
65 exp_1 = exps[i] / 25;
66 exp_2 = (exps[i] % 25) / 5;
67 exp_3 = (exps[i] % 25) % 5;
68
69 exp_acc += (exp_1 - 2);
70
71 switch(expstr)
72 {
73 case MPEG3_EXP_D45:
74 dest[j++] = exp_acc;
75 dest[j++] = exp_acc;
76 case MPEG3_EXP_D25:
77 dest[j++] = exp_acc;
78 case MPEG3_EXP_D15:
79 dest[j++] = exp_acc;
80 }
81
82 exp_acc += (exp_2 - 2);
83
84 switch(expstr)
85 {
86 case MPEG3_EXP_D45:
87 dest[j++] = exp_acc;
88 dest[j++] = exp_acc;
89 case MPEG3_EXP_D25:
90 dest[j++] = exp_acc;
91 case MPEG3_EXP_D15:
92 dest[j++] = exp_acc;
93 }
94
95 exp_acc += (exp_3 - 2);
96
97 switch(expstr)
98 {
99 case MPEG3_EXP_D45:
100 dest[j++] = exp_acc;
101 dest[j++] = exp_acc;
102 case MPEG3_EXP_D25:
103 dest[j++] = exp_acc;
104 case MPEG3_EXP_D15:
105 dest[j++] = exp_acc;
106 }
107 }
108 return 0;
109}
110
111int mpeg3audio_ac3_exponent_unpack(mpeg3audio_t *audio,
112 mpeg3_ac3bsi_t *bsi,
113 mpeg3_ac3audblk_t *audblk)
114{
115 int i, result = 0;
116
117 for(i = 0; i < bsi->nfchans; i++)
118 result |= mpeg3audio_ac3_exp_unpack_ch(UNPACK_FBW,
119 audblk->chexpstr[i],
120 audblk->nchgrps[i],
121 audblk->exps[i][0],
122 &audblk->exps[i][1],
123 audblk->fbw_exp[i]);
124
125 if(audblk->cplinu && !result)
126 result |= mpeg3audio_ac3_exp_unpack_ch(UNPACK_CPL,
127 audblk->cplexpstr,
128 audblk->ncplgrps,
129 audblk->cplabsexp << 1,
130 audblk->cplexps,
131 &audblk->cpl_exp[audblk->cplstrtmant]);
132
133 if(bsi->lfeon && !result)
134 result |= mpeg3audio_ac3_exp_unpack_ch(UNPACK_LFE,
135 audblk->lfeexpstr,
136 2,
137 audblk->lfeexps[0],
138 &audblk->lfeexps[1],
139 audblk->lfe_exp);
140 return result;
141}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/fptables.h b/core/multimedia/opieplayer/libmpeg3/audio/fptables.h
new file mode 100644
index 0000000..2836984
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/fptables.h
@@ -0,0 +1,1556 @@
1#ifdef USE_FP_TABLES
2static long mpeg3_xcos1_fixedpoints[] = {
30xffff8001, 0xffff8004, 0xffff800c, 0xffff8019, 0xffff802a, 0xffff8041, 0xffff805d, 0xffff807e,
40xffff80a3, 0xffff80ce, 0xffff80fd, 0xffff8131, 0xffff816b, 0xffff81a9, 0xffff81ec, 0xffff8233,
50xffff8280, 0xffff82d1, 0xffff8328, 0xffff8383, 0xffff83e3, 0xffff8447, 0xffff84b1, 0xffff851f,
60xffff8592, 0xffff860a, 0xffff8686, 0xffff8707, 0xffff878d, 0xffff8817, 0xffff88a6, 0xffff893a,
70xffff89d2, 0xffff8a6f, 0xffff8b10, 0xffff8bb6, 0xffff8c60, 0xffff8d0f, 0xffff8dc2, 0xffff8e7a,
80xffff8f35, 0xffff8ff6, 0xffff90ba, 0xffff9183, 0xffff9250, 0xffff9322, 0xffff93f7, 0xffff94d1,
90xffff95af, 0xffff9691, 0xffff9777, 0xffff9861, 0xffff994f, 0xffff9a41, 0xffff9b37, 0xffff9c31,
100xffff9d2e, 0xffff9e30, 0xffff9f35, 0xffffa03e, 0xffffa14b, 0xffffa25b, 0xffffa36f, 0xffffa487,
110xffffa5a2, 0xffffa6c0, 0xffffa7e2, 0xffffa907, 0xffffaa30, 0xffffab5c, 0xffffac8b, 0xffffadbe,
120xffffaef4, 0xffffb02c, 0xffffb168, 0xffffb2a7, 0xffffb3e9, 0xffffb52e, 0xffffb676, 0xffffb7c0,
130xffffb90d, 0xffffba5d, 0xffffbbb0, 0xffffbd06, 0xffffbe5e, 0xffffbfb8, 0xffffc115, 0xffffc274,
140xffffc3d6, 0xffffc53a, 0xffffc6a1, 0xffffc809, 0xffffc974, 0xffffcae1, 0xffffcc50, 0xffffcdc0,
150xffffcf33, 0xffffd0a8, 0xffffd21e, 0xffffd397, 0xffffd511, 0xffffd68c, 0xffffd80a, 0xffffd988,
160xffffdb09, 0xffffdc8a, 0xffffde0d, 0xffffdf92, 0xffffe117, 0xffffe29e, 0xffffe426, 0xffffe5af,
170xffffe739, 0xffffe8c4, 0xffffea50, 0xffffebdd, 0xffffed6a, 0xffffeef8, 0xfffff087, 0xfffff217,
180xfffff3a7, 0xfffff537, 0xfffff6c8, 0xfffff859, 0xfffff9eb, 0xfffffb7d, 0xfffffd0f, 0xfffffea1,
19};
20static mpeg3_real_t *mpeg3_xcos1 =
21(mpeg3_real_t*)mpeg3_xcos1_fixedpoints;
22static long mpeg3_xsin1_fixedpoints[] = {
230xffffffce, 0xfffffe3c, 0xfffffcaa, 0xfffffb18, 0xfffff986, 0xfffff7f5, 0xfffff664, 0xfffff4d3,
240xfffff343, 0xfffff1b3, 0xfffff023, 0xffffee95, 0xffffed07, 0xffffeb79, 0xffffe9ed, 0xffffe861,
250xffffe6d6, 0xffffe54d, 0xffffe3c4, 0xffffe23c, 0xffffe0b6, 0xffffdf30, 0xffffddac, 0xffffdc2a,
260xffffdaa8, 0xffffd928, 0xffffd7aa, 0xffffd62d, 0xffffd4b2, 0xffffd338, 0xffffd1c1, 0xffffd04b,
270xffffced6, 0xffffcd64, 0xffffcbf4, 0xffffca85, 0xffffc919, 0xffffc7af, 0xffffc647, 0xffffc4e1,
280xffffc37d, 0xffffc21c, 0xffffc0bd, 0xffffbf61, 0xffffbe07, 0xffffbcb0, 0xffffbb5b, 0xffffba09,
290xffffb8ba, 0xffffb76d, 0xffffb623, 0xffffb4dc, 0xffffb398, 0xffffb257, 0xffffb119, 0xffffafde,
300xffffaea6, 0xffffad71, 0xffffac3f, 0xffffab11, 0xffffa9e6, 0xffffa8be, 0xffffa799, 0xffffa678,
310xffffa55b, 0xffffa440, 0xffffa32a, 0xffffa217, 0xffffa107, 0xffff9ffc, 0xffff9ef3, 0xffff9def,
320xffff9cef, 0xffff9bf2, 0xffff9af9, 0xffff9a04, 0xffff9913, 0xffff9826, 0xffff973d, 0xffff9658,
330xffff9577, 0xffff949a, 0xffff93c1, 0xffff92ed, 0xffff921d, 0xffff9151, 0xffff9089, 0xffff8fc5,
340xffff8f06, 0xffff8e4b, 0xffff8d95, 0xffff8ce3, 0xffff8c35, 0xffff8b8c, 0xffff8ae7, 0xffff8a47,
350xffff89ac, 0xffff8915, 0xffff8882, 0xffff87f4, 0xffff876b, 0xffff86e7, 0xffff8667, 0xffff85eb,
360xffff8575, 0xffff8503, 0xffff8496, 0xffff842e, 0xffff83ca, 0xffff836c, 0xffff8312, 0xffff82bd,
370xffff826c, 0xffff8221, 0xffff81da, 0xffff8199, 0xffff815c, 0xffff8124, 0xffff80f1, 0xffff80c3,
380xffff8099, 0xffff8075, 0xffff8056, 0xffff803b, 0xffff8026, 0xffff8015, 0xffff8009, 0xffff8002,
39};
40static mpeg3_real_t *mpeg3_xsin1 =
41(mpeg3_real_t*)mpeg3_xsin1_fixedpoints;
42static long mpeg3_xcos2_fixedpoints[] = {
430xffff8001, 0xffff800d, 0xffff802d, 0xffff8061, 0xffff80a8, 0xffff8103, 0xffff8172, 0xffff81f4,
440xffff828a, 0xffff8333, 0xffff83ef, 0xffff84be, 0xffff85a1, 0xffff8696, 0xffff879e, 0xffff88b9,
450xffff89e5, 0xffff8b25, 0xffff8c76, 0xffff8dd9, 0xffff8f4d, 0xffff90d3, 0xffff926a, 0xffff9412,
460xffff95cb, 0xffff9794, 0xffff996d, 0xffff9b56, 0xffff9d4e, 0xffff9f56, 0xffffa16d, 0xffffa392,
470xffffa5c5, 0xffffa807, 0xffffaa55, 0xffffacb2, 0xffffaf1b, 0xffffb190, 0xffffb411, 0xffffb69f,
480xffffb937, 0xffffbbdb, 0xffffbe89, 0xffffc141, 0xffffc403, 0xffffc6ce, 0xffffc9a1, 0xffffcc7e,
490xffffcf62, 0xffffd24d, 0xffffd540, 0xffffd839, 0xffffdb39, 0xffffde3e, 0xffffe148, 0xffffe457,
500xffffe76a, 0xffffea81, 0xffffed9c, 0xfffff0b9, 0xfffff3d9, 0xfffff6fa, 0xfffffa1d, 0xfffffd41,
510xffffff9c, 0xfffffc78, 0xfffff954, 0xfffff632, 0xfffff311, 0xffffeff2, 0xffffecd5, 0xffffe9bb,
520xffffe6a5, 0xffffe393, 0xffffe085, 0xffffdd7c, 0xffffda78, 0xffffd77a, 0xffffd483, 0xffffd192,
530xffffcea8, 0xffffcbc6, 0xffffc8ec, 0xffffc61a, 0xffffc351, 0xffffc092, 0xffffbddc, 0xffffbb31,
540xffffb890, 0xffffb5fa, 0xffffb370, 0xffffb0f1, 0xffffae7f, 0xffffac19, 0xffffa9c0, 0xffffa775,
550xffffa537, 0xffffa307, 0xffffa0e6, 0xffff9ed3, 0xffff9ccf, 0xffff9ada, 0xffff98f5, 0xffff9720,
560xffff955b, 0xffff93a7, 0xffff9203, 0xffff9070, 0xffff8eee, 0xffff8d7e, 0xffff8c20, 0xffff8ad3,
570xffff8998, 0xffff8870, 0xffff875a, 0xffff8657, 0xffff8566, 0xffff8489, 0xffff83be, 0xffff8307,
580xffff8263, 0xffff81d2, 0xffff8155, 0xffff80eb, 0xffff8095, 0xffff8052, 0xffff8023, 0xffff8008,
59};
60static mpeg3_real_t *mpeg3_xcos2 =
61(mpeg3_real_t*)mpeg3_xcos2_fixedpoints;
62static long mpeg3_xsin2_fixedpoints[] = {
630xffffff9c, 0xfffffc78, 0xfffff954, 0xfffff632, 0xfffff311, 0xffffeff2, 0xffffecd5, 0xffffe9bb,
640xffffe6a5, 0xffffe393, 0xffffe085, 0xffffdd7c, 0xffffda78, 0xffffd77a, 0xffffd483, 0xffffd192,
650xffffcea8, 0xffffcbc6, 0xffffc8ec, 0xffffc61a, 0xffffc351, 0xffffc092, 0xffffbddc, 0xffffbb31,
660xffffb890, 0xffffb5fa, 0xffffb370, 0xffffb0f1, 0xffffae7f, 0xffffac19, 0xffffa9c0, 0xffffa775,
670xffffa537, 0xffffa307, 0xffffa0e6, 0xffff9ed3, 0xffff9ccf, 0xffff9ada, 0xffff98f5, 0xffff9720,
680xffff955b, 0xffff93a7, 0xffff9203, 0xffff9070, 0xffff8eee, 0xffff8d7e, 0xffff8c20, 0xffff8ad3,
690xffff8998, 0xffff8870, 0xffff875a, 0xffff8657, 0xffff8566, 0xffff8489, 0xffff83be, 0xffff8307,
700xffff8263, 0xffff81d2, 0xffff8155, 0xffff80eb, 0xffff8095, 0xffff8052, 0xffff8023, 0xffff8008,
710x00000004, 0x00000007, 0x0000000c, 0x00000010, 0x00000015, 0x0000001c, 0x00000023, 0x0000002a,
720x00000033, 0x0000003d, 0x00000048, 0x00000053, 0x00000061, 0x0000006f, 0x0000007f, 0x00000091,
730x000000a4, 0x000000b8, 0x000000cf, 0x000000e7, 0x00000101, 0x0000011d, 0x0000013b, 0x0000015b,
740x0000017e, 0x000001a3, 0x000001ca, 0x000001f4, 0x00000220, 0x0000024f, 0x00000281, 0x000002b7,
750x000002ef, 0x0000032a, 0x00000368, 0x000003aa, 0x000003ee, 0x00000437, 0x00000483, 0x000004d3,
760x00000526, 0x0000057e, 0x000005d9, 0x00000639, 0x0000069c, 0x00000704, 0x0000076f, 0x000007e0,
770x00000854, 0x000008cd, 0x0000094b, 0x000009cd, 0x00000a54, 0x00000adf, 0x00000b6f, 0x00000c04,
780x00000c9e, 0x00000d3d, 0x00000de0, 0x00000e89, 0x00000f36, 0x00000fe8, 0x0000109f, 0x0000115c,
79};
80static mpeg3_real_t *mpeg3_xsin2 =
81(mpeg3_real_t*)mpeg3_xsin2_fixedpoints;
82typedef struct { long r, i; } fixed_cmplx;
83fixed_cmplx ac3_w_d1[] = {
84 { 0x00008000, 0x00000000 },};
85fixed_cmplx ac3_w_d2[] = {
86 { 0x00008000, 0x00000000 }, { 0x00000000, 0xffff8000 },};
87fixed_cmplx ac3_w_d4[] = {
88 { 0x00008000, 0x00000000 }, { 0x00005a82, 0xffffa57e }, { 0x00000000, 0xffff8002 }, { 0xffffa580, 0xffffa580 },};
89fixed_cmplx ac3_w_d8[] = {
90 { 0x00008000, 0x00000000 }, { 0x00007641, 0xffffcf05 }, { 0x00005a81, 0xffffa580 }, { 0x000030fb, 0xffff89c4 },
91 { 0x00000002, 0xffff8007 }, { 0xffffcf09, 0xffff89c6 }, { 0xffffa587, 0xffffa583 }, { 0xffff89cb, 0xffffcf05 },};
92fixed_cmplx ac3_w_d16[] = {
93 { 0x00008000, 0x00000000 }, { 0x00007d8a, 0xffffe708 }, { 0x00007642, 0xffffcf06 }, { 0x00006a6e, 0xffffb8e7 },
94 { 0x00005a84, 0xffffa583 }, { 0x00004720, 0xffff9599 }, { 0x00003100, 0xffff89c6 }, { 0x000018ff, 0xffff827e },
95 { 0x00000008, 0xffff8008 }, { 0xffffe711, 0xffff827d }, { 0xffffcf11, 0xffff89c4 }, { 0xffffb8f2, 0xffff9595 },
96 { 0xffffa58e, 0xffffa57d }, { 0xffff95a5, 0xffffb8df }, { 0xffff89d2, 0xffffcefd }, { 0xffff8289, 0xffffe6fc },};
97fixed_cmplx ac3_w_d32[] = {
98 { 0x00008000, 0x00000000 }, { 0x00007f62, 0xfffff375 }, { 0x00007d8a, 0xffffe70a }, { 0x00007a7d, 0xffffdadc },
99 { 0x00007642, 0xffffcf0a }, { 0x000070e4, 0xffffc3b1 }, { 0x00006a70, 0xffffb8ed }, { 0x000062f6, 0xffffaed7 },
100 { 0x00005a88, 0xffffa58a }, { 0x0000513b, 0xffff9d1b }, { 0x00004726, 0xffff95a1 }, { 0x00003c62, 0xffff8f2d },
101 { 0x00003109, 0xffff89cf }, { 0x00002538, 0xffff8593 }, { 0x0000190b, 0xffff8286 }, { 0x00000ca1, 0xffff80ad },
102 { 0x00000017, 0xffff800f }, { 0xfffff38d, 0xffff80ab }, { 0xffffe723, 0xffff8281 }, { 0xffffdaf6, 0xffff858b },
103 { 0xffffcf25, 0xffff89c4 }, { 0xffffc3cc, 0xffff8f1f }, { 0xffffb908, 0xffff9591 }, { 0xffffaef3, 0xffff9d09 },
104 { 0xffffa5a6, 0xffffa575 }, { 0xffff9d37, 0xffffaebf }, { 0xffff95bb, 0xffffb8d2 }, { 0xffff8f46, 0xffffc393 },
105 { 0xffff89e7, 0xffffcee9 }, { 0xffff85aa, 0xffffdab8 }, { 0xffff829b, 0xffffe6e3 }, { 0xffff80c1, 0xfffff34b },};
106fixed_cmplx ac3_w_d64[] = {
107 { 0x00008000, 0x00000000 }, { 0x00007fd8, 0xfffff9b9 }, { 0x00007f62, 0xfffff376 }, { 0x00007e9d, 0xffffed3b },
108 { 0x00007d8a, 0xffffe70c }, { 0x00007c29, 0xffffe0ec }, { 0x00007a7c, 0xffffdae0 }, { 0x00007883, 0xffffd4eb },
109 { 0x00007641, 0xffffcf11 }, { 0x000073b6, 0xffffc955 }, { 0x000070e3, 0xffffc3bb }, { 0x00006dcb, 0xffffbe45 },
110 { 0x00006a6f, 0xffffb8f8 }, { 0x000066d2, 0xffffb3d7 }, { 0x000062f5, 0xffffaee5 }, { 0x00005edc, 0xffffaa25 },
111 { 0x00005a89, 0xffffa59a }, { 0x000055fe, 0xffffa147 }, { 0x0000513e, 0xffff9d2e }, { 0x00004c4c, 0xffff9952 },
112 { 0x0000472b, 0xffff95b6 }, { 0x000041de, 0xffff925b }, { 0x00003c69, 0xffff8f44 }, { 0x000036cf, 0xffff8c72 },
113 { 0x00003113, 0xffff89e7 }, { 0x00002b39, 0xffff87a4 }, { 0x00002544, 0xffff85ac }, { 0x00001f39, 0xffff8400 },
114 { 0x0000191b, 0xffff82a0 }, { 0x000012ed, 0xffff818d }, { 0x00000cb4, 0xffff80c8 }, { 0x00000673, 0xffff8051 },
115 { 0x0000002d, 0xffff8029 }, { 0xfffff9e8, 0xffff804f }, { 0xfffff3a7, 0xffff80c3 }, { 0xffffed6e, 0xffff8186 },
116 { 0xffffe741, 0xffff8297 }, { 0xffffe123, 0xffff83f5 }, { 0xffffdb18, 0xffff859f }, { 0xffffd524, 0xffff8795 },
117 { 0xffffcf4b, 0xffff89d5 }, { 0xffffc990, 0xffff8c5d }, { 0xffffc3f7, 0xffff8f2d }, { 0xffffbe82, 0xffff9242 },
118 { 0xffffb936, 0xffff959b }, { 0xffffb416, 0xffff9935 }, { 0xffffaf24, 0xffff9d0f }, { 0xffffaa64, 0xffffa125 },
119 { 0xffffa5d9, 0xffffa575 }, { 0xffffa186, 0xffffa9fd }, { 0xffff9d6d, 0xffffaeba }, { 0xffff9990, 0xffffb3a9 },
120 { 0xffff95f3, 0xffffb8c7 }, { 0xffff9297, 0xffffbe11 }, { 0xffff8f7f, 0xffffc383 }, { 0xffff8cac, 0xffffc91a },
121 { 0xffff8a20, 0xffffced3 }, { 0xffff87dc, 0xffffd4aa }, { 0xffff85e2, 0xffffda9c }, { 0xffff8434, 0xffffe0a5 },
122 { 0xffff82d2, 0xffffe6c1 }, { 0xffff81be, 0xffffecec }, { 0xffff80f7, 0xfffff323 }, { 0xffff807e, 0xfffff962 },};
123fixed_cmplx *ac3_w_fixedpoints[] = {
124ac3_w_d1, ac3_w_d2, ac3_w_d4, ac3_w_d8, ac3_w_d16, ac3_w_d32, ac3_w_d64, };
125#endif
126#ifdef USE_DATA_TABLES
127static long mpeg3_muls_data[] = {
1280x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1290x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1300x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1310x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1320x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1330x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1340x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1350x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1360xffff5556, 0xffff788b, 0xffff947d, 0xffffaaab, 0xffffbc46, 0xffffca3f, 0xffffd556, 0xffffde23,
1370xffffe520, 0xffffeaab, 0xffffef12, 0xfffff290, 0xfffff556, 0xfffff789, 0xfffff948, 0xfffffaab,
1380xfffffbc5, 0xfffffca4, 0xfffffd56, 0xfffffde3, 0xfffffe52, 0xfffffeab, 0xfffffef2, 0xffffff29,
1390xffffff56, 0xffffff79, 0xffffff95, 0xffffffab, 0xffffffbd, 0xffffffcb, 0xffffffd6, 0xffffffdf,
1400xffffffe6, 0xffffffeb, 0xfffffff0, 0xfffffff3, 0xfffffff6, 0xfffffff8, 0xfffffffa, 0xfffffffb,
1410xfffffffc, 0xfffffffd, 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000,
1420x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1430x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1440x0000aaaa, 0x00008775, 0x00006b83, 0x00005555, 0x000043ba, 0x000035c1, 0x00002aaa, 0x000021dd,
1450x00001ae0, 0x00001555, 0x000010ee, 0x00000d70, 0x00000aaa, 0x00000877, 0x000006b8, 0x00000555,
1460x0000043b, 0x0000035c, 0x000002aa, 0x0000021d, 0x000001ae, 0x00000155, 0x0000010e, 0x000000d7,
1470x000000aa, 0x00000087, 0x0000006b, 0x00000055, 0x00000043, 0x00000035, 0x0000002a, 0x00000021,
1480x0000001a, 0x00000015, 0x00000010, 0x0000000d, 0x0000000a, 0x00000008, 0x00000006, 0x00000005,
1490x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000,
1500x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1510x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1520x00004924, 0x00003a0d, 0x00002e13, 0x00002492, 0x00001d06, 0x00001709, 0x00001249, 0x00000e83,
1530x00000b84, 0x00000924, 0x00000741, 0x000005c2, 0x00000492, 0x000003a0, 0x000002e1, 0x00000249,
1540x000001d0, 0x00000170, 0x00000124, 0x000000e8, 0x000000b8, 0x00000092, 0x00000074, 0x0000005c,
1550x00000049, 0x0000003a, 0x0000002e, 0x00000024, 0x0000001d, 0x00000017, 0x00000012, 0x0000000e,
1560x0000000b, 0x00000009, 0x00000007, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002,
1570x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1580x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1590x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1600x00002222, 0x00001b17, 0x00001580, 0x00001111, 0x00000d8b, 0x00000ac0, 0x00000888, 0x000006c5,
1610x00000560, 0x00000444, 0x00000362, 0x000002b0, 0x00000222, 0x000001b1, 0x00000158, 0x00000111,
1620x000000d8, 0x000000ac, 0x00000088, 0x0000006c, 0x00000056, 0x00000044, 0x00000036, 0x0000002b,
1630x00000022, 0x0000001b, 0x00000015, 0x00000011, 0x0000000d, 0x0000000a, 0x00000008, 0x00000006,
1640x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001,
1650x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1660x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1670x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1680x00001084, 0x00000d1b, 0x00000a67, 0x00000842, 0x0000068d, 0x00000533, 0x00000421, 0x00000346,
1690x00000299, 0x00000210, 0x000001a3, 0x0000014c, 0x00000108, 0x000000d1, 0x000000a6, 0x00000084,
1700x00000068, 0x00000053, 0x00000042, 0x00000034, 0x00000029, 0x00000021, 0x0000001a, 0x00000014,
1710x00000010, 0x0000000d, 0x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003,
1720x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
1730x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1740x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1750x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1760x00000820, 0x00000673, 0x0000051e, 0x00000410, 0x00000339, 0x0000028f, 0x00000208, 0x0000019c,
1770x00000147, 0x00000104, 0x000000ce, 0x000000a3, 0x00000082, 0x00000067, 0x00000051, 0x00000041,
1780x00000033, 0x00000028, 0x00000020, 0x00000019, 0x00000014, 0x00000010, 0x0000000c, 0x0000000a,
1790x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001,
1800x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1810x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1820x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1830x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1840x00000408, 0x00000333, 0x0000028a, 0x00000204, 0x00000199, 0x00000145, 0x00000102, 0x000000cc,
1850x000000a2, 0x00000081, 0x00000066, 0x00000051, 0x00000040, 0x00000033, 0x00000028, 0x00000020,
1860x00000019, 0x00000014, 0x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006, 0x00000005,
1870x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000,
1880x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1890x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1900x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1910x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1920x00000202, 0x00000197, 0x00000143, 0x00000101, 0x000000cb, 0x000000a1, 0x00000080, 0x00000065,
1930x00000050, 0x00000040, 0x00000032, 0x00000028, 0x00000020, 0x00000019, 0x00000014, 0x00000010,
1940x0000000c, 0x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000002,
1950x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1960x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1970x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1980x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1990x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2000x00000100, 0x000000cb, 0x000000a1, 0x00000080, 0x00000065, 0x00000050, 0x00000040, 0x00000032,
2010x00000028, 0x00000020, 0x00000019, 0x00000014, 0x00000010, 0x0000000c, 0x0000000a, 0x00000008,
2020x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001,
2030x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2040x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2050x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2060x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2070x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2080x00000080, 0x00000065, 0x00000050, 0x00000040, 0x00000032, 0x00000028, 0x00000020, 0x00000019,
2090x00000014, 0x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004,
2100x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000,
2110x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2120x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2130x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2140x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2150x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2160x00000040, 0x00000032, 0x00000028, 0x00000020, 0x00000019, 0x00000014, 0x00000010, 0x0000000c,
2170x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002,
2180x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2190x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2200x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2210x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2220x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2230x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2240x00000020, 0x00000019, 0x00000014, 0x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006,
2250x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001,
2260x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2270x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2280x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2290x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2300x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2310x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2320x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003,
2330x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
2340x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2350x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2360x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2370x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2380x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2390x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2400x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001,
2410x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2420x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2430x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2440x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2450x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2460x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2470x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2480x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000,
2490x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2500x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2510x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2520x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2530x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2540x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2550x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2560x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2570x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2580x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2590x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2600x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2610x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2620x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2630x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2640xffff3334, 0xffff5d74, 0xffff7efc, 0xffff999a, 0xffffaeba, 0xffffbf7e, 0xffffcccd, 0xffffd75d,
2650xffffdfbf, 0xffffe667, 0xffffebaf, 0xffffefe0, 0xfffff334, 0xfffff5d8, 0xfffff7f0, 0xfffff99a,
2660xfffffaec, 0xfffffbf8, 0xfffffccd, 0xfffffd76, 0xfffffdfc, 0xfffffe67, 0xfffffebb, 0xfffffefe,
2670xffffff34, 0xffffff5e, 0xffffff7f, 0xffffff9a, 0xffffffaf, 0xffffffc0, 0xffffffcd, 0xffffffd8,
2680xffffffe0, 0xffffffe7, 0xffffffec, 0xfffffff0, 0xfffffff4, 0xfffffff6, 0xfffffff8, 0xfffffffa,
2690xfffffffb, 0xfffffffc, 0xfffffffd, 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff,
2700x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2710x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2720xffff999a, 0xffffaeba, 0xffffbf7e, 0xffffcccd, 0xffffd75d, 0xffffdfbf, 0xffffe667, 0xffffebaf,
2730xffffefe0, 0xfffff334, 0xfffff5d8, 0xfffff7f0, 0xfffff99a, 0xfffffaec, 0xfffffbf8, 0xfffffccd,
2740xfffffd76, 0xfffffdfc, 0xfffffe67, 0xfffffebb, 0xfffffefe, 0xffffff34, 0xffffff5e, 0xffffff7f,
2750xffffff9a, 0xffffffaf, 0xffffffc0, 0xffffffcd, 0xffffffd8, 0xffffffe0, 0xffffffe7, 0xffffffec,
2760xfffffff0, 0xfffffff4, 0xfffffff6, 0xfffffff8, 0xfffffffa, 0xfffffffb, 0xfffffffc, 0xfffffffd,
2770xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
2780x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2790x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2800x00006666, 0x00005146, 0x00004082, 0x00003333, 0x000028a3, 0x00002041, 0x00001999, 0x00001451,
2810x00001020, 0x00000ccc, 0x00000a28, 0x00000810, 0x00000666, 0x00000514, 0x00000408, 0x00000333,
2820x0000028a, 0x00000204, 0x00000199, 0x00000145, 0x00000102, 0x000000cc, 0x000000a2, 0x00000081,
2830x00000066, 0x00000051, 0x00000040, 0x00000033, 0x00000028, 0x00000020, 0x00000019, 0x00000014,
2840x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006, 0x00000005, 0x00000004, 0x00000003,
2850x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
2860x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2870x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2880x0000cccc, 0x0000a28c, 0x00008104, 0x00006666, 0x00005146, 0x00004082, 0x00003333, 0x000028a3,
2890x00002041, 0x00001999, 0x00001451, 0x00001020, 0x00000ccc, 0x00000a28, 0x00000810, 0x00000666,
2900x00000514, 0x00000408, 0x00000333, 0x0000028a, 0x00000204, 0x00000199, 0x00000145, 0x00000102,
2910x000000cc, 0x000000a2, 0x00000081, 0x00000066, 0x00000051, 0x00000040, 0x00000033, 0x00000028,
2920x00000020, 0x00000019, 0x00000014, 0x00000010, 0x0000000c, 0x0000000a, 0x00000008, 0x00000006,
2930x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001,
2940x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2950x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
2960xffff1c72, 0xffff4b64, 0xffff70a7, 0xffff8e39, 0xffffa5b2, 0xffffb854, 0xffffc71d, 0xffffd2d9,
2970xffffdc2a, 0xffffe38f, 0xffffe96d, 0xffffee15, 0xfffff1c8, 0xfffff4b7, 0xfffff70b, 0xfffff8e4,
2980xfffffa5c, 0xfffffb86, 0xfffffc72, 0xfffffd2e, 0xfffffdc3, 0xfffffe39, 0xfffffe97, 0xfffffee2,
2990xffffff1d, 0xffffff4c, 0xffffff71, 0xffffff8f, 0xffffffa6, 0xffffffb9, 0xffffffc8, 0xffffffd3,
3000xffffffdd, 0xffffffe4, 0xffffffea, 0xffffffef, 0xfffffff2, 0xfffffff5, 0xfffffff8, 0xfffffff9,
3010xfffffffb, 0xfffffffc, 0xfffffffd, 0xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff,
3020x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3030x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3040xffff8e39, 0xffffa5b2, 0xffffb854, 0xffffc71d, 0xffffd2d9, 0xffffdc2a, 0xffffe38f, 0xffffe96d,
3050xffffee15, 0xfffff1c8, 0xfffff4b7, 0xfffff70b, 0xfffff8e4, 0xfffffa5c, 0xfffffb86, 0xfffffc72,
3060xfffffd2e, 0xfffffdc3, 0xfffffe39, 0xfffffe97, 0xfffffee2, 0xffffff1d, 0xffffff4c, 0xffffff71,
3070xffffff8f, 0xffffffa6, 0xffffffb9, 0xffffffc8, 0xffffffd3, 0xffffffdd, 0xffffffe4, 0xffffffea,
3080xffffffef, 0xfffffff2, 0xfffffff5, 0xfffffff8, 0xfffffff9, 0xfffffffb, 0xfffffffc, 0xfffffffd,
3090xfffffffe, 0xfffffffe, 0xffffffff, 0xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
3100x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3110x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3120xffffc71d, 0xffffd2d9, 0xffffdc2a, 0xffffe38f, 0xffffe96d, 0xffffee15, 0xfffff1c8, 0xfffff4b7,
3130xfffff70b, 0xfffff8e4, 0xfffffa5c, 0xfffffb86, 0xfffffc72, 0xfffffd2e, 0xfffffdc3, 0xfffffe39,
3140xfffffe97, 0xfffffee2, 0xffffff1d, 0xffffff4c, 0xffffff71, 0xffffff8f, 0xffffffa6, 0xffffffb9,
3150xffffffc8, 0xffffffd3, 0xffffffdd, 0xffffffe4, 0xffffffea, 0xffffffef, 0xfffffff2, 0xfffffff5,
3160xfffffff8, 0xfffffff9, 0xfffffffb, 0xfffffffc, 0xfffffffd, 0xfffffffe, 0xfffffffe, 0xffffffff,
3170xffffffff, 0xffffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3180x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3190x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3200x000038e3, 0x00002d27, 0x000023d6, 0x00001c71, 0x00001693, 0x000011eb, 0x00000e38, 0x00000b49,
3210x000008f5, 0x0000071c, 0x000005a4, 0x0000047a, 0x0000038e, 0x000002d2, 0x0000023d, 0x000001c7,
3220x00000169, 0x0000011e, 0x000000e3, 0x000000b4, 0x0000008f, 0x00000071, 0x0000005a, 0x00000047,
3230x00000038, 0x0000002d, 0x00000023, 0x0000001c, 0x00000016, 0x00000011, 0x0000000e, 0x0000000b,
3240x00000008, 0x00000007, 0x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001,
3250x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3260x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3270x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3280x000071c7, 0x00005a4e, 0x000047ac, 0x000038e3, 0x00002d27, 0x000023d6, 0x00001c71, 0x00001693,
3290x000011eb, 0x00000e38, 0x00000b49, 0x000008f5, 0x0000071c, 0x000005a4, 0x0000047a, 0x0000038e,
3300x000002d2, 0x0000023d, 0x000001c7, 0x00000169, 0x0000011e, 0x000000e3, 0x000000b4, 0x0000008f,
3310x00000071, 0x0000005a, 0x00000047, 0x00000038, 0x0000002d, 0x00000023, 0x0000001c, 0x00000016,
3320x00000011, 0x0000000e, 0x0000000b, 0x00000008, 0x00000007, 0x00000005, 0x00000004, 0x00000003,
3330x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
3340x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3350x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3360x0000e38e, 0x0000b49c, 0x00008f59, 0x000071c7, 0x00005a4e, 0x000047ac, 0x000038e3, 0x00002d27,
3370x000023d6, 0x00001c71, 0x00001693, 0x000011eb, 0x00000e38, 0x00000b49, 0x000008f5, 0x0000071c,
3380x000005a4, 0x0000047a, 0x0000038e, 0x000002d2, 0x0000023d, 0x000001c7, 0x00000169, 0x0000011e,
3390x000000e3, 0x000000b4, 0x0000008f, 0x00000071, 0x0000005a, 0x00000047, 0x00000038, 0x0000002d,
3400x00000023, 0x0000001c, 0x00000016, 0x00000011, 0x0000000e, 0x0000000b, 0x00000008, 0x00000007,
3410x00000005, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000001, 0x00000001, 0x00000001,
3420x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3430x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,};
344#endif
345#ifdef USE_DATA_TABLES
346static long mpeg3_gainpow2_data[] = {
3470x05a82799, 0x04c1bf82, 0x04000000, 0x035d13f3, 0x02d413cc, 0x0260dfc1, 0x02000000, 0x01ae89f9,
3480x016a09e6, 0x01306fe0, 0x01000000, 0x00d744fc, 0x00b504f3, 0x009837f0, 0x00800000, 0x006ba27e,
3490x005a8279, 0x004c1bf8, 0x00400000, 0x0035d13f, 0x002d413c, 0x00260dfc, 0x00200000, 0x001ae89f,
3500x0016a09e, 0x001306fe, 0x00100000, 0x000d744f, 0x000b504f, 0x0009837f, 0x00080000, 0x0006ba27,
3510x0005a827, 0x0004c1bf, 0x00040000, 0x00035d13, 0x0002d413, 0x000260df, 0x00020000, 0x0001ae89,
3520x00016a09, 0x0001306f, 0x00010000, 0x0000d744, 0x0000b504, 0x00009837, 0x00008000, 0x00006ba2,
3530x00005a82, 0x00004c1b, 0x00004000, 0x000035d1, 0x00002d41, 0x0000260d, 0x00002000, 0x00001ae8,
3540x000016a0, 0x00001306, 0x00001000, 0x00000d74, 0x00000b50, 0x00000983, 0x00000800, 0x000006ba,
3550x000005a8, 0x000004c1, 0x00000400, 0x0000035d, 0x000002d4, 0x00000260, 0x00000200, 0x000001ae,
3560x0000016a, 0x00000130, 0x00000100, 0x000000d7, 0x000000b5, 0x00000098, 0x00000080, 0x0000006b,
3570x0000005a, 0x0000004c, 0x00000040, 0x00000035, 0x0000002d, 0x00000026, 0x00000020, 0x0000001a,
3580x00000016, 0x00000013, 0x00000010, 0x0000000d, 0x0000000b, 0x00000009, 0x00000008, 0x00000006,
3590x00000005, 0x00000004, 0x00000004, 0x00000003, 0x00000002, 0x00000002, 0x00000002, 0x00000001,
3600x00000001, 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3610x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3620x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3630x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3640x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3650x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3660x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3670x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3680x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3690x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3700x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3710x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3720x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3730x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3740x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3750x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3760x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3770x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3780x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3790x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3800x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3810x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3820x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3830x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3840x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3850x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3860x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3870x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3880x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3890x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3900x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3910x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3920x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3930x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
3940x00000000, 0x00000000,};
395#endif
396#ifdef USE_DATA_TABLES
397static long mpeg3_ispow_data[] = {
3980x00000000, 0x00008000, 0x0001428a, 0x000229d2, 0x00032cbf, 0x00044662, 0x0005738c, 0x0006b1fc,
3990x0007ffff, 0x00095c41, 0x000ac5ad, 0x000c3b5d, 0x000dbc8f, 0x000f489e, 0x0010def9, 0x00127f20,
4000x001428a2, 0x0015db1b, 0x00179630, 0x0019598d, 0x001b24e8, 0x001cf7fc, 0x001ed28a, 0x0020b458,
4010x00229d2e, 0x00248cdb, 0x0026832f, 0x00287fff, 0x002a8322, 0x002c8c70, 0x002e9bc5, 0x0030b0ff,
4020x0032cbfd, 0x0034eca0, 0x003712ca, 0x00393e60, 0x003b6f47, 0x003da567, 0x003fe0a5, 0x004220ed,
4030x00446627, 0x0046b03e, 0x0048ff1e, 0x004b52b3, 0x004daaeb, 0x005007b4, 0x005268fc, 0x0054ceb2,
4040x005738c7, 0x0059a72a, 0x005c19cd, 0x005e90a1, 0x00610b98, 0x00638aa4, 0x00660db9, 0x006894c9,
4050x006b1fc8, 0x006daeaa, 0x00704163, 0x0072d7e8, 0x0075722e, 0x0078102b, 0x007ab1d3, 0x007d571e,
4060x007fffff, 0x0082ac70, 0x00855c65, 0x00880fd6, 0x008ac6b9, 0x008d8107, 0x00903eb7, 0x0092ffc0,
4070x0095c41a, 0x00988bbe, 0x009b56a4, 0x009e24c4, 0x00a0f617, 0x00a3ca96, 0x00a6a239, 0x00a97cfa,
4080x00ac5ad2, 0x00af3bbb, 0x00b21fad, 0x00b506a3, 0x00b7f096, 0x00badd81, 0x00bdcd5d, 0x00c0c025,
4090x00c3b5d2, 0x00c6ae60, 0x00c9a9c8, 0x00cca805, 0x00cfa912, 0x00d2acea, 0x00d5b387, 0x00d8bce5,
4100x00dbc8fe, 0x00ded7ce, 0x00e1e950, 0x00e4fd7e, 0x00e81456, 0x00eb2dd1, 0x00ee49ec, 0x00f168a2,
4110x00f489ef, 0x00f7adce, 0x00fad43c, 0x00fdfd34, 0x010128b2, 0x010456b2, 0x01078731, 0x010aba29,
4120x010def99, 0x0111277b, 0x011461cc, 0x01179e89, 0x011addae, 0x011e1f37, 0x01216320, 0x0124a967,
4130x0127f208, 0x012b3d00, 0x012e8a4b, 0x0131d9e6, 0x01352bce, 0x01387fff, 0x013bd678, 0x013f2f33,
4140x01428a2f, 0x0145e768, 0x014946dc, 0x014ca888, 0x01500c68, 0x01537279, 0x0156daba, 0x015a4527,
4150x015db1bd, 0x0161207a, 0x0164915b, 0x0168045d, 0x016b797e, 0x016ef0bb, 0x01726a12, 0x0175e580,
4160x01796302, 0x017ce297, 0x0180643b, 0x0183e7ec, 0x01876da9, 0x018af56e, 0x018e7f38, 0x01920b07,
4170x019598d8, 0x019928a8, 0x019cba74, 0x01a04e3c, 0x01a3e3fd, 0x01a77bb4, 0x01ab155f, 0x01aeb0fd,
4180x01b24e8b, 0x01b5ee07, 0x01b98f70, 0x01bd32c2, 0x01c0d7fc, 0x01c47f1d, 0x01c82821, 0x01cbd308,
4190x01cf7fcf, 0x01d32e74, 0x01d6def6, 0x01da9153, 0x01de4588, 0x01e1fb94, 0x01e5b375, 0x01e96d29,
4200x01ed28af, 0x01f0e604, 0x01f4a528, 0x01f86617, 0x01fc28d2, 0x01ffed55, 0x0203b39f, 0x02077baf,
4210x020b4582, 0x020f1118, 0x0212de6e, 0x0216ad83, 0x021a7e56, 0x021e50e4, 0x0222252d, 0x0225fb2e,
4220x0229d2e6, 0x022dac54, 0x02318776, 0x0235644b, 0x023942d1, 0x023d2306, 0x024104e9, 0x0244e879,
4230x0248cdb5, 0x024cb49a, 0x02509d28, 0x0254875c, 0x02587337, 0x025c60b5, 0x02604fd7, 0x0264409a,
4240x026832fd, 0x026c26ff, 0x02701c9f, 0x027413db, 0x02780cb1, 0x027c0722, 0x0280032a, 0x028400ca,
4250x0287ffff, 0x028c00ca, 0x02900327, 0x02940716, 0x02980c97, 0x029c13a7, 0x02a01c45, 0x02a42670,
4260x02a83228, 0x02ac3f6a, 0x02b04e36, 0x02b45e8b, 0x02b87067, 0x02bc83c9, 0x02c098b1, 0x02c4af1c,
4270x02c8c70a, 0x02cce07a, 0x02d0fb6a, 0x02d517da, 0x02d935c9, 0x02dd5534, 0x02e1761c, 0x02e59880,
4280x02e9bc5d, 0x02ede1b3, 0x02f20882, 0x02f630c8, 0x02fa5a83, 0x02fe85b4, 0x0302b258, 0x0306e070,
4290x030b0ff9, 0x030f40f3, 0x0313735e, 0x0317a737, 0x031bdc7e, 0x03201333, 0x03244b53, 0x032884de,
4300x032cbfd4, 0x0330fc33, 0x033539fa, 0x03397929, 0x033db9be, 0x0341fbb8, 0x03463f17, 0x034a83da,
4310x034eca00, 0x03531187, 0x03575a6f, 0x035ba4b8, 0x035ff060, 0x03643d66, 0x03688bc9, 0x036cdb8a,
4320x03712ca6, 0x03757f1d, 0x0379d2ee, 0x037e2818, 0x03827e9a, 0x0386d674, 0x038b2fa5, 0x038f8a2c,
4330x0393e608, 0x03984338, 0x039ca1bc, 0x03a10192, 0x03a562ba, 0x03a9c533, 0x03ae28fd, 0x03b28e16,
4340x03b6f47e, 0x03bb5c33, 0x03bfc536, 0x03c42f85, 0x03c89b20, 0x03cd0806, 0x03d17636, 0x03d5e5af,
4350x03da5671, 0x03dec87b, 0x03e33bcc, 0x03e7b063, 0x03ec2640, 0x03f09d62, 0x03f515c9, 0x03f98f73,
4360x03fe0a5f, 0x0402868e, 0x040703fe, 0x040b82af, 0x041002a0, 0x041483d1, 0x04190640, 0x041d89ec,
4370x04220ed7, 0x042694fd, 0x042b1c60, 0x042fa4fe, 0x04342ed6, 0x0438b9e9, 0x043d4635, 0x0441d3b9,
4380x04466275, 0x044af269, 0x044f8393, 0x045415f3, 0x0458a988, 0x045d3e53, 0x0461d451, 0x04666b83,
4390x046b03e7, 0x046f9d7e, 0x04743846, 0x0478d440, 0x047d716a, 0x04820fc3, 0x0486af4c, 0x048b5003,
4400x048ff1e8, 0x049494fa, 0x04993939, 0x049ddea5, 0x04a2853c, 0x04a72cfd, 0x04abd5ea, 0x04b07fff,
4410x04b52b3f, 0x04b9d7a6, 0x04be8536, 0x04c333ee, 0x04c7e3cc, 0x04cc94d1, 0x04d146fb, 0x04d5fa4b,
4420x04daaebf, 0x04df6458, 0x04e41b14, 0x04e8d2f3, 0x04ed8bf5, 0x04f24618, 0x04f7015d, 0x04fbbdc3,
4430x05007b49, 0x050539ef, 0x0509f9b4, 0x050eba98, 0x05137c9a, 0x05183fba, 0x051d03f6, 0x0521c950,
4440x05268fc6, 0x052b5757, 0x05302003, 0x0534e9ca, 0x0539b4ab, 0x053e80a5, 0x05434db9, 0x05481be5,
4450x054ceb29, 0x0551bb85, 0x05568cf8, 0x055b5f81, 0x05603321, 0x056507d6, 0x0569dda0, 0x056eb47f,
4460x05738c72, 0x05786578, 0x057d3f92, 0x05821abe, 0x0586f6fd, 0x058bd44e, 0x0590b2af, 0x05959222,
4470x059a72a5, 0x059f5438, 0x05a436da, 0x05a91a8c, 0x05adff4b, 0x05b2e519, 0x05b7cbf5, 0x05bcb3dd,
4480x05c19cd3, 0x05c686d4, 0x05cb71e2, 0x05d05dfb, 0x05d54b1f, 0x05da394d, 0x05df2885, 0x05e418c7,
4490x05e90a12, 0x05edfc66, 0x05f2efc2, 0x05f7e426, 0x05fcd992, 0x0601d004, 0x0606c77d, 0x060bbffd,
4500x0610b982, 0x0615b40c, 0x061aaf9b, 0x061fac2f, 0x0624a9c7, 0x0629a863, 0x062ea802, 0x0633a8a3,
4510x0638aa47, 0x063dacee, 0x0642b095, 0x0647b53f, 0x064cbae8, 0x0651c193, 0x0656c93d, 0x065bd1e7,
4520x0660db90, 0x0665e639, 0x066af1df, 0x066ffe84, 0x06750c26, 0x067a1ac6, 0x067f2a62, 0x06843afb,
4530x06894c90, 0x068e5f21, 0x069372ad, 0x06988735, 0x069d9cb6, 0x06a2b332, 0x06a7caa8, 0x06ace318,
4540x06b1fc80, 0x06b716e2, 0x06bc323b, 0x06c14e8d, 0x06c66bd6, 0x06cb8a17, 0x06d0a94e, 0x06d5c97c,
4550x06daeaa0, 0x06e00cba, 0x06e52fca, 0x06ea53ce, 0x06ef78c8, 0x06f49eb5, 0x06f9c597, 0x06feed6d,
4560x07041635, 0x07093ff1, 0x070e6aa0, 0x07139640, 0x0718c2d3, 0x071df057, 0x07231ecd, 0x07284e33,
4570x072d7e8a, 0x0732afd2, 0x0737e209, 0x073d1530, 0x07424946, 0x07477e4a, 0x074cb43e, 0x0751eb20,
4580x075722ef, 0x075c5bac, 0x07619556, 0x0766cfee, 0x076c0b71, 0x077147e1, 0x0776853d, 0x077bc385,
4590x078102b8, 0x078642d6, 0x078b83de, 0x0790c5d1, 0x079608ae, 0x079b4c74, 0x07a09124, 0x07a5d6bd,
4600x07ab1d3e, 0x07b064a8, 0x07b5acfa, 0x07baf634, 0x07c04056, 0x07c58b5e, 0x07cad74e, 0x07d02424,
4610x07d571e0, 0x07dac082, 0x07e0100a, 0x07e56077, 0x07eab1ca, 0x07f00401, 0x07f5571c, 0x07faab1c,
4620x07ffffff, 0x080555c7, 0x080aac71, 0x081003fe, 0x08155c6e, 0x081ab5c0, 0x08200ff5, 0x08256b0b,
4630x082ac703, 0x083023dc, 0x08358196, 0x083ae030, 0x08403fab, 0x0845a006, 0x084b0141, 0x0850635b,
4640x0855c654, 0x085b2a2d, 0x08608ee4, 0x0865f479, 0x086b5aed, 0x0870c23e, 0x08762a6d, 0x087b9379,
4650x0880fd62, 0x08866828, 0x088bd3ca, 0x08914048, 0x0896ada3, 0x089c1bd8, 0x08a18aea, 0x08a6fad6,
4660x08ac6b9d, 0x08b1dd3f, 0x08b74fbb, 0x08bcc311, 0x08c23741, 0x08c7ac4a, 0x08cd222c, 0x08d298e8,
4670x08d8107c, 0x08dd88e8, 0x08e3022d, 0x08e87c49, 0x08edf73d, 0x08f37309, 0x08f8efac, 0x08fe6d25,
4680x0903eb75, 0x09096a9c, 0x090eea99, 0x09146b6b, 0x0919ed13, 0x091f6f91, 0x0924f2e3, 0x092a770b,
4690x092ffc06, 0x093581d7, 0x093b087b, 0x09408ff3, 0x0946183f, 0x094ba15e, 0x09512b51, 0x0956b616,
4700x095c41ae, 0x0961ce18, 0x09675b54, 0x096ce962, 0x09727842, 0x097807f3, 0x097d9876, 0x098329c9,
4710x0988bbed, 0x098e4ee1, 0x0993e2a6, 0x0999773a, 0x099f0c9f, 0x09a4a2d3, 0x09aa39d6, 0x09afd1a8,
4720x09b56a49, 0x09bb03b8, 0x09c09df6, 0x09c63902, 0x09cbd4dc, 0x09d17183, 0x09d70ef8, 0x09dcad3a,
4730x09e24c49, 0x09e7ec25, 0x09ed8ccd, 0x09f32e41, 0x09f8d082, 0x09fe738e, 0x0a041766, 0x0a09bc09,
4740x0a0f6178, 0x0a1507b1, 0x0a1aaeb5, 0x0a205684, 0x0a25ff1c, 0x0a2ba87f, 0x0a3152ac, 0x0a36fda2,
4750x0a3ca962, 0x0a4255ea, 0x0a48033c, 0x0a4db157, 0x0a536039, 0x0a590fe5, 0x0a5ec058, 0x0a647193,
4760x0a6a2396, 0x0a6fd660, 0x0a7589f2, 0x0a7b3e4b, 0x0a80f36a, 0x0a86a950, 0x0a8c5ffc, 0x0a92176f,
4770x0a97cfa7, 0x0a9d88a5, 0x0aa34269, 0x0aa8fcf2, 0x0aaeb840, 0x0ab47453, 0x0aba312b, 0x0abfeec8,
4780x0ac5ad28, 0x0acb6c4d, 0x0ad12c36, 0x0ad6ece2, 0x0adcae52, 0x0ae27085, 0x0ae8337b, 0x0aedf734,
4790x0af3bbb0, 0x0af980ee, 0x0aff46ef, 0x0b050db2, 0x0b0ad536, 0x0b109d7c, 0x0b166684, 0x0b1c304d,
4800x0b21fad7, 0x0b27c622, 0x0b2d922e, 0x0b335efa, 0x0b392c87, 0x0b3efad3, 0x0b44c9e0, 0x0b4a99ac,
4810x0b506a38, 0x0b563b83, 0x0b5c0d8e, 0x0b61e057, 0x0b67b3df, 0x0b6d8826, 0x0b735d2b, 0x0b7932ee,
4820x0b7f096f, 0x0b84e0ae, 0x0b8ab8ab, 0x0b909165, 0x0b966add, 0x0b9c4511, 0x0ba22003, 0x0ba7fbb1,
4830x0badd81b, 0x0bb3b542, 0x0bb99326, 0x0bbf71c5, 0x0bc55120, 0x0bcb3136, 0x0bd11208, 0x0bd6f395,
4840x0bdcd5dd, 0x0be2b8e0, 0x0be89c9e, 0x0bee8116, 0x0bf46649, 0x0bfa4c36, 0x0c0032dc, 0x0c061a3d,
4850x0c0c0257, 0x0c11eb2a, 0x0c17d4b7, 0x0c1dbefd, 0x0c23a9fc, 0x0c2995b3, 0x0c2f8223, 0x0c356f4c,
4860x0c3b5d2c, 0x0c414bc5, 0x0c473b16, 0x0c4d2b1e, 0x0c531bde, 0x0c590d55, 0x0c5eff83, 0x0c64f268,
4870x0c6ae604, 0x0c70da57, 0x0c76cf60, 0x0c7cc51f, 0x0c82bb95, 0x0c88b2c1, 0x0c8eaaa2, 0x0c94a339,
4880x0c9a9c85, 0x0ca09687, 0x0ca6913e, 0x0cac8caa, 0x0cb288ca, 0x0cb885a0, 0x0cbe8329, 0x0cc48167,
4890x0cca8059, 0x0cd07fff, 0x0cd68059, 0x0cdc8167, 0x0ce28328, 0x0ce8859c, 0x0cee88c4, 0x0cf48c9e,
4900x0cfa912b, 0x0d00966b, 0x0d069c5d, 0x0d0ca302, 0x0d12aa59, 0x0d18b262, 0x0d1ebb1d, 0x0d24c489,
4910x0d2acea7, 0x0d30d976, 0x0d36e4f7, 0x0d3cf128, 0x0d42fe0b, 0x0d490b9e, 0x0d4f19e2, 0x0d5528d6,
4920x0d5b387b, 0x0d6148cf, 0x0d6759d4, 0x0d6d6b88, 0x0d737dec, 0x0d799100, 0x0d7fa4c3, 0x0d85b935,
4930x0d8bce56, 0x0d91e426, 0x0d97faa4, 0x0d9e11d1, 0x0da429ad, 0x0daa4237, 0x0db05b6f, 0x0db67555,
4940x0dbc8fe9, 0x0dc2ab2a, 0x0dc8c719, 0x0dcee3b5, 0x0dd500ff, 0x0ddb1ef5, 0x0de13d99, 0x0de75ce9,
4950x0ded7ce6, 0x0df39d8f, 0x0df9bee5, 0x0dffe0e7, 0x0e060394, 0x0e0c26ee, 0x0e124af4, 0x0e186fa5,
4960x0e1e9501, 0x0e24bb09, 0x0e2ae1bb, 0x0e310919, 0x0e373122, 0x0e3d59d5, 0x0e438333, 0x0e49ad3c,
4970x0e4fd7ee, 0x0e56034b, 0x0e5c2f52, 0x0e625c02, 0x0e68895d, 0x0e6eb761, 0x0e74e60e, 0x0e7b1564,
4980x0e814564, 0x0e87760d, 0x0e8da75e, 0x0e93d959, 0x0e9a0bfb, 0x0ea03f47, 0x0ea6733a, 0x0eaca7d6,
4990x0eb2dd1a, 0x0eb91305, 0x0ebf4999, 0x0ec580d4, 0x0ecbb8b6, 0x0ed1f140, 0x0ed82a71, 0x0ede6449,
5000x0ee49ec8, 0x0eead9ed, 0x0ef115ba, 0x0ef7522d, 0x0efd8f46, 0x0f03cd05, 0x0f0a0b6b, 0x0f104a76,
5010x0f168a28, 0x0f1cca7f, 0x0f230b7b, 0x0f294d1d, 0x0f2f8f65, 0x0f35d251, 0x0f3c15e3, 0x0f425a19,
5020x0f489ef4, 0x0f4ee474, 0x0f552a98, 0x0f5b7161, 0x0f61b8ce, 0x0f6800df, 0x0f6e4994, 0x0f7492ed,
5030x0f7adce9, 0x0f81278a, 0x0f8772cd, 0x0f8dbeb4, 0x0f940b3e, 0x0f9a586b, 0x0fa0a63c, 0x0fa6f4af,
5040x0fad43c4, 0x0fb3937c, 0x0fb9e3d7, 0x0fc034d4, 0x0fc68673, 0x0fccd8b4, 0x0fd32b97, 0x0fd97f1c,
5050x0fdfd343, 0x0fe6280b, 0x0fec7d74, 0x0ff2d37f, 0x0ff92a2b, 0x0fff8178, 0x1005d966, 0x100c31f5,
5060x10128b24, 0x1018e4f4, 0x101f3f64, 0x10259a75, 0x102bf626, 0x10325277, 0x1038af67, 0x103f0cf8,
5070x10456b28, 0x104bc9f8, 0x10522967, 0x10588976, 0x105eea24, 0x10654b70, 0x106bad5c, 0x10720fe7,
5080x10787310, 0x107ed6d8, 0x10853b3f, 0x108ba043, 0x109205e6, 0x10986c27, 0x109ed307, 0x10a53a83,
5090x10aba29e, 0x10b20b57, 0x10b874ac, 0x10bedea0, 0x10c54930, 0x10cbb45e, 0x10d22029, 0x10d88c90,
5100x10def995, 0x10e56736, 0x10ebd574, 0x10f2444e, 0x10f8b3c5, 0x10ff23d8, 0x11059487, 0x110c05d2,
5110x111277b9, 0x1118ea3b, 0x111f5d59, 0x1125d113, 0x112c4568, 0x1132ba59, 0x11392fe5, 0x113fa60c,
5120x11461ccd, 0x114c942a, 0x11530c22, 0x115984b4, 0x115ffde0, 0x116677a7, 0x116cf209, 0x11736d04,
5130x1179e89a, 0x118064c9, 0x1186e192, 0x118d5ef5, 0x1193dcf2, 0x119a5b88, 0x11a0dab8, 0x11a75a81,
5140x11addae3, 0x11b45bde, 0x11badd72, 0x11c15f9f, 0x11c7e265, 0x11ce65c4, 0x11d4e9bb, 0x11db6e4a,
5150x11e1f372, 0x11e87931, 0x11eeff89, 0x11f58679, 0x11fc0e01, 0x12029621, 0x12091ed8, 0x120fa827,
5160x1216320d, 0x121cbc8a, 0x1223479f, 0x1229d34b, 0x12305f8e, 0x1236ec68, 0x123d79d9, 0x124407e0,
5170x124a967e, 0x125125b2, 0x1257b57d, 0x125e45de, 0x1264d6d6, 0x126b6863, 0x1271fa86, 0x12788d40,
5180x127f208f, 0x1285b473, 0x128c48ed, 0x1292ddfd, 0x129973a2, 0x12a009dc, 0x12a6a0ab, 0x12ad3810,
5190x12b3d009, 0x12ba6897, 0x12c101ba, 0x12c79b71, 0x12ce35bd, 0x12d4d09e, 0x12db6c13, 0x12e2081b,
5200x12e8a4b9, 0x12ef41ea, 0x12f5dfaf, 0x12fc7e07, 0x13031cf4, 0x1309bc74, 0x13105c88, 0x1316fd2f,
5210x131d9e69, 0x13244036, 0x132ae297, 0x1331858b, 0x13382911, 0x133ecd2b, 0x134571d7, 0x134c1716,
5220x1352bce7, 0x1359634a, 0x13600a40, 0x1366b1c9, 0x136d59e3, 0x1374028f, 0x137aabce, 0x1381559e,
5230x1387ffff, 0x138eaaf3, 0x13955678, 0x139c028e, 0x13a2af36, 0x13a95c6f, 0x13b00a39, 0x13b6b895,
5240x13bd6781, 0x13c416fe, 0x13cac70c, 0x13d177aa, 0x13d828d9, 0x13deda99, 0x13e58ce9, 0x13ec3fc9,
5250x13f2f33a, 0x13f9a73a, 0x14005bcb, 0x140710eb, 0x140dc69c, 0x14147cdc, 0x141b33ab, 0x1421eb0a,
5260x1428a2f9, 0x142f5b77, 0x14361484, 0x143cce21, 0x1443884c, 0x144a4307, 0x1450fe50, 0x1457ba28,
5270x145e768f, 0x14653384, 0x146bf108, 0x1472af1b, 0x14796dbb, 0x14802cea, 0x1486eca8, 0x148dacf3,
5280x14946dcc, 0x149b2f33, 0x14a1f128, 0x14a8b3aa, 0x14af76ba, 0x14b63a58, 0x14bcfe83, 0x14c3c33b,
5290x14ca8881, 0x14d14e54, 0x14d814b4, 0x14dedba0, 0x14e5a31a, 0x14ec6b21, 0x14f333b4, 0x14f9fcd4,
5300x1500c680, 0x150790b9, 0x150e5b7e, 0x151526cf, 0x151bf2ad, 0x1522bf17, 0x15298c0c, 0x1530598e,
5310x1537279b, 0x153df634, 0x1544c559, 0x154b950a, 0x15526545, 0x1559360d, 0x1560075f, 0x1566d93d,
5320x156daba6, 0x15747e99, 0x157b5218, 0x15822622, 0x1588fab6, 0x158fcfd6, 0x1596a57f, 0x159d7bb4,
5330x15a45272, 0x15ab29bc, 0x15b2018f, 0x15b8d9ed, 0x15bfb2d4, 0x15c68c46, 0x15cd6641, 0x15d440c7,
5340x15db1bd6, 0x15e1f76f, 0x15e8d391, 0x15efb03d, 0x15f68d73, 0x15fd6b31, 0x16044979, 0x160b284a,
5350x161207a5, 0x1618e788, 0x161fc7f4, 0x1626a8e9, 0x162d8a67, 0x16346c6d, 0x163b4efc, 0x16423213,
5360x164915b3, 0x164ff9dc, 0x1656de8c, 0x165dc3c5, 0x1664a985, 0x166b8fce, 0x1672769f, 0x16795df7,
5370x168045d8, 0x16872e40, 0x168e172f, 0x169500a7, 0x169beaa5, 0x16a2d52b, 0x16a9c038, 0x16b0abcd,
5380x16b797e8, 0x16be848b, 0x16c571b4, 0x16cc5f65, 0x16d34d9c, 0x16da3c5a, 0x16e12b9e, 0x16e81b69,
5390x16ef0bbb, 0x16f5fc93, 0x16fcedf1, 0x1703dfd6, 0x170ad241, 0x1711c531, 0x1718b8a8, 0x171faca5,
5400x1726a127, 0x172d9630, 0x17348bbe, 0x173b81d1, 0x1742786b, 0x17496f89, 0x1750672d, 0x17575f56,
5410x175e5805, 0x17655139, 0x176c4af1, 0x1773452f, 0x177a3ff2, 0x17813b39, 0x17883705, 0x178f3356,
5420x1796302c, 0x179d2d86, 0x17a42b64, 0x17ab29c7, 0x17b228ae, 0x17b92819, 0x17c02809, 0x17c7287c,
5430x17ce2974, 0x17d52aef, 0x17dc2cef, 0x17e32f72, 0x17ea3278, 0x17f13603, 0x17f83a11, 0x17ff3ea2,
5440x180643b7, 0x180d494f, 0x18144f6a, 0x181b5609, 0x18225d2a, 0x182964cf, 0x18306cf6, 0x183775a1,
5450x183e7ece, 0x1845887e, 0x184c92b0, 0x18539d65, 0x185aa89d, 0x1861b457, 0x1868c093, 0x186fcd52,
5460x1876da93, 0x187de856, 0x1884f69b, 0x188c0562, 0x189314aa, 0x189a2475, 0x18a134c2, 0x18a84590,
5470x18af56e0, 0x18b668b1, 0x18bd7b04, 0x18c48dd8, 0x18cba12d, 0x18d2b504, 0x18d9c95c, 0x18e0de35,
5480x18e7f38f, 0x18ef096b, 0x18f61fc7, 0x18fd36a3, 0x19044e01, 0x190b65df, 0x19127e3e, 0x1919971d,
5490x1920b07d, 0x1927ca5d, 0x192ee4be, 0x1935ff9f, 0x193d1b00, 0x194436e1, 0x194b5342, 0x19527023,
5500x19598d84, 0x1960ab65, 0x1967c9c6, 0x196ee8a6, 0x19760806, 0x197d27e6, 0x19844845, 0x198b6923,
5510x19928a81, 0x1999ac5e, 0x19a0ceba, 0x19a7f196, 0x19af14f0, 0x19b638ca, 0x19bd5d22, 0x19c481f9,
5520x19cba74f, 0x19d2cd24, 0x19d9f378, 0x19e11a4a, 0x19e8419a, 0x19ef6969, 0x19f691b6, 0x19fdba82,
5530x1a04e3cc, 0x1a0c0d94, 0x1a1337da, 0x1a1a629f, 0x1a218de1, 0x1a28b9a1, 0x1a2fe5df, 0x1a37129b,
5540x1a3e3fd4, 0x1a456d8b, 0x1a4c9bc0, 0x1a53ca72, 0x1a5af9a2, 0x1a62294f, 0x1a695979, 0x1a708a21,
5550x1a77bb45, 0x1a7eece7, 0x1a861f06, 0x1a8d51a2, 0x1a9484bb, 0x1a9bb850, 0x1aa2ec62, 0x1aaa20f1,
5560x1ab155fd, 0x1ab88b85, 0x1abfc18a, 0x1ac6f80b, 0x1ace2f09, 0x1ad56683, 0x1adc9e79, 0x1ae3d6eb,
5570x1aeb0fda, 0x1af24944, 0x1af9832b, 0x1b00bd8d, 0x1b07f86c, 0x1b0f33c6, 0x1b166f9c, 0x1b1dabed,
5580x1b24e8ba, 0x1b2c2603, 0x1b3363c7, 0x1b3aa206, 0x1b41e0c1, 0x1b491ff7, 0x1b505fa9, 0x1b579fd5,
5590x1b5ee07d, 0x1b66219f, 0x1b6d633d, 0x1b74a555, 0x1b7be7e9, 0x1b832af7, 0x1b8a6e7f, 0x1b91b283,
5600x1b98f701, 0x1ba03bf9, 0x1ba7816c, 0x1baec75a, 0x1bb60dc1, 0x1bbd54a3, 0x1bc49bff, 0x1bcbe3d6,
5610x1bd32c26, 0x1bda74f1, 0x1be1be35, 0x1be907f3, 0x1bf0522b, 0x1bf79cdd, 0x1bfee809, 0x1c0633ae,
5620x1c0d7fcc, 0x1c14cc65, 0x1c1c1976, 0x1c236702, 0x1c2ab506, 0x1c320384, 0x1c39527b, 0x1c40a1eb,
5630x1c47f1d4, 0x1c4f4236, 0x1c569311, 0x1c5de466, 0x1c653632, 0x1c6c8878, 0x1c73db37, 0x1c7b2e6e,
5640x1c82821d, 0x1c89d646, 0x1c912ae6, 0x1c987fff, 0x1c9fd591, 0x1ca72b9b, 0x1cae821d, 0x1cb5d917,
5650x1cbd3089, 0x1cc48874, 0x1ccbe0d6, 0x1cd339b1, 0x1cda9303, 0x1ce1eccd, 0x1ce9470f, 0x1cf0a1c8,
5660x1cf7fcf9, 0x1cff58a2, 0x1d06b4c2, 0x1d0e115a, 0x1d156e69, 0x1d1ccbf0, 0x1d2429ed, 0x1d2b8862,
5670x1d32e74e, 0x1d3a46b2, 0x1d41a68c, 0x1d4906dd, 0x1d5067a6, 0x1d57c8e5, 0x1d5f2a9b, 0x1d668cc7,
5680x1d6def6b, 0x1d755285, 0x1d7cb615, 0x1d841a1c, 0x1d8b7e9a, 0x1d92e38e, 0x1d9a48f9, 0x1da1aed9,
5690x1da91530, 0x1db07bfd, 0x1db7e340, 0x1dbf4afa, 0x1dc6b329, 0x1dce1bce, 0x1dd584e9, 0x1ddcee7a,
5700x1de45881, 0x1debc2fe, 0x1df32df0, 0x1dfa9957, 0x1e020535, 0x1e097187, 0x1e10de50, 0x1e184b8d,
5710x1e1fb940, 0x1e272768, 0x1e2e9606, 0x1e360518, 0x1e3d74a0, 0x1e44e49d, 0x1e4c550e, 0x1e53c5f5,
5720x1e5b3750, 0x1e62a921, 0x1e6a1b66, 0x1e718e20, 0x1e79014e, 0x1e8074f1, 0x1e87e909, 0x1e8f5d95,
5730x1e96d295, 0x1e9e480a, 0x1ea5bdf3, 0x1ead3450, 0x1eb4ab22, 0x1ebc2268, 0x1ec39a22, 0x1ecb1250,
5740x1ed28af1, 0x1eda0407, 0x1ee17d91, 0x1ee8f78f, 0x1ef07200, 0x1ef7ece5, 0x1eff683d, 0x1f06e40a,
5750x1f0e604a, 0x1f15dcfd, 0x1f1d5a24, 0x1f24d7be, 0x1f2c55cb, 0x1f33d44c, 0x1f3b5340, 0x1f42d2a7,
5760x1f4a5281, 0x1f51d2ce, 0x1f59538f, 0x1f60d4c2, 0x1f685668, 0x1f6fd881, 0x1f775b0d, 0x1f7ede0c,
5770x1f86617d, 0x1f8de561, 0x1f9569b7, 0x1f9cee80, 0x1fa473bb, 0x1fabf969, 0x1fb37f8a, 0x1fbb061c,
5780x1fc28d21, 0x1fca1498, 0x1fd19c81, 0x1fd924dc, 0x1fe0ada9, 0x1fe836e9, 0x1fefc09a, 0x1ff74abd,
5790x1ffed552, 0x20066059, 0x200debd1, 0x201577bc, 0x201d0417, 0x202490e5, 0x202c1e24, 0x2033abd4,
5800x203b39f6, 0x2042c889, 0x204a578d, 0x2051e703, 0x205976ea, 0x20610742, 0x2068980b, 0x20702946,
5810x2077baf1, 0x207f4d0d, 0x2086df9a, 0x208e7298, 0x20960607, 0x209d99e7, 0x20a52e37, 0x20acc2f8,
5820x20b45829, 0x20bbedcb, 0x20c383de, 0x20cb1a61, 0x20d2b154, 0x20da48b8, 0x20e1e08c, 0x20e978d0,
5830x20f11185, 0x20f8aaa9, 0x2100443e, 0x2107de43, 0x210f78b7, 0x2117139c, 0x211eaef0, 0x21264ab5,
5840x212de6e9, 0x2135838d, 0x213d20a0, 0x2144be24, 0x214c5c16, 0x2153fa79, 0x215b994b, 0x2163388c,
5850x216ad83d, 0x2172785d, 0x217a18ec, 0x2181b9ea, 0x21895b58, 0x2190fd35, 0x21989f81, 0x21a0423c,
5860x21a7e566, 0x21af88ff, 0x21b72d06, 0x21bed17d, 0x21c67663, 0x21ce1bb7, 0x21d5c17a, 0x21dd67ab,
5870x21e50e4b, 0x21ecb55a, 0x21f45cd7, 0x21fc04c3, 0x2203ad1d, 0x220b55e5, 0x2212ff1c, 0x221aa8c1,
5880x222252d4, 0x2229fd56, 0x2231a845, 0x223953a3, 0x2240ff6e, 0x2248aba8, 0x2250584f, 0x22580565,
5890x225fb2e8, 0x226760d9, 0x226f0f37, 0x2276be04, 0x227e6d3e, 0x22861ce5, 0x228dccfa, 0x22957d7d,
5900x229d2e6d, 0x22a4dfcb, 0x22ac9195, 0x22b443cd, 0x22bbf673, 0x22c3a985, 0x22cb5d05, 0x22d310f2,
5910x22dac54c, 0x22e27a13, 0x22ea2f47, 0x22f1e4e8, 0x22f99af5, 0x23015170, 0x23090857, 0x2310bfab,
5920x2318776c, 0x23202f99, 0x2327e833, 0x232fa13a, 0x23375aad, 0x233f148c, 0x2346ced8, 0x234e8991,
5930x235644b5, 0x235e0046, 0x2365bc43, 0x236d78ac, 0x23753582, 0x237cf2c3, 0x2384b071, 0x238c6e8a,
5940x23942d10, 0x239bec01, 0x23a3ab5e, 0x23ab6b28, 0x23b32b5c, 0x23baebfd, 0x23c2ad09, 0x23ca6e81,
5950x23d23064, 0x23d9f2b3, 0x23e1b56e, 0x23e97894, 0x23f13c25, 0x23f90022, 0x2400c48a, 0x2408895d,
5960x24104e9b, 0x24181445, 0x241fda5a, 0x2427a0da, 0x242f67c5, 0x24372f1a, 0x243ef6db, 0x2446bf07,
5970x244e879e, 0x2456509f, 0x245e1a0b, 0x2465e3e2, 0x246dae24, 0x247578d0, 0x247d43e7, 0x24850f68,
5980x248cdb54, 0x2494a7ab, 0x249c746b, 0x24a44197, 0x24ac0f2c, 0x24b3dd2c, 0x24bbab96, 0x24c37a6a,
5990x24cb49a8, 0x24d31951, 0x24dae963, 0x24e2b9e0, 0x24ea8ac6, 0x24f25c17, 0x24fa2dd1, 0x2501fff5,
6000x2509d283, 0x2511a57b, 0x251978dc, 0x25214ca7, 0x252920dc, 0x2530f57b, 0x2538ca82, 0x25409ff4,
6010x254875cf, 0x25504c13, 0x255822c0, 0x255ff9d7, 0x2567d157, 0x256fa941, 0x25778193, 0x257f5a4f,
6020x25873374, 0x258f0d02, 0x2596e6f9, 0x259ec159, 0x25a69c22, 0x25ae7753, 0x25b652ee, 0x25be2ef1,
6030x25c60b5e, 0x25cde833, 0x25d5c570, 0x25dda316, 0x25e58125, 0x25ed5f9d, 0x25f53e7c, 0x25fd1dc5,
6040x2604fd76, 0x260cdd8f, 0x2614be10, 0x261c9efa, 0x2624804c, 0x262c6206, 0x26344429, 0x263c26b3,
6050x264409a6, 0x264bed01, 0x2653d0c3, 0x265bb4ee, 0x26639980, 0x266b7e7b, 0x267363dd, 0x267b49a7,
6060x26832fd9, 0x268b1673, 0x2692fd74, 0x269ae4dd, 0x26a2ccad, 0x26aab4e5, 0x26b29d85, 0x26ba868c,
6070x26c26ffa, 0x26ca59d0, 0x26d2440d, 0x26da2eb1, 0x26e219bd, 0x26ea0530, 0x26f1f10a, 0x26f9dd4b,
6080x2701c9f4, 0x2709b703, 0x2711a479, 0x27199257, 0x2721809b, 0x27296f46, 0x27315e58, 0x27394dd1,
6090x27413db0, 0x27492df7, 0x27511ea4, 0x27590fb7, 0x27610132, 0x2768f312, 0x2770e55a, 0x2778d808,
6100x2780cb1c, 0x2788be96, 0x2790b277, 0x2798a6bf, 0x27a09b6c, 0x27a89080, 0x27b085fa, 0x27b87bdb,
6110x27c07221, 0x27c868cd, 0x27d05fe0, 0x27d85758, 0x27e04f37, 0x27e8477b, 0x27f04026, 0x27f83936,
6120x280032ac, 0x28082c87, 0x281026c9, 0x28182170, 0x28201c7d, 0x282817ef, 0x283013c7, 0x28381004,
6130x28400ca7, 0x284809b0, 0x2850071d, 0x285804f1, 0x28600329, 0x286801c7, 0x287000ca, 0x28780032,
6140x287fffff, 0x28880032, 0x289000ca, 0x289801c6, 0x28a00328, 0x28a804ef, 0x28b0071b, 0x28b809ab,
6150x28c00ca1, 0x28c80ffb, 0x28d013ba, 0x28d817de, 0x28e01c66, 0x28e82153, 0x28f026a5, 0x28f82c5b,
6160x29003276, 0x290838f6, 0x29103fda, 0x29184722, 0x29204ecf, 0x292856e0, 0x29305f55, 0x2938682f,
6170x2940716d, 0x29487b0f, 0x29508516, 0x29588f80, 0x29609a4f, 0x2968a582, 0x2970b118, 0x2978bd13,
6180x2980c972, 0x2988d634, 0x2990e35a, 0x2998f0e5, 0x29a0fed3, 0x29a90d24, 0x29b11bda, 0x29b92af3,
6190x29c13a70, 0x29c94a50, 0x29d15a94, 0x29d96b3c, 0x29e17c47, 0x29e98db5, 0x29f19f87, 0x29f9b1bc,
6200x2a01c455, 0x2a09d751, 0x2a11eab0, 0x2a19fe72, 0x2a221298, 0x2a2a2721, 0x2a323c0d, 0x2a3a515c,
6210x2a42670e, 0x2a4a7d23, 0x2a52939b, 0x2a5aaa75, 0x2a62c1b3, 0x2a6ad954, 0x2a72f157, 0x2a7b09be,
6220x2a832287, 0x2a8b3bb2, 0x2a935541, 0x2a9b6f32, 0x2aa38986, 0x2aaba43c, 0x2ab3bf55, 0x2abbdad0,
6230x2ac3f6ad, 0x2acc12ee, 0x2ad42f90, 0x2adc4c95, 0x2ae469fc, 0x2aec87c6, 0x2af4a5f1, 0x2afcc47f,
6240x2b04e36f, 0x2b0d02c1, 0x2b152276, 0x2b1d428c, 0x2b256304, 0x2b2d83df, 0x2b35a51b, 0x2b3dc6b9,
6250x2b45e8b9, 0x2b4e0b1b, 0x2b562ddf, 0x2b5e5104, 0x2b66748c, 0x2b6e9875, 0x2b76bcbf, 0x2b7ee16b,
6260x2b870679, 0x2b8f2be9, 0x2b9751b9, 0x2b9f77ec, 0x2ba79e80, 0x2bafc575, 0x2bb7eccb, 0x2bc01483,
6270x2bc83c9d, 0x2bd06517, 0x2bd88df3, 0x2be0b730, 0x2be8e0ce, 0x2bf10acd, 0x2bf9352e, 0x2c015fef,
6280x2c098b11, 0x2c11b695, 0x2c19e279, 0x2c220ebf, 0x2c2a3b65, 0x2c32686c, 0x2c3a95d4, 0x2c42c39c,
6290x2c4af1c6, 0x2c532050, 0x2c5b4f3a, 0x2c637e86, 0x2c6bae32, 0x2c73de3e, 0x2c7c0eab, 0x2c843f79,
6300x2c8c70a7, 0x2c94a236, 0x2c9cd424, 0x2ca50674, 0x2cad3923, 0x2cb56c33, 0x2cbd9fa3, 0x2cc5d374,
6310x2cce07a4, 0x2cd63c35, 0x2cde7126, 0x2ce6a677, 0x2ceedc28, 0x2cf71238, 0x2cff48a9, 0x2d077f7a,
6320x2d0fb6ab, 0x2d17ee3c, 0x2d20262c, 0x2d285e7d, 0x2d30972d, 0x2d38d03d, 0x2d4109ac, 0x2d49437c,
6330x2d517daa, 0x2d59b839, 0x2d61f327, 0x2d6a2e75, 0x2d726a22, 0x2d7aa62e, 0x2d82e29b, 0x2d8b1f66,
6340x2d935c91, 0x2d9b9a1b, 0x2da3d804, 0x2dac164d, 0x2db454f5, 0x2dbc93fc, 0x2dc4d363, 0x2dcd1328,
6350x2dd5534d, 0x2ddd93d0, 0x2de5d4b3, 0x2dee15f5, 0x2df65795, 0x2dfe9995, 0x2e06dbf4, 0x2e0f1eb1,
6360x2e1761cd, 0x2e1fa548, 0x2e27e922, 0x2e302d5a, 0x2e3871f2, 0x2e40b6e8, 0x2e48fc3c, 0x2e5141ef,
6370x2e598801, 0x2e61ce71, 0x2e6a1540, 0x2e725c6d, 0x2e7aa3f9, 0x2e82ebe3, 0x2e8b342b, 0x2e937cd2,
6380x2e9bc5d7, 0x2ea40f3b, 0x2eac58fc, 0x2eb4a31c, 0x2ebced9a, 0x2ec53876, 0x2ecd83b0, 0x2ed5cf49,
6390x2ede1b3f, 0x2ee66794, 0x2eeeb446, 0x2ef70156, 0x2eff4ec5, 0x2f079c91, 0x2f0feabb, 0x2f183942,
6400x2f208828, 0x2f28d76b, 0x2f31270c, 0x2f39770b, 0x2f41c768, 0x2f4a1822, 0x2f526939, 0x2f5abaaf,
6410x2f630c81, 0x2f6b5eb2, 0x2f73b13f, 0x2f7c042a, 0x2f845773, 0x2f8cab19, 0x2f94ff1c, 0x2f9d537d,
6420x2fa5a83a, 0x2fadfd56, 0x2fb652ce, 0x2fbea8a3, 0x2fc6fed6, 0x2fcf5566, 0x2fd7ac52, 0x2fe0039c,
6430x2fe85b43, 0x2ff0b347, 0x2ff90ba8, 0x30016466, 0x3009bd80, 0x301216f8, 0x301a70cc, 0x3022cafd,
6440x302b258b, 0x30338076, 0x303bdbbd, 0x30443761, 0x304c9362, 0x3054efbf, 0x305d4c79, 0x3065a98f,
6450x306e0702, 0x307664d2, 0x307ec2fe, 0x30872186, 0x308f806b, 0x3097dfac, 0x30a03f49, 0x30a89f43,
6460x30b0ff99, 0x30b9604b, 0x30c1c159, 0x30ca22c4, 0x30d2848a, 0x30dae6ad, 0x30e3492c, 0x30ebac07,
6470x30f40f3e, 0x30fc72d1, 0x3104d6c0, 0x310d3b0b, 0x31159fb1, 0x311e04b4, 0x31266a12, 0x312ecfcd,
6480x313735e3, 0x313f9c55, 0x31480322, 0x31506a4b, 0x3158d1d0, 0x316139b0, 0x3169a1ed, 0x31720a84,
6490x317a7377, 0x3182dcc6, 0x318b4670, 0x3193b076, 0x319c1ad6, 0x31a48593, 0x31acf0aa, 0x31b55c1d,
6500x31bdc7ec, 0x31c63415, 0x31cea09a, 0x31d70d7a, 0x31df7ab5, 0x31e7e84b, 0x31f0563d, 0x31f8c489,
6510x32013331, 0x3209a233, 0x32121191, 0x321a8149, 0x3222f15d, 0x322b61cb, 0x3233d294, 0x323c43b8,
6520x3244b537, 0x324d2711, 0x32559945, 0x325e0bd4, 0x32667ebe, 0x326ef202, 0x327765a1, 0x327fd99b,
6530x32884def, 0x3290c29e, 0x329937a7, 0x32a1ad0b, 0x32aa22c9, 0x32b298e2, 0x32bb0f55, 0x32c38622,
6540x32cbfd4a, 0x32d474cc, 0x32dceca8, 0x32e564df, 0x32eddd70, 0x32f6565b, 0x32fecfa0, 0x3307493f,
6550x330fc338, 0x33183d8c, 0x3320b839, 0x33293341, 0x3331aea2, 0x333a2a5e, 0x3342a673, 0x334b22e2,
6560x33539fab, 0x335c1cce, 0x33649a4b, 0x336d1821, 0x33759652, 0x337e14dc, 0x338693bf, 0x338f12fd,
6570x33979294, 0x33a01284, 0x33a892cf, 0x33b11372, 0x33b9946f, 0x33c215c6, 0x33ca9776, 0x33d31980,
6580x33db9be3, 0x33e41ea0, 0x33eca1b5, 0x33f52524, 0x33fda8ed, 0x34062d0e, 0x340eb189, 0x3417365d,
6590x341fbb8b, 0x34284111, 0x3430c6f1, 0x34394d29, 0x3441d3bb, 0x344a5aa6, 0x3452e1e9, 0x345b6986,
6600x3463f17c, 0x346c79ca, 0x34750272, 0x347d8b72, 0x348614cb, 0x348e9e7d, 0x34972888, 0x349fb2eb,
6610x34a83da8, 0x34b0c8bd, 0x34b9542a, 0x34c1dff0, 0x34ca6c0f, 0x34d2f887, 0x34db8557, 0x34e4127f,
6620x34eca000, 0x34f52dda, 0x34fdbc0c, 0x35064a96, 0x350ed979, 0x351768b4, 0x351ff847, 0x35288833,
6630x35311877, 0x3539a913, 0x35423a08, 0x354acb54, 0x35535cf9, 0x355beef6, 0x3564814b, 0x356d13f8,
6640x3575a6fe, 0x357e3a5b, 0x3586ce10, 0x358f621d, 0x3597f682, 0x35a08b40, 0x35a92055, 0x35b1b5c1,
6650x35ba4b86, 0x35c2e1a3, 0x35cb7817, 0x35d40ee3, 0x35dca607, 0x35e53d82, 0x35edd555, 0x35f66d80,
6660x35ff0602, 0x36079edc, 0x3610380e, 0x3618d197, 0x36216b77, 0x362a05af, 0x3632a03f, 0x363b3b26,
6670x3643d664, 0x364c71fa, 0x36550de7, 0x365daa2b, 0x366646c7, 0x366ee3ba, 0x36778104, 0x36801ea5,
6680x3688bc9e, 0x36915aee, 0x3699f994, 0x36a29892, 0x36ab37e7, 0x36b3d793, 0x36bc7796, 0x36c517f1,
6690x36cdb8a2, 0x36d659aa, 0x36defb08, 0x36e79cbe, 0x36f03ecb, 0x36f8e12e, 0x370183e9, 0x370a26fa,
6700x3712ca62, 0x371b6e20, 0x37241235, 0x372cb6a1, 0x37355b64, 0x373e007d, 0x3746a5ed, 0x374f4bb3,
6710x3757f1d0, 0x37609844, 0x37693f0e, 0x3771e62e, 0x377a8da5, 0x37833572, 0x378bdd96, 0x37948610,
6720x379d2ee0, 0x37a5d807, 0x37ae8183, 0x37b72b57, 0x37bfd580, 0x37c87fff, 0x37d12ad5, 0x37d9d601,
6730x37e28183, 0x37eb2d5b, 0x37f3d989, 0x37fc860e, 0x380532e8, 0x380de018, 0x38168d9e, 0x381f3b7b,
6740x3827e9ad, 0x38309835, 0x38394712, 0x3841f646, 0x384aa5d0, 0x385355af, 0x385c05e4, 0x3864b66f,
6750x386d674f, 0x38761885, 0x387eca11, 0x38877bf2, 0x38902e29, 0x3898e0b6, 0x38a19398, 0x38aa46d0,
6760x38b2fa5d, 0x38bbae40, 0x38c46278, 0x38cd1705, 0x38d5cbe8, 0x38de8120, 0x38e736ae, 0x38efec91,
6770x38f8a2c9, 0x39015957, 0x390a103a, 0x3912c772, 0x391b7eff, 0x392436e1, 0x392cef19, 0x3935a7a5,
6780x393e6087, 0x394719be, 0x394fd34a, 0x39588d2b, 0x39614760, 0x396a01eb, 0x3972bccb, 0x397b7800,
6790x39843389, 0x398cef68, 0x3995ab9b, 0x399e6823, 0x39a72500, 0x39afe232, 0x39b89fb8, 0x39c15d93,
6800x39ca1bc3, 0x39d2da47, 0x39db9921, 0x39e4584e, 0x39ed17d1, 0x39f5d7a8, 0x39fe97d3, 0x3a075853,
6810x3a101927, 0x3a18da50, 0x3a219bce, 0x3a2a5d9f, 0x3a331fc5, 0x3a3be240, 0x3a44a50f, 0x3a4d6832,
6820x3a562ba9, 0x3a5eef75, 0x3a67b395, 0x3a707809, 0x3a793cd2, 0x3a8201ee, 0x3a8ac75f, 0x3a938d24,
6830x3a9c533d, 0x3aa519aa, 0x3aade06b, 0x3ab6a780, 0x3abf6ee9, 0x3ac836a6, 0x3ad0feb7, 0x3ad9c71c,
6840x3ae28fd5, 0x3aeb58e1, 0x3af42242, 0x3afcebf6, 0x3b05b5fe, 0x3b0e805a, 0x3b174b0a, 0x3b20160d,
6850x3b28e164, 0x3b31ad0f, 0x3b3a790e, 0x3b434560, 0x3b4c1205, 0x3b54deff, 0x3b5dac4b, 0x3b6679ec,
6860x3b6f47e0, 0x3b781627, 0x3b80e4c2, 0x3b89b3b0, 0x3b9282f2, 0x3b9b5287, 0x3ba4226f, 0x3bacf2ab,
6870x3bb5c33a, 0x3bbe941c, 0x3bc76552, 0x3bd036db, 0x3bd908b7, 0x3be1dae6, 0x3beaad69, 0x3bf3803e,
6880x3bfc5367, 0x3c0526e3, 0x3c0dfab2, 0x3c16ced4, 0x3c1fa349, 0x3c287811, 0x3c314d2c, 0x3c3a229a,
6890x3c42f85b, 0x3c4bce6f, 0x3c54a4d5, 0x3c5d7b8f, 0x3c66529b, 0x3c6f29fa, 0x3c7801ac, 0x3c80d9b1,
6900x3c89b209, 0x3c928ab3, 0x3c9b63b0, 0x3ca43cff, 0x3cad16a2, 0x3cb5f097, 0x3cbecade, 0x3cc7a578,
6910x3cd08065, 0x3cd95ba4, 0x3ce23736, 0x3ceb131a, 0x3cf3ef50, 0x3cfccbd9, 0x3d05a8b5, 0x3d0e85e3,
6920x3d176363, 0x3d204136, 0x3d291f5b, 0x3d31fdd2, 0x3d3adc9b, 0x3d43bbb7, 0x3d4c9b25, 0x3d557ae5,
6930x3d5e5af7, 0x3d673b5c, 0x3d701c13, 0x3d78fd1b, 0x3d81de76, 0x3d8ac023, 0x3d93a222, 0x3d9c8473,
6940x3da56716, 0x3dae4a0b, 0x3db72d52, 0x3dc010eb, 0x3dc8f4d6, 0x3dd1d912, 0x3ddabda1, 0x3de3a281,
6950x3dec87b3, 0x3df56d37, 0x3dfe530d, 0x3e073934, 0x3e101fad, 0x3e190678, 0x3e21ed95, 0x3e2ad503,
6960x3e33bcc3, 0x3e3ca4d4, 0x3e458d37, 0x3e4e75ec, 0x3e575ef2, 0x3e60484a, 0x3e6931f3, 0x3e721bed,
6970x3e7b0639, 0x3e83f0d7, 0x3e8cdbc6, 0x3e95c706, 0x3e9eb298, 0x3ea79e7a, 0x3eb08aaf, 0x3eb97734,
6980x3ec2640b, 0x3ecb5133, 0x3ed43eac, 0x3edd2c77, 0x3ee61a93, 0x3eef08ff, 0x3ef7f7bd, 0x3f00e6cc,
6990x3f09d62c, 0x3f12c5de, 0x3f1bb5e0, 0x3f24a633, 0x3f2d96d7, 0x3f3687cd, 0x3f3f7913, 0x3f486aaa,
7000x3f515c92, 0x3f5a4ecb, 0x3f634155, 0x3f6c342f, 0x3f75275b, 0x3f7e1ad7, 0x3f870ea4, 0x3f9002c2,
7010x3f98f730, 0x3fa1ebef, 0x3faae0ff, 0x3fb3d660, 0x3fbccc11, 0x3fc5c213, 0x3fceb865, 0x3fd7af08,
7020x3fe0a5fc, 0x3fe99d40, 0x3ff294d4, 0x3ffb8cb9, 0x400484ef, 0x400d7d75, 0x4016764b, 0x401f6f72,
7030x402868e9, 0x403162b1, 0x403a5cc8, 0x40435730, 0x404c51e9, 0x40554cf2, 0x405e484b, 0x406743f4,
7040x40703fed, 0x40793c37, 0x408238d0, 0x408b35ba, 0x409432f4, 0x409d307e, 0x40a62e58, 0x40af2c82,
7050x40b82afd, 0x40c129c7, 0x40ca28e1, 0x40d3284b, 0x40dc2805, 0x40e5280f, 0x40ee2869, 0x40f72913,
7060x41002a0c, 0x41092b56, 0x41122cef, 0x411b2ed8, 0x41243111, 0x412d3399, 0x41363672, 0x413f399a,
7070x41483d11, 0x415140d9, 0x415a44f0, 0x41634956, 0x416c4e0c, 0x41755312, 0x417e5867, 0x41875e0c,
7080x41906401, 0x41996a44, 0x41a270d8, 0x41ab77ba, 0x41b47eed, 0x41bd866e, 0x41c68e3f, 0x41cf965f,
7090x41d89ecf, 0x41e1a78e, 0x41eab09c, 0x41f3b9fa, 0x41fcc3a6, 0x4205cda2, 0x420ed7ee, 0x4217e288,
7100x4220ed72, 0x4229f8aa, 0x42330432, 0x423c1009, 0x42451c2f, 0x424e28a4, 0x42573569, 0x4260427c,
7110x42694fde, 0x42725d8f, 0x427b6b8f, 0x428479de, 0x428d887c, 0x42969769, 0x429fa6a5, 0x42a8b62f,
7120x42b1c609, 0x42bad631, 0x42c3e6a8, 0x42ccf76e, 0x42d60882, 0x42df19e5, 0x42e82b97, 0x42f13d98,
7130x42fa4fe7, 0x43036285, 0x430c7572, 0x431588ad, 0x431e9c37, 0x4327b00f, 0x4330c436, 0x4339d8ab,
7140x4342ed6f, 0x434c0282, 0x435517e3, 0x435e2d92, 0x4367438f, 0x437059dc, 0x43797076, 0x4382875f,
7150x438b9e96, 0x4394b61b, 0x439dcdef, 0x43a6e611, 0x43affe81, 0x43b91740, 0x43c2304d, 0x43cb49a8,
7160x43d46351, 0x43dd7d48, 0x43e6978d, 0x43efb221, 0x43f8cd02, 0x4401e832, 0x440b03af, 0x44141f7b,
7170x441d3b95, 0x442657fc, 0x442f74b2, 0x443891b6, 0x4441af07, 0x444acca7, 0x4453ea94, 0x445d08cf,
7180x44662758, 0x446f462f, 0x44786553, 0x448184c6, 0x448aa486, 0x4493c494, 0x449ce4f0, 0x44a60599,
7190x44af2690, 0x44b847d5, 0x44c16967, 0x44ca8b47, 0x44d3ad74, 0x44dccfef, 0x44e5f2b8, 0x44ef15ce,
7200x44f83932, 0x45015ce3, 0x450a80e2, 0x4513a52e, 0x451cc9c8, 0x4525eeaf, 0x452f13e3, 0x45383965,
7210x45415f34, 0x454a8551, 0x4553abbb, 0x455cd272, 0x4565f976, 0x456f20c8, 0x45784867, 0x45817053,
7220x458a988c, 0x4593c113, 0x459ce9e7, 0x45a61307, 0x45af3c75, 0x45b86630, 0x45c19039, 0x45caba8e,
7230x45d3e530, 0x45dd101f, 0x45e63b5c, 0x45ef66e5, 0x45f892bb, 0x4601bede, 0x460aeb4e, 0x4614180b,
7240x461d4515, 0x4626726c, 0x462fa00f, 0x4638ce00, 0x4641fc3d, 0x464b2ac7, 0x4654599e, 0x465d88c1,
7250x4666b832, 0x466fe7ef, 0x467917f8, 0x4682484e, 0x468b78f1, 0x4694a9e1, 0x469ddb1d, 0x46a70ca6,
7260x46b03e7b, 0x46b9709d, 0x46c2a30c, 0x46cbd5c7, 0x46d508ce, 0x46de3c22, 0x46e76fc2, 0x46f0a3af,
7270x46f9d7e9, 0x47030c6e, 0x470c4140, 0x4715765f, 0x471eabc9, 0x4727e180, 0x47311784, 0x473a4dd3,
7280x4743846f, 0x474cbb57, 0x4755f28c, 0x475f2a0c, 0x476861d9, 0x477199f2, 0x477ad257, 0x47840b08,
7290x478d4405, 0x47967d4f, 0x479fb6e4, 0x47a8f0c5, 0x47b22af3, 0x47bb656c, 0x47c4a032, 0x47cddb43,
7300x47d716a1, 0x47e0524a, 0x47e98e40, 0x47f2ca81, 0x47fc070e, 0x480543e7, 0x480e810c, 0x4817be7c,
7310x4820fc39, 0x482a3a41, 0x48337895, 0x483cb735, 0x4845f620, 0x484f3557, 0x485874da, 0x4861b4a8,
7320x486af4c3, 0x48743528, 0x487d75da, 0x4886b6d7, 0x488ff81f, 0x489939b3, 0x48a27b93, 0x48abbdbe,
7330x48b50035, 0x48be42f7, 0x48c78605, 0x48d0c95e, 0x48da0d02, 0x48e350f2, 0x48ec952e, 0x48f5d9b4,
7340x48ff1e86, 0x490863a4, 0x4911a90c, 0x491aeec0, 0x492434bf, 0x492d7b0a, 0x4936c1a0, 0x49400881,
7350x49494fad, 0x49529724, 0x495bdee7, 0x496526f4, 0x496e6f4d, 0x4977b7f1, 0x498100e0, 0x498a4a1a,
7360x4993939f, 0x499cdd6f, 0x49a6278a, 0x49af71f0, 0x49b8bca2, 0x49c2079e, 0x49cb52e5, 0x49d49e77,
7370x49ddea53, 0x49e7367b, 0x49f082ee, 0x49f9cfab, 0x4a031cb4, 0x4a0c6a07, 0x4a15b7a5, 0x4a1f058d,
7380x4a2853c1, 0x4a31a23f, 0x4a3af108, 0x4a44401b, 0x4a4d8f7a, 0x4a56df23, 0x4a602f16, 0x4a697f55,
7390x4a72cfdd, 0x4a7c20b1, 0x4a8571cf, 0x4a8ec337, 0x4a9814eb, 0x4aa166e8, 0x4aaab930, 0x4ab40bc3,
7400x4abd5ea0, 0x4ac6b1c8, 0x4ad0053a, 0x4ad958f6, 0x4ae2acfd, 0x4aec014e, 0x4af555e9, 0x4afeaacf,
7410x4b07ffff, 0x4b11557a, 0x4b1aab3f, 0x4b24014e, 0x4b2d57a7, 0x4b36ae4b, 0x4b400538, 0x4b495c70,
7420x4b52b3f2, 0x4b5c0bbf, 0x4b6563d5, 0x4b6ebc36, 0x4b7814e0, 0x4b816dd5, 0x4b8ac714, 0x4b94209d,
7430x4b9d7a6f, 0x4ba6d48c, 0x4bb02ef3, 0x4bb989a4, 0x4bc2e49f, 0x4bcc3fe4, 0x4bd59b72, 0x4bdef74b,
7440x4be8536e, 0x4bf1afda, 0x4bfb0c90, 0x4c046990, 0x4c0dc6da, 0x4c17246e, 0x4c20824b, 0x4c29e073,
7450x4c333ee4, 0x4c3c9d9e, 0x4c45fca3, 0x4c4f5bf1, 0x4c58bb89, 0x4c621b6a, 0x4c6b7b95, 0x4c74dc0a,
7460x4c7e3cc9, 0x4c879dd0, 0x4c90ff22, 0x4c9a60bd, 0x4ca3c2a2, 0x4cad24d0, 0x4cb68747, 0x4cbfea09,
7470x4cc94d13, 0x4cd2b067, 0x4cdc1405, 0x4ce577ec, 0x4ceedc1c, 0x4cf84096, 0x4d01a559, 0x4d0b0a65,
7480x4d146fbb, 0x4d1dd55a, 0x4d273b42, 0x4d30a174, 0x4d3a07ee, 0x4d436eb2, 0x4d4cd5c0, 0x4d563d16,
7490x4d5fa4b6, 0x4d690c9f, 0x4d7274d1, 0x4d7bdd4c, 0x4d854610, 0x4d8eaf1e, 0x4d981874, 0x4da18214,
7500x4daaebfc, 0x4db4562e, 0x4dbdc0a8, 0x4dc72b6c, 0x4dd09679, 0x4dda01ce, 0x4de36d6d, 0x4decd954,
7510x4df64584, 0x4dffb1fe, 0x4e091ec0, 0x4e128bcb, 0x4e1bf91f, 0x4e2566bb, 0x4e2ed4a1, 0x4e3842cf,
7520x4e41b146, 0x4e4b2006, 0x4e548f0e, 0x4e5dfe5f, 0x4e676df9, 0x4e70dddc, 0x4e7a4e07, 0x4e83be7b,
7530x4e8d2f38, 0x4e96a03d, 0x4ea0118b, 0x4ea98321, 0x4eb2f500, 0x4ebc6728, 0x4ec5d998, 0x4ecf4c50,
7540x4ed8bf51, 0x4ee2329b, 0x4eeba62d, 0x4ef51a07, 0x4efe8e2a, 0x4f080296, 0x4f117749, 0x4f1aec45,
7550x4f24618a, 0x4f2dd717, 0x4f374cec, 0x4f40c309, 0x4f4a396f, 0x4f53b01d, 0x4f5d2713, 0x4f669e52,
7560x4f7015d9, 0x4f798da8, 0x4f8305bf, 0x4f8c7e1e, 0x4f95f6c6, 0x4f9f6fb5, 0x4fa8e8ed, 0x4fb2626d,
7570x4fbbdc35, 0x4fc55645, 0x4fced09d, 0x4fd84b3e, 0x4fe1c626, 0x4feb4156, 0x4ff4bcce, 0x4ffe388f,
7580x5007b497, 0x501130e7, 0x501aad7f, 0x50242a5f, 0x502da787, 0x503724f7, 0x5040a2ae, 0x504a20ae,
7590x50539ef5, 0x505d1d84, 0x50669c5b, 0x50701b7a, 0x50799ae0, 0x50831a8e, 0x508c9a84, 0x50961ac2,
7600x509f9b47, 0x50a91c14, 0x50b29d29, 0x50bc1e85, 0x50c5a029, 0x50cf2215, 0x50d8a448, 0x50e226c2,
7610x50eba985, 0x50f52c8f, 0x50feafe0, 0x51083379, 0x5111b759, 0x511b3b81, 0x5124bff1, 0x512e44a7,
7620x5137c9a6, 0x51414eeb, 0x514ad478, 0x51545a4d, 0x515de069, 0x516766cc, 0x5170ed76, 0x517a7468,
7630x5183fba1, 0x518d8322, 0x51970ae9, 0x51a092f8, 0x51aa1b4e, 0x51b3a3ec, 0x51bd2cd0, 0x51c6b5fc,
7640x51d03f6f, 0x51d9c929, 0x51e3532b, 0x51ecdd73, 0x51f66802, 0x51fff2d9, 0x52097df7, 0x5213095b,
7650x521c9507, 0x522620fa, 0x522fad34, 0x523939b5, 0x5242c67c, 0x524c538b, 0x5255e0e1, 0x525f6e7e,
7660x5268fc61, 0x52728a8c, 0x527c18fd, 0x5285a7b5, 0x528f36b4, 0x5298c5fa, 0x52a25587, 0x52abe55a,
7670x52b57575, 0x52bf05d6, 0x52c8967d, 0x52d2276c, 0x52dbb8a1, 0x52e54a1d, 0x52eedbe0, 0x52f86de9,
7680x53020039, 0x530b92d0, 0x531525ad, 0x531eb8d1, 0x53284c3c, 0x5331dfed, 0x533b73e4, 0x53450823,
7690x534e9ca7, 0x53583173, 0x5361c684, 0x536b5bdc, 0x5374f17b, 0x537e8760, 0x53881d8c, 0x5391b3fe,
7700x539b4ab6, 0x53a4e1b5, 0x53ae78fa, 0x53b81086, 0x53c1a858, 0x53cb4070, 0x53d4d8ce, 0x53de7173,
7710x53e80a5e, 0x53f1a390, 0x53fb3d07, 0x5404d6c5, 0x540e70c9, 0x54180b13, 0x5421a5a4, 0x542b407a,
7720x5434db97, 0x543e76fa, 0x544812a3, 0x5451ae92, 0x545b4ac8, 0x5464e743, 0x546e8404, 0x5478210c,
7730x5481be59, 0x548b5bed, 0x5494f9c6, 0x549e97e5, 0x54a8364b, 0x54b1d4f6, 0x54bb73e8, 0x54c5131f,
7740x54ceb29c, 0x54d8525f, 0x54e1f268, 0x54eb92b6, 0x54f5334b, 0x54fed425, 0x55087546, 0x551216ac,
7750x551bb858, 0x55255a49, 0x552efc80, 0x55389efe, 0x554241c0, 0x554be4c9, 0x55558817, 0x555f2bab,
7760x5568cf84, 0x557273a3, 0x557c1808, 0x5585bcb3, 0x558f61a3, 0x559906d8, 0x55a2ac53, 0x55ac5214,
7770x55b5f81a, 0x55bf9e66, 0x55c944f7, 0x55d2ebce, 0x55dc92ea, 0x55e63a4c, 0x55efe1f3, 0x55f989e0,
7780x56033212, 0x560cda89, 0x56168346, 0x56202c48, 0x5629d58f, 0x56337f1c, 0x563d28ee, 0x5646d306,
7790x56507d62, 0x565a2804, 0x5663d2ec, 0x566d7e18, 0x5677298a, 0x5680d541, 0x568a813d, 0x56942d7e,
7800x569dda05, 0x56a786d1, 0x56b133e1, 0x56bae137, 0x56c48ed2, 0x56ce3cb3, 0x56d7ead8, 0x56e19942,
7810x56eb47f1, 0x56f4f6e6, 0x56fea61f, 0x5708559e, 0x57120561, 0x571bb569, 0x572565b7, 0x572f1649,
7820x5738c720, 0x5742783c, 0x574c299e, 0x5755db43, 0x575f8d2e, 0x57693f5e, 0x5772f1d2, 0x577ca48c,
7830x5786578a, 0x57900acd, 0x5799be54, 0x57a37221, 0x57ad2632, 0x57b6da88, 0x57c08f23, 0x57ca4402,
7840x57d3f926, 0x57ddae8f, 0x57e7643c, 0x57f11a2f, 0x57fad065, 0x580486e1, 0x580e3da1, 0x5817f4a5,
7850x5821abee, 0x582b637c, 0x58351b4e, 0x583ed365, 0x58488bc0, 0x58524460, 0x585bfd44, 0x5865b66d,
7860x586f6fda, 0x5879298b, 0x5882e381, 0x588c9dbc, 0x5896583b, 0x58a012fe, 0x58a9ce05, 0x58b38951,
7870x58bd44e2, 0x58c700b6, 0x58d0bccf, 0x58da792c, 0x58e435ce, 0x58edf2b4, 0x58f7afde, 0x59016d4c,
7880x590b2afe, 0x5914e8f5, 0x591ea730, 0x592865af, 0x59322472, 0x593be379, 0x5945a2c5, 0x594f6255,
7890x59592228, 0x5962e240, 0x596ca29c, 0x5976633c, 0x59802420, 0x5989e548, 0x5993a6b4, 0x599d6864,
7900x59a72a58, 0x59b0ec90, 0x59baaf0c, 0x59c471cc, 0x59ce34d0, 0x59d7f818, 0x59e1bba3, 0x59eb7f73,
7910x59f54386, 0x59ff07dd, 0x5a08cc79, 0x5a129158, 0x5a1c567a, 0x5a261be1, 0x5a2fe18b, 0x5a39a779,
7920x5a436dab, 0x5a4d3421, 0x5a56fada, 0x5a60c1d8, 0x5a6a8918, 0x5a74509d, 0x5a7e1865, 0x5a87e071,
7930x5a91a8c0, 0x5a9b7153, 0x5aa53a2a, 0x5aaf0344, 0x5ab8cca2, 0x5ac29644, 0x5acc6029, 0x5ad62a51,
7940x5adff4bd, 0x5ae9bf6d, 0x5af38a60, 0x5afd5597, 0x5b072111, 0x5b10ecce, 0x5b1ab8cf, 0x5b248514,
7950x5b2e519c, 0x5b381e67, 0x5b41eb76, 0x5b4bb8c8, 0x5b55865d, 0x5b5f5436, 0x5b692252, 0x5b72f0b1,
7960x5b7cbf54, 0x5b868e3a, 0x5b905d63, 0x5b9a2cd0, 0x5ba3fc7f, 0x5badcc72, 0x5bb79ca9, 0x5bc16d22,
7970x5bcb3ddf, 0x5bd50ede, 0x5bdee021, 0x5be8b1a7, 0x5bf28371, 0x5bfc557d, 0x5c0627cc, 0x5c0ffa5f,
7980x5c19cd35, 0x5c23a04d, 0x5c2d73a9, 0x5c374748, 0x5c411b2a, 0x5c4aef4e, 0x5c54c3b6, 0x5c5e9861,
7990x5c686d4f, 0x5c724280, 0x5c7c17f3, 0x5c85edaa, 0x5c8fc3a3, 0x5c9999e0, 0x5ca3705f, 0x5cad4721,
8000x5cb71e26, 0x5cc0f56e, 0x5ccaccf9, 0x5cd4a4c6, 0x5cde7cd7, 0x5ce8552a, 0x5cf22dbf, 0x5cfc0698,
8010x5d05dfb3, 0x5d0fb912, 0x5d1992b2, 0x5d236c96, 0x5d2d46bc, 0x5d372125, 0x5d40fbd1, 0x5d4ad6bf,
8020x5d54b1f0, 0x5d5e8d63, 0x5d686919, 0x5d724512, 0x5d7c214d, 0x5d85fdcb, 0x5d8fda8b, 0x5d99b78e,
8030x5da394d4, 0x5dad725c, 0x5db75026, 0x5dc12e33, 0x5dcb0c82, 0x5dd4eb14, 0x5ddec9e9, 0x5de8a8ff,
8040x5df28858, 0x5dfc67f4, 0x5e0647d2, 0x5e1027f2, 0x5e1a0855, 0x5e23e8fa, 0x5e2dc9e1, 0x5e37ab0b,
8050x5e418c77, 0x5e4b6e25, 0x5e555016, 0x5e5f3249, 0x5e6914be, 0x5e72f775, 0x5e7cda6f, 0x5e86bdab,
8060x5e90a129, 0x5e9a84e9, 0x5ea468eb, 0x5eae4d30, 0x5eb831b6, 0x5ec2167f, 0x5ecbfb8a, 0x5ed5e0d7,
8070x5edfc666, 0x5ee9ac37, 0x5ef3924a, 0x5efd78a0, 0x5f075f37, 0x5f114610, 0x5f1b2d2c, 0x5f251489,
8080x5f2efc28, 0x5f38e40a, 0x5f42cc2d, 0x5f4cb492, 0x5f569d39, 0x5f608622, 0x5f6a6f4d, 0x5f7458ba,
8090x5f7e4269, 0x5f882c5a, 0x5f92168c, 0x5f9c0100, 0x5fa5ebb6, 0x5fafd6ae, 0x5fb9c1e8, 0x5fc3ad64,
8100x5fcd9921, 0x5fd78520, 0x5fe17161, 0x5feb5de3, 0x5ff54aa7, 0x5fff37ad, 0x600924f5, 0x6013127e,
8110x601d0049, 0x6026ee56, 0x6030dca4, 0x603acb34, 0x6044ba05, 0x604ea918, 0x6058986d, 0x60628803,
8120x606c77db, 0x607667f4, 0x6080584f, 0x608a48ec, 0x609439ca, 0x609e2ae9, 0x60a81c4a, 0x60b20dec,
8130x60bbffd0, 0x60c5f1f5, 0x60cfe45c, 0x60d9d704, 0x60e3c9ed, 0x60edbd18, 0x60f7b084, 0x6101a432,
8140x610b9821, 0x61158c51, 0x611f80c3, 0x61297576, 0x61336a6a, 0x613d5f9f, 0x61475516, 0x61514ace,
8150x615b40c7, 0x61653702, 0x616f2d7e, 0x6179243a, 0x61831b38, 0x618d1278, 0x619709f8, 0x61a101ba,
8160x61aaf9bd, 0x61b4f200, 0x61beea85, 0x61c8e34b, 0x61d2dc53, 0x61dcd59b, 0x61e6cf24, 0x61f0c8ee,
8170x61fac2fa, 0x6204bd46, 0x620eb7d4, 0x6218b2a2, 0x6222adb1, 0x622ca902, 0x6236a493, 0x6240a065,
8180x624a9c78, 0x625498cd, 0x625e9562, 0x62689238, 0x62728f4e, 0x627c8ca6, 0x62868a3e, 0x62908818,
8190x629a8632, 0x62a4848d, 0x62ae8329, 0x62b88205, 0x62c28123, 0x62cc8081, 0x62d68020, 0x62e07fff,
8200x62ea8020, 0x62f48081, 0x62fe8123, 0x63088205, 0x63128328, 0x631c848c, 0x63268631, 0x63308816,
8210x633a8a3b, 0x63448ca2, 0x634e8f49, 0x63589230, 0x63629558, 0x636c98c1, 0x63769c6a, 0x6380a054,
8220x638aa47e, 0x6394a8e9, 0x639ead94, 0x63a8b280, 0x63b2b7ac, 0x63bcbd19, 0x63c6c2c6, 0x63d0c8b3,
8230x63dacee1, 0x63e4d550, 0x63eedbff, 0x63f8e2ee, 0x6402ea1d, 0x640cf18d, 0x6416f93e, 0x6421012e,
8240x642b095f, 0x643511d0, 0x643f1a82, 0x64492374, 0x64532ca6, 0x645d3618, 0x64673fcb, 0x647149bd,
8250x647b53f0, 0x64855e64, 0x648f6917, 0x6499740b, 0x64a37f3e, 0x64ad8ab2, 0x64b79666, 0x64c1a25b,
8260x64cbae8f, 0x64d5bb03, 0x64dfc7b8, 0x64e9d4ad, 0x64f3e1e1, 0x64fdef56, 0x6507fd0b, 0x65120b00,
8270x651c1934, 0x652627a9, 0x6530365e, 0x653a4553, 0x65445488, 0x654e63fd, 0x655873b1, 0x656283a6,
8280x656c93db, 0x6576a44f, 0x6580b503, 0x658ac5f8, 0x6594d72c, 0x659ee8a0, 0x65a8fa54, 0x65b30c47,
8290x65bd1e7b, 0x65c730ee, 0x65d143a1, 0x65db5694, 0x65e569c7, 0x65ef7d39, 0x65f990eb, 0x6603a4dd,
8300x660db90f, 0x6617cd80, 0x6621e231, 0x662bf722, 0x66360c52, 0x664021c2, 0x664a3772, 0x66544d62,
8310x665e6390, 0x666879ff, 0x667290ad, 0x667ca79b, 0x6686bec8, 0x6690d635, 0x669aede2, 0x66a505ce,
8320x66af1df9, 0x66b93664, 0x66c34f0f, 0x66cd67f9, 0x66d78123, 0x66e19a8c, 0x66ebb434, 0x66f5ce1c,
8330x66ffe843, 0x670a02aa, 0x67141d50, 0x671e3836, 0x6728535b, 0x67326ebf, 0x673c8a63, 0x6746a646,
8340x6750c268, 0x675adeca, 0x6764fb6b, 0x676f184b, 0x6779356a, 0x678352c9, 0x678d7067, 0x67978e45,
8350x67a1ac61, 0x67abcabd, 0x67b5e958, 0x67c00832, 0x67ca274c, 0x67d446a4, 0x67de663c, 0x67e88613,
8360x67f2a629, 0x67fcc67e, 0x6806e712, 0x681107e6, 0x681b28f8, 0x68254a4a, 0x682f6bda, 0x68398daa,
8370x6843afb9, 0x684dd206, 0x6857f493, 0x6862175f, 0x686c3a6a, 0x68765db3, 0x6880813c, 0x688aa504,
8380x6894c90a, 0x689eed50, 0x68a911d5, 0x68b33698, 0x68bd5b9a, 0x68c780dc, 0x68d1a65c, 0x68dbcc1b,
8390x68e5f218, 0x68f01855, 0x68fa3ed0, 0x6904658b, 0x690e8c84, 0x6918b3bc, 0x6922db32, 0x692d02e8,
8400x69372adc, 0x6941530f, 0x694b7b81, 0x6955a431, 0x695fcd20, 0x6969f64e, 0x69741fbb, 0x697e4966,
8410x69887350, 0x69929d78, 0x699cc7df, 0x69a6f285, 0x69b11d69, 0x69bb488c, 0x69c573ee, 0x69cf9f8e,
8420x69d9cb6d, 0x69e3f78a, 0x69ee23e6, 0x69f85080, 0x6a027d59, 0x6a0caa71, 0x6a16d7c7, 0x6a21055b,
8430x6a2b332e, 0x6a35613f, 0x6a3f8f8f, 0x6a49be1d, 0x6a53ecea, 0x6a5e1bf5, 0x6a684b3f, 0x6a727ac7,
8440x6a7caa8d, 0x6a86da91, 0x6a910ad4, 0x6a9b3b56, 0x6aa56c15, 0x6aaf9d13, 0x6ab9ce50, 0x6ac3ffca,
8450x6ace3183, 0x6ad8637b, 0x6ae295b0, 0x6aecc824, 0x6af6fad6, 0x6b012dc6, 0x6b0b60f4, 0x6b159461,
8460x6b1fc80c, 0x6b29fbf5, 0x6b34301c, 0x6b3e6481, 0x6b489925, 0x6b52ce06, 0x6b5d0326, 0x6b673884,
8470x6b716e20, 0x6b7ba3fa, 0x6b85da12, 0x6b901068, 0x6b9a46fd, 0x6ba47dcf, 0x6baeb4df, 0x6bb8ec2e,
8480x6bc323ba, 0x6bcd5b85, 0x6bd7938d, 0x6be1cbd3, 0x6bec0458, 0x6bf63d1a, 0x6c00761a, 0x6c0aaf58,
8490x6c14e8d4, 0x6c1f228e, 0x6c295c86, 0x6c3396bc, 0x6c3dd130, 0x6c480be1, 0x6c5246d1, 0x6c5c81fe,
8500x6c66bd69, 0x6c70f912, 0x6c7b34f8, 0x6c85711d, 0x6c8fad7f, 0x6c99ea1f, 0x6ca426fd, 0x6cae6418,
8510x6cb8a172, 0x6cc2df09, 0x6ccd1cdd, 0x6cd75af0, 0x6ce19940, 0x6cebd7ce, 0x6cf61699, 0x6d0055a2,
8520x6d0a94e9, 0x6d14d46d, 0x6d1f142f, 0x6d29542f, 0x6d33946c, 0x6d3dd4e7, 0x6d4815a0, 0x6d525695,
8530x6d5c97c9, 0x6d66d93a, 0x6d711ae9, 0x6d7b5cd5, 0x6d859eff, 0x6d8fe166, 0x6d9a240a, 0x6da466ec,
8540x6daeaa0c, 0x6db8ed69, 0x6dc33104, 0x6dcd74db, 0x6dd7b8f1, 0x6de1fd44, 0x6dec41d4, 0x6df686a1,
8550x6e00cbac, 0x6e0b10f5, 0x6e15567a, 0x6e1f9c3d, 0x6e29e23d, 0x6e34287b, 0x6e3e6ef6, 0x6e48b5ae,
8560x6e52fca4, 0x6e5d43d7, 0x6e678b47, 0x6e71d2f4, 0x6e7c1adf, 0x6e866307, 0x6e90ab6c, 0x6e9af40e,
8570x6ea53ced, 0x6eaf860a, 0x6eb9cf64, 0x6ec418fb, 0x6ece62cf, 0x6ed8ace0, 0x6ee2f72e, 0x6eed41ba,
8580x6ef78c83, 0x6f01d788, 0x6f0c22cb, 0x6f166e4b, 0x6f20ba08, 0x6f2b0602, 0x6f355239, 0x6f3f9ead,
8590x6f49eb5e, 0x6f54384d, 0x6f5e8578, 0x6f68d2e0, 0x6f732085, 0x6f7d6e67, 0x6f87bc86, 0x6f920ae2,
8600x6f9c597b, 0x6fa6a851, 0x6fb0f763, 0x6fbb46b3, 0x6fc59640, 0x6fcfe609, 0x6fda360f, 0x6fe48652,
8610x6feed6d2, 0x6ff9278f, 0x70037889, 0x700dc9bf, 0x70181b32, 0x70226ce3, 0x702cbecf, 0x703710f9,
8620x7041635f, 0x704bb602, 0x705608e2, 0x70605bff, 0x706aaf58, 0x707502ee, 0x707f56c1, 0x7089aad0,
8630x7093ff1c, 0x709e53a5, 0x70a8a86a, 0x70b2fd6c, 0x70bd52ab, 0x70c7a826, 0x70d1fdde, 0x70dc53d2,
8640x70e6aa03, 0x70f10071, 0x70fb571b, 0x7105ae02, 0x71100525, 0x711a5c85, 0x7124b421, 0x712f0bfa,
8650x7139640f, 0x7143bc61, 0x714e14ef, 0x71586dba, 0x7162c6c1, 0x716d2004, 0x71777984, 0x7181d341,
8660x718c2d3a, 0x7196876f, 0x71a0e1e1, 0x71ab3c8f, 0x71b59779, 0x71bff2a0, 0x71ca4e03, 0x71d4a9a3,
8670x71df057e, 0x71e96197, 0x71f3bdeb, 0x71fe1a7c, 0x72087749, 0x7212d452, 0x721d3197, 0x72278f19,
8680x7231ecd7, 0x723c4ad1, 0x7246a908, 0x7251077b, 0x725b6629, 0x7265c514, 0x7270243c, 0x727a839f,
8690x7284e33f, 0x728f431a, 0x7299a332, 0x72a40386, 0x72ae6416, 0x72b8c4e2, 0x72c325eb, 0x72cd872f,
8700x72d7e8af, 0x72e24a6c, 0x72ecac64, 0x72f70e99, 0x73017109, 0x730bd3b6, 0x7316369f, 0x732099c3,
8710x732afd24, 0x733560c0, 0x733fc499, 0x734a28ad, 0x73548cfe, 0x735ef18a, 0x73695652, 0x7373bb57,
8720x737e2097, 0x73888613, 0x7392ebca, 0x739d51be, 0x73a7b7ee, 0x73b21e59, 0x73bc8500, 0x73c6ebe4,
8730x73d15302, 0x73dbba5d, 0x73e621f4, 0x73f089c6, 0x73faf1d4, 0x74055a1e, 0x740fc2a3, 0x741a2b65,
8740x74249462, 0x742efd9b, 0x7439670f, 0x7443d0bf, 0x744e3aab, 0x7458a4d3, 0x74630f36, 0x746d79d5,
8750x7477e4af, 0x74824fc6, 0x748cbb17, 0x749726a5, 0x74a1926e, 0x74abfe73, 0x74b66ab3, 0x74c0d72f,
8760x74cb43e6, 0x74d5b0d9, 0x74e01e07, 0x74ea8b71, 0x74f4f917, 0x74ff66f8, 0x7509d514, 0x7514436c,
8770x751eb200, 0x752920cf, 0x75338fd9, 0x753dff1f, 0x75486ea1, 0x7552de5d, 0x755d4e56, 0x7567be89,
8780x75722ef8, 0x757c9fa3, 0x75871089, 0x759181aa, 0x759bf306, 0x75a6649e, 0x75b0d671, 0x75bb4880,
8790x75c5baca, 0x75d02d4f, 0x75daa00f, 0x75e5130b, 0x75ef8642, 0x75f9f9b4, 0x76046d62, 0x760ee14b,
8800x7619556f, 0x7623c9ce, 0x762e3e68, 0x7638b33e, 0x7643284f, 0x764d9d9b, 0x76581322, 0x766288e4,
8810x766cfee2, 0x7677751b, 0x7681eb8e, 0x768c623d, 0x7696d927, 0x76a1504d, 0x76abc7ad, 0x76b63f48,
8820x76c0b71f, 0x76cb2f30, 0x76d5a77d, 0x76e02004, 0x76ea98c7, 0x76f511c4, 0x76ff8afd, 0x770a0471,
8830x77147e1f, 0x771ef809, 0x7729722d, 0x7733ec8d, 0x773e6727, 0x7748e1fd, 0x77535d0d, 0x775dd858,
8840x776853df, 0x7772cfa0, 0x777d4b9c, 0x7787c7d2, 0x77924444, 0x779cc0f1, 0x77a73dd8, 0x77b1bafa,
8850x77bc3858, 0x77c6b5ef, 0x77d133c2, 0x77dbb1d0, 0x77e63018, 0x77f0ae9b, 0x77fb2d59, 0x7805ac52,
8860x78102b85, 0x781aaaf3, 0x78252a9c, 0x782faa80, 0x783a2a9e, 0x7844aaf7, 0x784f2b8a, 0x7859ac59,
8870x78642d62, 0x786eaea5, 0x78793024, 0x7883b1dd, 0x788e33d0, 0x7898b5fe, 0x78a33867, 0x78adbb0b,
8880x78b83de9, 0x78c2c101, 0x78cd4454, 0x78d7c7e2, 0x78e24baa, 0x78eccfad, 0x78f753ea, 0x7901d862,
8890x790c5d15, 0x7916e202, 0x79216729, 0x792bec8b, 0x79367227, 0x7940f7fe, 0x794b7e0f, 0x7956045b,
8900x79608ae1, 0x796b11a1, 0x7975989c, 0x79801fd1, 0x798aa741, 0x79952eeb, 0x799fb6d0, 0x79aa3eee,
8910x79b4c748, 0x79bf4fdb, 0x79c9d8a9, 0x79d461b1, 0x79deeaf4, 0x79e97470, 0x79f3fe27, 0x79fe8819,
8920x7a091244, 0x7a139caa, 0x7a1e274a, 0x7a28b225, 0x7a333d39, 0x7a3dc888, 0x7a485411, 0x7a52dfd4,
8930x7a5d6bd2, 0x7a67f809, 0x7a72847b, 0x7a7d1127, 0x7a879e0d, 0x7a922b2e, 0x7a9cb888, 0x7aa7461d,
8940x7ab1d3eb, 0x7abc61f4, 0x7ac6f037, 0x7ad17eb4, 0x7adc0d6b, 0x7ae69c5c, 0x7af12b87, 0x7afbbaec,
8950x7b064a8b, 0x7b10da64, 0x7b1b6a78, 0x7b25fac5, 0x7b308b4c, 0x7b3b1c0e, 0x7b45ad09, 0x7b503e3e,
8960x7b5acfad, 0x7b656156, 0x7b6ff339, 0x7b7a8556, 0x7b8517ad, 0x7b8faa3e, 0x7b9a3d09, 0x7ba4d00d,
8970x7baf634c, 0x7bb9f6c4, 0x7bc48a76, 0x7bcf1e62, 0x7bd9b288, 0x7be446e8, 0x7beedb82, 0x7bf97055,
8980x7c040562, 0x7c0e9aa9, 0x7c19302a, 0x7c23c5e5, 0x7c2e5bd9, 0x7c38f207, 0x7c43886f, 0x7c4e1f10,
8990x7c58b5ec, 0x7c634d01, 0x7c6de450, 0x7c787bd8, 0x7c83139a, 0x7c8dab96, 0x7c9843cb, 0x7ca2dc3a,
9000x7cad74e3, 0x7cb80dc6, 0x7cc2a6e2, 0x7ccd4037, 0x7cd7d9c7, 0x7ce27390, 0x7ced0d92, 0x7cf7a7ce,
9010x7d024244, 0x7d0cdcf3, 0x7d1777dc, 0x7d2212fe, 0x7d2cae5a, 0x7d3749ef, 0x7d41e5be, 0x7d4c81c7,
9020x7d571e08, 0x7d61ba84, 0x7d6c5739, 0x7d76f427, 0x7d81914f, 0x7d8c2eb0, 0x7d96cc4b, 0x7da16a1f,
9030x7dac082d, 0x7db6a673, 0x7dc144f4, 0x7dcbe3ae, 0x7dd682a1, 0x7de121cd, 0x7debc133, 0x7df660d2,
9040x7e0100ab, 0x7e0ba0bd, 0x7e164108, 0x7e20e18d, 0x7e2b824b, 0x7e362342, 0x7e40c472, 0x7e4b65dc,
9050x7e56077f, 0x7e60a95b, 0x7e6b4b71, 0x7e75edc0, 0x7e809048, 0x7e8b3309, 0x7e95d603, 0x7ea07937,
9060x7eab1ca4, 0x7eb5c04a, 0x7ec06429, 0x7ecb0842, 0x7ed5ac93, 0x7ee0511e, 0x7eeaf5e2, 0x7ef59adf,
9070x7f004015, 0x7f0ae584, 0x7f158b2c, 0x7f20310e, 0x7f2ad728, 0x7f357d7c, 0x7f402409, 0x7f4acace,
9080x7f5571cd, 0x7f601905, 0x7f6ac076, 0x7f75681f, 0x7f801002, 0x7f8ab81e, 0x7f956073, 0x7fa00901,
9090x7faab1c7, 0x7fb55ac7, 0x7fc00400, 0x7fcaad71, 0x7fd5571c, 0x7fe00100, 0x7feaab1c, 0x7ff55571,
9100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9240x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9250x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9260x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9270x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9280x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9290x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9300x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9310x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9320x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9330x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9340x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9350x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9360x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9370x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9380x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9390x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9400x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9410x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9420x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9430x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9440x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9450x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9460x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9470x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9480x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9490x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9500x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9510x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9520x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9530x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9540x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9550x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9560x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9570x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9580x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9590x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9600x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9610x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9620x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9630x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9640x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9650x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9660x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9670x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9680x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9690x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9700x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9710x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9720x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9730x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9740x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9750x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9760x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9770x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9780x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9790x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9800x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9810x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9820x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9830x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9840x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9850x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9860x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9870x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9880x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9890x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9900x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9910x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9920x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9930x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9940x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9950x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9960x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9970x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9980x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
9990x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10000x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10010x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10020x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10030x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10040x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10050x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10060x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10070x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10080x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10090x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10240x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10250x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10260x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10270x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10280x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10290x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10300x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10310x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10320x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10330x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10340x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10350x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10360x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10370x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10380x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10390x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10400x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10410x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10420x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10430x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10440x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10450x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10460x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10470x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10480x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10490x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10500x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10510x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10520x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10530x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10540x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10550x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10560x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10570x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10580x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10590x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10600x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10610x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10620x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10630x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10640x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10650x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10660x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10670x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10680x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10690x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10700x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10710x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10720x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10730x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10740x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10750x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10760x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10770x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10780x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10790x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10800x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10810x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10820x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10830x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10840x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10850x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10860x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10870x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10880x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10890x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10900x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10910x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10920x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10930x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10940x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10950x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10960x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10970x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10980x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
10990x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11000x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11010x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11020x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11030x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11040x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11050x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11060x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11070x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11080x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11090x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11240x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11250x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11260x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11270x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11280x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11290x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11300x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11310x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11320x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11330x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11340x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11350x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11360x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11370x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11380x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11390x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11400x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11410x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11420x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11430x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11440x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11450x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11460x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11470x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11480x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11490x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11500x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11510x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11520x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11530x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11540x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11550x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11560x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11570x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11580x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11590x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11600x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11610x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11620x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11630x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11640x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11650x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11660x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11670x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11680x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11690x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11700x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11710x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11720x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11730x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11740x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11750x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11760x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11770x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11780x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11790x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11800x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11810x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11820x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11830x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11840x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11850x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11860x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11870x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11880x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11890x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11900x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11910x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11920x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11930x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11940x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11950x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11960x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11970x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11980x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
11990x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12000x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12010x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12020x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12030x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12040x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12050x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12060x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12070x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12080x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12090x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12240x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12250x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12260x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12270x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12280x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12290x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12300x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12310x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12320x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12330x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12340x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12350x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12360x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12370x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12380x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12390x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12400x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12410x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12420x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12430x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12440x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12450x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12460x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12470x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12480x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12490x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12500x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12510x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12520x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12530x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12540x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12550x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12560x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12570x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12580x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12590x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12600x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12610x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12620x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12630x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12640x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12650x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12660x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12670x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12680x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12690x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12700x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12710x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12720x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12730x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12740x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12750x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12760x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12770x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12780x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12790x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12800x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12810x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12820x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12830x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12840x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12850x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12860x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12870x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12880x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12890x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12900x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12910x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12920x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12930x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12940x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12950x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12960x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12970x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12980x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
12990x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13000x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13010x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13020x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13030x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13040x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13050x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13060x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13070x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13080x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13090x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13240x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13250x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13260x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13270x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13280x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13290x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13300x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13310x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13320x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13330x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13340x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13350x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13360x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13370x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13380x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13390x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13400x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13410x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13420x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13430x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13440x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13450x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13460x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13470x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13480x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13490x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13500x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13510x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13520x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13530x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13540x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13550x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13560x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13570x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13580x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13590x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13600x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13610x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13620x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13630x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13640x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13650x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13660x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13670x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13680x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13690x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13700x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13710x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13720x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13730x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13740x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13750x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13760x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13770x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13780x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13790x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13800x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13810x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13820x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13830x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13840x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13850x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13860x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13870x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13880x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13890x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13900x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13910x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13920x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13930x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13940x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13950x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13960x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13970x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13980x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
13990x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14000x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14010x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14020x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14030x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14040x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14050x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14060x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14070x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14080x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14090x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14100x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14110x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14120x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14130x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14140x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14150x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14160x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14170x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14180x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14190x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14200x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14210x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14220x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,
14230x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff,};
1424#endif
1425#ifdef USE_DATA_TABLES
1426static long mpeg3_aa_cs_data[] = {
14270x00006dc2, 0x000070dc, 0x0000798d, 0x00007ddd, 0x00007f6d, 0x00007fe4, 0x00007ffc, 0x00007fff,};
1428#endif
1429#ifdef USE_DATA_TABLES
1430static long mpeg3_aa_ca_data[] = {
14310xffffbe26, 0xffffc39f, 0xffffd7e4, 0xffffe8b8, 0xfffff3e5, 0xfffffac2, 0xfffffe2f, 0xffffff87,};
1432#endif
1433#ifdef USE_DATA_TABLES
1434static long mpeg3_win_data[] = {
14350x00000421, 0x00000db8, 0x000019c7, 0x000029ad, 0x00003fff, 0x00006246, 0x00009ee0, 0x00012a7d,
14360x0003df40, 0xfffbc63e, 0xfffe7b01, 0xffff069e, 0xffff4338, 0xffff657e, 0xffff7bd0, 0xffff8bb6,
14370xffff97c5, 0xffffa15c, 0xffffa947, 0xffffb006, 0xffffb5eb, 0xffffbb30, 0xffffc000, 0xffffc47a,
14380xffffc8b7, 0xffffccca, 0xffffd0c5, 0xffffd4b9, 0xffffd8b4, 0xffffdcc8, 0xffffe104, 0xffffe57e,
14390xffffea4e, 0xffffef94, 0xfffff579, 0xfffffc37, 0x00000421, 0x00000db8, 0x000019c7, 0x000029ad,
14400x00003fff, 0x00006246, 0x00009ee0, 0x00012a7d, 0x0003df40, 0xfffbc63e, 0xfffe7b01, 0xffff069e,
14410xffff4338, 0xffff657e, 0xffff7bd0, 0xffff8bb6, 0xffff97c5, 0xffffa15c, 0xffffa932, 0xffffaf55,
14420xffffb41e, 0xffffb7d9, 0xffffbabb, 0xffffbce5, 0xffffbf02, 0xffffc45d, 0xffffcd2e, 0xffffd901,
14430xffffe74d, 0xfffff772, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14440x00000db8, 0x00003fff, 0x00012a7d, 0xfffe7b01, 0xffff657e, 0xffff97c5, 0xffffb006, 0xffffc000,
14450xffffccca, 0xffffd8b4, 0xffffe57e, 0xfffff579, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14460x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14470x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14480x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14490x00000000, 0x00000000, 0x00002698, 0x0000bba3, 0x00037d32, 0xfffb73f7, 0xfffe3b01, 0xfffedad6,
14500xffff2b2b, 0xffff58c3, 0xffff7566, 0xffff88e3, 0xffff96df, 0xffffa145, 0xffffa947, 0xffffb006,
14510xffffb5eb, 0xffffbb30, 0xffffc000, 0xffffc47a, 0xffffc8b7, 0xffffccca, 0xffffd0c5, 0xffffd4b9,
14520xffffd8b4, 0xffffdcc8, 0xffffe104, 0xffffe57e, 0xffffea4e, 0xffffef94, 0xfffff579, 0xfffffc37,};
1453#endif
1454#ifdef USE_DATA_TABLES
1455static long mpeg3_COS9_data[] = {
14560x00008000, 0x00007e0e, 0x00007847, 0x00006ed9, 0x0000620d, 0x00005246, 0x00004000, 0x00002bc7,
14570x0000163a,};
1458#endif
1459#ifdef USE_DATA_TABLES
1460static long mpeg3_tfcos36_data[] = {
14610x0000403e, 0x00004241, 0x0000469d, 0x00004e21, 0x00005a82, 0x00006f94, 0x0000976f, 0x0000f746,
14620x0002de51,};
1463#endif
1464#ifdef USE_DATA_TABLES
1465static long mpeg3_tfcos12_data[] = {
14660x00004241, 0x00005a82, 0x0000f746,};
1467#endif
1468#ifdef USE_DATA_TABLES
1469static long mpeg3_cos9_data[] = {
14700x00007847, 0xffffe9c6, 0xffff9df3,};
1471#endif
1472#ifdef USE_DATA_TABLES
1473static long mpeg3_cos18_data[] = {
14740x00007e0e, 0xffffd439, 0xffffadba,};
1475#endif
1476#ifdef USE_DATA_TABLES
1477static long mpeg3_COS1_data[] = {
14780x00004deb, 0xffff89bf, 0xffffef4b, 0x00007ee7, 0xffffcf05, 0xffff9a74, 0x000030fb, 0xffff89bf,
14790x00007641, 0xffffcf05, 0xffffcf05, 0x00007641, 0x000010b5, 0xffffcf05, 0x00004deb, 0xffff9a74,
14800x00007641, 0xffff8119, 0xffffef4b, 0x000030fb, 0xffffb215, 0x0000658c, 0xffff89bf, 0x00007ee7,
14810xffffcf05, 0x00007641, 0xffff89bf, 0x000030fb, 0x000030fb, 0xffff89bf, 0xffffb215, 0x00007641,
14820x000010b5, 0xffff8119, 0x000030fb, 0x0000658c, 0xffff9a74, 0x000030fb, 0x00007ee7, 0x000010b5,
14830xffff89bf, 0xffffb215, 0xffff89bf, 0xffffcf05, 0x000030fb, 0x00007641, 0x00007641, 0x000030fb,
14840xffff8119, 0xffff89bf, 0xffff9a74, 0xffffb215, 0xffffcf05, 0xffffef4b, 0xffff8119, 0xffff89bf,
14850xffff9a74, 0xffffb215, 0xffffcf05, 0xffffef4b, 0xffff89bf, 0xffffcf05, 0x000030fb, 0x00007641,
14860x00007641, 0x000030fb, 0xffff9a74, 0x000030fb, 0x00007ee7, 0x000010b5, 0xffff89bf, 0xffffb215,};
1487#endif
1488#ifdef USE_DATA_TABLES
1489static long mpeg3_win1_data[] = {
14900x00000421, 0xfffff248, 0x000019c7, 0xffffd653, 0x00003fff, 0xffff9dba, 0x00009ee0, 0xfffed583,
14910x0003df40, 0x000439c2, 0xfffe7b01, 0x0000f962, 0xffff4338, 0x00009a82, 0xffff7bd0, 0x0000744a,
14920xffff97c5, 0x00005ea4, 0xffffa947, 0x00004ffa, 0xffffb5eb, 0x000044d0, 0xffffc000, 0x00003b86,
14930xffffc8b7, 0x00003336, 0xffffd0c5, 0x00002b47, 0xffffd8b4, 0x00002338, 0xffffe104, 0x00001a82,
14940xffffea4e, 0x0000106c, 0xfffff579, 0x000003c9, 0x00000421, 0xfffff248, 0x000019c7, 0xffffd653,
14950x00003fff, 0xffff9dba, 0x00009ee0, 0xfffed583, 0x0003df40, 0x000439c2, 0xfffe7b01, 0x0000f962,
14960xffff4338, 0x00009a82, 0xffff7bd0, 0x0000744a, 0xffff97c5, 0x00005ea4, 0xffffa932, 0x000050ab,
14970xffffb41e, 0x00004827, 0xffffbabb, 0x0000431b, 0xffffbf02, 0x00003ba3, 0xffffcd2e, 0x000026ff,
14980xffffe74d, 0x0000088e, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
14990x00000db8, 0xffffc001, 0x00012a7d, 0x000184ff, 0xffff657e, 0x0000683b, 0xffffb006, 0x00004000,
15000xffffccca, 0x0000274c, 0xffffe57e, 0x00000a87, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
15010x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
15020x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
15030x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
15040x00000000, 0x00000000, 0x00002698, 0xffff445d, 0x00037d32, 0x00048c09, 0xfffe3b01, 0x0001252a,
15050xffff2b2b, 0x0000a73d, 0xffff7566, 0x0000771d, 0xffff96df, 0x00005ebb, 0xffffa947, 0x00004ffa,
15060xffffb5eb, 0x000044d0, 0xffffc000, 0x00003b86, 0xffffc8b7, 0x00003336, 0xffffd0c5, 0x00002b47,
15070xffffd8b4, 0x00002338, 0xffffe104, 0x00001a82, 0xffffea4e, 0x0000106c, 0xfffff579, 0x000003c9,};
1508#endif
1509#ifdef USE_DATA_TABLES
1510static long mpeg3_tan1_1_data[] = {
15110x00000000, 0x00001b0c, 0x00002ed9, 0x00003fff, 0x00005126, 0x000064f3, 0x00007fff, 0x0000aed9,
15120x00012ed9, 0x7fffffff, 0xffff5127, 0xffffd127, 0x00000000, 0x00001b0c, 0x00002ed9, 0x00003fff,};
1513#endif
1514#ifdef USE_DATA_TABLES
1515static long mpeg3_tan2_1_data[] = {
15160x00008000, 0x000064f3, 0x00005126, 0x00004000, 0x00002ed9, 0x00001b0c, 0x00000000, 0xffffd127,
15170xffff5127, 0x80000000, 0x00012ed9, 0x0000aed9, 0x00008000, 0x000064f3, 0x00005126, 0x00004000,};
1518#endif
1519#ifdef USE_DATA_TABLES
1520static long mpeg3_tan1_2_data[] = {
15210x00000000, 0x00002640, 0x00004241, 0x00005a82, 0x000072c2, 0x00008ec3, 0x0000b504, 0x0000f746,
15220x0001ac4b, 0x7fffffff, 0xffff08ba, 0xffffbdbf, 0x00000000, 0x00002640, 0x00004241, 0x00005a82,};
1523#endif
1524#ifdef USE_DATA_TABLES
1525static long mpeg3_tan2_2_data[] = {
15260x0000b504, 0x00008ec3, 0x000072c2, 0x00005a82, 0x00004241, 0x00002640, 0x00000000, 0xffffbdbf,
15270xffff08ba, 0x80000000, 0x0001ac4b, 0x0000f746, 0x0000b504, 0x00008ec3, 0x000072c2, 0x00005a82,};
1528#endif
1529#ifdef USE_DATA_TABLES
1530static long mpeg3_pow1_1_data[] = {
15310x00008000, 0x00006ba2, 0x00008000, 0x00005a82, 0x00008000, 0x00004c1b, 0x00008000, 0x00004000,
15320x00008000, 0x000035d1, 0x00008000, 0x00002d41, 0x00008000, 0x0000260d, 0x00008000, 0x00002000,
15330x00008000, 0x00005a82, 0x00008000, 0x00003fff, 0x00008000, 0x00002d41, 0x00008000, 0x00001fff,
15340x00008000, 0x000016a0, 0x00008000, 0x00000fff, 0x00008000, 0x00000b50, 0x00008000, 0x000007ff,};
1535#endif
1536#ifdef USE_DATA_TABLES
1537static long mpeg3_pow2_1_data[] = {
15380x00008000, 0x00008000, 0x00006ba2, 0x00008000, 0x00005a82, 0x00008000, 0x00004c1b, 0x00008000,
15390x00004000, 0x00008000, 0x000035d1, 0x00008000, 0x00002d41, 0x00008000, 0x0000260d, 0x00008000,
15400x00008000, 0x00008000, 0x00005a82, 0x00008000, 0x00003fff, 0x00008000, 0x00002d41, 0x00008000,
15410x00001fff, 0x00008000, 0x000016a0, 0x00008000, 0x00000fff, 0x00008000, 0x00000b50, 0x00008000,};
1542#endif
1543#ifdef USE_DATA_TABLES
1544static long mpeg3_pow1_2_data[] = {
15450x0000b504, 0x00009837, 0x0000b504, 0x00008000, 0x0000b504, 0x00006ba2, 0x0000b504, 0x00005a82,
15460x0000b504, 0x00004c1b, 0x0000b504, 0x00004000, 0x0000b504, 0x000035d1, 0x0000b504, 0x00002d41,
15470x0000b504, 0x00008000, 0x0000b504, 0x00005a82, 0x0000b504, 0x00003fff, 0x0000b504, 0x00002d41,
15480x0000b504, 0x00001fff, 0x0000b504, 0x000016a0, 0x0000b504, 0x00000fff, 0x0000b504, 0x00000b50,};
1549#endif
1550#ifdef USE_DATA_TABLES
1551static long mpeg3_pow2_2_data[] = {
15520x0000b504, 0x0000b504, 0x00009837, 0x0000b504, 0x00008000, 0x0000b504, 0x00006ba2, 0x0000b504,
15530x00005a82, 0x0000b504, 0x00004c1b, 0x0000b504, 0x00004000, 0x0000b504, 0x000035d1, 0x0000b504,
15540x0000b504, 0x0000b504, 0x00008000, 0x0000b504, 0x00005a82, 0x0000b504, 0x00003fff, 0x0000b504,
15550x00002d41, 0x0000b504, 0x00001fff, 0x0000b504, 0x000016a0, 0x0000b504, 0x00000fff, 0x0000b504,};
1556#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/header.c b/core/multimedia/opieplayer/libmpeg3/audio/header.c
new file mode 100644
index 0000000..02b5e7c
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/header.c
@@ -0,0 +1,163 @@
1#include "mpeg3audio.h"
2#include "tables.h"
3#include "../libmpeg3.h"
4#include "../mpeg3protos.h"
5
6#include <stdio.h>
7
8/* Return 1 if the head check doesn't find a header. */
9int mpeg3audio_head_check(unsigned long head)
10{
11 if((head & 0xffe00000) != 0xffe00000) return 1;
12 if(!((head >> 17) & 3)) return 1;
13 if(((head >> 12) & 0xf) == 0xf) return 1;
14 if(!((head >> 12) & 0xf)) return 1;
15 if(((head >> 10) & 0x3) == 0x3 ) return 1;
16 if(((head >> 19) & 1) == 1 && ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1)
17 return 1;
18 if((head & 0xffff0000) == 0xfffe0000) return 1;
19
20 return 0;
21}
22
23int mpeg3audio_decode_header(mpeg3audio_t *audio)
24{
25 if(audio->newhead & (1 << 20))
26 {
27 audio->lsf = (audio->newhead & (1 << 19)) ? 0x0 : 0x1;
28 audio->mpeg35 = 0;
29 }
30 else
31 {
32 audio->lsf = 1;
33 audio->mpeg35 = 1;
34 }
35
36 audio->layer = 4 - ((audio->newhead >> 17) & 3);
37 if(audio->mpeg35)
38 audio->sampling_frequency_code = 6 + ((audio->newhead >> 10) & 0x3);
39 else
40 audio->sampling_frequency_code = ((audio->newhead >> 10) & 0x3) + (audio->lsf * 3);
41
42 audio->error_protection = ((audio->newhead >> 16) & 0x1) ^ 0x1;
43
44 audio->bitrate_index = ((audio->newhead >> 12) & 0xf);
45 audio->padding = ((audio->newhead >> 9) & 0x1);
46 audio->extension = ((audio->newhead >> 8) & 0x1);
47 audio->mode = ((audio->newhead >> 6) & 0x3);
48 audio->mode_ext = ((audio->newhead >> 4) & 0x3);
49 audio->copyright = ((audio->newhead >> 3) & 0x1);
50 audio->original = ((audio->newhead >> 2) & 0x1);
51 audio->emphasis = audio->newhead & 0x3;
52 audio->channels = (audio->mode == MPG_MD_MONO) ? 1 : 2;
53 if(audio->channels > 1)
54 audio->single = -1;
55 else
56 audio->single = 3;
57
58 audio->prev_framesize = audio->framesize;
59
60 if(!audio->bitrate_index) return 1;
61 audio->bitrate = 1000 * mpeg3_tabsel_123[audio->lsf][audio->layer - 1][audio->bitrate_index];
62
63 switch(audio->layer)
64 {
65 case 1:
66 audio->framesize = (long)mpeg3_tabsel_123[audio->lsf][0][audio->bitrate_index] * 12000;
67 audio->framesize /= mpeg3_freqs[audio->sampling_frequency_code];
68 audio->framesize = ((audio->framesize + audio->padding) << 2) - 4;
69 break;
70 case 2:
71 audio->framesize = (long)mpeg3_tabsel_123[audio->lsf][1][audio->bitrate_index] * 144000;
72 audio->framesize /= mpeg3_freqs[audio->sampling_frequency_code];
73 audio->framesize += audio->padding - 4;
74 break;
75 case 3:
76 if(audio->lsf)
77 audio->ssize = (audio->channels == 1) ? 9 : 17;
78 else
79 audio->ssize = (audio->channels == 1) ? 17 : 32;
80 if(audio->error_protection)
81 audio->ssize += 2;
82 audio->framesize = (long)mpeg3_tabsel_123[audio->lsf][2][audio->bitrate_index] * 144000;
83 audio->framesize /= mpeg3_freqs[audio->sampling_frequency_code] << (audio->lsf);
84 audio->framesize = audio->framesize + audio->padding - 4;
85 break;
86 default:
87 return 1;
88 }
89
90 if(audio->framesize > MAXFRAMESIZE) return 1;
91
92 return 0;
93}
94
95int mpeg3audio_read_frame_body(mpeg3audio_t *audio)
96{
97 int i;
98 for(i = 0; i < audio->framesize; i++)
99 {
100 audio->bsbuf[i] = mpeg3bits_getbits(audio->astream, 8);
101 }
102 return 0;
103}
104
105/* Seek to the start of the previous header */
106int mpeg3audio_prev_header(mpeg3audio_t *audio)
107{
108 int result = 0, i, len = (int)audio->avg_framesize;
109
110 for(i = 0; i < len && !result; i++)
111 {
112 mpeg3bits_getbits_reverse(audio->astream, 8);
113 }
114/* Get reading in the forward direction again. */
115 result |= mpeg3bits_refill(audio->astream);
116 return result;
117}
118
119/* Read the next header */
120int mpeg3audio_read_header(mpeg3audio_t *audio)
121{
122 unsigned int code;
123 int i;
124 int attempt = 0;
125 int result = 0;
126
127 switch(audio->format)
128 {
129 case AUDIO_AC3:
130 result = mpeg3audio_read_ac3_header(audio);
131 break;
132
133 case AUDIO_MPEG:
134/* Layer 1 not supported */
135 if(audio->layer == 1)
136 {
137 fprintf(stderr, "mpeg3audio_new: layer 1 not supported\n");
138 result = 1;
139 }
140 audio->newhead = mpeg3bits_showbits(audio->astream, 32);
141 if(!mpeg3bits_eof(audio->astream) &&
142 (mpeg3audio_head_check(audio->newhead) || mpeg3audio_decode_header(audio)))
143 {
144 do
145 {
146 attempt++;
147 mpeg3bits_getbyte_noptr(audio->astream);
148 audio->newhead = mpeg3bits_showbits(audio->astream, 32);
149 }while(!mpeg3bits_eof(audio->astream) &&
150 attempt < 65536 &&
151 (mpeg3audio_head_check(audio->newhead) || mpeg3audio_decode_header(audio)));
152 }
153
154/* Skip the 4 bytes containing the header */
155 mpeg3bits_getbits(audio->astream, 32);
156 break;
157
158 case AUDIO_PCM:
159 mpeg3audio_read_pcm_header(audio);
160 break;
161 }
162 return mpeg3bits_eof(audio->astream);
163}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/huffman.h b/core/multimedia/opieplayer/libmpeg3/audio/huffman.h
new file mode 100644
index 0000000..a9c8fff
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/huffman.h
@@ -0,0 +1,355 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef HUFFMAN_H
21#define HUFFMAN_H
22
23/*
24 * huffman tables ... recalcualted to work with my optimzed
25 * decoder scheme (MH)
26 *
27 * probably we could save a few bytes of memory, because the
28 * smaller tables are often the part of a bigger table
29 */
30
31struct newhuff
32{
33 unsigned int linbits;
34 short *table;
35};
36
37static short mpeg3_tab0[] =
38{
39 0
40};
41
42static short mpeg3_tab1[] =
43{
44 -5, -3, -1, 17, 1, 16, 0
45};
46
47static short mpeg3_tab2[] =
48{
49 -15, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 17, -1, 1,
50 16, 0
51};
52
53static short mpeg3_tab3[] =
54{
55 -13, -11, -9, -5, -3, -1, 34, 2, 18, -1, 33, 32, 16, 17, -1,
56 1, 0
57};
58
59static short mpeg3_tab5[] =
60{
61 -29, -25, -23, -15, -7, -5, -3, -1, 51, 35, 50, 49, -3, -1, 19,
62 3, -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, 17, -1, 1, 16,
63 0
64};
65
66static short mpeg3_tab6[] =
67{
68 -25, -19, -13, -9, -5, -3, -1, 51, 3, 35, -1, 50, 48, -1, 19,
69 49, -3, -1, 34, 2, 18, -3, -1, 33, 32, 1, -1, 17, -1, 16,
70 0
71};
72
73static short mpeg3_tab7[] =
74{
75 -69, -65, -57, -39, -29, -17, -11, -7, -3, -1, 85, 69, -1, 84, 83,
76 -1, 53, 68, -3, -1, 37, 82, 21, -5, -1, 81, -1, 5, 52, -1,
77 80, -1, 67, 51, -5, -3, -1, 36, 66, 20, -1, 65, 64, -11, -7,
78 -3, -1, 4, 35, -1, 50, 3, -1, 19, 49, -3, -1, 48, 34, 18,
79 -5, -1, 33, -1, 2, 32, 17, -1, 1, 16, 0
80};
81
82static short mpeg3_tab8[] =
83{
84 -65, -63, -59, -45, -31, -19, -13, -7, -5, -3, -1, 85, 84, 69, 83,
85 -3, -1, 53, 68, 37, -3, -1, 82, 5, 21, -5, -1, 81, -1, 52,
86 67, -3, -1, 80, 51, 36, -5, -3, -1, 66, 20, 65, -3, -1, 4,
87 64, -1, 35, 50, -9, -7, -3, -1, 19, 49, -1, 3, 48, 34, -1,
88 2, 32, -1, 18, 33, 17, -3, -1, 1, 16, 0
89};
90
91static short mpeg3_tab9[] =
92{
93 -63, -53, -41, -29, -19, -11, -5, -3, -1, 85, 69, 53, -1, 83, -1,
94 84, 5, -3, -1, 68, 37, -1, 82, 21, -3, -1, 81, 52, -1, 67,
95 -1, 80, 4, -7, -3, -1, 36, 66, -1, 51, 64, -1, 20, 65, -5,
96 -3, -1, 35, 50, 19, -1, 49, -1, 3, 48, -5, -3, -1, 34, 2,
97 18, -1, 33, 32, -3, -1, 17, 1, -1, 16, 0
98};
99
100static short mpeg3_tab10[] =
101{
102-125,-121,-111, -83, -55, -35, -21, -13, -7, -3, -1, 119, 103, -1, 118,
103 87, -3, -1, 117, 102, 71, -3, -1, 116, 86, -1, 101, 55, -9, -3,
104 -1, 115, 70, -3, -1, 85, 84, 99, -1, 39, 114, -11, -5, -3, -1,
105 100, 7, 112, -1, 98, -1, 69, 53, -5, -1, 6, -1, 83, 68, 23,
106 -17, -5, -1, 113, -1, 54, 38, -5, -3, -1, 37, 82, 21, -1, 81,
107 -1, 52, 67, -3, -1, 22, 97, -1, 96, -1, 5, 80, -19, -11, -7,
108 -3, -1, 36, 66, -1, 51, 4, -1, 20, 65, -3, -1, 64, 35, -1,
109 50, 3, -3, -1, 19, 49, -1, 48, 34, -7, -3, -1, 18, 33, -1,
110 2, 32, 17, -1, 1, 16, 0
111};
112
113static short mpeg3_tab11[] =
114{
115-121,-113, -89, -59, -43, -27, -17, -7, -3, -1, 119, 103, -1, 118, 117,
116 -3, -1, 102, 71, -1, 116, -1, 87, 85, -5, -3, -1, 86, 101, 55,
117 -1, 115, 70, -9, -7, -3, -1, 69, 84, -1, 53, 83, 39, -1, 114,
118 -1, 100, 7, -5, -1, 113, -1, 23, 112, -3, -1, 54, 99, -1, 96,
119 -1, 68, 37, -13, -7, -5, -3, -1, 82, 5, 21, 98, -3, -1, 38,
120 6, 22, -5, -1, 97, -1, 81, 52, -5, -1, 80, -1, 67, 51, -1,
121 36, 66, -15, -11, -7, -3, -1, 20, 65, -1, 4, 64, -1, 35, 50,
122 -1, 19, 49, -5, -3, -1, 3, 48, 34, 33, -5, -1, 18, -1, 2,
123 32, 17, -3, -1, 1, 16, 0
124};
125
126static short mpeg3_tab12[] =
127{
128-115, -99, -73, -45, -27, -17, -9, -5, -3, -1, 119, 103, 118, -1, 87,
129 117, -3, -1, 102, 71, -1, 116, 101, -3, -1, 86, 55, -3, -1, 115,
130 85, 39, -7, -3, -1, 114, 70, -1, 100, 23, -5, -1, 113, -1, 7,
131 112, -1, 54, 99, -13, -9, -3, -1, 69, 84, -1, 68, -1, 6, 5,
132 -1, 38, 98, -5, -1, 97, -1, 22, 96, -3, -1, 53, 83, -1, 37,
133 82, -17, -7, -3, -1, 21, 81, -1, 52, 67, -5, -3, -1, 80, 4,
134 36, -1, 66, 20, -3, -1, 51, 65, -1, 35, 50, -11, -7, -5, -3,
135 -1, 64, 3, 48, 19, -1, 49, 34, -1, 18, 33, -7, -5, -3, -1,
136 2, 32, 0, 17, -1, 1, 16
137};
138
139static short mpeg3_tab13[] =
140{
141-509,-503,-475,-405,-333,-265,-205,-153,-115, -83, -53, -35, -21, -13, -9,
142 -7, -5, -3, -1, 254, 252, 253, 237, 255, -1, 239, 223, -3, -1, 238,
143 207, -1, 222, 191, -9, -3, -1, 251, 206, -1, 220, -1, 175, 233, -1,
144 236, 221, -9, -5, -3, -1, 250, 205, 190, -1, 235, 159, -3, -1, 249,
145 234, -1, 189, 219, -17, -9, -3, -1, 143, 248, -1, 204, -1, 174, 158,
146 -5, -1, 142, -1, 127, 126, 247, -5, -1, 218, -1, 173, 188, -3, -1,
147 203, 246, 111, -15, -7, -3, -1, 232, 95, -1, 157, 217, -3, -1, 245,
148 231, -1, 172, 187, -9, -3, -1, 79, 244, -3, -1, 202, 230, 243, -1,
149 63, -1, 141, 216, -21, -9, -3, -1, 47, 242, -3, -1, 110, 156, 15,
150 -5, -3, -1, 201, 94, 171, -3, -1, 125, 215, 78, -11, -5, -3, -1,
151 200, 214, 62, -1, 185, -1, 155, 170, -1, 31, 241, -23, -13, -5, -1,
152 240, -1, 186, 229, -3, -1, 228, 140, -1, 109, 227, -5, -1, 226, -1,
153 46, 14, -1, 30, 225, -15, -7, -3, -1, 224, 93, -1, 213, 124, -3,
154 -1, 199, 77, -1, 139, 184, -7, -3, -1, 212, 154, -1, 169, 108, -1,
155 198, 61, -37, -21, -9, -5, -3, -1, 211, 123, 45, -1, 210, 29, -5,
156 -1, 183, -1, 92, 197, -3, -1, 153, 122, 195, -7, -5, -3, -1, 167,
157 151, 75, 209, -3, -1, 13, 208, -1, 138, 168, -11, -7, -3, -1, 76,
158 196, -1, 107, 182, -1, 60, 44, -3, -1, 194, 91, -3, -1, 181, 137,
159 28, -43, -23, -11, -5, -1, 193, -1, 152, 12, -1, 192, -1, 180, 106,
160 -5, -3, -1, 166, 121, 59, -1, 179, -1, 136, 90, -11, -5, -1, 43,
161 -1, 165, 105, -1, 164, -1, 120, 135, -5, -1, 148, -1, 119, 118, 178,
162 -11, -3, -1, 27, 177, -3, -1, 11, 176, -1, 150, 74, -7, -3, -1,
163 58, 163, -1, 89, 149, -1, 42, 162, -47, -23, -9, -3, -1, 26, 161,
164 -3, -1, 10, 104, 160, -5, -3, -1, 134, 73, 147, -3, -1, 57, 88,
165 -1, 133, 103, -9, -3, -1, 41, 146, -3, -1, 87, 117, 56, -5, -1,
166 131, -1, 102, 71, -3, -1, 116, 86, -1, 101, 115, -11, -3, -1, 25,
167 145, -3, -1, 9, 144, -1, 72, 132, -7, -5, -1, 114, -1, 70, 100,
168 40, -1, 130, 24, -41, -27, -11, -5, -3, -1, 55, 39, 23, -1, 113,
169 -1, 85, 7, -7, -3, -1, 112, 54, -1, 99, 69, -3, -1, 84, 38,
170 -1, 98, 53, -5, -1, 129, -1, 8, 128, -3, -1, 22, 97, -1, 6,
171 96, -13, -9, -5, -3, -1, 83, 68, 37, -1, 82, 5, -1, 21, 81,
172 -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20, -19, -11,
173 -5, -1, 65, -1, 4, 64, -3, -1, 35, 50, 19, -3, -1, 49, 3,
174 -1, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
175 0
176};
177
178static short mpeg3_tab15[] =
179{
180-495,-445,-355,-263,-183,-115, -77, -43, -27, -13, -7, -3, -1, 255, 239,
181 -1, 254, 223, -1, 238, -1, 253, 207, -7, -3, -1, 252, 222, -1, 237,
182 191, -1, 251, -1, 206, 236, -7, -3, -1, 221, 175, -1, 250, 190, -3,
183 -1, 235, 205, -1, 220, 159, -15, -7, -3, -1, 249, 234, -1, 189, 219,
184 -3, -1, 143, 248, -1, 204, 158, -7, -3, -1, 233, 127, -1, 247, 173,
185 -3, -1, 218, 188, -1, 111, -1, 174, 15, -19, -11, -3, -1, 203, 246,
186 -3, -1, 142, 232, -1, 95, 157, -3, -1, 245, 126, -1, 231, 172, -9,
187 -3, -1, 202, 187, -3, -1, 217, 141, 79, -3, -1, 244, 63, -1, 243,
188 216, -33, -17, -9, -3, -1, 230, 47, -1, 242, -1, 110, 240, -3, -1,
189 31, 241, -1, 156, 201, -7, -3, -1, 94, 171, -1, 186, 229, -3, -1,
190 125, 215, -1, 78, 228, -15, -7, -3, -1, 140, 200, -1, 62, 109, -3,
191 -1, 214, 227, -1, 155, 185, -7, -3, -1, 46, 170, -1, 226, 30, -5,
192 -1, 225, -1, 14, 224, -1, 93, 213, -45, -25, -13, -7, -3, -1, 124,
193 199, -1, 77, 139, -1, 212, -1, 184, 154, -7, -3, -1, 169, 108, -1,
194 198, 61, -1, 211, 210, -9, -5, -3, -1, 45, 13, 29, -1, 123, 183,
195 -5, -1, 209, -1, 92, 208, -1, 197, 138, -17, -7, -3, -1, 168, 76,
196 -1, 196, 107, -5, -1, 182, -1, 153, 12, -1, 60, 195, -9, -3, -1,
197 122, 167, -1, 166, -1, 192, 11, -1, 194, -1, 44, 91, -55, -29, -15,
198 -7, -3, -1, 181, 28, -1, 137, 152, -3, -1, 193, 75, -1, 180, 106,
199 -5, -3, -1, 59, 121, 179, -3, -1, 151, 136, -1, 43, 90, -11, -5,
200 -1, 178, -1, 165, 27, -1, 177, -1, 176, 105, -7, -3, -1, 150, 74,
201 -1, 164, 120, -3, -1, 135, 58, 163, -17, -7, -3, -1, 89, 149, -1,
202 42, 162, -3, -1, 26, 161, -3, -1, 10, 160, 104, -7, -3, -1, 134,
203 73, -1, 148, 57, -5, -1, 147, -1, 119, 9, -1, 88, 133, -53, -29,
204 -13, -7, -3, -1, 41, 103, -1, 118, 146, -1, 145, -1, 25, 144, -7,
205 -3, -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 71, -7,
206 -3, -1, 40, 130, -1, 24, 129, -7, -3, -1, 116, 8, -1, 128, 86,
207 -3, -1, 101, 55, -1, 115, 70, -17, -7, -3, -1, 39, 114, -1, 100,
208 23, -3, -1, 85, 113, -3, -1, 7, 112, 54, -7, -3, -1, 99, 69,
209 -1, 84, 38, -3, -1, 98, 22, -3, -1, 6, 96, 53, -33, -19, -9,
210 -5, -1, 97, -1, 83, 68, -1, 37, 82, -3, -1, 21, 81, -3, -1,
211 5, 80, 52, -7, -3, -1, 67, 36, -1, 66, 51, -1, 65, -1, 20,
212 4, -9, -3, -1, 35, 50, -3, -1, 64, 3, 19, -3, -1, 49, 48,
213 34, -9, -7, -3, -1, 18, 33, -1, 2, 32, 17, -3, -1, 1, 16,
214 0
215};
216
217static short mpeg3_tab16[] =
218{
219-509,-503,-461,-323,-103, -37, -27, -15, -7, -3, -1, 239, 254, -1, 223,
220 253, -3, -1, 207, 252, -1, 191, 251, -5, -1, 175, -1, 250, 159, -3,
221 -1, 249, 248, 143, -7, -3, -1, 127, 247, -1, 111, 246, 255, -9, -5,
222 -3, -1, 95, 245, 79, -1, 244, 243, -53, -1, 240, -1, 63, -29, -19,
223 -13, -7, -5, -1, 206, -1, 236, 221, 222, -1, 233, -1, 234, 217, -1,
224 238, -1, 237, 235, -3, -1, 190, 205, -3, -1, 220, 219, 174, -11, -5,
225 -1, 204, -1, 173, 218, -3, -1, 126, 172, 202, -5, -3, -1, 201, 125,
226 94, 189, 242, -93, -5, -3, -1, 47, 15, 31, -1, 241, -49, -25, -13,
227 -5, -1, 158, -1, 188, 203, -3, -1, 142, 232, -1, 157, 231, -7, -3,
228 -1, 187, 141, -1, 216, 110, -1, 230, 156, -13, -7, -3, -1, 171, 186,
229 -1, 229, 215, -1, 78, -1, 228, 140, -3, -1, 200, 62, -1, 109, -1,
230 214, 155, -19, -11, -5, -3, -1, 185, 170, 225, -1, 212, -1, 184, 169,
231 -5, -1, 123, -1, 183, 208, 227, -7, -3, -1, 14, 224, -1, 93, 213,
232 -3, -1, 124, 199, -1, 77, 139, -75, -45, -27, -13, -7, -3, -1, 154,
233 108, -1, 198, 61, -3, -1, 92, 197, 13, -7, -3, -1, 138, 168, -1,
234 153, 76, -3, -1, 182, 122, 60, -11, -5, -3, -1, 91, 137, 28, -1,
235 192, -1, 152, 121, -1, 226, -1, 46, 30, -15, -7, -3, -1, 211, 45,
236 -1, 210, 209, -5, -1, 59, -1, 151, 136, 29, -7, -3, -1, 196, 107,
237 -1, 195, 167, -1, 44, -1, 194, 181, -23, -13, -7, -3, -1, 193, 12,
238 -1, 75, 180, -3, -1, 106, 166, 179, -5, -3, -1, 90, 165, 43, -1,
239 178, 27, -13, -5, -1, 177, -1, 11, 176, -3, -1, 105, 150, -1, 74,
240 164, -5, -3, -1, 120, 135, 163, -3, -1, 58, 89, 42, -97, -57, -33,
241 -19, -11, -5, -3, -1, 149, 104, 161, -3, -1, 134, 119, 148, -5, -3,
242 -1, 73, 87, 103, 162, -5, -1, 26, -1, 10, 160, -3, -1, 57, 147,
243 -1, 88, 133, -9, -3, -1, 41, 146, -3, -1, 118, 9, 25, -5, -1,
244 145, -1, 144, 72, -3, -1, 132, 117, -1, 56, 131, -21, -11, -5, -3,
245 -1, 102, 40, 130, -3, -1, 71, 116, 24, -3, -1, 129, 128, -3, -1,
246 8, 86, 55, -9, -5, -1, 115, -1, 101, 70, -1, 39, 114, -5, -3,
247 -1, 100, 85, 7, 23, -23, -13, -5, -1, 113, -1, 112, 54, -3, -1,
248 99, 69, -1, 84, 38, -3, -1, 98, 22, -1, 97, -1, 6, 96, -9,
249 -5, -1, 83, -1, 53, 68, -1, 37, 82, -1, 81, -1, 21, 5, -33,
250 -23, -13, -7, -3, -1, 52, 67, -1, 80, 36, -3, -1, 66, 51, 20,
251 -5, -1, 65, -1, 4, 64, -1, 35, 50, -3, -1, 19, 49, -3, -1,
252 3, 48, 34, -3, -1, 18, 33, -1, 2, 32, -3, -1, 17, 1, 16,
253 0
254};
255
256static short mpeg3_tab24[] =
257{
258-451,-117, -43, -25, -15, -7, -3, -1, 239, 254, -1, 223, 253, -3, -1,
259 207, 252, -1, 191, 251, -5, -1, 250, -1, 175, 159, -1, 249, 248, -9,
260 -5, -3, -1, 143, 127, 247, -1, 111, 246, -3, -1, 95, 245, -1, 79,
261 244, -71, -7, -3, -1, 63, 243, -1, 47, 242, -5, -1, 241, -1, 31,
262 240, -25, -9, -1, 15, -3, -1, 238, 222, -1, 237, 206, -7, -3, -1,
263 236, 221, -1, 190, 235, -3, -1, 205, 220, -1, 174, 234, -15, -7, -3,
264 -1, 189, 219, -1, 204, 158, -3, -1, 233, 173, -1, 218, 188, -7, -3,
265 -1, 203, 142, -1, 232, 157, -3, -1, 217, 126, -1, 231, 172, 255,-235,
266-143, -77, -45, -25, -15, -7, -3, -1, 202, 187, -1, 141, 216, -5, -3,
267 -1, 14, 224, 13, 230, -5, -3, -1, 110, 156, 201, -1, 94, 186, -9,
268 -5, -1, 229, -1, 171, 125, -1, 215, 228, -3, -1, 140, 200, -3, -1,
269 78, 46, 62, -15, -7, -3, -1, 109, 214, -1, 227, 155, -3, -1, 185,
270 170, -1, 226, 30, -7, -3, -1, 225, 93, -1, 213, 124, -3, -1, 199,
271 77, -1, 139, 184, -31, -15, -7, -3, -1, 212, 154, -1, 169, 108, -3,
272 -1, 198, 61, -1, 211, 45, -7, -3, -1, 210, 29, -1, 123, 183, -3,
273 -1, 209, 92, -1, 197, 138, -17, -7, -3, -1, 168, 153, -1, 76, 196,
274 -3, -1, 107, 182, -3, -1, 208, 12, 60, -7, -3, -1, 195, 122, -1,
275 167, 44, -3, -1, 194, 91, -1, 181, 28, -57, -35, -19, -7, -3, -1,
276 137, 152, -1, 193, 75, -5, -3, -1, 192, 11, 59, -3, -1, 176, 10,
277 26, -5, -1, 180, -1, 106, 166, -3, -1, 121, 151, -3, -1, 160, 9,
278 144, -9, -3, -1, 179, 136, -3, -1, 43, 90, 178, -7, -3, -1, 165,
279 27, -1, 177, 105, -1, 150, 164, -17, -9, -5, -3, -1, 74, 120, 135,
280 -1, 58, 163, -3, -1, 89, 149, -1, 42, 162, -7, -3, -1, 161, 104,
281 -1, 134, 119, -3, -1, 73, 148, -1, 57, 147, -63, -31, -15, -7, -3,
282 -1, 88, 133, -1, 41, 103, -3, -1, 118, 146, -1, 25, 145, -7, -3,
283 -1, 72, 132, -1, 87, 117, -3, -1, 56, 131, -1, 102, 40, -17, -7,
284 -3, -1, 130, 24, -1, 71, 116, -5, -1, 129, -1, 8, 128, -1, 86,
285 101, -7, -5, -1, 23, -1, 7, 112, 115, -3, -1, 55, 39, 114, -15,
286 -7, -3, -1, 70, 100, -1, 85, 113, -3, -1, 54, 99, -1, 69, 84,
287 -7, -3, -1, 38, 98, -1, 22, 97, -5, -3, -1, 6, 96, 53, -1,
288 83, 68, -51, -37, -23, -15, -9, -3, -1, 37, 82, -1, 21, -1, 5,
289 80, -1, 81, -1, 52, 67, -3, -1, 36, 66, -1, 51, 20, -9, -5,
290 -1, 65, -1, 4, 64, -1, 35, 50, -1, 19, 49, -7, -5, -3, -1,
291 3, 48, 34, 18, -1, 33, -1, 2, 32, -3, -1, 17, 1, -1, 16,
292 0
293};
294
295static short mpeg3_tab_c0[] =
296{
297 -29, -21, -13, -7, -3, -1, 11, 15, -1, 13, 14, -3, -1, 7, 5,
298 9, -3, -1, 6, 3, -1, 10, 12, -3, -1, 2, 1, -1, 4, 8,
299 0
300};
301
302static short mpeg3_tab_c1[] =
303{
304 -15, -7, -3, -1, 15, 14, -1, 13, 12, -3, -1, 11, 10, -1, 9,
305 8, -7, -3, -1, 7, 6, -1, 5, 4, -3, -1, 3, 2, -1, 1,
306 0
307};
308
309
310
311static struct newhuff mpeg3_ht[] =
312{
313 { /* 0 */ 0 , mpeg3_tab0 } ,
314 { /* 2 */ 0 , mpeg3_tab1 } ,
315 { /* 3 */ 0 , mpeg3_tab2 } ,
316 { /* 3 */ 0 , mpeg3_tab3 } ,
317 { /* 0 */ 0 , mpeg3_tab0 } ,
318 { /* 4 */ 0 , mpeg3_tab5 } ,
319 { /* 4 */ 0 , mpeg3_tab6 } ,
320 { /* 6 */ 0 , mpeg3_tab7 } ,
321 { /* 6 */ 0 , mpeg3_tab8 } ,
322 { /* 6 */ 0 , mpeg3_tab9 } ,
323 { /* 8 */ 0 , mpeg3_tab10 } ,
324 { /* 8 */ 0 , mpeg3_tab11 } ,
325 { /* 8 */ 0 , mpeg3_tab12 } ,
326 { /* 16 */ 0 , mpeg3_tab13 } ,
327 { /* 0 */ 0 , mpeg3_tab0 } ,
328 { /* 16 */ 0 , mpeg3_tab15 } ,
329
330 { /* 16 */ 1 , mpeg3_tab16 } ,
331 { /* 16 */ 2 , mpeg3_tab16 } ,
332 { /* 16 */ 3 , mpeg3_tab16 } ,
333 { /* 16 */ 4 , mpeg3_tab16 } ,
334 { /* 16 */ 6 , mpeg3_tab16 } ,
335 { /* 16 */ 8 , mpeg3_tab16 } ,
336 { /* 16 */ 10, mpeg3_tab16 } ,
337 { /* 16 */ 13, mpeg3_tab16 } ,
338 { /* 16 */ 4 , mpeg3_tab24 } ,
339 { /* 16 */ 5 , mpeg3_tab24 } ,
340 { /* 16 */ 6 , mpeg3_tab24 } ,
341 { /* 16 */ 7 , mpeg3_tab24 } ,
342 { /* 16 */ 8 , mpeg3_tab24 } ,
343 { /* 16 */ 9 , mpeg3_tab24 } ,
344 { /* 16 */ 11, mpeg3_tab24 } ,
345 { /* 16 */ 13, mpeg3_tab24 }
346};
347
348static struct newhuff mpeg3_htc[] =
349{
350 { /* 1 , 1 , */ 0 , mpeg3_tab_c0 } ,
351 { /* 1 , 1 , */ 0 , mpeg3_tab_c1 }
352};
353
354
355#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/layer1.c b/core/multimedia/opieplayer/libmpeg3/audio/layer1.c
new file mode 100644
index 0000000..0c355f3
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/layer1.c
@@ -0,0 +1,6 @@
1#include "mpeg3audio.h"
2
3int mpeg3audio_dolayer1(mpeg3audio_t *audio)
4{
5 ;
6}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/layer2.c b/core/multimedia/opieplayer/libmpeg3/audio/layer2.c
new file mode 100644
index 0000000..01582fe
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/layer2.c
@@ -0,0 +1,418 @@
1/*
2 * most other tables are calculated on program start (which is (of course)
3 * not ISO-conform) ..
4 * Layer-3 huffman table is in huffman.h
5 */
6
7#include "mpeg3audio.h"
8#include "../libmpeg3.h"
9#include "../mpeg3protos.h"
10#include "tables.h"
11
12struct al_table alloc_0[] = {
13 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
14 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
15 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
16 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
17 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
18 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
19 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
20 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
21 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
22 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
23 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
24 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
25 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
26 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
27 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
28 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
29 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
30 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
31 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
32 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
33 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
34 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
35 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
36 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
37 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
38 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
39 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
40 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
41 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
42 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
43 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
44 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
45 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
46 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
47 {2,0},{5,3},{7,5},{16,-32767},
48 {2,0},{5,3},{7,5},{16,-32767},
49 {2,0},{5,3},{7,5},{16,-32767},
50 {2,0},{5,3},{7,5},{16,-32767} };
51
52struct al_table alloc_1[] = {
53 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
54 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
55 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
56 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
57 {4,0},{5,3},{3,-3},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},{10,-511},
58 {11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},{16,-32767},
59 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
60 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
61 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
62 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
63 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
64 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
65 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
66 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
67 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
68 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
69 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
70 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
71 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
72 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
73 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
74 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{16,-32767},
75 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
76 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
77 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
78 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
79 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
80 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
81 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
82 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
83 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
84 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
85 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
86 {3,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{16,-32767},
87 {2,0},{5,3},{7,5},{16,-32767},
88 {2,0},{5,3},{7,5},{16,-32767},
89 {2,0},{5,3},{7,5},{16,-32767},
90 {2,0},{5,3},{7,5},{16,-32767},
91 {2,0},{5,3},{7,5},{16,-32767},
92 {2,0},{5,3},{7,5},{16,-32767},
93 {2,0},{5,3},{7,5},{16,-32767} };
94
95struct al_table alloc_2[] = {
96 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
97 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
98 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
99 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
100 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
101 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
102 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
103 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
104 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
105 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} };
106
107struct al_table alloc_3[] = {
108 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
109 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
110 {4,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},{9,-255},
111 {10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},{15,-16383},
112 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
113 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
114 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
115 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
116 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
117 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
118 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
119 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
120 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
121 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63} };
122
123struct al_table alloc_4[] = {
124 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
125 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
126 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
127 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
128 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
129 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
130 {4,0},{5,3},{7,5},{3,-3},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},{8,-127},
131 {9,-255},{10,-511},{11,-1023},{12,-2047},{13,-4095},{14,-8191},
132 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
133 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
134 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
135 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
136 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
137 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
138 {3,0},{5,3},{7,5},{10,9},{4,-7},{5,-15},{6,-31},{7,-63},
139 {2,0},{5,3},{7,5},{10,9},
140 {2,0},{5,3},{7,5},{10,9},
141 {2,0},{5,3},{7,5},{10,9},
142 {2,0},{5,3},{7,5},{10,9},
143 {2,0},{5,3},{7,5},{10,9},
144 {2,0},{5,3},{7,5},{10,9},
145 {2,0},{5,3},{7,5},{10,9},
146 {2,0},{5,3},{7,5},{10,9},
147 {2,0},{5,3},{7,5},{10,9},
148 {2,0},{5,3},{7,5},{10,9},
149 {2,0},{5,3},{7,5},{10,9},
150 {2,0},{5,3},{7,5},{10,9},
151 {2,0},{5,3},{7,5},{10,9},
152 {2,0},{5,3},{7,5},{10,9},
153 {2,0},{5,3},{7,5},{10,9},
154 {2,0},{5,3},{7,5},{10,9},
155 {2,0},{5,3},{7,5},{10,9},
156 {2,0},{5,3},{7,5},{10,9},
157 {2,0},{5,3},{7,5},{10,9} };
158
159
160int mpeg3audio_II_select_table(mpeg3audio_t *audio)
161{
162 static int translate[3][2][16] =
163 {{{ 0,2,2,2,2,2,2,0,0,0,1,1,1,1,1,0},
164 { 0,2,2,0,0,0,1,1,1,1,1,1,1,1,1,0}},
165 {{ 0,2,2,2,2,2,2,0,0,0,0,0,0,0,0,0},
166 { 0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0}},
167 {{ 0,3,3,3,3,3,3,0,0,0,1,1,1,1,1,0},
168 { 0,3,3,0,0,0,1,1,1,1,1,1,1,1,1,0}}};
169 int table, sblim;
170 static struct al_table *tables[5] =
171 {alloc_0, alloc_1, alloc_2, alloc_3, alloc_4};
172 static int sblims[5] = {27, 30, 8, 12, 30};
173
174 if(audio->lsf)
175 table = 4;
176 else
177 table = translate[audio->sampling_frequency_code][2 - audio->channels][audio->bitrate_index];
178 sblim = sblims[table];
179
180 audio->alloc = tables[table];
181 audio->II_sblimit = sblim;
182 return 0;
183}
184
185int mpeg3audio_II_step_one(mpeg3audio_t *audio, unsigned int *bit_alloc, int *scale)
186{
187 int stereo = audio->channels - 1;
188 int sblimit = audio->II_sblimit;
189 int jsbound = audio->jsbound;
190 int sblimit2 = audio->II_sblimit << stereo;
191 struct al_table *alloc1 = audio->alloc;
192 int i, result = 0;
193 unsigned int *scfsi_buf = audio->layer2_scfsi_buf;
194 unsigned int *scfsi, *bita;
195 int sc, step;
196
197 bita = bit_alloc;
198 if(stereo)
199 {
200/* Stereo */
201 for(i = jsbound;i ; i--, alloc1 += (1 << step))
202 {
203 *bita++ = (char)mpeg3bits_getbits(audio->astream, step = alloc1->bits);
204 *bita++ = (char)mpeg3bits_getbits(audio->astream, step);
205 }
206 for(i = sblimit-jsbound; i; i--, alloc1 += (1 << step))
207 {
208 bita[0] = (char)mpeg3bits_getbits(audio->astream, step = alloc1->bits);
209 bita[1] = bita[0];
210 bita += 2;
211 }
212 bita = bit_alloc;
213 scfsi = scfsi_buf;
214 for(i = sblimit2; i; i--)
215 if(*bita++) *scfsi++ = (char)mpeg3bits_getbits(audio->astream, 2);
216 }
217 else
218 {
219/* mono */
220 for(i = sblimit; i; i--, alloc1 += (1 << step))
221 *bita++ = (char)mpeg3bits_getbits(audio->astream, step = alloc1->bits);
222 bita = bit_alloc;
223 scfsi = scfsi_buf;
224 for(i = sblimit; i; i--) if (*bita++) *scfsi++ = (char)mpeg3bits_getbits(audio->astream, 2);
225 }
226
227 bita = bit_alloc;
228 scfsi = scfsi_buf;
229 for(i = sblimit2; i; i--)
230 {
231 if(*bita++)
232 switch(*scfsi++)
233 {
234 case 0:
235 *scale++ = mpeg3bits_getbits(audio->astream, 6);
236 *scale++ = mpeg3bits_getbits(audio->astream, 6);
237 *scale++ = mpeg3bits_getbits(audio->astream, 6);
238 break;
239 case 1 :
240 *scale++ = sc = mpeg3bits_getbits(audio->astream, 6);
241 *scale++ = sc;
242 *scale++ = mpeg3bits_getbits(audio->astream, 6);
243 break;
244 case 2:
245 *scale++ = sc = mpeg3bits_getbits(audio->astream, 6);
246 *scale++ = sc;
247 *scale++ = sc;
248 break;
249 default: /* case 3 */
250 *scale++ = mpeg3bits_getbits(audio->astream, 6);
251 *scale++ = sc = mpeg3bits_getbits(audio->astream, 6);
252 *scale++ = sc;
253 break;
254 }
255 }
256 return result | mpeg3bits_error(audio->astream);
257}
258
259int mpeg3audio_II_step_two(mpeg3audio_t *audio, unsigned int *bit_alloc, mpeg3_real_t fraction[2][4][SBLIMIT], int *scale, int x1)
260{
261 int i, j, k, ba, result = 0;
262 int channels = audio->channels;
263 int sblimit = audio->II_sblimit;
264 int jsbound = audio->jsbound;
265 struct al_table *alloc2, *alloc1 = audio->alloc;
266 unsigned int *bita = bit_alloc;
267 int d1, step, test;
268
269 for(i = 0; i < jsbound; i++, alloc1 += (1 << step))
270 {
271 step = alloc1->bits;
272 for(j = 0; j < channels; j++)
273 {
274 if(ba = *bita++)
275 {
276 k = (alloc2 = alloc1 + ba)->bits;
277 if((d1 = alloc2->d) < 0)
278 {
279 mpeg3_real_t cm = mpeg3_muls[k][scale[x1]];
280
281 fraction[j][0][i] = ((mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
282 fraction[j][1][i] = ((mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
283 fraction[j][2][i] = ((mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
284 }
285 else
286 {
287 static int *table[] =
288 {0, 0, 0, mpeg3_grp_3tab, 0, mpeg3_grp_5tab, 0, 0, 0, mpeg3_grp_9tab};
289 unsigned int idx, *tab, m = scale[x1];
290
291 idx = (unsigned int)mpeg3bits_getbits(audio->astream, k);
292 tab = (unsigned int*)(table[d1] + idx + idx + idx);
293 fraction[j][0][i] = mpeg3_muls[*tab++][m];
294 fraction[j][1][i] = mpeg3_muls[*tab++][m];
295 fraction[j][2][i] = mpeg3_muls[*tab][m];
296 }
297 scale += 3;
298 }
299 else
300 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
301 }
302 }
303
304 for(i = jsbound; i < sblimit; i++, alloc1 += (1 << step))
305 {
306 step = alloc1->bits;
307/* channel 1 and channel 2 bitalloc are the same */
308 bita++;
309 if((ba = *bita++))
310 {
311 k=(alloc2 = alloc1+ba)->bits;
312 if((d1 = alloc2->d) < 0)
313 {
314 mpeg3_real_t cm;
315
316 cm = mpeg3_muls[k][scale[x1 + 3]];
317 fraction[1][0][i] = (fraction[0][0][i] = (mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
318 fraction[1][1][i] = (fraction[0][1][i] = (mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
319 fraction[1][2][i] = (fraction[0][2][i] = (mpeg3_real_t)((int)mpeg3bits_getbits(audio->astream, k) + d1)) * cm;
320 cm = mpeg3_muls[k][scale[x1]];
321 fraction[0][0][i] *= cm;
322 fraction[0][1][i] *= cm;
323 fraction[0][2][i] *= cm;
324 }
325 else
326 {
327 static int *table[] = {0, 0, 0, mpeg3_grp_3tab, 0, mpeg3_grp_5tab, 0, 0, 0, mpeg3_grp_9tab};
328 unsigned int idx, *tab, m1, m2;
329
330 m1 = scale[x1];
331 m2 = scale[x1+3];
332 idx = (unsigned int)mpeg3bits_getbits(audio->astream, k);
333 tab = (unsigned int*)(table[d1] + idx + idx + idx);
334 fraction[0][0][i] = mpeg3_muls[*tab][m1];
335 fraction[1][0][i] = mpeg3_muls[*tab++][m2];
336 fraction[0][1][i] = mpeg3_muls[*tab][m1];
337 fraction[1][1][i] = mpeg3_muls[*tab++][m2];
338 fraction[0][2][i] = mpeg3_muls[*tab][m1];
339 fraction[1][2][i] = mpeg3_muls[*tab][m2];
340 }
341 scale += 6;
342 }
343 else
344 {
345 fraction[0][0][i] = fraction[0][1][i] = fraction[0][2][i] =
346 fraction[1][0][i] = fraction[1][1][i] = fraction[1][2][i] = 0.0;
347 }
348/*
349 should we use individual scalefac for channel 2 or
350 is the current way the right one , where we just copy channel 1 to
351 channel 2 ??
352 The current 'strange' thing is, that we throw away the scalefac
353 values for the second channel ...!!
354-> changed .. now we use the scalefac values of channel one !!
355*/
356 }
357
358 if(sblimit > SBLIMIT) sblimit = SBLIMIT;
359
360 for(i = sblimit; i < SBLIMIT; i++)
361 for(j = 0; j < channels; j++)
362 fraction[j][0][i] = fraction[j][1][i] = fraction[j][2][i] = 0.0;
363
364 return result | mpeg3bits_error(audio->astream);
365}
366
367int mpeg3audio_dolayer2(mpeg3audio_t *audio)
368{
369 int i, j, result = 0;
370 int channels = audio->channels;
371 mpeg3_real_t fraction[2][4][SBLIMIT]; /* pick_table clears unused subbands */
372 unsigned int bit_alloc[64];
373 int scale[192];
374 int single = audio->single;
375
376 if(audio->error_protection)
377 mpeg3bits_getbits(audio->astream, 16);
378
379 mpeg3audio_II_select_table(audio);
380
381 audio->jsbound = (audio->mode == MPG_MD_JOINT_STEREO) ?
382 (audio->mode_ext << 2) + 4 : audio->II_sblimit;
383
384 if(channels == 1 || single == 3)
385 single = 0;
386
387 result |= mpeg3audio_II_step_one(audio, bit_alloc, scale);
388
389 for(i = 0; i < SCALE_BLOCK && !result; i++)
390 {
391 result |= mpeg3audio_II_step_two(audio, bit_alloc, fraction, scale, i >> 2);
392
393 for(j = 0; j < 3; j++)
394 {
395 if(single >= 0)
396 {
397/* Monaural */
398 mpeg3audio_synth_mono(audio, fraction[single][j], audio->pcm_sample, &(audio->pcm_point));
399 }
400 else
401 {
402/* Stereo */
403 int p1 = audio->pcm_point;
404 mpeg3audio_synth_stereo(audio, fraction[0][j], 0, audio->pcm_sample, &p1);
405 mpeg3audio_synth_stereo(audio, fraction[1][j], 1, audio->pcm_sample, &(audio->pcm_point));
406 }
407
408 if(audio->pcm_point / audio->channels >= audio->pcm_allocated - MPEG3AUDIO_PADDING * audio->channels)
409 {
410/* Need more room */
411 mpeg3audio_replace_buffer(audio, audio->pcm_allocated + MPEG3AUDIO_PADDING * audio->channels);
412 }
413 }
414 }
415
416
417 return result;
418}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/layer3.c b/core/multimedia/opieplayer/libmpeg3/audio/layer3.c
new file mode 100644
index 0000000..b8a5f06
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/layer3.c
@@ -0,0 +1,1254 @@
1#include "huffman.h"
2#include "mpeg3audio.h"
3#include "../libmpeg3.h"
4#include "../mpeg3protos.h"
5#include "tables.h"
6
7#include <stdio.h>
8#include <string.h>
9
10struct gr_info_s {
11 int scfsi;
12 unsigned part2_3_length;
13 unsigned big_values;
14 unsigned scalefac_compress;
15 unsigned block_type;
16 unsigned mixed_block_flag;
17 unsigned table_select[3];
18 unsigned subblock_gain[3];
19 unsigned maxband[3];
20 unsigned maxbandl;
21 unsigned maxb;
22 unsigned region1start;
23 unsigned region2start;
24 unsigned preflag;
25 unsigned scalefac_scale;
26 unsigned count1table_select;
27 mpeg3_real_t *full_gain[3];
28 mpeg3_real_t *pow2gain;
29};
30
31struct mpeg3_III_sideinfo
32{
33 unsigned main_data_begin;
34 unsigned private_bits;
35 struct
36 {
37 struct gr_info_s gr[2];
38 } ch[2];
39};
40
41int mpeg3audio_III_get_scale_factors_1(mpeg3audio_t *audio,
42 int *scf,
43 struct gr_info_s *gr_info,
44 int ch,
45 int gr)
46{
47 static unsigned char slen[2][16] =
48 {{0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
49 {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}};
50 int numbits;
51 int num0 = slen[0][gr_info->scalefac_compress];
52 int num1 = slen[1][gr_info->scalefac_compress];
53
54 if (gr_info->block_type == 2)
55 {
56 int i = 18;
57 numbits = (num0 + num1) * 18;
58
59 if (gr_info->mixed_block_flag)
60 {
61 for(i = 8; i; i--)
62 *scf++ = mpeg3bits_getbits(audio->astream, num0);
63 i = 9;
64/* num0 * 17 + num1 * 18 */
65 numbits -= num0;
66 }
67
68 for( ; i; i--)
69 *scf++ = mpeg3bits_getbits(audio->astream, num0);
70 for(i = 18; i; i--)
71 *scf++ = mpeg3bits_getbits(audio->astream, num1);
72/* short[13][0..2] = 0 */
73 *scf++ = 0;
74 *scf++ = 0;
75 *scf++ = 0;
76 }
77 else
78 {
79 int i;
80 int scfsi = gr_info->scfsi;
81
82 if(scfsi < 0)
83 {
84/* scfsi < 0 => granule == 0 */
85 for(i = 11; i; i--)
86 {
87 *scf++ = mpeg3bits_getbits(audio->astream, num0);
88 }
89 for(i = 10; i; i--)
90 *scf++ = mpeg3bits_getbits(audio->astream, num1);
91 numbits = (num0 + num1) * 10 + num0;
92 *scf++ = 0;
93 }
94 else
95 {
96 numbits = 0;
97 if(!(scfsi & 0x8))
98 {
99 for(i = 0; i < 6; i++)
100 {
101 *scf++ = mpeg3bits_getbits(audio->astream, num0);
102 }
103 numbits += num0 * 6;
104 }
105 else
106 {
107 scf += 6;
108 }
109
110 if(!(scfsi & 0x4))
111 {
112 for(i = 0; i < 5; i++)
113 *scf++ = mpeg3bits_getbits(audio->astream, num0);
114 numbits += num0 * 5;
115 }
116 else
117 {
118 scf += 5;
119 }
120
121 if(!(scfsi & 0x2))
122 {
123 for(i = 0; i < 5; i++)
124 *scf++ = mpeg3bits_getbits(audio->astream, num1);
125 numbits += num1 * 5;
126 }
127 else
128 {
129 scf += 5;
130 }
131
132 if(!(scfsi & 0x1))
133 {
134 for(i = 0; i < 5; i++)
135 *scf++ = mpeg3bits_getbits(audio->astream, num1);
136 numbits += num1 * 5;
137 }
138 else
139 {
140 scf += 5;
141 }
142 *scf++ = 0; /* no l[21] in original sources */
143 }
144 }
145 return numbits;
146}
147
148int mpeg3audio_III_get_scale_factors_2(mpeg3audio_t *audio,
149 int *scf,
150 struct gr_info_s *gr_info,
151 int i_stereo)
152{
153 unsigned char *pnt;
154 int i, j, n = 0, numbits = 0;
155 unsigned int slen;
156 static unsigned char stab[3][6][4] =
157 {{{ 6, 5, 5,5 }, { 6, 5, 7,3 }, { 11,10,0,0},
158 { 7, 7, 7,0 }, { 6, 6, 6,3 }, { 8, 8,5,0}},
159 {{ 9, 9, 9,9 }, { 9, 9,12,6 }, { 18,18,0,0},
160 {12,12,12,0 }, {12, 9, 9,6 }, { 15,12,9,0}},
161 {{ 6, 9, 9,9 }, { 6, 9,12,6 }, { 15,18,0,0},
162 { 6,15,12,0 }, { 6,12, 9,6 }, { 6,18,9,0}}};
163
164/* i_stereo AND second channel -> do_layer3() checks this */
165 if(i_stereo)
166 slen = mpeg3_i_slen2[gr_info->scalefac_compress >> 1];
167 else
168 slen = mpeg3_n_slen2[gr_info->scalefac_compress];
169
170 gr_info->preflag = (slen >> 15) & 0x1;
171
172 n = 0;
173 if(gr_info->block_type == 2 )
174 {
175 n++;
176 if(gr_info->mixed_block_flag)
177 n++;
178 }
179
180 pnt = stab[n][(slen >> 12) & 0x7];
181
182 for(i = 0; i < 4; i++)
183 {
184 int num = slen & 0x7;
185 slen >>= 3;
186 if(num)
187 {
188 for(j = 0; j < (int)(pnt[i]); j++)
189 *scf++ = mpeg3bits_getbits(audio->astream, num);
190 numbits += pnt[i] * num;
191 }
192 else
193 {
194 for(j = 0; j < (int)(pnt[i]); j++)
195 *scf++ = 0;
196 }
197 }
198
199 n = (n << 1) + 1;
200 for(i = 0; i < n; i++)
201 *scf++ = 0;
202
203 return numbits;
204}
205
206static int pretab1[22] = {0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,2,2,3,3,3,2,0};
207static int pretab2[22] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
208
209/*
210 * Dequantize samples (includes huffman decoding)
211 *
212 * 24 is enough because tab13 has max. a 19 bit huffvector
213 */
214
215#define BITSHIFT ((sizeof(long) - 1) * 8)
216#define REFRESH_MASK \
217 while(num < BITSHIFT) \
218 { \
219 mask |= mpeg3bits_getbits(audio->astream, 8) << (BITSHIFT - num); \
220 num += 8; \
221 part2remain -= 8; \
222 }
223
224int mpeg3audio_III_dequantize_sample(mpeg3audio_t *audio,
225 mpeg3_real_t xr[SBLIMIT][SSLIMIT],
226 int *scf,
227 struct gr_info_s *gr_info,
228 int sfreq,
229 int part2bits)
230{
231 int shift = 1 + gr_info->scalefac_scale;
232 mpeg3_real_t *xrpnt = (mpeg3_real_t*)xr;
233 int l[3],l3;
234 int part2remain = gr_info->part2_3_length - part2bits;
235 int *me;
236 int num = mpeg3bits_getbitoffset(audio->astream);
237 long mask = mpeg3bits_getbits(audio->astream, num);
238//printf("III_dequantize_sample 1 %08x %d\n", mask, num);
239 mask = mask << (BITSHIFT + 8 - num);
240 part2remain -= num;
241
242 {
243 int bv = gr_info->big_values;
244 int region1 = gr_info->region1start;
245 int region2 = gr_info->region2start;
246
247 l3 = ((576 >> 1) - bv) >> 1;
248
249/*
250 * we may lose the 'odd' bit here !!
251 * check this later again
252 */
253
254 if(bv <= region1)
255 {
256 l[0] = bv;
257 l[1] = 0;
258 l[2] = 0;
259 }
260 else
261 {
262 l[0] = region1;
263 if(bv <= region2)
264 {
265 l[1] = bv - l[0]; l[2] = 0;
266 }
267 else
268 {
269 l[1] = region2 - l[0];
270 l[2] = bv - region2;
271 }
272 }
273 }
274
275 if(gr_info->block_type == 2)
276 {
277/*
278 * decoding with short or mixed mode BandIndex table
279 */
280 int i, max[4];
281 int step = 0, lwin = 3, cb = 0;
282 register mpeg3_real_t v = 0.0;
283 register int *m, mc;
284
285 if(gr_info->mixed_block_flag)
286 {
287 max[3] = -1;
288 max[0] = max[1] = max[2] = 2;
289 m = mpeg3_map[sfreq][0];
290 me = mpeg3_mapend[sfreq][0];
291 }
292 else
293 {
294 max[0] = max[1] = max[2] = max[3] = -1;
295/* max[3] not floatly needed in this case */
296 m = mpeg3_map[sfreq][1];
297 me = mpeg3_mapend[sfreq][1];
298 }
299
300 mc = 0;
301 for(i = 0; i < 2; i++)
302 {
303 int lp = l[i];
304 struct newhuff *h = mpeg3_ht + gr_info->table_select[i];
305 for( ; lp; lp--, mc--)
306 {
307 register int x,y;
308 if(!mc)
309 {
310 mc = *m++;
311 xrpnt = ((mpeg3_real_t*)xr) + (*m++);
312 lwin = *m++;
313 cb = *m++;
314 if(lwin == 3)
315 {
316 v = gr_info->pow2gain[(*scf++) << shift];
317 step = 1;
318 }
319 else
320 {
321 v = gr_info->full_gain[lwin][(*scf++) << shift];
322 step = 3;
323 }
324 }
325
326 {
327 register short *val = h->table;
328 REFRESH_MASK;
329 while((y = *val++) < 0)
330 {
331 if (mask < 0)
332 val -= y;
333 num--;
334 mask <<= 1;
335 }
336 x = y >> 4;
337 y &= 0xf;
338 }
339
340 if(x == 15 && h->linbits)
341 {
342 max[lwin] = cb;
343 REFRESH_MASK;
344 x += ((unsigned long)mask) >> (BITSHIFT + 8 - h->linbits);
345 num -= h->linbits + 1;
346 mask <<= h->linbits;
347 if(mask < 0)
348 *xrpnt = -mpeg3_ispow[x] * v;
349 else
350 *xrpnt = mpeg3_ispow[x] * v;
351 mask <<= 1;
352 }
353 else
354 if(x)
355 {
356 max[lwin] = cb;
357 if(mask < 0)
358 *xrpnt = -mpeg3_ispow[x] * v;
359 else
360 *xrpnt = mpeg3_ispow[x] * v;
361 num--;
362 mask <<= 1;
363 }
364 else
365 *xrpnt = 0.0;
366
367 xrpnt += step;
368 if(y == 15 && h->linbits)
369 {
370 max[lwin] = cb;
371 REFRESH_MASK;
372 y += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
373 num -= h->linbits + 1;
374 mask <<= h->linbits;
375 if(mask < 0)
376 *xrpnt = -mpeg3_ispow[y] * v;
377 else
378 *xrpnt = mpeg3_ispow[y] * v;
379 mask <<= 1;
380 }
381 else
382 if(y)
383 {
384 max[lwin] = cb;
385 if(mask < 0)
386 *xrpnt = -mpeg3_ispow[y] * v;
387 else
388 *xrpnt = mpeg3_ispow[y] * v;
389 num--;
390 mask <<= 1;
391 }
392 else
393 *xrpnt = 0.0;
394 xrpnt += step;
395 }
396 }
397
398 for( ;l3 && (part2remain + num > 0); l3--)
399 {
400 struct newhuff *h = mpeg3_htc + gr_info->count1table_select;
401 register short *val = h->table, a;
402
403 REFRESH_MASK;
404 while((a = *val++) < 0)
405 {
406 if (mask < 0)
407 val -= a;
408 num--;
409 mask <<= 1;
410 }
411 if(part2remain + num <= 0)
412 {
413 num -= part2remain + num;
414 break;
415 }
416
417 for(i = 0; i < 4; i++)
418 {
419 if(!(i & 1))
420 {
421 if(!mc)
422 {
423 mc = *m++;
424 xrpnt = ((mpeg3_real_t*)xr) + (*m++);
425 lwin = *m++;
426 cb = *m++;
427 if(lwin == 3)
428 {
429 v = gr_info->pow2gain[(*scf++) << shift];
430 step = 1;
431 }
432 else
433 {
434 v = gr_info->full_gain[lwin][(*scf++) << shift];
435 step = 3;
436 }
437 }
438 mc--;
439 }
440 if((a & (0x8 >> i)))
441 {
442 max[lwin] = cb;
443 if(part2remain + num <= 0)
444 {
445 break;
446 }
447 if(mask < 0)
448 *xrpnt = -v;
449 else
450 *xrpnt = v;
451 num--;
452 mask <<= 1;
453 }
454 else
455 *xrpnt = 0.0;
456 xrpnt += step;
457 }
458 }
459
460 if(lwin < 3)
461 {
462/* short band? */
463 while(1)
464 {
465 for( ;mc > 0; mc--)
466 {
467/* short band -> step=3 */
468 *xrpnt = 0.0;
469 xrpnt += 3;
470 *xrpnt = 0.0;
471 xrpnt += 3;
472 }
473 if(m >= me)
474 break;
475 mc = *m++;
476 xrpnt = ((mpeg3_real_t*)xr) + *m++;
477/* optimize: field will be set to zero at the end of the function */
478 if(*m++ == 0)
479 break;
480/* cb */
481 m++;
482 }
483 }
484
485 gr_info->maxband[0] = max[0] + 1;
486 gr_info->maxband[1] = max[1] + 1;
487 gr_info->maxband[2] = max[2] + 1;
488 gr_info->maxbandl = max[3] + 1;
489
490 {
491 int rmax = max[0] > max[1] ? max[0] : max[1];
492 rmax = (rmax > max[2] ? rmax : max[2]) + 1;
493 gr_info->maxb = rmax ? mpeg3_shortLimit[sfreq][rmax] : mpeg3_longLimit[sfreq][max[3] + 1];
494 }
495
496 }
497 else
498 {
499/*
500 * decoding with 'long' BandIndex table (block_type != 2)
501 */
502 int *pretab = gr_info->preflag ? pretab1 : pretab2;
503 int i, max = -1;
504 int cb = 0;
505 int *m = mpeg3_map[sfreq][2];
506 register mpeg3_real_t v = 0.0;
507 int mc = 0;
508
509/*
510 * long hash table values
511 */
512 for(i = 0; i < 3; i++)
513 {
514 int lp = l[i];
515 struct newhuff *h = mpeg3_ht + gr_info->table_select[i];
516
517 for(; lp; lp--, mc--)
518 {
519 int x, y;
520
521 if(!mc)
522 {
523 mc = *m++;
524 cb = *m++;
525 if(cb == 21)
526 v = 0.0;
527 else
528 v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
529 }
530 {
531 register short *val = h->table;
532 REFRESH_MASK;
533 while((y = *val++) < 0)
534 {
535 if(mask < 0)
536 val -= y;
537 num--;
538 mask <<= 1;
539 }
540 x = y >> 4;
541 y &= 0xf;
542 }
543
544 if(x == 15 && h->linbits)
545 {
546 max = cb;
547 REFRESH_MASK;
548 x += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
549 num -= h->linbits + 1;
550 mask <<= h->linbits;
551 if(mask < 0)
552 *xrpnt++ = -mpeg3_ispow[x] * v;
553 else
554 *xrpnt++ = mpeg3_ispow[x] * v;
555 mask <<= 1;
556 }
557 else
558 if(x)
559 {
560 max = cb;
561 if(mask < 0)
562 *xrpnt++ = -mpeg3_ispow[x] * v;
563 else
564 *xrpnt++ = mpeg3_ispow[x] * v;
565 num--;
566 mask <<= 1;
567 }
568 else
569 *xrpnt++ = 0.0;
570
571 if(y == 15 && h->linbits)
572 {
573 max = cb;
574 REFRESH_MASK;
575 y += ((unsigned long) mask) >> (BITSHIFT + 8 - h->linbits);
576 num -= h->linbits + 1;
577 mask <<= h->linbits;
578 if(mask < 0)
579 *xrpnt++ = -mpeg3_ispow[y] * v;
580 else
581 *xrpnt++ = mpeg3_ispow[y] * v;
582 mask <<= 1;
583 }
584 else
585 if(y)
586 {
587 max = cb;
588 if(mask < 0)
589 *xrpnt++ = -mpeg3_ispow[y] * v;
590 else
591 *xrpnt++ = mpeg3_ispow[y] * v;
592 num--;
593 mask <<= 1;
594 }
595 else
596 *xrpnt++ = 0.0;
597 }
598 }
599
600/*
601 * short (count1table) values
602 */
603 for( ; l3 && (part2remain + num > 0); l3--)
604 {
605 struct newhuff *h = mpeg3_htc + gr_info->count1table_select;
606 register short *val = h->table, a;
607
608 REFRESH_MASK;
609 while((a = *val++) < 0)
610 {
611 if(mask < 0)
612 val -= a;
613 num--;
614 mask <<= 1;
615 }
616 if(part2remain + num <= 0)
617 {
618 num -= part2remain + num;
619 break;
620 }
621
622 for(i = 0; i < 4; i++)
623 {
624 if(!(i & 1))
625 {
626 if(!mc)
627 {
628 mc = *m++;
629 cb = *m++;
630 if(cb == 21)
631 v = 0.0;
632 else
633 v = gr_info->pow2gain[((*scf++) + (*pretab++)) << shift];
634 }
635 mc--;
636 }
637 if((a & (0x8 >> i)))
638 {
639 max = cb;
640 if(part2remain + num <= 0)
641 {
642 break;
643 }
644 if(mask < 0)
645 *xrpnt++ = -v;
646 else
647 *xrpnt++ = v;
648 num--;
649 mask <<= 1;
650 }
651 else
652 *xrpnt++ = 0.0;
653 }
654 }
655
656 gr_info->maxbandl = max + 1;
657 gr_info->maxb = mpeg3_longLimit[sfreq][gr_info->maxbandl];
658 }
659
660 part2remain += num;
661
662//printf("III_dequantize_sample 2 %d %04x\n", num, mpeg3bits_showbits(audio->astream, 16));
663 mpeg3bits_start_reverse(audio->astream);
664 mpeg3bits_getbits_reverse(audio->astream, num);
665 mpeg3bits_start_forward(audio->astream);
666//printf("III_dequantize_sample 3 %d %04x\n", audio->astream->bit_number, mpeg3bits_showbits(audio->astream, 16));
667 num = 0;
668
669 while(xrpnt < &xr[SBLIMIT][0])
670 *xrpnt++ = 0.0;
671
672 while(part2remain > 16)
673 {
674 mpeg3bits_getbits(audio->astream, 16); /* Dismiss stuffing Bits */
675 part2remain -= 16;
676 }
677 if(part2remain > 0)
678 {
679 mpeg3bits_getbits(audio->astream, part2remain);
680 }
681 else
682 if(part2remain < 0)
683 {
684 fprintf(stderr,"mpeg3audio_III_dequantize_sample: Can't rewind stream %d bits!\n", -part2remain);
685 return 1; /* -> error */
686 }
687 return 0;
688}
689
690int mpeg3audio_III_get_side_info(mpeg3audio_t *audio,
691 struct mpeg3_III_sideinfo *si,
692 int channels,
693 int ms_stereo,
694 long sfreq,
695 int single,
696 int lsf)
697{
698 int ch, gr;
699 int powdiff = (single == 3) ? 4 : 0;
700 static const int tabs[2][5] = { { 2,9,5,3,4 } , { 1,8,1,2,9 } };
701 const int *tab = tabs[lsf];
702
703 si->main_data_begin = mpeg3bits_getbits(audio->astream, tab[1]);
704 if(channels == 1)
705 si->private_bits = mpeg3bits_getbits(audio->astream, tab[2]);
706 else
707 si->private_bits = mpeg3bits_getbits(audio->astream, tab[3]);
708 if(!lsf)
709 {
710 for(ch = 0; ch < channels; ch++)
711 {
712 si->ch[ch].gr[0].scfsi = -1;
713 si->ch[ch].gr[1].scfsi = mpeg3bits_getbits(audio->astream, 4);
714 }
715 }
716
717 for(gr = 0; gr < tab[0]; gr++)
718 {
719 for(ch = 0; ch < channels; ch++)
720 {
721 register struct gr_info_s *gr_info = &(si->ch[ch].gr[gr]);
722
723 gr_info->part2_3_length = mpeg3bits_getbits(audio->astream, 12);
724 gr_info->big_values = mpeg3bits_getbits(audio->astream, 9);
725 if(gr_info->big_values > 288)
726 {
727 fprintf(stderr,"mpeg3_III_get_side_info: big_values too large!\n");
728 gr_info->big_values = 288;
729 }
730 gr_info->pow2gain = mpeg3_gainpow2 + 256 - mpeg3bits_getbits(audio->astream, 8) + powdiff;
731 if(ms_stereo)
732 gr_info->pow2gain += 2;
733 gr_info->scalefac_compress = mpeg3bits_getbits(audio->astream, tab[4]);
734
735 if(mpeg3bits_getbits(audio->astream, 1))
736 {
737/* window switch flag */
738 int i;
739 gr_info->block_type = mpeg3bits_getbits(audio->astream, 2);
740 gr_info->mixed_block_flag = mpeg3bits_getbits(audio->astream, 1);
741 gr_info->table_select[0] = mpeg3bits_getbits(audio->astream, 5);
742 gr_info->table_select[1] = mpeg3bits_getbits(audio->astream, 5);
743/*
744 * table_select[2] not needed, because there is no region2,
745 * but to satisfy some verifications tools we set it either.
746 */
747 gr_info->table_select[2] = 0;
748 for(i = 0; i < 3; i++)
749 gr_info->full_gain[i] = gr_info->pow2gain + (mpeg3bits_getbits(audio->astream, 3) << 3);
750
751 if(gr_info->block_type == 0)
752 {
753 fprintf(stderr,"Blocktype == 0 and window-switching == 1 not allowed.\n");
754 return 1;
755 }
756
757/* region_count/start parameters are implicit in this case. */
758 if(!lsf || gr_info->block_type == 2)
759 gr_info->region1start = 36 >> 1;
760 else
761 {
762/* check this again for 2.5 and sfreq=8 */
763 if(sfreq == 8)
764 gr_info->region1start = 108 >> 1;
765 else
766 gr_info->region1start = 54 >> 1;
767 }
768 gr_info->region2start = 576 >> 1;
769 }
770 else
771 {
772 int i, r0c, r1c;
773 for(i = 0; i < 3; i++)
774 gr_info->table_select[i] = mpeg3bits_getbits(audio->astream, 5);
775
776 r0c = mpeg3bits_getbits(audio->astream, 4);
777 r1c = mpeg3bits_getbits(audio->astream, 3);
778 gr_info->region1start = mpeg3_bandInfo[sfreq].longIdx[r0c + 1] >> 1 ;
779 gr_info->region2start = mpeg3_bandInfo[sfreq].longIdx[r0c + 1 + r1c + 1] >> 1;
780 gr_info->block_type = 0;
781 gr_info->mixed_block_flag = 0;
782 }
783 if(!lsf) gr_info->preflag = mpeg3bits_getbits(audio->astream, 1);
784 gr_info->scalefac_scale = mpeg3bits_getbits(audio->astream, 1);
785 gr_info->count1table_select = mpeg3bits_getbits(audio->astream, 1);
786 }
787 }
788 return 0;
789}
790
791int mpeg3audio_III_hybrid(mpeg3audio_t *audio,
792 mpeg3_real_t fsIn[SBLIMIT][SSLIMIT],
793 mpeg3_real_t tsOut[SSLIMIT][SBLIMIT],
794 int ch,
795 struct gr_info_s *gr_info)
796{
797 mpeg3_real_t *tspnt = (mpeg3_real_t *) tsOut;
798 mpeg3_real_t *rawout1,*rawout2;
799 int bt, sb = 0;
800
801
802 {
803 int b = audio->mp3_blc[ch];
804 rawout1 = audio->mp3_block[b][ch];
805 b = -b + 1;
806 rawout2 = audio->mp3_block[b][ch];
807 audio->mp3_blc[ch] = b;
808 }
809
810 if(gr_info->mixed_block_flag)
811 {
812 sb = 2;
813 mpeg3audio_dct36(fsIn[0], rawout1, rawout2, mpeg3_win[0], tspnt);
814 mpeg3audio_dct36(fsIn[1], rawout1 + 18, rawout2 + 18, mpeg3_win1[0], tspnt + 1);
815 rawout1 += 36;
816 rawout2 += 36;
817 tspnt += 2;
818 }
819
820 bt = gr_info->block_type;
821 if(bt == 2)
822 {
823 for( ; sb < gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36)
824 {
825 mpeg3audio_dct12(fsIn[sb] ,rawout1 ,rawout2 ,mpeg3_win[2] ,tspnt);
826 mpeg3audio_dct12(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, mpeg3_win1[2], tspnt + 1);
827 }
828 }
829 else
830 {
831 for( ; sb < gr_info->maxb; sb += 2, tspnt += 2, rawout1 += 36, rawout2 += 36)
832 {
833 mpeg3audio_dct36(fsIn[sb], rawout1, rawout2, mpeg3_win[bt], tspnt);
834 mpeg3audio_dct36(fsIn[sb + 1], rawout1 + 18, rawout2 + 18, mpeg3_win1[bt], tspnt + 1);
835 }
836 }
837
838 for( ; sb < SBLIMIT; sb++, tspnt++)
839 {
840 int i;
841 for(i = 0; i < SSLIMIT; i++)
842 {
843 tspnt[i * SBLIMIT] = *rawout1++;
844 *rawout2++ = 0.0;
845 }
846 }
847 return 0;
848}
849
850int mpeg3audio_III_antialias(mpeg3audio_t *audio,
851 mpeg3_real_t xr[SBLIMIT][SSLIMIT],
852 struct gr_info_s *gr_info)
853{
854 int sblim;
855
856 if(gr_info->block_type == 2)
857 {
858 if(!gr_info->mixed_block_flag)
859 return 0;
860 sblim = 1;
861 }
862 else
863 {
864 sblim = gr_info->maxb-1;
865 }
866
867/* 31 alias-reduction operations between each pair of sub-bands */
868/* with 8 butterflies between each pair */
869
870 {
871 int sb;
872 mpeg3_real_t *xr1 = (mpeg3_real_t*)xr[1];
873
874 for(sb = sblim; sb; sb--, xr1 += 10)
875 {
876 int ss;
877 mpeg3_real_t *cs, *ca;
878 mpeg3_real_t *xr2;
879 cs = mpeg3_aa_cs;
880 ca = mpeg3_aa_ca;
881 xr2 = xr1;
882
883 for(ss = 7; ss >= 0; ss--)
884 {
885/* upper and lower butterfly inputs */
886 register mpeg3_real_t bu, bd;
887 bu = *--xr2;
888 bd = *xr1;
889 *xr2 = (bu * (*cs) ) - (bd * (*ca) );
890 *xr1++ = (bd * (*cs++) ) + (bu * (*ca++) );
891 }
892 }
893 }
894 return 0;
895}
896
897/*
898 * III_stereo: calculate mpeg3_real_t channel values for Joint-I-Stereo-mode
899 */
900int mpeg3audio_III_i_stereo(mpeg3audio_t *audio,
901 mpeg3_real_t xr_buf[2][SBLIMIT][SSLIMIT],
902 int *scalefac,
903 struct gr_info_s *gr_info,
904 int sfreq,
905 int ms_stereo,
906 int lsf)
907{
908 mpeg3_real_t (*xr)[SBLIMIT*SSLIMIT] = (mpeg3_real_t (*)[SBLIMIT*SSLIMIT] ) xr_buf;
909 struct mpeg3_bandInfoStruct *bi = &mpeg3_bandInfo[sfreq];
910 const mpeg3_real_t *tab1, *tab2;
911
912 int tab;
913/* TODO: optimize as static */
914 static const mpeg3_real_t *tabs[3][2][2] =
915 {
916 { { mpeg3_tan1_1, mpeg3_tan2_1 } , { mpeg3_tan1_2, mpeg3_tan2_2 } },
917 { { mpeg3_pow1_1[0], mpeg3_pow2_1[0] } , { mpeg3_pow1_2[0], mpeg3_pow2_2[0] } } ,
918 { { mpeg3_pow1_1[1], mpeg3_pow2_1[1] } , { mpeg3_pow1_2[1], mpeg3_pow2_2[1] } }
919 };
920
921 tab = lsf + (gr_info->scalefac_compress & lsf);
922 tab1 = tabs[tab][ms_stereo][0];
923 tab2 = tabs[tab][ms_stereo][1];
924
925 if(gr_info->block_type == 2)
926 {
927 int lwin,do_l = 0;
928 if(gr_info->mixed_block_flag)
929 do_l = 1;
930
931 for(lwin = 0; lwin < 3; lwin++)
932 {
933/* process each window */
934/* get first band with zero values */
935/* sfb is minimal 3 for mixed mode */
936 int is_p, sb, idx, sfb = gr_info->maxband[lwin];
937 if(sfb > 3) do_l = 0;
938
939 for( ; sfb < 12 ; sfb++)
940 {
941/* scale: 0-15 */
942 is_p = scalefac[sfb * 3 + lwin - gr_info->mixed_block_flag];
943 if(is_p != 7)
944 {
945 mpeg3_real_t t1, t2;
946 sb = bi->shortDiff[sfb];
947 idx = bi->shortIdx[sfb] + lwin;
948 t1 = tab1[is_p];
949 t2 = tab2[is_p];
950 for( ; sb > 0; sb--, idx += 3)
951 {
952 mpeg3_real_t v = xr[0][idx];
953 xr[0][idx] = v * t1;
954 xr[1][idx] = v * t2;
955 }
956 }
957 }
958
959/* in the original: copy 10 to 11 , here: copy 11 to 12
960maybe still wrong??? (copy 12 to 13?) */
961/* scale: 0-15 */
962 is_p = scalefac[11 * 3 + lwin - gr_info->mixed_block_flag];
963 sb = bi->shortDiff[12];
964 idx = bi->shortIdx[12] + lwin;
965 if(is_p != 7)
966 {
967 mpeg3_real_t t1, t2;
968 t1 = tab1[is_p];
969 t2 = tab2[is_p];
970 for( ; sb > 0; sb--, idx += 3)
971 {
972 mpeg3_real_t v = xr[0][idx];
973 xr[0][idx] = v * t1;
974 xr[1][idx] = v * t2;
975 }
976 }
977 } /* end for(lwin; .. ; . ) */
978
979/* also check l-part, if ALL bands in the three windows are 'empty'
980* and mode = mixed_mode
981*/
982 if(do_l)
983 {
984 int sfb = gr_info->maxbandl;
985 int idx = bi->longIdx[sfb];
986
987 for ( ; sfb < 8; sfb++)
988 {
989 int sb = bi->longDiff[sfb];
990/* scale: 0-15 */
991 int is_p = scalefac[sfb];
992 if(is_p != 7)
993 {
994 mpeg3_real_t t1, t2;
995 t1 = tab1[is_p];
996 t2 = tab2[is_p];
997 for( ; sb > 0; sb--, idx++)
998 {
999 mpeg3_real_t v = xr[0][idx];
1000 xr[0][idx] = v * t1;
1001 xr[1][idx] = v * t2;
1002 }
1003 }
1004 else
1005 idx += sb;
1006 }
1007 }
1008 }
1009 else
1010 {
1011/* ((gr_info->block_type != 2)) */
1012 int sfb = gr_info->maxbandl;
1013 int is_p, idx = bi->longIdx[sfb];
1014 for( ; sfb < 21; sfb++)
1015 {
1016 int sb = bi->longDiff[sfb];
1017/* scale: 0-15 */
1018 is_p = scalefac[sfb];
1019 if(is_p != 7)
1020 {
1021 mpeg3_real_t t1, t2;
1022 t1 = tab1[is_p];
1023 t2 = tab2[is_p];
1024 for( ; sb > 0; sb--, idx++)
1025 {
1026 mpeg3_real_t v = xr[0][idx];
1027 xr[0][idx] = v * t1;
1028 xr[1][idx] = v * t2;
1029 }
1030 }
1031 else
1032 idx += sb;
1033 }
1034
1035 is_p = scalefac[20];
1036 if(is_p != 7)
1037 {
1038/* copy l-band 20 to l-band 21 */
1039 int sb;
1040 mpeg3_real_t t1 = tab1[is_p], t2 = tab2[is_p];
1041
1042 for(sb = bi->longDiff[21]; sb > 0; sb--, idx++)
1043 {
1044 mpeg3_real_t v = xr[0][idx];
1045 xr[0][idx] = v * t1;
1046 xr[1][idx] = v * t2;
1047 }
1048 }
1049 } /* ... */
1050}
1051
1052/* Read just the frame after a seek. */
1053int mpeg3audio_read_layer3_frame(mpeg3audio_t *audio)
1054{
1055 int result = 0;
1056
1057 result = mpeg3audio_read_header(audio);
1058 if(!result)
1059 {
1060 audio->bsbufold = audio->bsbuf;
1061 audio->bsbuf = audio->bsspace[audio->bsnum] + 512;
1062 audio->bsnum ^= 1;
1063 result = mpeg3bits_read_buffer(audio->astream, audio->bsbuf, audio->framesize);
1064 }
1065
1066 return result;
1067}
1068
1069int mpeg3audio_dolayer3(mpeg3audio_t *audio)
1070{
1071 int gr, ch, ss;
1072 int scalefacs[2][39]; /* max 39 for short[13][3] mode, mixed: 38, long: 22 */
1073 struct mpeg3_III_sideinfo sideinfo;
1074 int channels = audio->channels;
1075 int single = audio->single;
1076 int ms_stereo, i_stereo;
1077 int sfreq = audio->sampling_frequency_code;
1078 int stereo1, granules;
1079 int i;
1080
1081/* flip/init buffer */
1082 audio->bsbufold = audio->bsbuf;
1083 audio->bsbuf = audio->bsspace[audio->bsnum] + 512;
1084 audio->bsnum ^= 1;
1085
1086/* read main data into memory */
1087 if(mpeg3bits_read_buffer(audio->astream, audio->bsbuf, audio->framesize))
1088 return 1;
1089 mpeg3bits_use_ptr(audio->astream, audio->bsbuf);
1090
1091/* CRC must be skipped here for proper alignment with the backstep */
1092 if(audio->error_protection)
1093 mpeg3bits_getbits(audio->astream, 16);
1094
1095 if(channels == 1)
1096 {
1097/* stream is mono */
1098 stereo1 = 1;
1099 single = 0;
1100 }
1101 else
1102 {
1103/* Stereo */
1104 stereo1 = 2;
1105 }
1106
1107 if(audio->mode == MPG_MD_JOINT_STEREO)
1108 {
1109 ms_stereo = (audio->mode_ext & 0x2) >> 1;
1110 i_stereo = audio->mode_ext & 0x1;
1111 }
1112 else
1113 ms_stereo = i_stereo = 0;
1114
1115 if(audio->lsf)
1116 {
1117 granules = 1;
1118 }
1119 else
1120 {
1121 granules = 2;
1122 }
1123
1124 if(mpeg3audio_III_get_side_info(audio, &sideinfo, channels, ms_stereo, sfreq, single, audio->lsf))
1125 return 1;
1126
1127/* Step back */
1128 if(sideinfo.main_data_begin >= 512)
1129 return 1;
1130
1131 if(sideinfo.main_data_begin)
1132 {
1133 memcpy(audio->bsbuf + audio->ssize - sideinfo.main_data_begin,
1134 audio->bsbufold + audio->prev_framesize - sideinfo.main_data_begin,
1135 sideinfo.main_data_begin);
1136 mpeg3bits_use_ptr(audio->astream, audio->bsbuf + audio->ssize - sideinfo.main_data_begin);
1137 }
1138
1139 for(gr = 0; gr < granules; gr++)
1140 {
1141 mpeg3_real_t hybridIn [2][SBLIMIT][SSLIMIT];
1142 mpeg3_real_t hybridOut[2][SSLIMIT][SBLIMIT];
1143
1144 {
1145 struct gr_info_s *gr_info = &(sideinfo.ch[0].gr[gr]);
1146 long part2bits;
1147 if(audio->lsf)
1148 part2bits = mpeg3audio_III_get_scale_factors_2(audio, scalefacs[0], gr_info, 0);
1149 else
1150 part2bits = mpeg3audio_III_get_scale_factors_1(audio, scalefacs[0], gr_info, 0, gr);
1151//printf("dolayer3 4 %04x\n", mpeg3bits_showbits(audio->astream, 16));
1152
1153 if(mpeg3audio_III_dequantize_sample(audio, hybridIn[0], scalefacs[0], gr_info, sfreq, part2bits))
1154 {
1155 mpeg3bits_use_demuxer(audio->astream);
1156 return 1;
1157 }
1158//printf("dolayer3 5 %04x\n", mpeg3bits_showbits(audio->astream, 16));
1159 }
1160
1161 if(channels == 2)
1162 {
1163 struct gr_info_s *gr_info = &(sideinfo.ch[1].gr[gr]);
1164 long part2bits;
1165 if(audio->lsf)
1166 part2bits = mpeg3audio_III_get_scale_factors_2(audio, scalefacs[1], gr_info, i_stereo);
1167 else
1168 part2bits = mpeg3audio_III_get_scale_factors_1(audio, scalefacs[1], gr_info, 1, gr);
1169
1170 if(mpeg3audio_III_dequantize_sample(audio, hybridIn[1], scalefacs[1], gr_info, sfreq, part2bits))
1171 {
1172 mpeg3bits_use_demuxer(audio->astream);
1173 return 1;
1174 }
1175
1176 if(ms_stereo)
1177 {
1178 int i;
1179 int maxb = sideinfo.ch[0].gr[gr].maxb;
1180 if(sideinfo.ch[1].gr[gr].maxb > maxb)
1181 maxb = sideinfo.ch[1].gr[gr].maxb;
1182 for(i = 0; i < SSLIMIT * maxb; i++)
1183 {
1184 mpeg3_real_t tmp0 = ((mpeg3_real_t*)hybridIn[0])[i];
1185 mpeg3_real_t tmp1 = ((mpeg3_real_t*)hybridIn[1])[i];
1186 ((mpeg3_real_t*)hybridIn[0])[i] = tmp0 + tmp1;
1187 ((mpeg3_real_t*)hybridIn[1])[i] = tmp0 - tmp1;
1188 }
1189 }
1190
1191 if(i_stereo)
1192 mpeg3audio_III_i_stereo(audio, hybridIn, scalefacs[1], gr_info, sfreq, ms_stereo, audio->lsf);
1193
1194 if(ms_stereo || i_stereo || (single == 3))
1195 {
1196 if(gr_info->maxb > sideinfo.ch[0].gr[gr].maxb)
1197 sideinfo.ch[0].gr[gr].maxb = gr_info->maxb;
1198 else
1199 gr_info->maxb = sideinfo.ch[0].gr[gr].maxb;
1200 }
1201
1202 switch(single)
1203 {
1204 case 3:
1205 {
1206 register int i;
1207 register mpeg3_real_t *in0 = (mpeg3_real_t*)hybridIn[0], *in1 = (mpeg3_real_t*)hybridIn[1];
1208/* *0.5 done by pow-scale */
1209 for(i = 0; i < SSLIMIT * gr_info->maxb; i++, in0++)
1210 *in0 = (*in0 + *in1++);
1211 }
1212 break;
1213 case 1:
1214 {
1215 register int i;
1216 register mpeg3_real_t *in0 = (mpeg3_real_t*)hybridIn[0], *in1 = (mpeg3_real_t*)hybridIn[1];
1217 for(i = 0; i < SSLIMIT * gr_info->maxb; i++)
1218 *in0++ = *in1++;
1219 }
1220 break;
1221 }
1222 }
1223
1224 for(ch = 0; ch < stereo1; ch++)
1225 {
1226 struct gr_info_s *gr_info = &(sideinfo.ch[ch].gr[gr]);
1227 mpeg3audio_III_antialias(audio, hybridIn[ch], gr_info);
1228 mpeg3audio_III_hybrid(audio, hybridIn[ch], hybridOut[ch], ch, gr_info);
1229 }
1230
1231 for(ss = 0; ss < SSLIMIT; ss++)
1232 {
1233 if(single >= 0)
1234 {
1235 mpeg3audio_synth_mono(audio, hybridOut[0][ss], audio->pcm_sample, &(audio->pcm_point));
1236 }
1237 else
1238 {
1239 int p1 = audio->pcm_point;
1240 mpeg3audio_synth_stereo(audio, hybridOut[0][ss], 0, audio->pcm_sample, &p1);
1241 mpeg3audio_synth_stereo(audio, hybridOut[1][ss], 1, audio->pcm_sample, &(audio->pcm_point));
1242 }
1243
1244 if(audio->pcm_point / audio->channels >= audio->pcm_allocated - MPEG3AUDIO_PADDING * audio->channels)
1245 {
1246/* Need more room */
1247 mpeg3audio_replace_buffer(audio, audio->pcm_allocated + MPEG3AUDIO_PADDING * audio->channels);
1248 }
1249 }
1250 }
1251
1252 mpeg3bits_use_demuxer(audio->astream);
1253 return 0;
1254}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/mantissa.c b/core/multimedia/opieplayer/libmpeg3/audio/mantissa.c
new file mode 100644
index 0000000..05fe251
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/mantissa.c
@@ -0,0 +1,387 @@
1/*
2 *
3 *mantissa.c Copyright (C) Aaron Holtzman - May 1999
4 *
5 *
6 * This file is part of libmpeg3
7 *
8 * libmpeg3 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, or (at your option)
11 * any later version.
12 *
13 * libmpeg3 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 GNU Make; see the file COPYING. If not, write to
20 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
21 *
22 */
23
24#include "mpeg3audio.h"
25#include "../libmpeg3.h"
26#include "../mpeg3protos.h"
27
28
29/* Lookup tables of 0.16 two's complement quantization values */
30static short mpeg3_q_1[3] =
31{
32 (-2 << 15) / 3,
33 0,
34 (2 << 15) / 3
35};
36
37static short mpeg3_q_2[5] =
38{
39 (-4 << 15) / 5,
40 ((-2 << 15) / 5) << 1,
41 0,
42 (2 << 15) / 5,
43 ((4 << 15) / 5) << 1
44};
45
46static short mpeg3_q_3[7] =
47{
48 (-6 << 15) / 7,
49 (-4 << 15) / 7,
50 (-2 << 15) / 7,
51 0,
52 (2 << 15) / 7,
53 (4 << 15) / 7,
54 (6 << 15) / 7
55};
56
57static short mpeg3_q_4[11] =
58{
59 (-10 << 15) / 11,
60 (-8 << 15) / 11,
61 (-6 << 15) / 11,
62 (-4 << 15) / 11,
63 (-2 << 15) / 11,
64 0,
65 ( 2 << 15) / 11,
66 ( 4 << 15) / 11,
67 ( 6 << 15) / 11,
68 ( 8 << 15) / 11,
69 (10 << 15) / 11
70};
71
72static short mpeg3_q_5[15] =
73{
74 (-14 << 15) / 15,
75 (-12 << 15) / 15,
76 (-10 << 15) / 15,
77 (-8 << 15) / 15,
78 (-6 << 15) / 15,
79 (-4 << 15) / 15,
80 (-2 << 15) / 15,
81 0,
82 ( 2 << 15) / 15,
83 ( 4 << 15) / 15,
84 ( 6 << 15) / 15,
85 ( 8 << 15) / 15,
86 (10 << 15) / 15,
87 (12 << 15) / 15,
88 (14 << 15) / 15
89};
90
91static short mpeg3_qnttztab[16] = {0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16};
92
93
94/* */
95/* Scale factors for tofloat */
96/* */
97
98static const unsigned MPEG3_INT32 mpeg3_scale_factors[25] =
99{
100 0x38000000, /*2 ^ -(0 + 15) */
101 0x37800000, /*2 ^ -(1 + 15) */
102 0x37000000, /*2 ^ -(2 + 15) */
103 0x36800000, /*2 ^ -(3 + 15) */
104 0x36000000, /*2 ^ -(4 + 15) */
105 0x35800000, /*2 ^ -(5 + 15) */
106 0x35000000, /*2 ^ -(6 + 15) */
107 0x34800000, /*2 ^ -(7 + 15) */
108 0x34000000, /*2 ^ -(8 + 15) */
109 0x33800000, /*2 ^ -(9 + 15) */
110 0x33000000, /*2 ^ -(10 + 15) */
111 0x32800000, /*2 ^ -(11 + 15) */
112 0x32000000, /*2 ^ -(12 + 15) */
113 0x31800000, /*2 ^ -(13 + 15) */
114 0x31000000, /*2 ^ -(14 + 15) */
115 0x30800000, /*2 ^ -(15 + 15) */
116 0x30000000, /*2 ^ -(16 + 15) */
117 0x2f800000, /*2 ^ -(17 + 15) */
118 0x2f000000, /*2 ^ -(18 + 15) */
119 0x2e800000, /*2 ^ -(19 + 15) */
120 0x2e000000, /*2 ^ -(20 + 15) */
121 0x2d800000, /*2 ^ -(21 + 15) */
122 0x2d000000, /*2 ^ -(22 + 15) */
123 0x2c800000, /*2 ^ -(23 + 15) */
124 0x2c000000 /*2 ^ -(24 + 15) */
125};
126
127static MPEG3_FLOAT32 *mpeg3_scale_factor = (MPEG3_FLOAT32*)mpeg3_scale_factors;
128
129static inline mpeg3_real_t mpeg3audio_ac3_tofloat(unsigned short exponent, int mantissa)
130{
131 mpeg3_real_t x;
132 x = mantissa * mpeg3_scale_factor[exponent];
133 return x;
134}
135
136static inline void mpeg3audio_ac3_mantissa_reset(mpeg3_ac3_mantissa_t *mantissa)
137{
138 mantissa->m_1[2] = mantissa->m_1[1] = mantissa->m_1[0] = 0;
139 mantissa->m_2[2] = mantissa->m_2[1] = mantissa->m_2[0] = 0;
140 mantissa->m_4[1] = mantissa->m_4[0] = 0;
141/* Force new groups to be loaded */
142 mantissa->m_1_pointer = mantissa->m_2_pointer = mantissa->m_4_pointer = 3;
143}
144
145/*
146 * Generate eight bits of pseudo-entropy using a 16 bit linear
147 * feedback shift register (LFSR). The primitive polynomial used
148 * is 1 + x^4 + x^14 + x^16.
149 *
150 * The distribution is uniform, over the range [-0.707,0.707]
151 *
152 */
153inline unsigned int mpeg3audio_ac3_dither_gen(mpeg3audio_t *audio)
154{
155 int i;
156 unsigned int state;
157
158/* explicitly bring the state into a local var as gcc > 3.0? */
159/* doesn't know how to optimize out the stores */
160 state = audio->ac3_lfsr_state;
161
162/* Generate eight pseudo random bits */
163 for(i = 0; i < 8; i++)
164 {
165 state <<= 1;
166
167 if(state & 0x10000)
168 state ^= 0xa011;
169 }
170
171 audio->ac3_lfsr_state = state;
172 return (((((int)state << 8) >> 8) * (int)(0.707106f * 256.0f)) >> 16);
173}
174
175
176/* Fetch an unpacked, left justified, and properly biased/dithered mantissa value */
177static inline unsigned short mpeg3audio_ac3_mantissa_get(mpeg3audio_t *audio,
178 unsigned short bap,
179 unsigned short dithflag)
180{
181 unsigned short mantissa;
182 unsigned int group_code;
183 mpeg3_ac3_mantissa_t *mantissa_struct = &(audio->ac3_mantissa);
184
185/* If the bap is 0-5 then we have special cases to take care of */
186 switch(bap)
187 {
188 case 0:
189 if(dithflag)
190 mantissa = mpeg3audio_ac3_dither_gen(audio);
191 else
192 mantissa = 0;
193 break;
194
195 case 1:
196 if(mantissa_struct->m_1_pointer > 2)
197 {
198 group_code = mpeg3bits_getbits(audio->astream, 5);
199
200 if(group_code > 26)
201 {
202/* FIXME do proper block error handling */
203 fprintf(stderr, "mpeg3audio_ac3_mantissa_get: Invalid mantissa 1 %d\n", group_code);
204 return 0;
205 }
206
207 mantissa_struct->m_1[0] = group_code / 9;
208 mantissa_struct->m_1[1] = (group_code % 9) / 3;
209 mantissa_struct->m_1[2] = (group_code % 9) % 3;
210 mantissa_struct->m_1_pointer = 0;
211 }
212 mantissa = mantissa_struct->m_1[mantissa_struct->m_1_pointer++];
213 mantissa = mpeg3_q_1[mantissa];
214 break;
215
216 case 2:
217 if(mantissa_struct->m_2_pointer > 2)
218 {
219 group_code = mpeg3bits_getbits(audio->astream, 7);
220
221 if(group_code > 124)
222 {
223 fprintf(stderr, "mpeg3audio_ac3_mantissa_get: Invalid mantissa 2 %d\n", group_code);
224 return 0;
225 }
226
227 mantissa_struct->m_2[0] = group_code / 25;
228 mantissa_struct->m_2[1] = (group_code % 25) / 5;
229 mantissa_struct->m_2[2] = (group_code % 25) % 5;
230 mantissa_struct->m_2_pointer = 0;
231 }
232 mantissa = mantissa_struct->m_2[mantissa_struct->m_2_pointer++];
233 mantissa = mpeg3_q_2[mantissa];
234 break;
235
236 case 3:
237 mantissa = mpeg3bits_getbits(audio->astream, 3);
238
239 if(mantissa > 6)
240 {
241 fprintf(stderr, "mpeg3audio_ac3_mantissa_get: Invalid mantissa 3 %d\n", mantissa);
242 return 0;
243 }
244
245 mantissa = mpeg3_q_3[mantissa];
246 break;
247
248 case 4:
249 if(mantissa_struct->m_4_pointer > 1)
250 {
251 group_code = mpeg3bits_getbits(audio->astream, 7);
252
253 if(group_code > 120)
254 {
255 fprintf(stderr, "mpeg3audio_ac3_mantissa_get: Invalid mantissa 4 %d\n", group_code);
256 return 0;
257 }
258
259 mantissa_struct->m_4[0] = group_code / 11;
260 mantissa_struct->m_4[1] = group_code % 11;
261 mantissa_struct->m_4_pointer = 0;
262 }
263 mantissa = mantissa_struct->m_4[mantissa_struct->m_4_pointer++];
264 mantissa = mpeg3_q_4[mantissa];
265 break;
266
267 case 5:
268 mantissa = mpeg3bits_getbits(audio->astream, 4);
269
270 if(mantissa > 14)
271 {
272/* FIXME do proper block error handling */
273 fprintf(stderr, "mpeg3audio_ac3_mantissa_get: Invalid mantissa 5 %d\n", mantissa);
274 return 0;
275 }
276
277 mantissa = mpeg3_q_5[mantissa];
278 break;
279
280 default:
281 mantissa = mpeg3bits_getbits(audio->astream, mpeg3_qnttztab[bap]);
282 mantissa <<= 16 - mpeg3_qnttztab[bap];
283 }
284 return mantissa;
285}
286
287void mpeg3audio_ac3_uncouple_channel(mpeg3audio_t *audio,
288 mpeg3_real_t samples[],
289 mpeg3_ac3bsi_t *bsi,
290 mpeg3_ac3audblk_t *audblk,
291 unsigned int ch)
292{
293 unsigned int bnd = 0;
294 unsigned int sub_bnd = 0;
295 unsigned int i, j;
296 MPEG3_FLOAT32 cpl_coord = 1.0;
297 unsigned int cpl_exp_tmp;
298 unsigned int cpl_mant_tmp;
299 short mantissa;
300
301 for(i = audblk->cplstrtmant; i < audblk->cplendmant; )
302 {
303 if(!audblk->cplbndstrc[sub_bnd++])
304 {
305 cpl_exp_tmp = audblk->cplcoexp[ch][bnd] + 3 * audblk->mstrcplco[ch];
306 if(audblk->cplcoexp[ch][bnd] == 15)
307 cpl_mant_tmp = (audblk->cplcomant[ch][bnd]) << 11;
308 else
309 cpl_mant_tmp = ((0x10) | audblk->cplcomant[ch][bnd]) << 10;
310
311 cpl_coord = mpeg3audio_ac3_tofloat(cpl_exp_tmp, cpl_mant_tmp) * 8.0f;
312
313/*Invert the phase for the right channel if necessary */
314 if(bsi->acmod == 0x2 && audblk->phsflginu && ch == 1 && audblk->phsflg[bnd])
315 cpl_coord *= -1;
316
317 bnd++;
318 }
319
320 for(j = 0; j < 12; j++)
321 {
322/* Get new dither values for each channel if necessary, so */
323/* the channels are uncorrelated */
324 if(audblk->dithflag[ch] && audblk->cpl_bap[i] == 0)
325 mantissa = mpeg3audio_ac3_dither_gen(audio);
326 else
327 mantissa = audblk->cplmant[i];
328
329 samples[i] = cpl_coord * mpeg3audio_ac3_tofloat(audblk->cpl_exp[i], mantissa);;
330
331 i++;
332 }
333 }
334 return;
335}
336
337int mpeg3audio_ac3_coeff_unpack(mpeg3audio_t *audio,
338 mpeg3_ac3bsi_t *bsi,
339 mpeg3_ac3audblk_t *audblk,
340 mpeg3ac3_stream_samples_t samples)
341{
342 int i, j;
343 int done_cpl = 0;
344 short mantissa;
345
346 mpeg3audio_ac3_mantissa_reset(&(audio->ac3_mantissa));
347
348 for(i = 0; i < bsi->nfchans && !mpeg3bits_error(audio->astream); i++)
349 {
350 for(j = 0; j < audblk->endmant[i] && !mpeg3bits_error(audio->astream); j++)
351 {
352 mantissa = mpeg3audio_ac3_mantissa_get(audio, audblk->fbw_bap[i][j], audblk->dithflag[i]);
353 samples[i][j] = mpeg3audio_ac3_tofloat(audblk->fbw_exp[i][j], mantissa);
354 }
355
356 if(audblk->cplinu && audblk->chincpl[i] && !(done_cpl) && !mpeg3bits_error(audio->astream))
357 {
358/* ncplmant is equal to 12 * ncplsubnd */
359/* Don't dither coupling channel until channel separation so that
360 * interchannel noise is uncorrelated */
361 for(j = audblk->cplstrtmant;
362 j < audblk->cplendmant && !mpeg3bits_error(audio->astream);
363 j++)
364 {
365 audblk->cplmant[j] = mpeg3audio_ac3_mantissa_get(audio, audblk->cpl_bap[j], 0);
366 }
367 done_cpl = 1;
368 }
369 }
370
371/* Uncouple the channel */
372 if(audblk->cplinu)
373 {
374 if(audblk->chincpl[i])
375 mpeg3audio_ac3_uncouple_channel(audio, samples[i], bsi, audblk, i);
376 }
377
378 if(bsi->lfeon && !mpeg3bits_error(audio->astream))
379 {
380/* There are always 7 mantissas for lfe, no dither for lfe */
381 for(j = 0; j < 7 && !mpeg3bits_error(audio->astream); j++)
382 mantissa = mpeg3audio_ac3_mantissa_get(audio, audblk->lfe_bap[j], 0);
383 samples[5][j] = mpeg3audio_ac3_tofloat(audblk->lfe_exp[j], mantissa);
384 }
385
386 return mpeg3bits_error(audio->astream);
387}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.c b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.c
new file mode 100644
index 0000000..e2d3912
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.c
@@ -0,0 +1,536 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3audio.h"
4#include "tables.h"
5
6#include <math.h>
7#include <stdlib.h>
8
9mpeg3audio_t* mpeg3audio_allocate_struct(mpeg3_t *file, mpeg3_atrack_t *track)
10{
11 mpeg3audio_t *audio = (mpeg3audio_t*)calloc(1, sizeof(mpeg3audio_t));
12 audio->file = file;
13 audio->track = track;
14 audio->astream = mpeg3bits_new_stream(file, track->demuxer);
15 audio->outscale = 1;
16 audio->bsbuf = audio->bsspace[1];
17 audio->init = 1;
18 audio->bo = 1;
19 audio->channels = 1;
20 return audio;
21}
22
23
24int mpeg3audio_delete_struct(mpeg3audio_t *audio)
25{
26 mpeg3bits_delete_stream(audio->astream);
27 if(audio->pcm_sample) free(audio->pcm_sample);
28 free(audio);
29 return 0;
30}
31
32int mpeg3audio_replace_buffer(mpeg3audio_t *audio, long new_allocation)
33{
34 long i;
35
36 audio->pcm_sample = (mpeg3_real_t*)realloc( audio->pcm_sample, sizeof(mpeg3_real_t) * new_allocation * audio->channels );
37 audio->pcm_allocated = new_allocation;
38/*
39 // Isn't this exactly the same as what the ANSI C function call realloc does,
40 // or did I miss C Programming 101 ?
41
42 if(!audio->pcm_sample)
43 {
44 audio->pcm_sample = (mpeg3_real_t*)malloc(sizeof(mpeg3_real_t) * new_allocation * audio->channels);
45 audio->pcm_allocated = new_allocation;
46 }
47 else
48 {
49 mpeg3_real_t *new_samples = (mpeg3_real_t*)malloc(sizeof(mpeg3_real_t) * new_allocation * audio->channels);
50 for(i = 0; i < audio->pcm_allocated * audio->channels; i++)
51 {
52 new_samples[i] = audio->pcm_sample[i];
53 }
54 free(audio->pcm_sample);
55 audio->pcm_sample = new_samples;
56 audio->pcm_allocated = new_allocation;
57 }
58*/
59 return 0;
60}
61
62int mpeg3audio_read_frame(mpeg3audio_t *audio)
63{
64 int result = 0;
65 result = mpeg3audio_read_header(audio);
66
67 if(!result)
68 {
69 switch(audio->format)
70 {
71 case AUDIO_AC3:
72 result = mpeg3audio_do_ac3(audio);
73 break;
74
75 case AUDIO_MPEG:
76 switch(audio->layer)
77 {
78 case 1:
79 break;
80
81 case 2:
82 result = mpeg3audio_dolayer2(audio);
83 break;
84
85 case 3:
86 result = mpeg3audio_dolayer3(audio);
87 break;
88
89 default:
90 result = 1;
91 break;
92 }
93 break;
94
95 case AUDIO_PCM:
96 result = mpeg3audio_do_pcm(audio);
97 break;
98 }
99 }
100
101 if(!result)
102 {
103/* Byte align the stream */
104 mpeg3bits_byte_align(audio->astream);
105 }
106 return result;
107}
108
109/* Get the length but also initialize the frame sizes. */
110int mpeg3audio_get_length(mpeg3audio_t *audio, mpeg3_atrack_t *track)
111{
112 long result = 0;
113 long framesize1 = 0, total1 = 0;
114 long framesize2 = 0, total2 = 0;
115 long total_framesize = 0, total_frames = 0;
116 long byte_limit = 131072; /* Total bytes to gather information from */
117 long total_bytes = 0;
118 long major_framesize; /* Bigger framesize + header */
119 long minor_framesize; /* Smaller framesize + header */
120 long major_total;
121 long minor_total;
122 mpeg3_t *file = audio->file;
123
124/* Get the frame sizes */
125 mpeg3bits_seek_start(audio->astream);
126 audio->pcm_point = 0;
127 result = mpeg3audio_read_frame(audio); /* Stores the framesize */
128 audio->samples_per_frame = audio->pcm_point / audio->channels;
129
130 switch(audio->format)
131 {
132 case AUDIO_AC3:
133 audio->avg_framesize = audio->framesize;
134 break;
135
136 case AUDIO_MPEG:
137 framesize1 = audio->framesize;
138 total_bytes += audio->framesize;
139 total1 = 1;
140
141 while(!result && total_bytes < byte_limit)
142 {
143 audio->pcm_point = 0;
144 result = mpeg3audio_read_frame(audio);
145 total_bytes += audio->framesize;
146 if(audio->framesize != framesize1)
147 {
148 framesize2 = audio->framesize;
149 total2 = 1;
150 break;
151 }
152 else
153 {
154 total1++;
155 }
156 }
157
158 while(!result && total_bytes < byte_limit)
159 {
160 audio->pcm_point = 0;
161 result = mpeg3audio_read_frame(audio);
162 total_bytes += audio->framesize;
163 if(audio->framesize != framesize2)
164 {
165 break;
166 }
167 else
168 {
169 total2++;
170 }
171 }
172
173 audio->pcm_point = 0;
174 result = mpeg3audio_read_frame(audio);
175 if(audio->framesize != framesize1 && audio->framesize != framesize2)
176 {
177/* Variable bit rate. Get the average frame size. */
178 while(!result && total_bytes < byte_limit)
179 {
180 audio->pcm_point = 0;
181 result = mpeg3audio_read_frame(audio);
182 total_bytes += audio->framesize;
183 if(!result)
184 {
185 total_framesize += audio->framesize;
186 total_frames++;
187 }
188 }
189 audio->avg_framesize = 4 + (total_framesize + framesize1 + framesize2) / (total_frames + total1 + total2);
190 }
191 else
192 {
193 major_framesize = framesize2 > framesize1 ? framesize2 : framesize1;
194 major_total = framesize2 > framesize1 ? total2 : total1;
195 minor_framesize = framesize2 > framesize1 ? framesize1 : framesize2;
196 minor_total = framesize2 > framesize1 ? total1 : total2;
197/* Add the headers to the framesizes */
198 audio->avg_framesize = 4 + (major_framesize * major_total + minor_framesize * minor_total) / (major_total + minor_total);
199 }
200 break;
201
202 case AUDIO_PCM:
203 break;
204 }
205
206/* Estimate the total samples */
207 if(file->is_audio_stream)
208 {
209/* From the raw file */
210 result = (long)((float)mpeg3demuxer_total_bytes(audio->astream->demuxer) / audio->avg_framesize * audio->samples_per_frame);
211 }
212 else
213 {
214/* Gross approximation from a multiplexed file. */
215 result = (long)(mpeg3demux_length(audio->astream->demuxer) * track->sample_rate);
216 /* result = (long)((mpeg3_real_t)mpeg3_video_frames(file, 0) / mpeg3_frame_rate(file, 0) * track->sample_rate); */
217/* We would scan the multiplexed packets here for the right timecode if only */
218/* they had meaningful timecode. */
219 }
220
221 audio->pcm_point = 0;
222 mpeg3bits_seek_start(audio->astream);
223 mpeg3audio_reset_synths(audio);
224 return result;
225}
226
227int mpeg3audio_seek(mpeg3audio_t *audio, long position)
228{
229 int result = 0;
230 mpeg3_t *file = audio->file;
231 mpeg3_atrack_t *track = audio->track;
232 long frame_number;
233 long byte_position;
234 double time_position;
235
236/* Sample seek wasn't requested */
237 if(audio->sample_seek < 0)
238 {
239 audio->pcm_position = position;
240 audio->pcm_size = 0;
241 return 0;
242 }
243
244/* Can't slide buffer. Seek instead. */
245 if(!file->is_audio_stream)
246 {
247/* Seek in a multiplexed stream using the multiplexer. */
248 time_position = (double)position / track->sample_rate;
249 result |= mpeg3bits_seek_time(audio->astream, time_position);
250 audio->pcm_position = (long)mpeg3bits_packet_time(audio->astream) * track->sample_rate;
251/*printf("wanted %f got %f\n", time_position, mpeg3bits_packet_time(audio->astream)); */
252 }
253 else
254 {
255/* Seek in an elemental stream. This algorithm achieves sample accuracy on fixed bitrates. */
256/* Forget about variable bitrates or program streams. */
257 frame_number = position / audio->samples_per_frame;
258 byte_position = (long)(audio->avg_framesize * frame_number);
259 audio->pcm_position = frame_number * audio->samples_per_frame;
260
261 if(byte_position < audio->avg_framesize * 2)
262 {
263 result |= mpeg3bits_seek_start(audio->astream);
264 audio->pcm_position = 0;
265 }
266 else
267 {
268 result |= mpeg3bits_seek_byte(audio->astream, byte_position);
269 }
270 }
271
272/* Arm the backstep buffer for layer 3 if not at the beginning already. */
273 if(byte_position >= audio->avg_framesize * 2 && audio->layer == 3 && !result)
274 {
275 result |= mpeg3audio_prev_header(audio);
276 result |= mpeg3audio_read_layer3_frame(audio);
277 }
278
279/* Reset the tables. */
280 mpeg3audio_reset_synths(audio);
281 audio->pcm_size = 0;
282 audio->pcm_point = 0;
283 return result;
284}
285
286/* ================================================================ */
287/* ENTRY POINTS */
288/* ================================================================ */
289
290
291
292
293mpeg3audio_t* mpeg3audio_new(mpeg3_t *file, mpeg3_atrack_t *track, int format)
294{
295 mpeg3audio_t *audio = mpeg3audio_allocate_struct(file, track);
296 int result = 0;
297
298/* Init tables */
299 mpeg3audio_new_decode_tables(audio);
300 audio->percentage_seek = -1;
301 audio->sample_seek = -1;
302 audio->format = format;
303
304/* Determine the format of the stream */
305 if(format == AUDIO_UNKNOWN)
306 {
307 if(((mpeg3bits_showbits(audio->astream, 32) & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE)
308 audio->format = AUDIO_AC3;
309 else
310 audio->format = AUDIO_MPEG;
311 }
312
313/* get channel count */
314 result = mpeg3audio_read_header(audio);
315
316/* Set up the sample buffer */
317 mpeg3audio_replace_buffer(audio, 262144);
318
319/* Copy information to the mpeg struct */
320 if(!result)
321 {
322 track->channels = audio->channels;
323
324 switch(audio->format)
325 {
326 case AUDIO_AC3:
327 track->sample_rate = mpeg3_ac3_samplerates[audio->sampling_frequency_code];
328 break;
329
330 case AUDIO_MPEG:
331 track->sample_rate = mpeg3_freqs[audio->sampling_frequency_code];
332 break;
333
334 case AUDIO_PCM:
335 track->sample_rate = 48000;
336 break;
337 }
338
339 track->total_samples = mpeg3audio_get_length(audio, track);
340 result |= mpeg3bits_seek_start(audio->astream);
341 }
342 else
343 {
344 mpeg3audio_delete_struct(audio);
345 audio = 0;
346 }
347
348 return audio;
349}
350
351int mpeg3audio_delete(mpeg3audio_t *audio)
352{
353 mpeg3audio_delete_struct(audio);
354 return 0;
355}
356
357int mpeg3audio_seek_percentage(mpeg3audio_t *audio, double percentage)
358{
359 audio->percentage_seek = percentage;
360 return 0;
361}
362
363int mpeg3audio_seek_sample(mpeg3audio_t *audio, long sample)
364{
365 audio->sample_seek = sample;
366 return 0;
367}
368
369/* Read raw frames for concatenation purposes */
370int mpeg3audio_read_raw(mpeg3audio_t *audio, unsigned char *output, long *size, long max_size)
371{
372 int result = 0;
373 int i;
374 *size = 0;
375
376 switch(audio->format)
377 {
378 case AUDIO_AC3:
379/* Just write the AC3 stream */
380 if(mpeg3bits_read_buffer(audio->astream, output, audio->framesize))
381 return 1;
382 *size = audio->framesize;
383 break;
384
385 case AUDIO_MPEG:
386/* Fix the mpeg stream */
387 result = mpeg3audio_read_header(audio);
388 if(!result)
389 {
390 if(max_size < 4) return 1;
391 *output++ = (audio->newhead & 0xff000000) >> 24;
392 *output++ = (audio->newhead & 0xff0000) >> 16;
393 *output++ = (audio->newhead & 0xff00) >> 8;
394 *output++ = (audio->newhead & 0xff);
395 *size += 4;
396
397 if(max_size < 4 + audio->framesize) return 1;
398 if(mpeg3bits_read_buffer(audio->astream, output, audio->framesize))
399 return 1;
400
401 *size += audio->framesize;
402 }
403 break;
404
405 case AUDIO_PCM:
406 if(mpeg3bits_read_buffer(audio->astream, output, audio->framesize))
407 return 1;
408 *size = audio->framesize;
409 break;
410 }
411 return result;
412}
413
414/* Channel is 0 to channels - 1 */
415int mpeg3audio_decode_audio(mpeg3audio_t *audio,
416 mpeg3_real_t *output_f,
417 short *output_i, int sampleSpacing,
418 int channel,
419 long start_position,
420 long len)
421{
422 long allocation_needed = len + MPEG3AUDIO_PADDING;
423 long i, j, result = 0;
424 mpeg3_t *file = audio->file;
425 mpeg3_atrack_t *atrack = audio->track;
426 long attempts;
427
428/* Create new buffer */
429 if(audio->pcm_allocated < allocation_needed)
430 {
431 mpeg3audio_replace_buffer(audio, allocation_needed);
432 }
433
434/* There was a percentage seek */
435 if(audio->percentage_seek >= 0)
436 {
437 mpeg3bits_seek_percentage(audio->astream, audio->percentage_seek);
438/* Force the pcm buffer to be reread. */
439 audio->pcm_position = start_position;
440 audio->pcm_size = 0;
441 audio->percentage_seek = -1;
442 }
443 else
444 {
445/* Entire output is in buffer so don't do anything. */
446 if(start_position >= audio->pcm_position && start_position < audio->pcm_position + audio->pcm_size &&
447 start_position + len <= audio->pcm_size)
448 {
449 ;
450 }
451 else
452/* Output starts in buffer but ends later so slide it back. */
453 if(start_position <= audio->pcm_position + audio->pcm_size &&
454 start_position >= audio->pcm_position)
455 {
456 for(i = 0, j = (start_position - audio->pcm_position) * audio->channels;
457 j < audio->pcm_size * audio->channels;
458 i++, j++)
459 {
460 audio->pcm_sample[i] = audio->pcm_sample[j];
461 }
462
463 audio->pcm_point = i;
464 audio->pcm_size -= start_position - audio->pcm_position;
465 audio->pcm_position = start_position;
466 }
467 else
468 {
469/* Output is outside buffer completely. */
470 result = mpeg3audio_seek(audio, start_position);
471 audio->sample_seek = -1;
472/* Check sanity */
473 if(start_position < audio->pcm_position) audio->pcm_position = start_position;
474 }
475 audio->sample_seek = -1;
476 }
477
478/* Read packets until the buffer is full. */
479 if(!result)
480 {
481 attempts = 0;
482 result = 1;
483 while(attempts < 6 &&
484 !mpeg3bits_eof(audio->astream) &&
485 audio->pcm_size + audio->pcm_position < start_position + len)
486 {
487 result = mpeg3audio_read_frame(audio);
488 if(result) attempts++;
489 audio->pcm_size = audio->pcm_point / audio->channels;
490 }
491 }
492
493
494
495/* Copy the buffer to the output */
496 if(output_f)
497 {
498 for(i = 0, j = (start_position - audio->pcm_position) * audio->channels + channel;
499 i < len && j < audio->pcm_size * audio->channels;
500 i++, j += audio->channels)
501 {
502 output_f[i] = audio->pcm_sample[j];
503 }
504 for( ; i < len; i++)
505 {
506 output_f[i] = 0;
507 }
508 }
509 else
510 if(output_i)
511 {
512 int sample;
513 for(i = 0, j = (start_position - audio->pcm_position) * audio->channels + channel;
514 i < (len*(sampleSpacing+1)) && j < audio->pcm_size * audio->channels;
515 i++, j += audio->channels)
516 {
517 sample = (int)(audio->pcm_sample[j] * 32767);
518 if(sample > 32767) sample = 32767;
519 else
520 if(sample < -32768) sample = -32768;
521
522 output_i[i] = sample;
523 i += sampleSpacing;
524 }
525 for( ; i < (len*(sampleSpacing+1)); i++)
526 {
527 output_i[i] = 0;
528 i += sampleSpacing;
529 }
530 }
531
532 if(audio->pcm_point > 0)
533 return 0;
534 else
535 return result;
536}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.h b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.h
new file mode 100644
index 0000000..2117be7
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3audio.h
@@ -0,0 +1,144 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3AUDIO_H
21#define MPEG3AUDIO_H
22
23#include "ac3.h"
24#include "../bitstream.h"
25typedef struct mpeg3_atrack_rec mpeg3_atrack_t;
26
27#define MAXFRAMESIZE 1792
28#define HDRCMPMASK 0xfffffd00
29#define SBLIMIT 32
30#define SSLIMIT 18
31#define SCALE_BLOCK 12
32#define MPEG3AUDIO_PADDING 1024
33
34/* Values for mode */
35 #define MPG_MD_STEREO 0
36 #define MPG_MD_JOINT_STEREO 1
37 #define MPG_MD_DUAL_CHANNEL 2
38 #define MPG_MD_MONO 3
39
40/* IMDCT variables */
41typedef struct
42{
43 mpeg3_real_t real;
44 mpeg3_real_t imag;
45} mpeg3_complex_t;
46
47#define AC3_N 512
48
49struct al_table
50{
51 short bits;
52 short d;
53};
54
55typedef struct
56{
57 struct mpeg3_rec* file;
58 mpeg3_atrack_t* track;
59 mpeg3_bits_t *astream;
60
61/* In order of importance */
62 int format; /* format of audio */
63 int layer; /* layer if mpeg */
64 int channels;
65 long outscale;
66 long framenum;
67 long prev_framesize;
68 long framesize; /* For mp3 current framesize without header. For AC3 current framesize with header. */
69 int avg_framesize; /* Includes the 4 byte header */
70 mpeg3_real_t *pcm_sample; /* Interlaced output from synthesizer in floats */
71 int pcm_point; /* Float offset in pcm_sample to write to */
72 long pcm_position; /* Sample start of pcm_samples in file */
73 long pcm_size; /* Number of pcm samples in the buffer */
74 long pcm_allocated; /* Allocated number of samples in pcm_samples */
75 int sample_seek;
76 double percentage_seek;
77 unsigned long oldhead;
78 unsigned long newhead;
79 unsigned long firsthead;
80 int bsnum;
81 int lsf;
82 int mpeg35;
83 int sampling_frequency_code;
84 int bitrate_index;
85 int bitrate;
86 int samples_per_frame;
87 int padding;
88 int extension;
89 int mode;
90 int mode_ext;
91 int copyright;
92 int original;
93 int emphasis;
94 int error_protection;
95
96/* Back step buffers for mp3 */
97 unsigned char bsspace[2][MAXFRAMESIZE + 512]; /* MAXFRAMESIZE */
98 unsigned char *bsbuf, *bsbufold;
99 long ssize;
100 int init;
101 int single;
102 struct al_table *alloc;
103 int II_sblimit;
104 int jsbound;
105 int bo; /* Static variable in synthesizer */
106
107/* MP3 Static arrays here */
108 mpeg3_real_t synth_stereo_buffs[2][2][0x110];
109 mpeg3_real_t synth_mono_buff[64];
110 unsigned int layer2_scfsi_buf[64];
111
112 mpeg3_real_t mp3_block[2][2][SBLIMIT * SSLIMIT];
113 int mp3_blc[2];
114
115/* AC3 specific stuff. AC3 also shares objects with MPEG */
116 unsigned int ac3_framesize_code;
117 mpeg3_ac3bsi_t ac3_bsi;
118 mpeg3_ac3audblk_t ac3_audblk;
119 mpeg3_ac3_bitallocation_t ac3_bit_allocation;
120 mpeg3_ac3_mantissa_t ac3_mantissa;
121 mpeg3_complex_t ac3_imdct_buf[AC3_N / 4];
122
123/* Delay buffer for DCT interleaving */
124 mpeg3_real_t ac3_delay[6][AC3_N / 2];
125/* Twiddle factor LUT */
126 mpeg3_complex_t *ac3_w[7];
127#if !defined(USE_FIXED_POINT) || defined(PRINT_FIXED_POINT_TABLES)
128 /* Just for allocated memory */
129 mpeg3_complex_t ac3_w_1[1];
130 mpeg3_complex_t ac3_w_2[2];
131 mpeg3_complex_t ac3_w_4[4];
132 mpeg3_complex_t ac3_w_8[8];
133 mpeg3_complex_t ac3_w_16[16];
134 mpeg3_complex_t ac3_w_32[32];
135 mpeg3_complex_t ac3_w_64[64];
136#endif
137 int ac3_lfsr_state;
138 unsigned char ac3_buffer[MAX_AC3_FRAMESIZE];
139 mpeg3ac3_stream_samples_t ac3_samples;
140} mpeg3audio_t;
141
142
143
144#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h
new file mode 100644
index 0000000..cdcac3d
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/mpeg3real.h
@@ -0,0 +1,232 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3REAL_H
21#define MPEG3REAL_H
22
23#ifdef USE_FIXED_POINT
24
25#include <limits.h>
26#include <stdio.h>
27
28#ifndef LONGLONG
29#define LONGLONG long long
30#endif
31
32//#define SC (1<<16)
33#define SC (1<<15)
34
35class mpeg3_real_t {
36 long v;
37public:
38 mpeg3_real_t() { } // Uninitialized, just like a float
39 mpeg3_real_t(double d) { v=long(d*SC); }
40 mpeg3_real_t(float f) { v=long(f*SC); }
41 mpeg3_real_t(int i) { v=long(i*SC); }
42 long fixedPoint() const { return v; }
43 operator float() const { return ((float)v)/SC; }
44 operator int() const { return (int)(v/SC); }
45 mpeg3_real_t operator+() const;
46 mpeg3_real_t operator-() const;
47 mpeg3_real_t& operator= (const mpeg3_real_t&);
48 mpeg3_real_t& operator+= (const mpeg3_real_t&);
49 mpeg3_real_t& operator-= (const mpeg3_real_t&);
50 mpeg3_real_t& operator*= (const mpeg3_real_t&);
51 mpeg3_real_t& operator/= (const mpeg3_real_t&);
52 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const mpeg3_real_t&);
53 friend mpeg3_real_t operator- (const mpeg3_real_t&, const mpeg3_real_t&);
54 friend mpeg3_real_t operator* (const mpeg3_real_t&, const mpeg3_real_t&);
55 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const mpeg3_real_t&);
56 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const float&);
57 friend mpeg3_real_t operator- (const mpeg3_real_t&, const float&);
58 friend mpeg3_real_t operator* (const mpeg3_real_t&, const float&);
59 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const float&);
60 friend mpeg3_real_t operator+ (const float&, const mpeg3_real_t&);
61 friend mpeg3_real_t operator- (const float&, const mpeg3_real_t&);
62 friend mpeg3_real_t operator* (const float&, const mpeg3_real_t&);
63 friend mpeg3_real_t operator/ (const float&, const mpeg3_real_t&);
64 friend mpeg3_real_t operator+ (const mpeg3_real_t&, const int&);
65 friend mpeg3_real_t operator- (const mpeg3_real_t&, const int&);
66 friend mpeg3_real_t operator* (const mpeg3_real_t&, const int&);
67 friend mpeg3_real_t operator/ (const mpeg3_real_t&, const int&);
68 friend mpeg3_real_t operator+ (const int&, const mpeg3_real_t&);
69 friend mpeg3_real_t operator- (const int&, const mpeg3_real_t&);
70 friend mpeg3_real_t operator* (const int&, const mpeg3_real_t&);
71 friend mpeg3_real_t operator/ (const int&, const mpeg3_real_t&);
72};
73
74inline mpeg3_real_t mpeg3_real_t::operator+() const
75{
76 return *this;
77}
78
79inline mpeg3_real_t mpeg3_real_t::operator-() const
80{
81 mpeg3_real_t r;
82 r.v=-v;
83 return r;
84}
85
86inline mpeg3_real_t& mpeg3_real_t::operator= (const mpeg3_real_t& o)
87{
88 v=o.v;
89 return *this;
90}
91
92inline mpeg3_real_t& mpeg3_real_t::operator+= (const mpeg3_real_t& o)
93{
94 v += o.v;
95 return *this;
96}
97
98inline mpeg3_real_t& mpeg3_real_t::operator-= (const mpeg3_real_t& o)
99{
100 v -= o.v;
101 return *this;
102}
103
104inline mpeg3_real_t& mpeg3_real_t::operator*= (const mpeg3_real_t& o)
105{
106 *this = *this * o;
107 return *this;
108}
109
110inline mpeg3_real_t& mpeg3_real_t::operator/= (const mpeg3_real_t& o)
111{
112 *this = *this / o;
113 return *this;
114}
115
116
117inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const mpeg3_real_t&b)
118{
119 mpeg3_real_t r;
120 r.v=a.v+b.v;
121 return r;
122}
123
124inline mpeg3_real_t operator- (const mpeg3_real_t&a, const mpeg3_real_t&b)
125{
126 mpeg3_real_t r;
127 r.v=a.v-b.v;
128 return r;
129}
130
131inline mpeg3_real_t operator* (const mpeg3_real_t&a, const mpeg3_real_t&b)
132{
133 mpeg3_real_t r;
134 r.v = (LONGLONG)a.v * b.v / SC;
135 return r;
136}
137
138inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const mpeg3_real_t&b)
139{
140 mpeg3_real_t r;
141 r.v = (LONGLONG)a.v * SC / b.v;
142 return r;
143}
144
145inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const float&b)
146{
147 return a+mpeg3_real_t(b);
148}
149
150inline mpeg3_real_t operator- (const mpeg3_real_t&a, const float&b)
151{
152 return a-mpeg3_real_t(b);
153}
154
155inline mpeg3_real_t operator* (const mpeg3_real_t&a, const float&b)
156{
157 return a*mpeg3_real_t(b);
158}
159
160inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const float&b)
161{
162 return a/mpeg3_real_t(b);
163}
164
165
166inline mpeg3_real_t operator+ (const float&a, const mpeg3_real_t&b)
167{
168 return mpeg3_real_t(a)+b;
169}
170
171inline mpeg3_real_t operator- (const float&a, const mpeg3_real_t&b)
172{
173 return mpeg3_real_t(a)-b;
174}
175
176inline mpeg3_real_t operator* (const float&a, const mpeg3_real_t&b)
177{
178 return mpeg3_real_t(a)*b;
179}
180
181inline mpeg3_real_t operator/ (const float&a, const mpeg3_real_t&b)
182{
183 return mpeg3_real_t(a)/b;
184}
185
186
187inline mpeg3_real_t operator+ (const mpeg3_real_t&a, const int&b)
188{
189 return a+mpeg3_real_t(b);
190}
191
192inline mpeg3_real_t operator- (const mpeg3_real_t&a, const int&b)
193{
194 return a-mpeg3_real_t(b);
195}
196
197inline mpeg3_real_t operator* (const mpeg3_real_t&a, const int&b)
198{
199 return a*mpeg3_real_t(b);
200}
201
202inline mpeg3_real_t operator/ (const mpeg3_real_t&a, const int&b)
203{
204 return a/mpeg3_real_t(b);
205}
206
207
208inline mpeg3_real_t operator+ (const int&a, const mpeg3_real_t&b)
209{
210 return mpeg3_real_t(a)+b;
211}
212
213inline mpeg3_real_t operator- (const int&a, const mpeg3_real_t&b)
214{
215 return mpeg3_real_t(a)-b;
216}
217
218inline mpeg3_real_t operator* (const int&a, const mpeg3_real_t&b)
219{
220 return mpeg3_real_t(a)*b;
221}
222
223inline mpeg3_real_t operator/ (const int&a, const mpeg3_real_t&b)
224{
225 return mpeg3_real_t(a)/b;
226}
227
228#else
229typedef float mpeg3_real_t;
230#endif
231
232#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/pcm.c b/core/multimedia/opieplayer/libmpeg3/audio/pcm.c
new file mode 100644
index 0000000..8fa0d25
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/pcm.c
@@ -0,0 +1,51 @@
1#include "mpeg3audio.h"
2#include "../libmpeg3.h"
3#include "../mpeg3protos.h"
4
5int mpeg3audio_read_pcm_header(mpeg3audio_t *audio)
6{
7 unsigned int code;
8
9 code = mpeg3bits_getbits(audio->astream, 16);
10 while(!mpeg3bits_eof(audio->astream) && code != MPEG3_PCM_START_CODE)
11 {
12 code <<= 8;
13 code &= 0xffff;
14 code |= mpeg3bits_getbits(audio->astream, 8);
15 }
16
17 audio->avg_framesize = audio->framesize = 0x7db;
18 audio->channels = 2;
19
20 return mpeg3bits_eof(audio->astream);
21}
22
23int mpeg3audio_do_pcm(mpeg3audio_t *audio)
24{
25 int i, j, k;
26 MPEG3_INT16 sample;
27 int frame_samples = (audio->framesize - 3) / audio->channels / 2;
28
29 if(mpeg3bits_read_buffer(audio->astream, audio->ac3_buffer, frame_samples * audio->channels * 2))
30 return 1;
31
32/* Need more room */
33 if(audio->pcm_point / audio->channels >= audio->pcm_allocated - MPEG3AUDIO_PADDING * audio->channels)
34 {
35 mpeg3audio_replace_buffer(audio, audio->pcm_allocated + MPEG3AUDIO_PADDING * audio->channels);
36 }
37
38 k = 0;
39 for(i = 0; i < frame_samples; i++)
40 {
41 for(j = 0; j < audio->channels; j++)
42 {
43 sample = ((MPEG3_INT16)(audio->ac3_buffer[k++])) << 8;
44 sample |= audio->ac3_buffer[k++];
45 audio->pcm_sample[audio->pcm_point + i * audio->channels + j] =
46 (mpeg3_real_t)sample / 32767;
47 }
48 }
49 audio->pcm_point += frame_samples * audio->channels;
50 return 0;
51}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/synthesizers.c b/core/multimedia/opieplayer/libmpeg3/audio/synthesizers.c
new file mode 100644
index 0000000..71a74b3
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/synthesizers.c
@@ -0,0 +1,174 @@
1#include "mpeg3audio.h"
2#include "../libmpeg3.h"
3#include "../mpeg3protos.h"
4#include "tables.h"
5
6#define WRITE_SAMPLE(samples, sum) \
7{ \
8 (*samples) = (sum); \
9}
10
11int mpeg3audio_synth_stereo(mpeg3audio_t *audio, mpeg3_real_t *bandPtr, int channel, mpeg3_real_t *out, int *pnt)
12{
13 const int step = 2;
14 mpeg3_real_t *samples = out + *pnt;
15 register mpeg3_real_t sum;
16 mpeg3_real_t *b0, (*buf)[0x110];
17 int bo1;
18
19 if(!channel)
20 {
21 audio->bo--;
22 audio->bo &= 0xf;
23 buf = audio->synth_stereo_buffs[0];
24 }
25 else
26 {
27 samples++;
28 buf = audio->synth_stereo_buffs[1];
29 }
30
31 if(audio->bo & 0x1)
32 {
33 b0 = buf[0];
34 bo1 = audio->bo;
35 mpeg3audio_dct64(buf[1] + ((audio->bo + 1) & 0xf), buf[0] + audio->bo, bandPtr);
36 }
37 else
38 {
39 b0 = buf[1];
40 bo1 = audio->bo + 1;
41 mpeg3audio_dct64(buf[0] + audio->bo, buf[1] + audio->bo + 1, bandPtr);
42 }
43
44/*printf("%f %f %f\n", buf[0][0], buf[1][0], bandPtr[0]); */
45
46 {
47 register int j;
48 mpeg3_real_t *window = mpeg3_decwin + 16 - bo1;
49
50 for(j = 16; j; j--, b0 += 0x10, window += 0x20, samples += step)
51 {
52 sum = window[0x0] * b0[0x0];
53 sum -= window[0x1] * b0[0x1];
54 sum += window[0x2] * b0[0x2];
55 sum -= window[0x3] * b0[0x3];
56 sum += window[0x4] * b0[0x4];
57 sum -= window[0x5] * b0[0x5];
58 sum += window[0x6] * b0[0x6];
59 sum -= window[0x7] * b0[0x7];
60 sum += window[0x8] * b0[0x8];
61 sum -= window[0x9] * b0[0x9];
62 sum += window[0xA] * b0[0xA];
63 sum -= window[0xB] * b0[0xB];
64 sum += window[0xC] * b0[0xC];
65 sum -= window[0xD] * b0[0xD];
66 sum += window[0xE] * b0[0xE];
67 sum -= window[0xF] * b0[0xF];
68
69 WRITE_SAMPLE(samples, sum);
70 }
71
72 sum = window[0x0] * b0[0x0];
73 sum += window[0x2] * b0[0x2];
74 sum += window[0x4] * b0[0x4];
75 sum += window[0x6] * b0[0x6];
76 sum += window[0x8] * b0[0x8];
77 sum += window[0xA] * b0[0xA];
78 sum += window[0xC] * b0[0xC];
79 sum += window[0xE] * b0[0xE];
80 WRITE_SAMPLE(samples, sum);
81 b0 -= 0x10;
82 window -= 0x20;
83 samples += step;
84 window += bo1 << 1;
85
86 for(j = 15; j; j--, b0 -= 0x10, window -= 0x20, samples += step)
87 {
88 sum = -window[-0x1] * b0[0x0];
89 sum -= window[-0x2] * b0[0x1];
90 sum -= window[-0x3] * b0[0x2];
91 sum -= window[-0x4] * b0[0x3];
92 sum -= window[-0x5] * b0[0x4];
93 sum -= window[-0x6] * b0[0x5];
94 sum -= window[-0x7] * b0[0x6];
95 sum -= window[-0x8] * b0[0x7];
96 sum -= window[-0x9] * b0[0x8];
97 sum -= window[-0xA] * b0[0x9];
98 sum -= window[-0xB] * b0[0xA];
99 sum -= window[-0xC] * b0[0xB];
100 sum -= window[-0xD] * b0[0xC];
101 sum -= window[-0xE] * b0[0xD];
102 sum -= window[-0xF] * b0[0xE];
103 sum -= window[-0x0] * b0[0xF];
104
105 WRITE_SAMPLE(samples, sum);
106 }
107 }
108 *pnt += 64;
109
110 return 0;
111}
112
113int mpeg3audio_synth_mono(mpeg3audio_t *audio, mpeg3_real_t *bandPtr, mpeg3_real_t *samples, int *pnt)
114{
115 mpeg3_real_t *samples_tmp = audio->synth_mono_buff;
116 mpeg3_real_t *tmp1 = samples_tmp;
117 int i, ret;
118 int pnt1 = 0;
119
120 ret = mpeg3audio_synth_stereo(audio, bandPtr, 0, samples_tmp, &pnt1);
121 samples += *pnt;
122
123 for(i = 0; i < 32; i++)
124 {
125 *samples = *tmp1;
126 samples++;
127 tmp1 += 2;
128 }
129 *pnt += 32;
130
131 return ret;
132}
133
134
135/* Call this after every seek to reset the buffers */
136int mpeg3audio_reset_synths(mpeg3audio_t *audio)
137{
138 int i, j, k;
139 for(i = 0; i < 2; i++)
140 {
141 for(j = 0; j < 2; j++)
142 {
143 for(k = 0; k < 0x110; k++)
144 {
145 audio->synth_stereo_buffs[i][j][k] = 0;
146 }
147 }
148 }
149 for(i = 0; i < 64; i++)
150 {
151 audio->synth_mono_buff[i] = 0;
152 audio->layer2_scfsi_buf[i] = 0;
153 }
154 for(i = 0; i < 2; i++)
155 {
156 for(j = 0; j < 2; j++)
157 {
158 for(k = 0; k < SBLIMIT * SSLIMIT; k++)
159 {
160 audio->mp3_block[i][j][k] = 0;
161 }
162 }
163 }
164 audio->mp3_blc[0] = 0;
165 audio->mp3_blc[1] = 0;
166 for(i = 0; i < audio->channels; i++)
167 {
168 for(j = 0; j < AC3_N / 2; j++)
169 {
170 audio->ac3_delay[i][j] = 0;
171 }
172 }
173 return 0;
174}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/tables.c b/core/multimedia/opieplayer/libmpeg3/audio/tables.c
new file mode 100644
index 0000000..aeab335
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/tables.c
@@ -0,0 +1,554 @@
1#include "mpeg3audio.h"
2#include "../libmpeg3.h"
3#include "../mpeg3protos.h"
4#include "tables.h"
5
6#include <math.h>
7
8/* Bitrate indexes */
9int mpeg3_tabsel_123[2][3][16] = {
10 { {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,},
11 {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384,},
12 {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320,} },
13
14 { {0,32,48,56,64,80,96,112,128,144,160,176,192,224,256,},
15 {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,},
16 {0,8,16,24,32,40,48,56,64,80,96,112,128,144,160,} }
17};
18
19long mpeg3_freqs[9] = { 44100, 48000, 32000, 22050, 24000, 16000 , 11025 , 12000 , 8000 };
20
21#ifdef USE_3DNOW
22mpeg3_real_t mpeg3_decwin[2 * (512 + 32)];
23mpeg3_real_t mpeg3_cos64[32], mpeg3_cos32[16], mpeg3_cos16[8], mpeg3_cos8[4], mpeg3_cos4[2];
24#else
25mpeg3_real_t mpeg3_decwin[512 + 32];
26mpeg3_real_t mpeg3_cos64[16], mpeg3_cos32[8], mpeg3_cos16[4], mpeg3_cos8[2], mpeg3_cos4[1];
27#endif
28
29mpeg3_real_t *mpeg3_pnts[] = { mpeg3_cos64, mpeg3_cos32, mpeg3_cos16, mpeg3_cos8, mpeg3_cos4 };
30
31int mpeg3_grp_3tab[32 * 3] = { 0, }; /* used: 27 */
32int mpeg3_grp_5tab[128 * 3] = { 0, }; /* used: 125 */
33int mpeg3_grp_9tab[1024 * 3] = { 0, }; /* used: 729 */
34
35 REAL_MATRIX(mpeg3_muls, [27], [64]);/* also used by layer 1 */
36REAL_MATRIX(mpeg3_gainpow2, [256 + 118 + 4], );
37REAL_MATRIX(mpeg3_ispow, [8207], );
38REAL_MATRIX(mpeg3_aa_ca, [8], );
39REAL_MATRIX(mpeg3_aa_cs, [8], );
40REAL_MATRIX(mpeg3_win, [4], [36]);
41REAL_MATRIX(mpeg3_win1, [4], [36]);
42REAL_MATRIX(mpeg3_COS1, [12], [6]);
43REAL_MATRIX(mpeg3_COS9, [9], );
44REAL_MATRIX(mpeg3_tfcos36, [9], );
45REAL_MATRIX(mpeg3_tfcos12, [3], );
46REAL_MATRIX(mpeg3_cos9, [3], );
47REAL_MATRIX(mpeg3_cos18, [3], );
48REAL_MATRIX(mpeg3_tan1_1, [16], );
49REAL_MATRIX(mpeg3_tan2_1, [16], );
50REAL_MATRIX(mpeg3_tan1_2, [16], );
51REAL_MATRIX(mpeg3_tan2_2, [16], );
52REAL_MATRIX(mpeg3_pow1_1, [2], [16]);
53REAL_MATRIX(mpeg3_pow2_1, [2], [16]);
54REAL_MATRIX(mpeg3_pow1_2, [2], [16]);
55REAL_MATRIX(mpeg3_pow2_2, [2], [16]);
56
57mpeg3_real_t mpeg3_COS6_1, mpeg3_COS6_2;
58
59#ifdef PRINT_FIXED_POINT_TABLES
60static void print_table(const char* var, mpeg3_real_t* data, int count)
61{
62 int i;
63 printf("#ifdef USE_DATA_TABLES\n");
64 printf("static long %s_data[] = {",var);
65 for(i = 0; i < count; i++) {
66 printf("%c0x%08x,", i%8?' ':'\n', data[i].fixedPoint());
67 }
68 printf("};\n");
69 printf("#endif\n");
70}
71#endif
72
73#ifdef PRINT_FIXED_POINT_TABLES
74# define DO_TABLE(T) print_table(#T, T, sizeof(T)/sizeof(mpeg3_real_t))
75# define DO_TABLE2(T,DIM) print_table(#T, (mpeg3_real_t*)T, sizeof(T)/sizeof(mpeg3_real_t))
76#elif USE_FIXED_POINT
77# define DO_TABLE(T) T = (mpeg3_real_t*)T##_data
78 // multidimensional
79# define DO_TABLE2(T,DIM) T = (mpeg3_real_t(*)DIM)T##_data
80#else
81# define DO_TABLE(T)
82# define DO_TABLE2(T,DIM)
83#endif
84
85#if defined(USE_FIXED_POINT) && !defined(PRINT_FIXED_POINT_TABLES)
86#define USE_DATA_TABLES
87#include "fptables.h"
88#endif
89
90long mpeg3_intwinbase[] = {
91 0, -1, -1, -1, -1, -1, -1, -2, -2, -2,
92 -2, -3, -3, -4, -4, -5, -5, -6, -7, -7,
93 -8, -9, -10, -11, -13, -14, -16, -17, -19, -21,
94 -24, -26, -29, -31, -35, -38, -41, -45, -49, -53,
95 -58, -63, -68, -73, -79, -85, -91, -97, -104, -111,
96 -117, -125, -132, -139, -147, -154, -161, -169, -176, -183,
97 -190, -196, -202, -208, -213, -218, -222, -225, -227, -228,
98 -228, -227, -224, -221, -215, -208, -200, -189, -177, -163,
99 -146, -127, -106, -83, -57, -29, 2, 36, 72, 111,
100 153, 197, 244, 294, 347, 401, 459, 519, 581, 645,
101 711, 779, 848, 919, 991, 1064, 1137, 1210, 1283, 1356,
102 1428, 1498, 1567, 1634, 1698, 1759, 1817, 1870, 1919, 1962,
103 2001, 2032, 2057, 2075, 2085, 2087, 2080, 2063, 2037, 2000,
104 1952, 1893, 1822, 1739, 1644, 1535, 1414, 1280, 1131, 970,
105 794, 605, 402, 185, -45, -288, -545, -814, -1095, -1388,
106 -1692, -2006, -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788,
107 -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, -7910, -8209,
108 -8491, -8755, -8998, -9219, -9416, -9585, -9727, -9838, -9916, -9959,
109 -9966, -9935, -9863, -9750, -9592, -9389, -9139, -8840, -8492, -8092,
110 -7640, -7134, -6574, -5959, -5288, -4561, -3776, -2935, -2037, -1082,
111 -70, 998, 2122, 3300, 4533, 5818, 7154, 8540, 9975, 11455,
112 12980, 14548, 16155, 17799, 19478, 21189, 22929, 24694, 26482, 28289,
113 30112, 31947, 33791, 35640, 37489, 39336, 41176, 43006, 44821, 46617,
114 48390, 50137, 51853, 53534, 55178, 56778, 58333, 59838, 61289, 62684,
115 64019, 65290, 66494, 67629, 68692, 69679, 70590, 71420, 72169, 72835,
116 73415, 73908, 74313, 74630, 74856, 74992, 75038 };
117
118int mpeg3_longLimit[9][23];
119int mpeg3_shortLimit[9][14];
120
121struct mpeg3_bandInfoStruct mpeg3_bandInfo[9] =
122{
123
124/* MPEG 1.0 */
125 { {0,4,8,12,16,20,24,30,36,44,52,62,74, 90,110,134,162,196,238,288,342,418,576},
126 {4,4,4,4,4,4,6,6,8, 8,10,12,16,20,24,28,34,42,50,54, 76,158},
127 {0,4*3,8*3,12*3,16*3,22*3,30*3,40*3,52*3,66*3, 84*3,106*3,136*3,192*3},
128 {4,4,4,4,6,8,10,12,14,18,22,30,56} } ,
129
130 { {0,4,8,12,16,20,24,30,36,42,50,60,72, 88,106,128,156,190,230,276,330,384,576},
131 {4,4,4,4,4,4,6,6,6, 8,10,12,16,18,22,28,34,40,46,54, 54,192},
132 {0,4*3,8*3,12*3,16*3,22*3,28*3,38*3,50*3,64*3, 80*3,100*3,126*3,192*3},
133 {4,4,4,4,6,6,10,12,14,16,20,26,66} } ,
134
135 { {0,4,8,12,16,20,24,30,36,44,54,66,82,102,126,156,194,240,296,364,448,550,576} ,
136 {4,4,4,4,4,4,6,6,8,10,12,16,20,24,30,38,46,56,68,84,102, 26} ,
137 {0,4*3,8*3,12*3,16*3,22*3,30*3,42*3,58*3,78*3,104*3,138*3,180*3,192*3} ,
138 {4,4,4,4,6,8,12,16,20,26,34,42,12} } ,
139
140/* MPEG 2.0 */
141 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
142 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 } ,
143 {0,4*3,8*3,12*3,18*3,24*3,32*3,42*3,56*3,74*3,100*3,132*3,174*3,192*3} ,
144 {4,4,4,6,6,8,10,14,18,26,32,42,18 } } ,
145
146 { {0,6,12,18,24,30,36,44,54,66,80,96,114,136,162,194,232,278,330,394,464,540,576},
147 {6,6,6,6,6,6,8,10,12,14,16,18,22,26,32,38,46,52,64,70,76,36 } ,
148 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,136*3,180*3,192*3} ,
149 {4,4,4,6,8,10,12,14,18,24,32,44,12 } } ,
150
151 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576},
152 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54 },
153 {0,4*3,8*3,12*3,18*3,26*3,36*3,48*3,62*3,80*3,104*3,134*3,174*3,192*3},
154 {4,4,4,6,8,10,12,14,18,24,30,40,18 } } ,
155/* MPEG 2.5 */
156 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
157 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
158 {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
159 {4,4,4,6,8,10,12,14,18,24,30,40,18} },
160 { {0,6,12,18,24,30,36,44,54,66,80,96,116,140,168,200,238,284,336,396,464,522,576} ,
161 {6,6,6,6,6,6,8,10,12,14,16,20,24,28,32,38,46,52,60,68,58,54},
162 {0,12,24,36,54,78,108,144,186,240,312,402,522,576},
163 {4,4,4,6,8,10,12,14,18,24,30,40,18} },
164 { {0,12,24,36,48,60,72,88,108,132,160,192,232,280,336,400,476,566,568,570,572,574,576},
165 {12,12,12,12,12,12,16,20,24,28,32,40,48,56,64,76,90,2,2,2,2,2},
166 {0, 24, 48, 72,108,156,216,288,372,480,486,492,498,576},
167 {8,8,8,12,16,20,24,28,36,2,2,2,26} } ,
168};
169
170int mpeg3_mapbuf0[9][152];
171int mpeg3_mapbuf1[9][156];
172int mpeg3_mapbuf2[9][44];
173int *mpeg3_map[9][3];
174int *mpeg3_mapend[9][3];
175
176unsigned int mpeg3_n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */
177unsigned int mpeg3_i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */
178
179int mpeg3audio_init_layer3(mpeg3audio_t *audio);
180
181int mpeg3audio_init_layer2(mpeg3audio_t *audio)
182{
183 static double mulmul[27] =
184 {
185 0.0 , -2.0/3.0 , 2.0/3.0 ,
186 2.0/7.0 , 2.0/15.0 , 2.0/31.0, 2.0/63.0 , 2.0/127.0 , 2.0/255.0 ,
187 2.0/511.0 , 2.0/1023.0 , 2.0/2047.0 , 2.0/4095.0 , 2.0/8191.0 ,
188 2.0/16383.0 , 2.0/32767.0 , 2.0/65535.0 ,
189 -4.0/5.0 , -2.0/5.0 , 2.0/5.0, 4.0/5.0 ,
190 -8.0/9.0 , -4.0/9.0 , -2.0/9.0 , 2.0/9.0 , 4.0/9.0 , 8.0/9.0
191 };
192 static int base[3][9] =
193 {
194 { 1 , 0, 2 , } ,
195 { 17, 18, 0 , 19, 20 , } ,
196 { 21, 1, 22, 23, 0, 24, 25, 2, 26 }
197 };
198 static int tablen[3] = { 3, 5, 9 };
199 static int *itable, *tables[3] = {mpeg3_grp_3tab, mpeg3_grp_5tab, mpeg3_grp_9tab};
200 int i, j, k, l, len;
201 mpeg3_real_t *table;
202
203 for(i = 0; i < 3; i++)
204 {
205 itable = tables[i];
206 len = tablen[i];
207 for(j = 0; j < len; j++)
208 for(k = 0; k < len; k++)
209 for(l = 0; l < len; l++)
210 {
211 *itable++ = base[i][l];
212 *itable++ = base[i][k];
213 *itable++ = base[i][j];
214 }
215 }
216
217#if !defined(USE_FIXED_POINT) || defined(PRINT_FIXED_POINT_TABLES)
218#if defined(PRINT_FIXED_POINT_TABLES)
219 //mpeg3audio_init_layer3(audio); // we depend on mpeg3_muls table
220#endif
221 for(k = 0; k < 27; k++)
222 {
223 double m = mulmul[k];
224 table = mpeg3_muls[k];
225 for(j = 3, i = 0; i < 63; i++, j--)
226 *table++ = m * pow(2.0, (double)j / 3.0);
227 *table++ = 0.0;
228 }
229#endif
230 DO_TABLE2(mpeg3_muls,[64]);
231 return 0;
232}
233
234int mpeg3audio_init_layer3(mpeg3audio_t *audio)
235{
236 int i, j, k, l;
237 int down_sample_sblimit = 32;
238
239 audio->mp3_block[0][0][0] = 0;
240 audio->mp3_blc[0] = 0;
241 audio->mp3_blc[1] = 0;
242
243#if !defined(USE_FIXED_POINT) || defined(PRINT_FIXED_POINT_TABLES)
244 for(i = -256; i < 118 + 4; i++)
245 mpeg3_gainpow2[i + 256] = pow((double)2.0, -0.25 * (double)(i + 210));
246
247 for(i = 0; i < 8207; i++)
248 mpeg3_ispow[i] = pow((double)i, (double)4.0 / 3.0);
249
250 for(i = 0; i < 8; i++)
251 {
252 static double Ci[8] = {-0.6,-0.535,-0.33,-0.185,-0.095,-0.041,-0.0142,-0.0037};
253 double sq = sqrt(1.0+Ci[i]*Ci[i]);
254 mpeg3_aa_cs[i] = 1.0/sq;
255 mpeg3_aa_ca[i] = Ci[i]/sq;
256 }
257
258 for(i = 0; i < 18; i++)
259 {
260 mpeg3_win[0][i] = mpeg3_win[1][i] = 0.5 * sin( M_PI / 72.0 * (double)(2 * (i + 0) + 1) ) / cos (M_PI * (double)(2 * (i + 0) + 19) / 72.0);
261 mpeg3_win[0][i+18] = mpeg3_win[3][i+18] = 0.5 * sin( M_PI / 72.0 * (double)(2 * (i + 18) + 1) ) / cos (M_PI * (double)(2 * (i + 18) + 19) / 72.0);
262 }
263 for(i = 0; i < 6; i++)
264 {
265 mpeg3_win[1][i + 18] = 0.5 / cos ( M_PI * (double) (2*(i+18)+19) / 72.0 );
266 mpeg3_win[3][i + 12] = 0.5 / cos ( M_PI * (double) (2*(i+12)+19) / 72.0 );
267 mpeg3_win[1][i + 24] = 0.5 * sin( M_PI / 24.0 * (double)(2 * i + 13) ) / cos (M_PI * (double)(2 * (i + 24)+ 19) / 72.0 );
268 mpeg3_win[1][i + 30] = mpeg3_win[3][i] = 0.0;
269 mpeg3_win[3][i + 6 ] = 0.5 * sin( M_PI / 24.0 * (double)(2 * i + 1) ) / cos (M_PI * (double)(2 * (i + 6 )+ 19) / 72.0 );
270 }
271
272 for(i = 0; i < 9; i++)
273 mpeg3_COS9[i] = cos(M_PI / 18.0 * (double)i);
274
275 for(i = 0; i < 9; i++)
276 mpeg3_tfcos36[i] = 0.5 / cos (M_PI * (double) (i*2+1) / 36.0);
277 for(i = 0; i < 3; i++)
278 mpeg3_tfcos12[i] = 0.5 / cos (M_PI * (double) (i*2+1) / 12.0);
279
280 mpeg3_cos9[0] = cos(1.0 * M_PI / 9.0);
281 mpeg3_cos9[1] = cos(5.0 * M_PI / 9.0);
282 mpeg3_cos9[2] = cos(7.0 * M_PI / 9.0);
283 mpeg3_cos18[0] = cos(1.0 * M_PI / 18.0);
284 mpeg3_cos18[1] = cos(11.0 * M_PI / 18.0);
285 mpeg3_cos18[2] = cos(13.0 * M_PI / 18.0);
286
287 for(i = 0; i < 12; i++)
288 {
289 mpeg3_win[2][i] = 0.5 * sin(M_PI / 24.0 * (double) (2 * i + 1)) / cos(M_PI * (double)(2 * i + 7) / 24.0);
290 for(j = 0; j < 6; j++)
291 mpeg3_COS1[i][j] = cos(M_PI / 24.0 * (double) ((2 * i + 7) * (2 * j + 1)));
292 }
293
294 for(j = 0; j < 4; j++)
295 {
296 static int len[4] = {36, 36, 12, 36};
297 for(i = 0; i < len[j]; i += 2)
298 mpeg3_win1[j][i] = + mpeg3_win[j][i];
299 for(i = 1; i < len[j]; i += 2)
300 mpeg3_win1[j][i] = - mpeg3_win[j][i];
301 }
302
303 for(i = 0; i < 16; i++)
304 {
305 double t = tan( (double) i * M_PI / 12.0 );
306 mpeg3_tan1_1[i] = t / (1.0 + t);
307 mpeg3_tan2_1[i] = 1.0 / (1.0 + t);
308 mpeg3_tan1_2[i] = M_SQRT2 * t / (1.0 + t);
309 mpeg3_tan2_2[i] = M_SQRT2 / (1.0 + t);
310
311 for(j = 0; j < 2; j++)
312 {
313 double base = pow(2.0, -0.25 * (j + 1.0));
314 double p1 = 1.0,p2 = 1.0;
315 if(i > 0)
316 {
317 if( i & 1 )
318 p1 = pow(base, (i + 1.0) * 0.5);
319 else
320 p2 = pow(base, i * 0.5);
321 }
322 mpeg3_pow1_1[j][i] = p1;
323 mpeg3_pow2_1[j][i] = p2;
324 mpeg3_pow1_2[j][i] = M_SQRT2 * p1;
325 mpeg3_pow2_2[j][i] = M_SQRT2 * p2;
326 }
327 }
328
329#endif
330
331 DO_TABLE(mpeg3_gainpow2);
332 DO_TABLE(mpeg3_ispow);
333 DO_TABLE(mpeg3_aa_cs);
334 DO_TABLE(mpeg3_aa_ca);
335 DO_TABLE2(mpeg3_win,[36]);
336 DO_TABLE(mpeg3_COS9);
337 DO_TABLE(mpeg3_tfcos36);
338 DO_TABLE(mpeg3_tfcos12);
339 DO_TABLE(mpeg3_cos9);
340 DO_TABLE(mpeg3_cos18);
341 DO_TABLE2(mpeg3_COS1,[6]);
342 DO_TABLE2(mpeg3_win1,[36]);
343 DO_TABLE(mpeg3_tan1_1);
344 DO_TABLE(mpeg3_tan2_1);
345 DO_TABLE(mpeg3_tan1_2);
346 DO_TABLE(mpeg3_tan2_2);
347 DO_TABLE2(mpeg3_pow1_1,[16]);
348 DO_TABLE2(mpeg3_pow2_1,[16]);
349 DO_TABLE2(mpeg3_pow1_2,[16]);
350 DO_TABLE2(mpeg3_pow2_2,[16]);
351
352 mpeg3_COS6_1 = cos( M_PI / 6.0 * (double) 1);
353 mpeg3_COS6_2 = cos( M_PI / 6.0 * (double) 2);
354
355 for(j = 0; j < 9; j++)
356 {
357 struct mpeg3_bandInfoStruct *bi = &mpeg3_bandInfo[j];
358 int *mp;
359 int cb,lwin;
360 int *bdf;
361
362 mp = mpeg3_map[j][0] = mpeg3_mapbuf0[j];
363 bdf = bi->longDiff;
364 for(i = 0, cb = 0; cb < 8; cb++, i += *bdf++)
365 {
366 *mp++ = (*bdf) >> 1;
367 *mp++ = i;
368 *mp++ = 3;
369 *mp++ = cb;
370 }
371 bdf = bi->shortDiff + 3;
372 for(cb = 3; cb < 13; cb++)
373 {
374 int l = (*bdf++) >> 1;
375 for(lwin = 0; lwin < 3; lwin++)
376 {
377 *mp++ = l;
378 *mp++ = i + lwin;
379 *mp++ = lwin;
380 *mp++ = cb;
381 }
382 i += 6 * l;
383 }
384 mpeg3_mapend[j][0] = mp;
385
386 mp = mpeg3_map[j][1] = mpeg3_mapbuf1[j];
387 bdf = bi->shortDiff+0;
388 for(i = 0,cb = 0; cb < 13; cb++)
389 {
390 int l = (*bdf++) >> 1;
391 for(lwin = 0; lwin < 3; lwin++)
392 {
393 *mp++ = l;
394 *mp++ = i + lwin;
395 *mp++ = lwin;
396 *mp++ = cb;
397 }
398 i += 6 * l;
399 }
400 mpeg3_mapend[j][1] = mp;
401
402 mp = mpeg3_map[j][2] = mpeg3_mapbuf2[j];
403 bdf = bi->longDiff;
404 for(cb = 0; cb < 22 ; cb++)
405 {
406 *mp++ = (*bdf++) >> 1;
407 *mp++ = cb;
408 }
409 mpeg3_mapend[j][2] = mp;
410 }
411
412 for(j = 0; j < 9; j++)
413 {
414 for(i = 0; i < 23; i++)
415 {
416 mpeg3_longLimit[j][i] = (mpeg3_bandInfo[j].longIdx[i] - 1 + 8) / 18 + 1;
417 if(mpeg3_longLimit[j][i] > (down_sample_sblimit))
418 mpeg3_longLimit[j][i] = down_sample_sblimit;
419 }
420 for(i = 0; i < 14; i++)
421 {
422 mpeg3_shortLimit[j][i] = (mpeg3_bandInfo[j].shortIdx[i] - 1) / 18 + 1;
423 if(mpeg3_shortLimit[j][i] > (down_sample_sblimit) )
424 mpeg3_shortLimit[j][i] = down_sample_sblimit;
425 }
426 }
427
428 for(i = 0; i < 5; i++)
429 {
430 for(j = 0; j < 6; j++)
431 {
432 for(k = 0; k < 6; k++)
433 {
434 int n = k + j * 6 + i * 36;
435 mpeg3_i_slen2[n] = i | (j << 3) | (k << 6) | (3 << 12);
436 }
437 }
438 }
439 for(i = 0; i < 4; i++)
440 {
441 for(j = 0; j < 4; j++)
442 {
443 for(k = 0; k < 4; k++)
444 {
445 int n = k + j * 4 + i * 16;
446 mpeg3_i_slen2[n+180] = i | (j << 3) | (k << 6) | (4 << 12);
447 }
448 }
449 }
450 for(i = 0; i < 4; i++)
451 {
452 for(j = 0; j < 3; j++)
453 {
454 int n = j + i * 3;
455 mpeg3_i_slen2[n + 244] = i | (j << 3) | (5 << 12);
456 mpeg3_n_slen2[n + 500] = i | (j << 3) | (2 << 12) | (1 << 15);
457 }
458 }
459
460 for(i = 0; i < 5; i++)
461 {
462 for(j = 0; j < 5; j++)
463 {
464 for(k = 0; k < 4; k++)
465 {
466 for(l = 0; l < 4; l++)
467 {
468 int n = l + k * 4 + j * 16 + i * 80;
469 mpeg3_n_slen2[n] = i | (j << 3) | ( k << 6) | (l << 9) | (0 << 12);
470 }
471 }
472 }
473 }
474 for(i = 0; i < 5; i++)
475 {
476 for(j = 0; j < 5; j++)
477 {
478 for(k = 0; k < 4; k++)
479 {
480 int n = k + j * 4 + i * 20;
481 mpeg3_n_slen2[n + 400] = i | (j << 3) | (k << 6) | (1 << 12);
482 }
483 }
484 }
485
486 return 0;
487}
488
489int mpeg3audio_new_decode_tables(mpeg3audio_t *audio)
490{
491 int i, j, k, kr, divv;
492 mpeg3_real_t *costab;
493 int idx;
494 long scaleval = audio->outscale;
495
496
497 for(i = 0; i < 5; i++)
498 {
499 kr = 0x10 >> i;
500 divv = 0x40 >> i;
501 costab = mpeg3_pnts[i];
502 for(k = 0; k < kr; k++)
503 costab[k] = 1.0 / (2.0 * cos(M_PI * ((double)k * 2.0 + 1.0) / (double)divv));
504
505#ifdef USE_3DNOW
506 for(k = 0; k < kr; k++)
507 costab[k + kr] = -costab[k];
508#endif
509
510 }
511
512 idx = 0;
513 scaleval = -scaleval;
514 for(i = 0, j = 0; i < 256; i++, j++,idx += 32)
515 {
516 if(idx < 512 + 16)
517 mpeg3_decwin[idx+16] = mpeg3_decwin[idx] = (double)mpeg3_intwinbase[j] / 65536.0 * (double)scaleval;
518
519 if(i % 32 == 31)
520 idx -= 1023;
521 if(i % 64 == 63)
522 scaleval = -scaleval;
523 }
524
525 for( ; i < 512; i++, j--, idx += 32)
526 {
527 if(idx < 512 + 16)
528 mpeg3_decwin[idx + 16] = mpeg3_decwin[idx] = (double)mpeg3_intwinbase[j] / 65536.0 * (double)scaleval;
529
530 if(i % 32 == 31)
531 idx -= 1023;
532 if(i % 64 == 63)
533 scaleval = -scaleval;
534 }
535
536#ifdef USE_3DNOW
537 if(!param.down_sample)
538 {
539 for(i = 0; i < 512 + 32; i++)
540 {
541 mpeg3_decwin[512 + 31 - i] *= 65536.0; /* allows faster clipping in 3dnow code */
542 mpeg3_decwin[512 + 32 + i] = mpeg3_decwin[512 + 31 - i];
543 }
544 }
545#endif
546
547/* Initialize AC3 */
548 audio->ac3_lfsr_state = 1;
549 mpeg3audio_imdct_init(audio);
550/* Initialize MPEG */
551 mpeg3audio_init_layer2(audio); /* inits also shared tables with layer1 */
552 mpeg3audio_init_layer3(audio);
553 return 0;
554}
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/tables.h b/core/multimedia/opieplayer/libmpeg3/audio/tables.h
new file mode 100644
index 0000000..7b14de1
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/tables.h
@@ -0,0 +1,88 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef TABLES_H
21#define TABLES_H
22
23extern int mpeg3_tabsel_123[2][3][16];
24
25extern long mpeg3_freqs[9];
26
27struct mpeg3_bandInfoStruct
28{
29 int longIdx[23];
30 int longDiff[22];
31 int shortIdx[14];
32 int shortDiff[13];
33};
34
35
36extern mpeg3_real_t mpeg3_decwin[512 + 32];
37extern mpeg3_real_t mpeg3_cos64[16], mpeg3_cos32[8], mpeg3_cos16[4], mpeg3_cos8[2], mpeg3_cos4[1];
38
39extern mpeg3_real_t *mpeg3_pnts[5];
40
41extern int mpeg3_grp_3tab[32 * 3]; /* used: 27 */
42extern int mpeg3_grp_5tab[128 * 3]; /* used: 125 */
43extern int mpeg3_grp_9tab[1024 * 3]; /* used: 729 */
44extern long mpeg3_intwinbase[257];
45extern mpeg3_real_t mpeg3_COS6_1, mpeg3_COS6_2;
46
47#if defined(USE_FIXED_POINT) && !defined(PRINT_FIXED_POINT_TABLES)
48# define REAL_MATRIX(var,dim1,dimn) mpeg3_real_t (*var)dimn
49#else
50# define REAL_MATRIX(var,dim1,dimn) mpeg3_real_t var dim1 dimn
51#endif
52 extern REAL_MATRIX(mpeg3_muls, [27], [64]);/* also used by layer 1 */
53extern REAL_MATRIX(mpeg3_gainpow2, [256 + 118 + 4], );
54extern REAL_MATRIX(mpeg3_ispow, [8207], );
55extern REAL_MATRIX(mpeg3_aa_ca, [8], );
56extern REAL_MATRIX(mpeg3_aa_cs, [8], );
57extern REAL_MATRIX(mpeg3_win, [4], [36]);
58extern REAL_MATRIX(mpeg3_win1, [4], [36]);
59extern REAL_MATRIX(mpeg3_COS1, [12], [6]);
60extern REAL_MATRIX(mpeg3_COS9, [9], );
61extern REAL_MATRIX(mpeg3_tfcos36, [9], );
62extern REAL_MATRIX(mpeg3_tfcos12, [3], );
63extern REAL_MATRIX(mpeg3_cos9, [3], );
64extern REAL_MATRIX(mpeg3_cos18, [3], );
65extern REAL_MATRIX(mpeg3_tan1_1, [16], );
66extern REAL_MATRIX(mpeg3_tan2_1, [16], );
67extern REAL_MATRIX(mpeg3_tan1_2, [16], );
68extern REAL_MATRIX(mpeg3_tan2_2, [16], );
69extern REAL_MATRIX(mpeg3_pow1_1, [2], [16]);
70extern REAL_MATRIX(mpeg3_pow2_1, [2], [16]);
71extern REAL_MATRIX(mpeg3_pow1_2, [2], [16]);
72extern REAL_MATRIX(mpeg3_pow2_2, [2], [16]);
73
74extern int mpeg3_longLimit[9][23];
75extern int mpeg3_shortLimit[9][14];
76
77extern struct mpeg3_bandInfoStruct mpeg3_bandInfo[9];
78
79extern int mpeg3_mapbuf0[9][152];
80extern int mpeg3_mapbuf1[9][156];
81extern int mpeg3_mapbuf2[9][44];
82extern int *mpeg3_map[9][3];
83extern int *mpeg3_mapend[9][3];
84
85extern unsigned int mpeg3_n_slen2[512]; /* MPEG 2.0 slen for 'normal' mode */
86extern unsigned int mpeg3_i_slen2[256]; /* MPEG 2.0 slen for intensity stereo */
87
88#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/audio/uncouple.c b/core/multimedia/opieplayer/libmpeg3/audio/uncouple.c
new file mode 100644
index 0000000..d87a078
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/audio/uncouple.c
@@ -0,0 +1,135 @@
1/*
2 *
3 *uncouple.c Copyright (C) Aaron Holtzman - May 1999
4 *
5 * This file is part of libmpeg3
6 *
7 * libmpeg3 is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * libmpeg3 is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22
23#include "../bitstream.h"
24#include "mpeg3audio.h"
25
26static unsigned char mpeg3_first_bit_lut[256] =
27{
28 0, 8, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5,
29 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
30 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
31 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
32 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
33 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
34 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
35 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
39 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
41 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
42 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
43 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
44};
45
46/* Converts an unsigned exponent in the range of 0-24 and a 16 bit mantissa
47 * to an IEEE single precision floating point value */
48static inline void mpeg3audio_ac3_convert_to_float(unsigned short exp,
49 unsigned short mantissa,
50 unsigned MPEG3_INT32 *dest)
51{
52 int num;
53 short exponent;
54 int i;
55
56/* If the mantissa is zero we can simply return zero */
57 if(mantissa == 0)
58 {
59 *dest = 0;
60 return;
61 }
62
63/* Exponent is offset by 127 in IEEE format minus the shift to
64 * align the mantissa to 1.f (subtracted in the final result) */
65 exponent = 127 - exp;
66
67/* Take care of the one asymmetric negative number */
68 if(mantissa == 0x8000)
69 mantissa++;
70
71/* Extract the sign bit, invert the mantissa if it's negative, and
72 shift out the sign bit */
73 if(mantissa & 0x8000)
74 {
75 mantissa *= -1;
76 num = 0x80000000 + (exponent << 23);
77 }
78 else
79 {
80 mantissa *= 1;
81 num = exponent << 23;
82 }
83
84/* Find the index of the most significant one bit */
85 i = mpeg3_first_bit_lut[mantissa >> 8];
86
87 if(i == 0)
88 i = mpeg3_first_bit_lut[mantissa & 0xff] + 8;
89
90 *dest = num - (i << 23) + (mantissa << (7 + i));
91 return;
92}
93
94
95int mpeg3audio_ac3_uncouple(mpeg3audio_t *audio,
96 mpeg3_ac3bsi_t *bsi,
97 mpeg3_ac3audblk_t *audblk,
98 mpeg3_stream_coeffs_t *coeffs)
99{
100 int i, j;
101
102 for(i = 0; i < bsi->nfchans; i++)
103 {
104 for(j = 0; j < audblk->endmant[i]; j++)
105 mpeg3audio_ac3_convert_to_float(audblk->fbw_exp[i][j],
106 audblk->chmant[i][j],
107 (unsigned MPEG3_INT32*)&coeffs->fbw[i][j]);
108 }
109
110 if(audblk->cplinu)
111 {
112 for(i = 0; i < bsi->nfchans; i++)
113 {
114 if(audblk->chincpl[i])
115 {
116 mpeg3audio_ac3_uncouple_channel(audio,
117 coeffs,
118 audblk,
119 i);
120 }
121 }
122
123 }
124
125 if(bsi->lfeon)
126 {
127/* There are always 7 mantissas for lfe */
128 for(j = 0; j < 7 ; j++)
129 mpeg3audio_ac3_convert_to_float(audblk->lfe_exp[j],
130 audblk->lfemant[j],
131 (unsigned MPEG3_INT32*)&coeffs->lfe[j]);
132
133 }
134 return 0;
135}
diff --git a/core/multimedia/opieplayer/libmpeg3/bitstream.c b/core/multimedia/opieplayer/libmpeg3/bitstream.c
new file mode 100644
index 0000000..b4f46e3
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/bitstream.c
@@ -0,0 +1,167 @@
1#include "mpeg3private.h"
2#include "mpeg3protos.h"
3
4#include <stdlib.h>
5
6mpeg3_bits_t* mpeg3bits_new_stream(mpeg3_t *file, mpeg3_demuxer_t *demuxer)
7{
8 mpeg3_bits_t *stream = (mpeg3_bits_t*)malloc(sizeof(mpeg3_bits_t));
9 stream->bfr = 0;
10 stream->bfr_size = 0;
11 stream->bit_number = 0;
12 stream->file = file;
13 stream->demuxer = demuxer;
14 stream->input_ptr = 0;
15 return stream;
16}
17
18int mpeg3bits_delete_stream(mpeg3_bits_t* stream)
19{
20 free(stream);
21 return 0;
22}
23
24
25/* Fill a buffer. Only works if bit_number is on an 8 bit boundary */
26int mpeg3bits_read_buffer(mpeg3_bits_t* stream, unsigned char *buffer, int bytes)
27{
28 int result, i = 0;
29 while(stream->bit_number > 0)
30 {
31 stream->bit_number -= 8;
32 mpeg3demux_read_prev_char(stream->demuxer);
33 }
34
35 stream->bit_number = 0;
36 stream->bfr_size = 0;
37 stream->bfr = 0;
38 result = mpeg3demux_read_data(stream->demuxer, buffer, bytes);
39 return result;
40}
41
42/* For mp3 decompression use a pointer in a buffer for getbits. */
43int mpeg3bits_use_ptr(mpeg3_bits_t* stream, unsigned char *buffer)
44{
45 stream->bfr_size = stream->bit_number = 0;
46 stream->bfr = 0;
47 stream->input_ptr = buffer;
48 return 0;
49}
50
51/* Go back to using the demuxer for getbits in mp3. */
52int mpeg3bits_use_demuxer(mpeg3_bits_t* stream)
53{
54 if(stream->input_ptr)
55 {
56 stream->bfr_size = stream->bit_number = 0;
57 stream->input_ptr = 0;
58 stream->bfr = 0;
59 }
60
61 return 0;
62}
63
64/* Reconfigure for reverse operation */
65/* Default is forward operation */
66void mpeg3bits_start_reverse(mpeg3_bits_t* stream)
67{
68 int i;
69 for(i = 0; i < stream->bfr_size; i += 8)
70 if(stream->input_ptr)
71 stream->input_ptr--;
72 else
73 mpeg3demux_read_prev_char(stream->demuxer);
74}
75
76/* Reconfigure for forward operation */
77void mpeg3bits_start_forward(mpeg3_bits_t* stream)
78{
79 int i;
80 for(i = 0; i < stream->bfr_size; i += 8)
81 if(stream->input_ptr)
82 stream->input_ptr++;
83 else
84 mpeg3demux_read_char(stream->demuxer);
85}
86
87/* Erase the buffer with the next 4 bytes in the file. */
88int mpeg3bits_refill(mpeg3_bits_t* stream)
89{
90 stream->bit_number = 32;
91 stream->bfr_size = 32;
92
93 if(stream->input_ptr)
94 {
95 stream->bfr = (unsigned int)(*stream->input_ptr++) << 24;
96 stream->bfr |= (unsigned int)(*stream->input_ptr++) << 16;
97 stream->bfr |= (unsigned int)(*stream->input_ptr++) << 8;
98 stream->bfr |= *stream->input_ptr++;
99 }
100 else
101 {
102 stream->bfr = mpeg3demux_read_char(stream->demuxer) << 24;
103 stream->bfr |= mpeg3demux_read_char(stream->demuxer) << 16;
104 stream->bfr |= mpeg3demux_read_char(stream->demuxer) << 8;
105 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
106 }
107 return mpeg3demux_eof(stream->demuxer);
108}
109
110/* Erase the buffer with the previous 4 bytes in the file. */
111int mpeg3bits_refill_backwards(mpeg3_bits_t* stream)
112{
113 stream->bit_number = 0;
114 stream->bfr_size = 32;
115 stream->bfr = mpeg3demux_read_prev_char(stream->demuxer);
116 stream->bfr |= (unsigned int)mpeg3demux_read_prev_char(stream->demuxer) << 8;
117 stream->bfr |= (unsigned int)mpeg3demux_read_prev_char(stream->demuxer) << 16;
118 stream->bfr |= (unsigned int)mpeg3demux_read_prev_char(stream->demuxer) << 24;
119 return mpeg3demux_eof(stream->demuxer);
120}
121
122int mpeg3bits_byte_align(mpeg3_bits_t *stream)
123{
124 stream->bit_number = (stream->bit_number + 7) & 0xf8;
125 return 0;
126}
127
128int mpeg3bits_seek_end(mpeg3_bits_t* stream)
129{
130 stream->bfr_size = stream->bit_number = 0;
131 return mpeg3demux_seek_byte(stream->demuxer, mpeg3demuxer_total_bytes(stream->demuxer));
132}
133
134int mpeg3bits_seek_start(mpeg3_bits_t* stream)
135{
136 stream->bfr_size = stream->bit_number = 0;
137 return mpeg3demux_seek_byte(stream->demuxer, 0);
138}
139
140int mpeg3bits_seek_time(mpeg3_bits_t* stream, double time_position)
141{
142 stream->bfr_size = stream->bit_number = 0;
143 return mpeg3demux_seek_time(stream->demuxer, time_position);
144}
145
146int mpeg3bits_seek_byte(mpeg3_bits_t* stream, long position)
147{
148 stream->bfr_size = stream->bit_number = 0;
149 return mpeg3demux_seek_byte(stream->demuxer, position);
150}
151
152int mpeg3bits_seek_percentage(mpeg3_bits_t* stream, double percentage)
153{
154 stream->bfr_size = stream->bit_number = 0;
155 return mpeg3demux_seek_percentage(stream->demuxer, percentage);
156}
157
158int mpeg3bits_tell(mpeg3_bits_t* stream)
159{
160 return mpeg3demux_tell(stream->demuxer);
161}
162
163int mpeg3bits_getbitoffset(mpeg3_bits_t *stream)
164{
165 return stream->bit_number & 7;
166}
167
diff --git a/core/multimedia/opieplayer/libmpeg3/bitstream.h b/core/multimedia/opieplayer/libmpeg3/bitstream.h
new file mode 100644
index 0000000..2f6dcf9
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/bitstream.h
@@ -0,0 +1,207 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef BITSTREAM_H
21#define BITSTREAM_H
22
23#include "mpeg3demux.h"
24
25#if defined(__cplusplus)
26extern "C" {
27#endif
28
29// next bit in forward direction
30// next bit in reverse direction |
31// v v
32// | | | | | | | | | | | | | | | | | | | | | | | | | | |1|1|1|1|1|1| */
33// ^ ^
34// | bit_number = 1
35// bfr_size = 6
36
37typedef struct
38{
39 unsigned MPEG3_INT32 bfr; /* bfr = buffer for bits */
40 int bit_number; /* position of pointer in bfr */
41 int bfr_size; /* number of bits in bfr. Should always be a multiple of 8 */
42 struct mpeg3_rec *file; /* Mpeg2 file */
43 mpeg3_demuxer_t *demuxer; /* Mpeg2 demuxer */
44/* If the input ptr is true, data is read from it instead of the demuxer. */
45 unsigned char *input_ptr;
46} mpeg3_bits_t;
47
48LIBMPEG_EXPORT unsigned int mpeg3demux_read_char_packet(mpeg3_demuxer_t *demuxer);
49LIBMPEG_EXPORT unsigned int mpeg3demux_read_prev_char_packet(mpeg3_demuxer_t *demuxer);
50
51/* ======================================================================== */
52/* Entry Points */
53/* ======================================================================== */
54
55#define mpeg3bits_tell_percentage(stream) mpeg3demux_tell_percentage((stream)->demuxer)
56
57#define mpeg3bits_packet_time(stream) mpeg3demux_current_time((stream)->demuxer)
58
59#define mpeg3bits_time_offset(stream) mepg2demux_time_offset((stream)->demuxer)
60
61#define mpeg3bits_error(stream) mpeg3demux_error((stream)->demuxer)
62
63#define mpeg3bits_eof(stream) mpeg3demux_eof((stream)->demuxer)
64
65#define mpeg3bits_bof(stream) mpeg3demux_bof((stream)->demuxer)
66
67/* Read bytes backward from the file until the reverse_bits is full. */
68static inline void mpeg3bits_fill_reverse_bits(mpeg3_bits_t* stream, int bits)
69{
70// Right justify
71 while(stream->bit_number > 7)
72 {
73 stream->bfr >>= 8;
74 stream->bfr_size -= 8;
75 stream->bit_number -= 8;
76 }
77
78// Insert bytes before bfr_size
79 while(stream->bfr_size - stream->bit_number < bits)
80 {
81 if(stream->input_ptr)
82 stream->bfr |= (unsigned int)(*--stream->input_ptr) << stream->bfr_size;
83 else
84 stream->bfr |= (unsigned int)mpeg3demux_read_prev_char(stream->demuxer) << stream->bfr_size;
85 stream->bfr_size += 8;
86 }
87}
88
89/* Read bytes forward from the file until the forward_bits is full. */
90extern inline void mpeg3bits_fill_bits(mpeg3_bits_t* stream, int bits)
91{
92 while(stream->bit_number < bits)
93 {
94 stream->bfr <<= 8;
95 if(stream->input_ptr)
96 {
97 stream->bfr |= *stream->input_ptr++;
98 }
99 else
100 {
101 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
102 }
103 stream->bit_number += 8;
104 stream->bfr_size += 8;
105 if(stream->bfr_size > 32) stream->bfr_size = 32;
106 }
107}
108
109/* Return 8 bits, advancing the file position. */
110extern inline unsigned int mpeg3bits_getbyte_noptr(mpeg3_bits_t* stream)
111{
112 if(stream->bit_number < 8)
113 {
114 stream->bfr <<= 8;
115 if(stream->input_ptr)
116 stream->bfr |= *stream->input_ptr++;
117 else
118 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
119
120 stream->bfr_size += 8;
121 if(stream->bfr_size > 32) stream->bfr_size = 32;
122
123 return (stream->bfr >> stream->bit_number) & 0xff;
124 }
125 return (stream->bfr >> (stream->bit_number -= 8)) & 0xff;
126}
127
128extern inline unsigned int mpeg3bits_getbit_noptr(mpeg3_bits_t* stream)
129{
130 if(!stream->bit_number)
131 {
132 stream->bfr <<= 8;
133 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
134
135 stream->bfr_size += 8;
136 if(stream->bfr_size > 32) stream->bfr_size = 32;
137
138 stream->bit_number = 7;
139
140 return (stream->bfr >> 7) & 0x1;
141 }
142 return (stream->bfr >> (--stream->bit_number)) & (0x1);
143}
144
145/* Return n number of bits, advancing the file position. */
146/* Use in place of flushbits */
147extern inline unsigned int mpeg3bits_getbits(mpeg3_bits_t* stream, int bits)
148{
149 if(bits <= 0) return 0;
150 mpeg3bits_fill_bits(stream, bits);
151 return (stream->bfr >> (stream->bit_number -= bits)) & (0xffffffff >> (32 - bits));
152}
153
154extern inline unsigned int mpeg3bits_showbits24_noptr(mpeg3_bits_t* stream)
155{
156 while(stream->bit_number < 24)
157 {
158 stream->bfr <<= 8;
159 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
160 stream->bit_number += 8;
161 stream->bfr_size += 8;
162 if(stream->bfr_size > 32) stream->bfr_size = 32;
163 }
164 return (stream->bfr >> (stream->bit_number - 24)) & 0xffffff;
165}
166
167extern inline unsigned int mpeg3bits_showbits32_noptr(mpeg3_bits_t* stream)
168{
169 while(stream->bit_number < 32)
170 {
171 stream->bfr <<= 8;
172 stream->bfr |= mpeg3demux_read_char(stream->demuxer);
173 stream->bit_number += 8;
174 stream->bfr_size += 8;
175 if(stream->bfr_size > 32) stream->bfr_size = 32;
176 }
177 return stream->bfr;
178}
179
180extern inline unsigned int mpeg3bits_showbits(mpeg3_bits_t* stream, int bits)
181{
182 mpeg3bits_fill_bits(stream, bits);
183 return (stream->bfr >> (stream->bit_number - bits)) & (0xffffffff >> (32 - bits));
184}
185
186extern inline unsigned int mpeg3bits_getbits_reverse(mpeg3_bits_t* stream, int bits)
187{
188 unsigned int result;
189 mpeg3bits_fill_reverse_bits(stream, bits);
190 result = (stream->bfr >> stream->bit_number) & (0xffffffff >> (32 - bits));
191 stream->bit_number += bits;
192 return result;
193}
194
195extern inline unsigned int mpeg3bits_showbits_reverse(mpeg3_bits_t* stream, int bits)
196{
197 unsigned int result;
198 mpeg3bits_fill_reverse_bits(stream, bits);
199 result = (stream->bfr >> stream->bit_number) & (0xffffffff >> (32 - bits));
200 return result;
201}
202
203#if defined(__cplusplus)
204}
205#endif
206
207#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/c_flags b/core/multimedia/opieplayer/libmpeg3/c_flags
new file mode 100755
index 0000000..0c8a75d
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/c_flags
@@ -0,0 +1,4 @@
1case "$1" in
2 *.c) echo $CFLAGS_lessopt
3;; *) echo $CFLAGS
4esac
diff --git a/core/multimedia/opieplayer/libmpeg3/configure b/core/multimedia/opieplayer/libmpeg3/configure
new file mode 100755
index 0000000..e75af76
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/configure
@@ -0,0 +1,102 @@
1#!/bin/sh
2
3USE_MMX=1
4USE_CSS=1
5LESS_OPT=
6PLATFORM_CFLAGS="-malign-loops=2 -malign-jumps=2 -malign-functions=2 -march=i486"
7DEBUG=
8OPTIMIZE=-O2
9OPTIMIZE_less=-O
10DEFINES=
11CC=gcc
12
13for ac_option
14do
15case "$ac_option" in
16 --fixed-point)
17 CC=g++
18 DEFINES="$DEFINES -DUSE_FIXED_POINT"
19 ;;
20
21 --lessopt)
22 LESS_OPT=1
23 ;;
24
25 --no-mmx)
26 USE_MMX=0
27 ;;
28
29 --no-css)
30 USE_CSS=0
31 ;;
32
33 --debug)
34 DEBUG=-g
35 ;;
36
37 --gcc-prefix=*)
38 CROSS=${ac_option#--gcc-prefix=}
39 PLATFORM_CFLAGS=""
40 ;;
41 -h | --help | -help)
42 cat << EOF
43Options:
44 --no-mmx Compile libmpeg3 with no MMX support.
45 --no-css Compile libmpeg3 with no CSS support.
46 --fixed-point Compile libmpeg3 to use integers instead of floats.
47 --debug Compile libmpeg3 with debug support.
48EOF
49 exit 0
50 ;;
51
52 *)
53 ;;
54esac
55done
56
57
58echo "Configuring libmpeg3"
59
60cat > global_config << EOF
61# DO NOT EDIT. EDIT ./configure INSTEAD AND RERUN IT.
62EOF
63
64
65if test -z "$CFLAGS"; then
66 CF="$DEFINES $DEBUG -funroll-loops -fomit-frame-pointer $PLATFORM_CFLAGS"
67 echo >> global_config "CFLAGS = $CF $OPTIMIZE"
68 if test -z "$LESS_OPT"; then
69 echo >> global_config "CFLAGS_lessopt = $CF $OPTIMIZE_less"
70 else
71 echo >> global_config "CFLAGS_lessopt = $CF $OPTIMIZE_less"
72 fi
73fi
74
75cat >> global_config << EOF
76CC = ${CROSS}$CC
77AR = ${CROSS}ar
78NASM = nasm
79EOF
80
81if [ ${USE_CSS} = 1 ]; then
82cat >> global_config << EOF
83CFLAGS += -DHAVE_CSS
84EOF
85fi
86
87if [ ${USE_MMX} = 1 ]; then
88cat >> global_config << EOF
89CFLAGS += -DHAVE_MMX
90MMXOBJS = \
91 video/mmxidct.o \
92 video/reconmmx.o
93MMXOBJS2 = \
94 mmxidct.o \
95 reconmmx.o
96EOF
97fi
98
99
100
101
102echo "done"
diff --git a/core/multimedia/opieplayer/libmpeg3/docs/index.html b/core/multimedia/opieplayer/libmpeg3/docs/index.html
new file mode 100644
index 0000000..2d79978
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/docs/index.html
@@ -0,0 +1,306 @@
1<TITLE>LibMPEG3</TITLE>
2
3<CENTER>
4<FONT FACE=HELVETICA SIZE=+4><B>Using LibMPEG3 to make your own MPEG applications</B></FONT><P>
5
6<TABLE>
7<TR>
8<TD>
9<CODE>
10Author: Adam Williams broadcast@earthling.net<BR>
11Homepage: heroinewarrior.com<BR>
12</CODE>
13</TD>
14</TR>
15</TABLE>
16</CENTER>
17
18<P>
19
20
21LibMPEG3 decodes the many many derivatives of MPEG standards into
22uncompressed data suitable for editing and playback.<P>
23
24libmpeg3 currently decodes:<P>
25
26<BLOCKQUOTE>MPEG-2 video<BR>
27MPEG-1 video<BR>
28mp3 audio<BR>
29mp2 audio<BR>
30ac3 audio<BR>
31MPEG-2 system streams<BR>
32MPEG-1 system streams
33</BLOCKQUOTE><P>
34
35The video output can be in many different color models and frame
36sizes. The audio output can be in twos compliment or floating
37point.<P>
38
39
40
41
42
43
44
45
46
47<FONT FACE=HELVETICA SIZE=+4><B>STEP 1: Verifying file compatibility</B></FONT><P>
48
49Programs using libmpeg3 must <CODE>#include "libmpeg3.h"</CODE>.<P>
50
51Call <CODE>mpeg3_check_sig</CODE> to verify if the file can be read by
52libmpeg3. This returns a 1 if it is compatible and 0 if it isn't.<P>
53
54
55
56
57
58
59
60
61
62
63
64<FONT FACE=HELVETICA SIZE=+4><B>STEP 2: Open the file</B></FONT><P>
65
66You need an <CODE>mpeg3_t*</CODE> file descriptor:<P>
67<CODE>
68mpeg3_t* file;
69</CODE>
70<P>
71
72Then you need to open the file:<P>
73
74<CODE>file = mpeg3_open(char *path);</CODE><P>
75
76<CODE>mpeg3_open</CODE> returns a NULL if the file couldn't be opened
77for some reason. Be sure to check this. Everything you do with
78libmpeg3 requires passing the <CODE>file</CODE> pointer.<P>
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93<FONT FACE=HELVETICA SIZE=+4><B>STEP 3: How many CPUs do you want to use?</B></FONT><P>
94
95Call <CODE>mpeg3_set_cpus(mpeg3_t *file, int cpus)</CODE> to set how
96many CPUs should be devoted to video decompression. LibMPEG3 can use
97any number. If you don't call this right after opening the file, the
98CPU number defaults to 1.<P>
99
100
101
102
103
104
105
106<FONT FACE=HELVETICA SIZE=+4><B>STEP 4: Get some information about the file.</B></FONT><P>
107
108There are a number of queries for the audio components of the stream:<P>
109
110<CODE><PRE>
111int mpeg3_has_audio(mpeg3_t *file);
112int mpeg3_total_astreams(mpeg3_t *file); // Number of multiplexed audio streams
113int mpeg3_audio_channels(mpeg3_t *file, int stream);
114int mpeg3_sample_rate(mpeg3_t *file, int stream);
115long mpeg3_audio_samples(mpeg3_t *file, int stream); // Total length
116</PRE></CODE>
117
118The audio is presented as a number of <B>streams</B> starting at 0 and
119including <CODE>mpeg3_total_astreams</CODE> - 1. Each stream contains a
120certain number of <B>channels</B> starting at 0 and including
121<CODE>mpeg3_audio_channels</CODE> - 1.
122
123The methodology is first determine if the file has audio, then get
124the number of streams in the file, then for each stream get the number
125of channels, sample rate, and length.<P>
126
127There are also queries for the video components:<P>
128
129<CODE><PRE>
130int mpeg3_has_video(mpeg3_t *file);
131int mpeg3_total_vstreams(mpeg3_t *file); // Number of multiplexed video streams
132int mpeg3_video_width(mpeg3_t *file, int stream);
133int mpeg3_video_height(mpeg3_t *file, int stream);
134float mpeg3_frame_rate(mpeg3_t *file, int stream); // Frames/sec
135long mpeg3_video_frames(mpeg3_t *file, int stream); // Total length
136</PRE></CODE>
137
138The video behavior is the same as with audio, except that video has no
139subdivision under <B>streams</B>. Frame rate is a floating point
140number of frames per second.<P>
141
142
143
144
145
146
147
148<FONT FACE=HELVETICA SIZE=+4><B>STEP 5: Seeking to a point in the file</B></FONT><P>
149
150Each audio stream and each video stream has a position in the file
151independant of each other stream. A variety of methods are available
152for specifying the position of a stream: percentage, frame, sample.
153Which method you use depends on whether you're seeking audio or video
154and whether you're seeking all tracks to a percentage of the file.<P>
155
156The preferred seeking method if you're writing a player is:<P>
157
158<CODE><PRE>
159int mpeg3_seek_percentage(mpeg3_t *file, double percentage);
160double mpeg3_tell_percentage(mpeg3_t *file);
161</PRE></CODE>
162
163This seeks all tracks to a percentage of the file length. The
164percentage is from 0 to 1.<P>
165
166The alternative is absolute seeking. The audio seeking is handled
167by:<P>
168
169<CODE><PRE>
170int mpeg3_set_sample(mpeg3_t *file, long sample, int stream); // Seek
171long mpeg3_get_sample(mpeg3_t *file, int stream); // Tell current position
172</PRE></CODE>
173
174and the video seeking is handled by:<P>
175
176<CODE><PRE>
177int mpeg3_set_frame(mpeg3_t *file, long frame, int stream); // Seek
178long mpeg3_get_frame(mpeg3_t *file, int stream); // Tell current position
179</PRE></CODE>
180
181
182You can either perform percentage seeking or absolute seeking but not
183both on the same file handle. Once you perform either method, the file
184becomes configured for that method.<P>
185
186If you're in percentage seeking mode and you want the current time
187stamp in the file you can't use mpeg3_tell_percentage because you don't
188know how many seconds the total length is. The
189<CODE>mpeg3_audio_samples</CODE> and <CODE>mpeg3_video_frames</CODE>
190commands don't work in percentage seeking. Instead use
191
192<CODE><PRE>
193double mpeg3_get_time(mpeg3_t *file);
194</PRE></CODE>
195
196which gives you the last timecode read in seconds. The MPEG standard
197specifies timecodes being placed in the streams.<P>
198
199
200
201
202
203
204
205
206
207
208
209<FONT FACE=HELVETICA SIZE=+4><B>STEP 6: Read the data</B></FONT><P>
210
211To read <B>audio</B> data use:<P>
212
213<CODE><PRE>
214int mpeg3_read_audio(mpeg3_t *file,
215 float *output_f, // Pointer to pre-allocated buffer of floats
216 short *output_i, // Pointer to pre-allocated buffer if int16's
217 int channel, // Channel to decode
218 long samples, // Number of samples to decode
219 int stream); // Stream containing the channel
220</PRE></CODE>
221
222This decodes a buffer of sequential floats or int16's for a single
223channel, depending on which *output... parameter has a nonzero
224argument. To get a floating point buffer pass a pre-allocated buffer
225to <CODE>output_f</CODE> and NULL to <CODE>output_i</CODE>. To get an
226int16 buffer pass NULL to <CODE>output_f</CODE> and a pre-allocated
227buffer to <CODE>output_i</CODE>.<P>
228
229After reading an audio buffer, the current position in the one stream
230is advanced. How then, do you read more than one channel of audio
231data? Use
232
233<CODE><PRE>
234mpeg3_reread_audio(mpeg3_t *file,
235 float *output_f, /* Pointer to pre-allocated buffer of floats */
236 short *output_i, /* Pointer to pre-allocated buffer of int16's */
237 int channel, /* Channel to decode */
238 long samples, /* Number of samples to decode */
239 int stream);
240</PRE></CODE>
241
242to read each remaining channel after the first channel.<P>
243
244To read <B>video</B> data there are two methods. RGB frames or YUV
245frames. To get an RGB frame use:<BR>
246
247<CODE><PRE>
248int mpeg3_read_frame(mpeg3_t *file,
249 unsigned char **output_rows, // Array of pointers to the start of each output row
250 int in_x, // Location in input frame to take picture
251 int in_y,
252 int in_w,
253 int in_h,
254 int out_w, // Dimensions of output_rows
255 int out_h,
256 int color_model, // One of the color model #defines given above.
257 int stream);
258</PRE></CODE>
259
260The video decoding works like a camcorder taking copy of a movie
261screen. The decoder "sees" a region of the movie screen defined by
262<CODE>in_x, in_y, in_w, in_h</CODE> and transfers it to the frame
263buffer defined by <CODE>**output_rows</CODE>. The input values must be
264within the boundaries given by <CODE>mpeg3_video_width</CODE> and
265<CODE>mpeg3_video_height</CODE>. The size of the frame buffer is
266defined by <CODE>out_w, out_h</CODE>. Although the input dimensions
267are constrained, the frame buffer can be any size.<P>
268
269<CODE>color_model</CODE> defines which RGB color model the picture
270should be decoded to and the possible values are given in
271<B>libmpeg3.h</B>. The frame buffer pointed to by
272<CODE>output_rows</CODE> must have enough memory allocated to store the
273color model you select.<P>
274
275<B>You must allocate 4 extra bytes in the last output_row.</B> This is
276scratch area for the MMX routines.<P>
277
278<CODE>mpeg3_read_frame</CODE> advances the position in the one stream by 1 frame.<P>
279
280The alternative is YUV frames:<BR>
281
282<CODE><PRE>
283int mpeg3_read_yuvframe(mpeg3_t *file,
284 char *y_output,
285 char *u_output,
286 char *v_output,
287 int in_x,
288 int in_y,
289 int in_w,
290 int in_h,
291 int stream);
292</PRE></CODE>
293
294The behavior of in_x, in_y, in_w, in_h is identical to mpeg3_read_frame
295except here you have no control over the output frame size. <B>You
296must allocate in_w * in_h for the y_output, and in_w * in_h / 4 for the
297chroma outputs.</B><P>
298
299
300
301
302
303<FONT FACE=HELVETICA SIZE=+4><B>STEP 7: Close the file</B></FONT><P>
304
305Be sure to close the file with <CODE>mpeg3_close(mpeg3_t *file)</CODE>
306when you're done with it.
diff --git a/core/multimedia/opieplayer/libmpeg3/dump.c b/core/multimedia/opieplayer/libmpeg3/dump.c
new file mode 100644
index 0000000..7158712
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/dump.c
@@ -0,0 +1,79 @@
1#include "libmpeg3.h"
2#include <stdlib.h>
3
4#define BUFSIZE 4096
5
6int main(int argc, char *argv[])
7{
8 mpeg3_t *file;
9 int i, result = 0;
10 unsigned char *output, **output_rows;
11 float *audio_output_f;
12 short *audio_output_i;
13 long total_samples = 0;
14
15 if(argc < 2)
16 {
17 printf("Need an MPEG stream.\n");
18 exit(1);
19 }
20
21 file = mpeg3_open(argv[1]);
22 if(file)
23 {
24 fprintf(stderr, "MMX supported %d\n", file->have_mmx);
25 fprintf(stderr, "Audio streams: %d\n", mpeg3_total_astreams(file));
26 for(i = 0; i < mpeg3_total_astreams(file); i++)
27 {
28 fprintf(stderr, " Stream %d: channels %d sample rate %d total samples %ld\n",
29 i,
30 mpeg3_audio_channels(file, i),
31 mpeg3_sample_rate(file, i),
32 mpeg3_audio_samples(file, i));
33 }
34 fprintf(stderr, "Video streams: %d\n", mpeg3_total_vstreams(file));
35 for(i = 0; i < mpeg3_total_vstreams(file); i++)
36 {
37 fprintf(stderr, " Stream %d: width %d height %d frame rate %0.3f total frames %ld\n",
38 i,
39 mpeg3_video_width(file, i),
40 mpeg3_video_height(file, i),
41 mpeg3_frame_rate(file, i),
42 mpeg3_video_frames(file, i));
43 }
44fprintf(stderr,"S");
45
46 mpeg3_set_cpus(file, 1);
47fprintf(stderr,"s");
48 /* audio_output_f = malloc(BUFSIZE * sizeof(float)); */
49 audio_output_i = (short*)malloc(BUFSIZE * 2 * sizeof(short));
50fprintf(stderr,"x");
51 /* mpeg3_set_sample(file, 11229518, 0); */
52 /*result = mpeg3_read_audio(file, audio_output_f, 0, 0, BUFSIZE, 0);*/
53 for (i=0; i<100; i++) {
54fprintf(stderr,"c");
55 result = mpeg3_read_audio(file, 0, audio_output_i, 0, BUFSIZE, 0);
56fprintf(stderr,"read\n");
57 }
58 //fwrite(audio_output_i, BUFSIZE, 1, stdout);
59
60 output = (unsigned char*)malloc(mpeg3_video_width(file, 0) * mpeg3_video_height(file, 0) * 3 + 4);
61 output_rows = (unsigned char**)malloc(sizeof(unsigned char*) * mpeg3_video_height(file, 0));
62 for(i = 0; i < mpeg3_video_height(file, 0); i++)
63 output_rows[i] = &output[i * mpeg3_video_width(file, 0) * 3];
64 // mpeg3_set_frame(file, 1000, 0);
65 result = mpeg3_read_frame(file,
66 output_rows,
67 0,
68 0,
69 mpeg3_video_width(file, 0),
70 mpeg3_video_height(file, 0),
71 mpeg3_video_width(file, 0),
72 mpeg3_video_height(file, 0),
73 MPEG3_RGB888,
74 0);
75
76 mpeg3_close(file);
77 }
78 return 0;
79}
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3.c b/core/multimedia/opieplayer/libmpeg3/libmpeg3.c
new file mode 100644
index 0000000..c0fc570
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3.c
@@ -0,0 +1,672 @@
1#include "libmpeg3.h"
2#include "mpeg3protos.h"
3
4#include <stdlib.h>
5#include <string.h>
6
7#define MAX(a, b) ((a) > (b) ? (a) : (b))
8
9mpeg3_t* mpeg3_new(char *path)
10{
11 int i;
12 mpeg3_t *file = (mpeg3_t*)calloc(1, sizeof(mpeg3_t));
13 file->cpus = 1;
14 file->fs = mpeg3_new_fs(path);
15 file->have_mmx = mpeg3_mmx_test();
16 file->demuxer = mpeg3_new_demuxer(file, 0, 0, -1);
17 return file;
18}
19
20int mpeg3_delete(mpeg3_t *file)
21{
22 int i;
23
24 for(i = 0; i < file->total_vstreams; i++)
25 mpeg3_delete_vtrack(file, file->vtrack[i]);
26
27 for(i = 0; i < file->total_astreams; i++)
28 mpeg3_delete_atrack(file, file->atrack[i]);
29
30 mpeg3_delete_fs(file->fs);
31 mpeg3_delete_demuxer(file->demuxer);
32 free(file);
33}
34
35int mpeg3_check_sig(char *path)
36{
37 mpeg3_fs_t *fs;
38 unsigned int bits;
39 char *ext;
40 int result = 0;
41
42 fs = mpeg3_new_fs(path);
43 if(mpeg3io_open_file(fs))
44 {
45/* File not found */
46 return 0;
47 }
48
49 bits = mpeg3io_read_int32(fs);
50/* Test header */
51 if(bits == MPEG3_TOC_PREFIX || bits == MPEG3_TOC_PREFIXLOWER)
52 {
53 result = 1;
54 }
55 else
56 if((((bits >> 24) & 0xff) == MPEG3_SYNC_BYTE) ||
57 (bits == MPEG3_PACK_START_CODE) ||
58 ((bits & 0xfff00000) == 0xfff00000) ||
59 (bits == MPEG3_SEQUENCE_START_CODE) ||
60 (bits == MPEG3_PICTURE_START_CODE) ||
61 (((bits & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE) ||
62 ((bits >> 8) == MPEG3_ID3_PREFIX) ||
63 (bits == MPEG3_RIFF_CODE))
64 {
65 result = 1;
66
67 ext = strrchr(path, '.');
68 if(ext)
69 {
70/* Test file extension. */
71 if(strncasecmp(ext, ".mp2", 4) &&
72 strncasecmp(ext, ".mp3", 4) &&
73 strncasecmp(ext, ".m1v", 4) &&
74 strncasecmp(ext, ".m2v", 4) &&
75 strncasecmp(ext, ".m2s", 4) &&
76 strncasecmp(ext, ".mpg", 4) &&
77 strncasecmp(ext, ".vob", 4) &&
78 strncasecmp(ext, ".mpeg", 4) &&
79 strncasecmp(ext, ".ac3", 4))
80 result = 0;
81 }
82 }
83
84 mpeg3io_close_file(fs);
85 mpeg3_delete_fs(fs);
86 return result;
87}
88
89mpeg3_t* mpeg3_open_copy(char *path, mpeg3_t *old_file)
90{
91 mpeg3_t *file = 0;
92 unsigned int bits;
93 int i, done;
94
95/* Initialize the file structure */
96 file = mpeg3_new(path);
97
98/* Need to perform authentication before reading a single byte. */
99 if(mpeg3io_open_file(file->fs))
100 {
101 mpeg3_delete(file);
102 return 0;
103 }
104
105/* =============================== Create the title objects ========================= */
106 bits = mpeg3io_read_int32(file->fs);
107
108 if(bits == MPEG3_TOC_PREFIX || bits == MPEG3_TOC_PREFIXLOWER) /* TOCV */
109 {
110/* Table of contents for another file */
111 if(mpeg3_read_toc(file))
112 {
113 mpeg3_delete(file);
114 return 0;
115 }
116 mpeg3io_close_file(file->fs);
117 }
118 else
119 if(((bits >> 24) & 0xff) == MPEG3_SYNC_BYTE)
120 {
121/* Transport stream */
122 file->packet_size = MPEG3_TS_PACKET_SIZE;
123 file->is_transport_stream = 1;
124 }
125 else
126 if(bits == MPEG3_PACK_START_CODE)
127 {
128/* Program stream */
129 file->packet_size = MPEG3_DVD_PACKET_SIZE;
130 file->is_program_stream = 1;
131 }
132 else
133 if((bits & 0xfff00000) == 0xfff00000 ||
134 ((bits >> 8) == MPEG3_ID3_PREFIX) ||
135 (bits == MPEG3_RIFF_CODE))
136 {
137/* MPEG Audio only */
138 file->packet_size = MPEG3_DVD_PACKET_SIZE;
139 file->has_audio = 1;
140 file->is_audio_stream = 1;
141 }
142 else
143 if(bits == MPEG3_SEQUENCE_START_CODE ||
144 bits == MPEG3_PICTURE_START_CODE)
145 {
146/* Video only */
147 file->packet_size = MPEG3_DVD_PACKET_SIZE;
148 file->is_video_stream = 1;
149 }
150 else
151 if(((bits & 0xffff0000) >> 16) == MPEG3_AC3_START_CODE)
152 {
153/* AC3 Audio only */
154 file->packet_size = MPEG3_DVD_PACKET_SIZE;
155 file->has_audio = 1;
156 file->is_audio_stream = 1;
157 }
158 else
159 {
160/* file->packet_size = MPEG3_DVD_PACKET_SIZE; */
161/* file->is_audio_stream = 1; */
162 mpeg3_delete(file);
163 fprintf(stderr, "mpeg3_open: not an MPEG 2 stream\n");
164 return 0;
165 }
166
167/* Create title */
168/* Copy timecodes from an old demuxer */
169 if(old_file && mpeg3_get_demuxer(old_file))
170 {
171 mpeg3demux_copy_titles(file->demuxer, mpeg3_get_demuxer(old_file));
172 }
173 else
174/* Start from scratch */
175 if(!file->demuxer->total_titles)
176 {
177 mpeg3demux_create_title(file->demuxer, 0, 0);
178 }
179
180/* =============================== Get title information ========================= */
181 if(file->is_transport_stream || file->is_program_stream)
182 {
183/* Create video tracks */
184/* Video must be created before audio because audio uses the video timecode */
185/* to get its length. */
186 for(i = 0; i < MPEG3_MAX_STREAMS; i++)
187 {
188 if(file->demuxer->vstream_table[i])
189 {
190 file->vtrack[file->total_vstreams] = mpeg3_new_vtrack(file, i, file->demuxer);
191 if(file->vtrack[file->total_vstreams]) file->total_vstreams++;
192 }
193 }
194
195/* Create audio tracks */
196 for(i = 0; i < MPEG3_MAX_STREAMS; i++)
197 {
198 if(file->demuxer->astream_table[i])
199 {
200 file->atrack[file->total_astreams] = mpeg3_new_atrack(file,
201 i,
202 file->demuxer->astream_table[i],
203 file->demuxer);
204 if(file->atrack[file->total_astreams]) file->total_astreams++;
205 }
206 }
207 }
208 else
209 if(file->is_video_stream)
210 {
211/* Create video tracks */
212 file->vtrack[0] = mpeg3_new_vtrack(file, -1, file->demuxer);
213 if(file->vtrack[0]) file->total_vstreams++;
214 }
215 else
216 if(file->is_audio_stream)
217 {
218/* Create audio tracks */
219 file->atrack[0] = mpeg3_new_atrack(file, -1, AUDIO_UNKNOWN, file->demuxer);
220 if(file->atrack[0]) file->total_astreams++;
221 }
222
223 if(file->total_vstreams) file->has_video = 1;
224 if(file->total_astreams) file->has_audio = 1;
225
226 mpeg3io_close_file(file->fs);
227 return file;
228}
229
230mpeg3_t* mpeg3_open(char *path)
231{
232 return mpeg3_open_copy(path, 0);
233}
234
235int mpeg3_close(mpeg3_t *file)
236{
237/* File is closed in the same procedure it is opened in. */
238 mpeg3_delete(file);
239 return 0;
240}
241
242int mpeg3_set_cpus(mpeg3_t *file, int cpus)
243{
244 int i;
245 file->cpus = cpus;
246 for(i = 0; i < file->total_vstreams; i++)
247 mpeg3video_set_cpus(file->vtrack[i]->video, cpus);
248 return 0;
249}
250
251int mpeg3_set_mmx(mpeg3_t *file, int use_mmx)
252{
253 int i;
254 file->have_mmx = use_mmx;
255 for(i = 0; i < file->total_vstreams; i++)
256 mpeg3video_set_mmx(file->vtrack[i]->video, use_mmx);
257 return 0;
258}
259
260int mpeg3_generate_toc(FILE *output, char *path, int timecode_search, int print_streams)
261{
262 mpeg3_t *file = mpeg3_open(path);
263 mpeg3_demuxer_t *demuxer;
264 int i;
265
266 if(file)
267 {
268 fprintf(output, "TOCVERSION 2\n"
269 "PATH: %s\n", path);
270 demuxer = mpeg3_new_demuxer(file, 0, 0, -1);
271 mpeg3demux_create_title(demuxer, timecode_search, output);
272/* Just print the first title's streams */
273 if(print_streams) mpeg3demux_print_streams(demuxer, output);
274
275 fprintf(output, "SIZE: %ld\n", demuxer->titles[demuxer->current_title]->total_bytes);
276 fprintf(output, "PACKETSIZE: %ld\n", demuxer->packet_size);
277
278 mpeg3demux_print_timecodes(demuxer->titles[demuxer->current_title], output);
279
280 mpeg3_delete_demuxer(demuxer);
281 mpeg3_close(file);
282 return 0;
283 }
284 return 1;
285}
286
287int mpeg3_read_toc(mpeg3_t *file)
288{
289 char string[MPEG3_STRLEN];
290 int number1;
291
292/* Test version number */
293 file->is_program_stream = 1;
294 mpeg3io_seek(file->fs, 0);
295 fscanf(file->fs->fd, "%s %d", string, &number1);
296 if(number1 > 2 || number1 < 2) return 1;
297
298/* Read titles */
299 mpeg3demux_read_titles(file->demuxer);
300 return 0;
301}
302
303int mpeg3_has_audio(mpeg3_t *file)
304{
305 return file->has_audio;
306}
307
308int mpeg3_total_astreams(mpeg3_t *file)
309{
310 return file->total_astreams;
311}
312
313int mpeg3_audio_channels(mpeg3_t *file,
314 int stream)
315{
316 if(file->has_audio)
317 return file->atrack[stream]->channels;
318 return -1;
319}
320
321int mpeg3_sample_rate(mpeg3_t *file,
322 int stream)
323{
324 if(file->has_audio)
325 return file->atrack[stream]->sample_rate;
326 return -1;
327}
328
329long mpeg3_get_sample(mpeg3_t *file,
330 int stream)
331{
332 if(file->has_audio)
333 return file->atrack[stream]->current_position;
334 return -1;
335}
336
337int mpeg3_set_sample(mpeg3_t *file,
338 long sample,
339 int stream)
340{
341 if(file->has_audio)
342 {
343 file->atrack[stream]->current_position = sample;
344 mpeg3audio_seek_sample(file->atrack[stream]->audio, sample);
345 return 0;
346 }
347 return -1;
348}
349
350long mpeg3_audio_samples(mpeg3_t *file,
351 int stream)
352{
353 if(file->has_audio)
354 return file->atrack[stream]->total_samples;
355 return -1;
356}
357
358int mpeg3_has_video(mpeg3_t *file)
359{
360 return file->has_video;
361}
362
363int mpeg3_total_vstreams(mpeg3_t *file)
364{
365 return file->total_vstreams;
366}
367
368int mpeg3_video_width(mpeg3_t *file,
369 int stream)
370{
371 if(file->has_video)
372 return file->vtrack[stream]->width;
373 return -1;
374}
375
376int mpeg3_video_height(mpeg3_t *file,
377 int stream)
378{
379 if(file->has_video)
380 return file->vtrack[stream]->height;
381 return -1;
382}
383
384float mpeg3_frame_rate(mpeg3_t *file,
385 int stream)
386{
387 if(file->has_video)
388 return file->vtrack[stream]->frame_rate;
389 return -1;
390}
391
392long mpeg3_video_frames(mpeg3_t *file,
393 int stream)
394{
395 if(file->has_video)
396 return file->vtrack[stream]->total_frames;
397 return -1;
398}
399
400long mpeg3_get_frame(mpeg3_t *file,
401 int stream)
402{
403 if(file->has_video)
404 return file->vtrack[stream]->current_position;
405 return -1;
406}
407
408int mpeg3_set_frame(mpeg3_t *file,
409 long frame,
410 int stream)
411{
412 if(file->has_video)
413 {
414 file->vtrack[stream]->current_position = frame;
415 mpeg3video_seek_frame(file->vtrack[stream]->video, frame);
416 return 0;
417 }
418 return -1;
419}
420
421int mpeg3_seek_percentage(mpeg3_t *file, double percentage)
422{
423 int i;
424 for(i = 0; i < file->total_astreams; i++)
425 {
426 mpeg3audio_seek_percentage(file->atrack[i]->audio, percentage);
427 }
428
429 for(i = 0; i < file->total_vstreams; i++)
430 {
431 mpeg3video_seek_percentage(file->vtrack[i]->video, percentage);
432 }
433 return 0;
434}
435
436int mpeg3_previous_frame(mpeg3_t *file, int stream)
437{
438 file->last_type_read = 2;
439 file->last_stream_read = stream;
440
441 if(file->has_video)
442 return mpeg3video_previous_frame(file->vtrack[stream]->video);
443}
444
445double mpeg3_tell_percentage(mpeg3_t *file)
446{
447 double percent = 0;
448 if(file->last_type_read == 1)
449 {
450 percent = mpeg3demux_tell_percentage(file->atrack[file->last_stream_read]->demuxer);
451 }
452
453 if(file->last_type_read == 2)
454 {
455 percent = mpeg3demux_tell_percentage(file->vtrack[file->last_stream_read]->demuxer);
456 }
457 return percent;
458}
459
460double mpeg3_get_time(mpeg3_t *file)
461{
462 double atime = 0, vtime = 0;
463
464 if(file->is_transport_stream || file->is_program_stream)
465 {
466/* Timecode only available in transport stream */
467 if(file->last_type_read == 1)
468 {
469 atime = mpeg3demux_get_time(file->atrack[file->last_stream_read]->demuxer);
470 }
471 else
472 if(file->last_type_read == 2)
473 {
474 vtime = mpeg3demux_get_time(file->vtrack[file->last_stream_read]->demuxer);
475 }
476 }
477 else
478 {
479/* Use percentage and total time */
480 if(file->has_audio)
481 {
482 atime = mpeg3demux_tell_percentage(file->atrack[0]->demuxer) *
483 mpeg3_audio_samples(file, 0) / mpeg3_sample_rate(file, 0);
484 }
485
486 if(file->has_video)
487 {
488 vtime = mpeg3demux_tell_percentage(file->vtrack[0]->demuxer) *
489 mpeg3_video_frames(file, 0) / mpeg3_frame_rate(file, 0);
490 }
491 }
492
493 return MAX(atime, vtime);
494}
495
496int mpeg3_end_of_audio(mpeg3_t *file, int stream)
497{
498 int result = 0;
499 result = mpeg3demux_eof(file->atrack[stream]->demuxer);
500 return result;
501}
502
503int mpeg3_end_of_video(mpeg3_t *file, int stream)
504{
505 int result = 0;
506 result = mpeg3demux_eof(file->vtrack[stream]->demuxer);
507 return result;
508}
509
510
511int mpeg3_read_frame(mpeg3_t *file,
512 unsigned char **output_rows,
513 int in_x,
514 int in_y,
515 int in_w,
516 int in_h,
517 int out_w,
518 int out_h,
519 int color_model,
520 int stream)
521{
522 int result = -1;
523
524 if(file->has_video)
525 {
526 result = mpeg3video_read_frame(file->vtrack[stream]->video,
527 file->vtrack[stream]->current_position,
528 output_rows,
529 in_x,
530 in_y,
531 in_w,
532 in_h,
533 out_w,
534 out_h,
535 color_model);
536 file->last_type_read = 2;
537 file->last_stream_read = stream;
538 file->vtrack[stream]->current_position++;
539 }
540 return result;
541}
542
543int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream)
544{
545 int result = -1;
546
547 if(file->has_video)
548 {
549 result = mpeg3video_drop_frames(file->vtrack[stream]->video,
550 frames);
551 if(frames > 0) file->vtrack[stream]->current_position += frames;
552 file->last_type_read = 2;
553 file->last_stream_read = stream;
554 }
555 return result;
556}
557
558int mpeg3_read_yuvframe(mpeg3_t *file,
559 char *y_output,
560 char *u_output,
561 char *v_output,
562 int in_x,
563 int in_y,
564 int in_w,
565 int in_h,
566 int stream)
567{
568 int result = -1;
569
570//printf("mpeg3_read_yuvframe 1 %d %d\n", mpeg3demux_tell(file->vtrack[stream]->demuxer), mpeg3demuxer_total_bytes(file->vtrack[stream]->demuxer));
571 if(file->has_video)
572 {
573 result = mpeg3video_read_yuvframe(file->vtrack[stream]->video,
574 file->vtrack[stream]->current_position,
575 y_output,
576 u_output,
577 v_output,
578 in_x,
579 in_y,
580 in_w,
581 in_h);
582 file->last_type_read = 2;
583 file->last_stream_read = stream;
584 file->vtrack[stream]->current_position++;
585 }
586//printf("mpeg3_read_yuvframe 2 %d %d\n", mpeg3demux_tell(file->vtrack[stream]->demuxer), mpeg3demuxer_total_bytes(file->vtrack[stream]->demuxer));
587 return result;
588}
589
590
591int mpeg3_read_audio(mpeg3_t *file,
592 mpeg3_real_t *output_f,
593 short *output_i, int sampleSpacing,
594 int channel,
595 long samples,
596 int stream)
597{
598 int result = -1;
599
600//printf("mpeg3_read_audio 1 %d %d\n", mpeg3demux_tell(file->atrack[stream]->demuxer), mpeg3demuxer_total_bytes(file->atrack[stream]->demuxer));
601 if(file->has_audio)
602 {
603 result = mpeg3audio_decode_audio(file->atrack[stream]->audio,
604 output_f,
605 output_i, sampleSpacing,
606 channel,
607 file->atrack[stream]->current_position,
608 samples);
609 file->last_type_read = 1;
610 file->last_stream_read = stream;
611 file->atrack[stream]->current_position += samples;
612 }
613//printf("mpeg3_read_audio 2 %d %d\n", mpeg3demux_tell(file->atrack[stream]->demuxer), mpeg3demuxer_total_bytes(file->atrack[stream]->demuxer));
614
615 return result;
616}
617
618int mpeg3_reread_audio(mpeg3_t *file,
619 mpeg3_real_t *output_f,
620 short *output_i, int sampleSpacing,
621 int channel,
622 long samples,
623 int stream)
624{
625 if(file->has_audio)
626 {
627 mpeg3_set_sample(file,
628 file->atrack[stream]->current_position - samples,
629 stream);
630 file->last_type_read = 1;
631 file->last_stream_read = stream;
632 return mpeg3_read_audio(file,
633 output_f,
634 output_i, sampleSpacing,
635 channel,
636 samples,
637 stream);
638 }
639 return -1;
640}
641
642int mpeg3_read_audio_chunk(mpeg3_t *file,
643 unsigned char *output,
644 long *size,
645 long max_size,
646 int stream)
647{
648 int result = 0;
649 if(file->has_audio)
650 {
651 result = mpeg3audio_read_raw(file->atrack[stream]->audio, output, size, max_size);
652 file->last_type_read = 1;
653 file->last_stream_read = stream;
654 }
655 return result;
656}
657
658int mpeg3_read_video_chunk(mpeg3_t *file,
659 unsigned char *output,
660 long *size,
661 long max_size,
662 int stream)
663{
664 int result = 0;
665 if(file->has_video)
666 {
667 result = mpeg3video_read_raw(file->vtrack[stream]->video, output, size, max_size);
668 file->last_type_read = 2;
669 file->last_stream_read = stream;
670 }
671 return result;
672}
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3.h
new file mode 100644
index 0000000..f4eced4
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3.h
@@ -0,0 +1,175 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef LIBMPEG3_H
21#define LIBMPEG3_H
22
23#include "mpeg3private.h"
24
25#if defined(__cplusplus)
26extern "C" {
27#endif
28
29/* Supported color models for mpeg3_read_frame */
30#define MPEG3_RGB565 2
31#define MPEG3_BGR888 0
32#define MPEG3_BGRA8888 1
33#define MPEG3_RGB888 3
34#define MPEG3_RGBA8888 4
35#define MPEG3_RGBA16161616 5
36
37/* Color models for the 601 to RGB conversion */
38/* 601 not implemented for scalar code */
39#define MPEG3_601_RGB565 11
40#define MPEG3_601_BGR888 7
41#define MPEG3_601_BGRA8888 8
42#define MPEG3_601_RGB888 9
43#define MPEG3_601_RGBA8888 10
44
45/* Check for file compatibility. Return 1 if compatible. */
46LIBMPEG_EXPORT int mpeg3_check_sig(char *path);
47
48/* Open the MPEG3 stream. */
49LIBMPEG_EXPORT mpeg3_t* mpeg3_open(char *path);
50
51/* Open the MPEG3 stream and copy the tables from an already open stream. */
52/* Eliminates the initial timecode search. */
53LIBMPEG_EXPORT mpeg3_t* mpeg3_open_copy(char *path, mpeg3_t *old_file);
54LIBMPEG_EXPORT int mpeg3_close(mpeg3_t *file);
55
56/* Performance */
57LIBMPEG_EXPORT int mpeg3_set_cpus(mpeg3_t *file, int cpus);
58LIBMPEG_EXPORT int mpeg3_set_mmx(mpeg3_t *file, int use_mmx);
59
60/* Query the MPEG3 stream about audio. */
61LIBMPEG_EXPORT int mpeg3_has_audio(mpeg3_t *file);
62LIBMPEG_EXPORT int mpeg3_total_astreams(mpeg3_t *file); /* Number of multiplexed audio streams */
63LIBMPEG_EXPORT int mpeg3_audio_channels(mpeg3_t *file, int stream);
64LIBMPEG_EXPORT int mpeg3_sample_rate(mpeg3_t *file, int stream);
65
66/* Total length obtained from the timecode. */
67/* For DVD files, this is unreliable. */
68LIBMPEG_EXPORT long mpeg3_audio_samples(mpeg3_t *file, int stream);
69LIBMPEG_EXPORT int mpeg3_set_sample(mpeg3_t *file, long sample, int stream); /* Seek to a sample */
70LIBMPEG_EXPORT long mpeg3_get_sample(mpeg3_t *file, int stream); /* Tell current position */
71
72/* Read a PCM buffer of audio from 1 channel and advance the position. */
73/* Return a 1 if error. */
74/* Stream defines the number of the multiplexed stream to read. */
75LIBMPEG_EXPORT int mpeg3_read_audio(mpeg3_t *file,
76 mpeg3_real_t *output_f, /* Pointer to pre-allocated buffer of floats */
77 short *output_i, /* Pointer to pre-allocated buffer of int16's */
78 int sampleSpacing, // how many bytes to skip over inbetween samples
79 int channel, /* Channel to decode */
80 long samples, /* Number of samples to decode */
81 int stream); /* Stream containing the channel */
82
83/* Reread the last PCM buffer from a different channel and advance the position */
84LIBMPEG_EXPORT int mpeg3_reread_audio(mpeg3_t *file,
85 mpeg3_real_t *output_f, /* Pointer to pre-allocated buffer of floats */
86 short *output_i, /* Pointer to pre-allocated buffer of int16's */
87 int sampleSpacing, // how many bytes to skip over inbetween samples
88 int channel, /* Channel to decode */
89 long samples, /* Number of samples to decode */
90 int stream); /* Stream containing the channel */
91
92/* Read the next compressed audio chunk. Store the size in size and return a */
93/* 1 if error. */
94/* Stream defines the number of the multiplexed stream to read. */
95LIBMPEG_EXPORT int mpeg3_read_audio_chunk(mpeg3_t *file,
96 unsigned char *output,
97 long *size,
98 long max_size,
99 int stream);
100
101/* Query the stream about video. */
102LIBMPEG_EXPORT int mpeg3_has_video(mpeg3_t *file);
103LIBMPEG_EXPORT int mpeg3_total_vstreams(mpeg3_t *file); /* Number of multiplexed video streams */
104LIBMPEG_EXPORT int mpeg3_video_width(mpeg3_t *file, int stream);
105LIBMPEG_EXPORT int mpeg3_video_height(mpeg3_t *file, int stream);
106LIBMPEG_EXPORT float mpeg3_frame_rate(mpeg3_t *file, int stream); /* Frames/sec */
107
108/* Total length. */
109/* For DVD files, this is 1 indicating only percentage seeking is available. */
110LIBMPEG_EXPORT long mpeg3_video_frames(mpeg3_t *file, int stream);
111LIBMPEG_EXPORT int mpeg3_set_frame(mpeg3_t *file, long frame, int stream); /* Seek to a frame */
112LIBMPEG_EXPORT int mpeg3_skip_frames();
113LIBMPEG_EXPORT long mpeg3_get_frame(mpeg3_t *file, int stream); /* Tell current position */
114
115/* Seek all the tracks based on a percentage of the total bytes in the */
116/* file or the total */
117/* time in a toc if one exists. Percentage is a 0 to 1 double. */
118/* This eliminates the need for tocs and 64 bit longs but doesn't */
119/* give frame accuracy. */
120LIBMPEG_EXPORT int mpeg3_seek_percentage(mpeg3_t *file, double percentage);
121LIBMPEG_EXPORT double mpeg3_tell_percentage(mpeg3_t *file);
122LIBMPEG_EXPORT int mpeg3_previous_frame(mpeg3_t *file, int stream);
123LIBMPEG_EXPORT int mpeg3_end_of_audio(mpeg3_t *file, int stream);
124LIBMPEG_EXPORT int mpeg3_end_of_video(mpeg3_t *file, int stream);
125
126/* Give the seconds time in the last packet read */
127LIBMPEG_EXPORT double mpeg3_get_time(mpeg3_t *file);
128
129/* Read a frame. The dimensions of the input area and output frame must be supplied. */
130/* The frame is taken from the input area and scaled to fit the output frame in 1 step. */
131/* Stream defines the number of the multiplexed stream to read. */
132/* The last row of **output_rows must contain 4 extra bytes for scratch work. */
133LIBMPEG_EXPORT int mpeg3_read_frame(mpeg3_t *file,
134 unsigned char **output_rows, /* Array of pointers to the start of each output row */
135 int in_x, /* Location in input frame to take picture */
136 int in_y,
137 int in_w,
138 int in_h,
139 int out_w, /* Dimensions of output_rows */
140 int out_h,
141 int color_model, /* One of the color model #defines */
142 int stream);
143
144/* Read a YUV frame. The 3 planes are copied into the y, u, and v buffers provided. */
145/* The input is cropped to the dimensions given but not scaled. */
146LIBMPEG_EXPORT int mpeg3_read_yuvframe(mpeg3_t *file,
147 char *y_output,
148 char *u_output,
149 char *v_output,
150 int in_x,
151 int in_y,
152 int in_w,
153 int in_h,
154 int stream);
155
156LIBMPEG_EXPORT int mpeg3_drop_frames(mpeg3_t *file, long frames, int stream);
157
158/* Read the next compressed frame including headers. */
159/* Store the size in size and return a 1 if error. */
160/* Stream defines the number of the multiplexed stream to read. */
161LIBMPEG_EXPORT int mpeg3_read_video_chunk(mpeg3_t *file,
162 unsigned char *output,
163 long *size,
164 long max_size,
165 int stream);
166
167/* Master control */
168LIBMPEG_EXPORT int mpeg3_total_programs();
169LIBMPEG_EXPORT int mpeg3_set_program(int program);
170
171#if defined(__cplusplus)
172}
173#endif
174
175#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro b/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro
new file mode 100644
index 0000000..e2c35d3
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3.pro
@@ -0,0 +1,42 @@
1 TEMPLATE= lib
2 CONFIG += qt warn_on release
3 HEADERS = libmpeg3plugin.h libmpeg3pluginimpl.h
4 SOURCES = libmpeg3plugin.cpp libmpeg3pluginimpl.cpp \
5 bitstream.c \
6 libmpeg3.c \
7 mpeg3atrack.c \
8 mpeg3css.c \
9 mpeg3demux.c \
10 mpeg3io.c \
11 mpeg3title.c \
12 mpeg3vtrack.c \
13 audio/ac3.c \
14 audio/bit_allocation.c \
15 audio/dct.c \
16 audio/exponents.c \
17 audio/header.c \
18 audio/layer2.c \
19 audio/layer3.c \
20 audio/mantissa.c \
21 audio/mpeg3audio.c \
22 audio/pcm.c \
23 audio/synthesizers.c \
24 audio/tables.c \
25 video/getpicture.c \
26 video/headers.c \
27 video/idct.c \
28 video/macroblocks.c \
29 video/mmxtest.c \
30 video/motion.c \
31 video/mpeg3video.c \
32 video/output.c \
33 video/reconstruct.c \
34 video/seek.c \
35 video/slice.c \
36 video/vlc.c
37 TARGET = mpeg3plugin
38 DESTDIR = ../../plugins/codecs
39INCLUDEPATH += $(QPEDIR)/include ..
40DEPENDPATH += ../$(QPEDIR)/include ..
41LIBS += -lqpe -lpthread -lm
42 VERSION = 1.0.0
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.cpp b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.cpp
new file mode 100644
index 0000000..044cb4a
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.cpp
@@ -0,0 +1,105 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "libmpeg3plugin.h"
21
22/*
23bool LibMpeg3Plugin::audioReadSamples( short *output, int channel, long samples, int stream ) {
24 return file ? mpeg3_read_audio( file, 0, output, 0, channel, samples, stream ) == 1 : FALSE;
25}
26
27
28bool LibMpeg3Plugin::audioReReadSamples( short *output, int channel, long samples, int stream ) {
29 return file ? mpeg3_reread_audio( file, 0, output, 0, channel, samples, stream ) == 1 : FALSE;
30}
31
32
33bool LibMpeg3Plugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) {
34 samplesRead = samples;
35 return file ? mpeg3_read_audio( file, 0, output, 0, 0, samples, stream ) == 1 : FALSE;
36}
37
38
39bool LibMpeg3Plugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) {
40 bool err = FALSE;
41 if ( file ) {
42#if 1
43 err = mpeg3_read_audio ( file, 0, output, 1, 0, samples, stream ) == 1;
44 if ( err == FALSE ) {
45 err = mpeg3_reread_audio( file, 0, output + 1, 1, 1, samples, stream ) == 1;
46#else
47 short left[samples];
48 short right[samples];
49 err = mpeg3_read_audio ( file, 0, left, 0, samples, stream ) == 1;
50 if ( !err )
51 err = mpeg3_reread_audio( file, 0, right, 1, samples, stream ) == 1;
52 for ( int j = 0; j < samples; j++ ) {
53 output[j*2+0] = left[j];
54 output[j*2+1] = right[j];
55#endif
56 }
57 }
58 samplesRead = samples;
59 return err;
60}
61*/
62
63bool LibMpeg3Plugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) {
64 samplesRead = samples;
65 switch ( channels ) {
66 case 1:
67 return file ? mpeg3_read_audio( file, 0, output, 0, 0, samples, stream ) == 1 : FALSE;
68 case 2:
69 if ( ( file ) && ( mpeg3_read_audio( file, 0, output, 1, 0, samples, stream ) != 1 ) &&
70 ( mpeg3_reread_audio( file, 0, output + 1, 1, 1, samples, stream ) != 1 ) )
71 return TRUE;
72 return FALSE;
73 }
74 return FALSE;
75}
76
77bool LibMpeg3Plugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) {
78 int format = MPEG3_RGB565;
79 switch ( color_model ) {
80 case RGB565:format = MPEG3_RGB565; break;
81 case BGR565: /*format = MPEG3_BGR565;*/ break;
82 case RGBA8888:format = MPEG3_RGBA8888; break;
83 case BGRA8888:format = MPEG3_BGRA8888; break;
84 }
85 return file ? mpeg3_read_frame( file, output_rows, in_x, in_y, in_w, in_h, in_w, in_h, format, stream ) == 1 : FALSE;
86}
87
88
89bool LibMpeg3Plugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) {
90 int format = MPEG3_RGB565;
91 switch ( color_model ) {
92 case RGB565:format = MPEG3_RGB565; break;
93 case BGR565:/*format = MPEG3_BGR565;*/ break;
94 case RGBA8888:format = MPEG3_RGBA8888; break;
95 case BGRA8888:format = MPEG3_BGRA8888; break;
96 }
97 return file ? mpeg3_read_frame( file, output_rows, in_x, in_y, in_w, in_h, out_w, out_h, format, stream ) == 1 : FALSE;
98}
99
100
101bool LibMpeg3Plugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) {
102 return file ? mpeg3_read_yuvframe( file, y_output, u_output, v_output, in_x, in_y, in_w, in_h, stream ) == 1 : FALSE;
103}
104
105
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
new file mode 100644
index 0000000..0a06264
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3plugin.h
@@ -0,0 +1,113 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef LIBMPEG3_PLUGIN_H
21#define LIBMPEG3_PLUGIN_H
22
23
24#include <qstring.h>
25#include <qapplication.h>
26#include "libmpeg3.h"
27#include "mpeg3protos.h"
28#include "mediaplayerplugininterface.h"
29
30
31class LibMpeg3Plugin : public MediaPlayerDecoder {
32
33public:
34 LibMpeg3Plugin() { file = NULL; }
35 ~LibMpeg3Plugin() { close(); }
36
37 const char *pluginName() { return "LibMpeg3Plugin"; }
38 const char *pluginComment() { return "This is the libmpeg3 library writen by ... which has been modified by trolltech to use fixed point maths"; }
39 double pluginVersion() { return 1.0; }
40
41 bool isFileSupported( const QString& fileName ) { return mpeg3_check_sig( (char *)fileName.latin1() ) == 1; }
42 bool open( const QString& fileName ) { file = mpeg3_open( (char *)fileName.latin1() ); return file != NULL; }
43 bool close() { if ( file ) { int r = mpeg3_close( file ); file = NULL; return r == 1; } return FALSE; }
44 bool isOpen() { return file != NULL; }
45 const QString &fileInfo() { return strInfo = QString( "" ); }
46
47 // If decoder doesn't support audio then return 0 here
48 int audioStreams() { return file ? mpeg3_total_astreams( file ) : 0; }
49 int audioChannels( int stream ) { return file ? mpeg3_audio_channels( file, stream ) : 0; }
50 int audioFrequency( int stream ) { return file ? mpeg3_sample_rate( file, stream ) : 0; }
51 int audioSamples( int stream ) { return file ? mpeg3_audio_samples( file, stream ) : 0; }
52 bool audioSetSample( long sample, int stream ) { return file ? mpeg3_set_sample( file, sample, stream) == 1 : FALSE; }
53 long audioGetSample( int stream ) { return file ? mpeg3_get_sample( file, stream ) : 0; }
54// bool audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream );
55// bool audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream );
56 bool audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream );
57// bool audioReadSamples( short *output, int channel, long samples, int stream );
58// bool audioReReadSamples( short *output, int channel, long samples, int stream );
59
60 // If decoder doesn't support video then return 0 here
61 int videoStreams() { return file ? mpeg3_total_vstreams( file ) : 0; }
62 int videoWidth( int stream ) { return file ? mpeg3_video_width( file, stream ) : 0; }
63 int videoHeight( int stream ) { return file ? mpeg3_video_height( file, stream ) : 0; }
64 double videoFrameRate( int stream ) { return file ? mpeg3_frame_rate( file, stream ) : 0.0; }
65 int videoFrames( int stream )
66{ return file ? mpeg3_video_frames( file, stream ) : 0; }
67/*
68{
69 if ( file ) {
70 int frames = mpeg3_video_frames( file, stream );
71 if ( frames == 1 ) {
72 int res = mpeg3_seek_percentage( file, 0.99 );
73 printf("res: %i\n", res );
74 mpeg3video_seek( file->vtrack[stream]->video );
75 frames = mpeg3_get_frame( file, stream );
76 mpeg3_seek_percentage( file, 0.0 );
77 }
78 return frames;
79 }
80 return 0;
81}
82*/
83 bool videoSetFrame( long frame, int stream ) { return file ? mpeg3_set_frame( file, frame, stream) == 1 : FALSE; }
84 long videoGetFrame( int stream ) { return file ? mpeg3_get_frame( file, stream ) : 0; }
85 bool videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream );
86 bool videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream );
87 bool videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream );
88
89 // Profiling
90 double getTime() { return file ? mpeg3_get_time( file ) : 0.0; }
91
92 // Ignore if these aren't supported
93 bool setSMP( int cpus ) { return file ? mpeg3_set_cpus( file, cpus ) == 1 : FALSE; }
94 bool setMMX( bool useMMX ) { return file ? mpeg3_set_mmx( file, useMMX ) == 1 : FALSE; }
95
96 // Capabilities
97 bool supportsAudio() { return TRUE; }
98 bool supportsVideo() { return TRUE; }
99 bool supportsYUV() { return TRUE; }
100 bool supportsMMX() { return TRUE; }
101 bool supportsSMP() { return TRUE; }
102 bool supportsStereo() { return TRUE; }
103 bool supportsScaling() { return TRUE; }
104
105private:
106 mpeg3_t *file;
107 QString strInfo;
108
109};
110
111
112#endif
113
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp
new file mode 100644
index 0000000..e7216af
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.cpp
@@ -0,0 +1,70 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include "libmpeg3plugin.h"
21#include "libmpeg3pluginimpl.h"
22
23
24LibMpeg3PluginImpl::LibMpeg3PluginImpl()
25 : libmpeg3plugin(0), ref(0)
26{
27}
28
29
30LibMpeg3PluginImpl::~LibMpeg3PluginImpl()
31{
32 if ( libmpeg3plugin )
33 delete libmpeg3plugin;
34}
35
36
37MediaPlayerDecoder *LibMpeg3PluginImpl::decoder()
38{
39 if ( !libmpeg3plugin )
40 libmpeg3plugin = new LibMpeg3Plugin;
41 return libmpeg3plugin;
42}
43
44
45MediaPlayerEncoder *LibMpeg3PluginImpl::encoder()
46{
47 return NULL;
48}
49
50
51#ifndef QT_NO_COMPONENT
52
53
54QRESULT LibMpeg3PluginImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
55{
56 *iface = 0;
57 if ( ( uuid == IID_QUnknown ) || ( uuid == IID_MediaPlayerPlugin ) )
58 *iface = this, (*iface)->addRef();
59 return QS_OK;
60}
61
62
63Q_EXPORT_INTERFACE()
64{
65 Q_CREATE_INSTANCE( LibMpeg3PluginImpl )
66}
67
68
69#endif
70
diff --git a/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
new file mode 100644
index 0000000..29ec6ba
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/libmpeg3pluginimpl.h
@@ -0,0 +1,53 @@
1/**********************************************************************
2** Copyright (C) 2001 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef LIBMPEG3_PLUGIN_IMPL_H
21#define LIBMPEG3_PLUGIN_IMPL_H
22
23
24#include "../mediaplayerplugininterface.h"
25
26
27class LibMpeg3Plugin;
28
29
30class LibMpeg3PluginImpl : public MediaPlayerPluginInterface
31{
32public:
33 LibMpeg3PluginImpl();
34 virtual ~LibMpeg3PluginImpl();
35
36#ifndef QT_NO_COMPONENT
37
38 QRESULT queryInterface( const QUuid&, QUnknownInterface** );
39 Q_REFCOUNT
40
41#endif
42
43 virtual MediaPlayerDecoder *decoder();
44 virtual MediaPlayerEncoder *encoder();
45
46private:
47 LibMpeg3Plugin *libmpeg3plugin;
48 ulong ref;
49};
50
51
52#endif
53
diff --git a/core/multimedia/opieplayer/libmpeg3/make_package b/core/multimedia/opieplayer/libmpeg3/make_package
new file mode 100755
index 0000000..4be86da
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/make_package
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3VERSION=1.2.1
4
5rm -r /tmp/libmpeg3-$VERSION
6mkdir -p /tmp/libmpeg3-$VERSION
7make clean
8cp -rd * /tmp/libmpeg3-$VERSION
9cd /tmp
10tar zcf libmpeg3-$VERSION.tar.gz libmpeg3-$VERSION
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.c b/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.c
new file mode 100644
index 0000000..e1a900b
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.c
@@ -0,0 +1,36 @@
1#include "libmpeg3.h"
2#include "mpeg3protos.h"
3
4#include <stdlib.h>
5
6mpeg3_atrack_t* mpeg3_new_atrack(mpeg3_t *file, int stream_id, int format, mpeg3_demuxer_t *demuxer)
7{
8 mpeg3_atrack_t *new_atrack;
9
10 new_atrack = (mpeg3_atrack_t*)calloc(1, sizeof(mpeg3_atrack_t));
11 new_atrack->channels = 0;
12 new_atrack->sample_rate = 0;
13 new_atrack->total_samples = 0;
14 new_atrack->current_position = 0;
15 new_atrack->demuxer = mpeg3_new_demuxer(file, 1, 0, stream_id);
16 if(demuxer) mpeg3demux_copy_titles(new_atrack->demuxer, demuxer);
17 new_atrack->audio = mpeg3audio_new(file, new_atrack, format);
18
19 if(!new_atrack->audio)
20 {
21/* Failed */
22 mpeg3_delete_atrack(file, new_atrack);
23 new_atrack = 0;
24 }
25 return new_atrack;
26}
27
28int mpeg3_delete_atrack(mpeg3_t *file, mpeg3_atrack_t *atrack)
29{
30 if(atrack->audio)
31 mpeg3audio_delete(atrack->audio);
32 if(atrack->demuxer)
33 mpeg3_delete_demuxer(atrack->demuxer);
34 free(atrack);
35}
36
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.h b/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.h
new file mode 100644
index 0000000..9d70640
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3atrack.h
@@ -0,0 +1,36 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3ATRACK_H
21#define MPEG3ATRACK_H
22
23#include "mpeg3demux.h"
24#include "audio/mpeg3audio.h"
25
26struct mpeg3_atrack_rec
27{
28 int channels;
29 int sample_rate;
30 mpeg3_demuxer_t *demuxer;
31 mpeg3audio_t *audio;
32 long current_position;
33 long total_samples;
34};
35
36#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3cat.c b/core/multimedia/opieplayer/libmpeg3/mpeg3cat.c
new file mode 100644
index 0000000..20f7660
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3cat.c
@@ -0,0 +1,225 @@
1/* Concatenate elementary streams */
2
3#include "libmpeg3.h"
4
5#include <stdio.h>
6#include <stdlib.h>
7#include <string.h>
8
9#define MPEG3_SEQUENCE_START_CODE 0x000001b3
10#define BUFFER_SIZE 1000000
11
12int main(int argc, char *argv[])
13{
14 char inpath[1024];
15 mpeg3_t *in;
16 int current_file, current_output_file = 0, i;
17 unsigned int bits;
18 unsigned char *buffer;
19 long output_size;
20 int result = 0;
21 long total_frames = 0;
22 int do_audio = 0, do_video = 0;
23 int stream = 0;
24
25 if(argc < 2)
26 {
27 fprintf(stderr, "Concatenate elementary streams or demultiplex a program stream.\n"
28 "Usage: mpeg3cat -[av0123456789] <infile> [infile...] > <outfile>\n\n"
29 "Example: Concatenate 2 video files: mpeg3cat xena1.m2v xena2.m2v > xena.m2v\n"
30 " Extract audio stream 0: mpeg3cat -a0 xena.vob > war_cry.ac3\n");
31 exit(1);
32 }
33
34 for(i = 1; i < argc; i++)
35 {
36 if(argv[i][0] == '-')
37 {
38 if(argv[i][1] != 'a' && argv[i][1] != 'v')
39 {
40 fprintf(stderr, "invalid option %s\n", argv[i]);
41 }
42 else
43 {
44 if(argv[i][1] == 'a') do_audio = 1;
45 else
46 if(argv[i][1] == 'v') do_video = 1;
47
48 if(argv[i][2] != 0)
49 {
50 stream = argv[i][2] - 48;
51 }
52 }
53 }
54 }
55
56 buffer = (unsigned char*)malloc(BUFFER_SIZE);
57
58 for(current_file = 1; current_file < argc; current_file++)
59 {
60 if(argv[current_file][0] == '-') continue;
61
62 strcpy(inpath, argv[current_file]);
63 if(!(in = mpeg3_open(inpath)))
64 {
65 fprintf(stderr, "Skipping %s\n", inpath);
66 continue;
67 }
68
69 if((mpeg3_has_audio(in) && in->is_audio_stream) ||
70 (do_audio && !in->is_audio_stream && !in->is_video_stream))
71 {
72 do_audio = 1;
73/* Add audio stream to end */
74 while(!mpeg3_read_audio_chunk(in, buffer,
75 &output_size,
76 BUFFER_SIZE,
77 stream))
78 {
79 result = !fwrite(buffer, output_size, 1, stdout);
80 if(result)
81 {
82 perror("fwrite audio chunk");
83 break;
84 }
85 }
86 }
87 else
88 if((mpeg3_has_video(in) && in->is_video_stream) ||
89 (do_video && !in->is_video_stream && !in->is_audio_stream))
90 {
91/* Add video stream to end */
92 int hour, minute, second, frame;
93 long gop_frame;
94 unsigned long code;
95 float carry;
96 int i, offset;
97
98 do_video = 1;
99 while(!mpeg3_read_video_chunk(in,
100 buffer,
101 &output_size,
102 BUFFER_SIZE,
103 stream) &&
104 output_size >= 4)
105 {
106 code = (unsigned long)buffer[output_size - 4] << 24;
107 code |= (unsigned long)buffer[output_size - 3] << 16;
108 code |= (unsigned long)buffer[output_size - 2] << 8;
109 code |= (unsigned long)buffer[output_size - 1];
110
111/* Got a frame at the end of this buffer. */
112 if(code == MPEG3_PICTURE_START_CODE)
113 {
114 total_frames++;
115 }
116 else
117 if(code == MPEG3_SEQUENCE_END_CODE)
118 {
119/* Got a sequence end code at the end of this buffer. */
120 output_size -= 4;
121 }
122
123 code = (unsigned long)buffer[0] << 24;
124 code |= (unsigned long)buffer[1] << 16;
125 code |= (unsigned long)buffer[2] << 8;
126 code |= buffer[3];
127
128 i = 0;
129 offset = 0;
130 if(code == MPEG3_SEQUENCE_START_CODE && current_output_file > 0)
131 {
132/* Skip the sequence start code */
133 i += 4;
134 while(i < output_size &&
135 code != MPEG3_GOP_START_CODE)
136 {
137 code <<= 8;
138 code |= buffer[i++];
139 }
140 i -= 4;
141 offset = i;
142 }
143
144/* Search for GOP header to fix */
145 code = (unsigned long)buffer[i++] << 24;
146 code |= (unsigned long)buffer[i++] << 16;
147 code |= (unsigned long)buffer[i++] << 8;
148 code |= buffer[i++];
149 while(i < output_size &&
150 code != MPEG3_GOP_START_CODE)
151 {
152 code <<= 8;
153 code |= buffer[i++];
154 }
155
156 if(code == MPEG3_GOP_START_CODE)
157 {
158/* Get the time code */
159 code = (unsigned long)buffer[i] << 24;
160 code |= (unsigned long)buffer[i + 1] << 16;
161 code |= (unsigned long)buffer[i + 2] << 8;
162 code |= (unsigned long)buffer[i + 3];
163
164 hour = code >> 26 & 0x1f;
165 minute = code >> 20 & 0x3f;
166 second = code >> 13 & 0x3f;
167 frame = code >> 7 & 0x3f;
168
169 gop_frame = (long)(hour * 3600 * mpeg3_frame_rate(in, stream) +
170 minute * 60 * mpeg3_frame_rate(in, stream) +
171 second * mpeg3_frame_rate(in, stream) +
172 frame);
173/* fprintf(stderr, "old: %02d:%02d:%02d:%02d ", hour, minute, second, frame); */
174/* Write a new time code */
175 hour = (long)((float)(total_frames - 1) / mpeg3_frame_rate(in, stream) / 3600);
176 carry = hour * 3600 * mpeg3_frame_rate(in, stream);
177 minute = (long)((float)(total_frames - 1 - carry) / mpeg3_frame_rate(in, stream) / 60);
178 carry += minute * 60 * mpeg3_frame_rate(in, stream);
179 second = (long)((float)(total_frames - 1 - carry) / mpeg3_frame_rate(in, stream));
180 carry += second * mpeg3_frame_rate(in, stream);
181 frame = (int)(total_frames - 1 - carry);
182
183 buffer[i] = ((code >> 24) & 0x80) | (hour << 2) | (minute >> 4);
184 buffer[i + 1] = ((code >> 16) & 0x08) | ((minute & 0xf) << 4) | (second >> 3);
185 buffer[i + 2] = ((second & 0x7) << 5) | (frame >> 1);
186 buffer[i + 3] = (code & 0x7f) | ((frame & 0x1) << 7);
187/* fprintf(stderr, "new: %02d:%02d:%02d:%02d\n", hour, minute, second, frame); */
188 }
189
190/* Write the frame */
191 result = !fwrite(buffer + offset, output_size - offset, 1, stdout);
192 if(result)
193 {
194 perror("fwrite video chunk");
195 break;
196 }
197 }
198 }
199 else
200 {
201 fprintf(stderr, "Unsupported stream type.\n");
202 mpeg3_close(in);
203 in = 0;
204 continue;
205 }
206
207 mpeg3_close(in);
208 in = 0;
209 current_output_file++;
210 }
211
212/* Terminate output */
213 if(current_output_file > 0 && do_video)
214 {
215/*fprintf(stderr, "\n"); */
216/* Write new end of sequence */
217 buffer[0] = MPEG3_SEQUENCE_END_CODE >> 24;
218 buffer[1] = (MPEG3_SEQUENCE_END_CODE >> 16) & 0xff;
219 buffer[2] = (MPEG3_SEQUENCE_END_CODE >> 8) & 0xff;
220 buffer[3] = MPEG3_SEQUENCE_END_CODE & 0xff;
221 result = !fwrite(buffer, 4, 1, stdout);
222 }
223
224 exit(0);
225}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3css.c b/core/multimedia/opieplayer/libmpeg3/mpeg3css.c
new file mode 100644
index 0000000..7f9ad8c
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3css.c
@@ -0,0 +1,32 @@
1#include "mpeg3css.h"
2#include "mpeg3private.h"
3
4extern "C" {
5
6int mpeg3_init_css(mpeg3_t *file, mpeg3_css_t *css)
7{
8 return 0;
9}
10
11int mpeg3_get_keys(mpeg3_css_t *css, char *path)
12{
13 return 1;
14}
15
16int mpeg3_decrypt_packet(mpeg3_css_t *css, unsigned char *sector)
17{
18 return 1;
19}
20
21mpeg3_css_t* mpeg3_new_css()
22{
23 return 0;
24}
25
26int mpeg3_delete_css(mpeg3_css_t *css)
27{
28 return 0;
29}
30
31};
32
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3css.h b/core/multimedia/opieplayer/libmpeg3/mpeg3css.h
new file mode 100644
index 0000000..1272574
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3css.h
@@ -0,0 +1,29 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3CSS_H
21#define MPEG3CSS_H
22
23/* Stubs for deCSS which can't be distributed legally */
24
25typedef struct
26{
27} mpeg3_css_t;
28
29#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.c b/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.c
new file mode 100644
index 0000000..0901195
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.c
@@ -0,0 +1,19 @@
1/* Stubs for deCSS which can't be distributed in source form */
2
3#include "mpeg3css.h"
4#include "mpeg3private.h"
5
6int mpeg3_init_css(mpeg3_t *file, mpeg3_css_t *css)
7{
8 return 0;
9}
10
11int mpeg3_get_keys(mpeg3_css_t *css, char *path)
12{
13 return 1;
14}
15
16int mpeg3_decrypt_packet(mpeg3_css_t *css, unsigned char *sector)
17{
18 return 1;
19}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.h b/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.h
new file mode 100644
index 0000000..1272574
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3css_fake.h
@@ -0,0 +1,29 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3CSS_H
21#define MPEG3CSS_H
22
23/* Stubs for deCSS which can't be distributed legally */
24
25typedef struct
26{
27} mpeg3_css_t;
28
29#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3demux.c b/core/multimedia/opieplayer/libmpeg3/mpeg3demux.c
new file mode 100644
index 0000000..cccc820
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3demux.c
@@ -0,0 +1,1849 @@
1#include "libmpeg3.h"
2#include "mpeg3io.h"
3#include "mpeg3protos.h"
4
5#include <math.h>
6#include <stdlib.h>
7#include <string.h>
8
9#define ABS(x) ((x) >= 0 ? (x) : -(x))
10
11/* Don't advance pointer */
12static inline unsigned char mpeg3packet_next_char(mpeg3_demuxer_t *demuxer)
13{
14 return demuxer->raw_data[demuxer->raw_offset];
15}
16
17unsigned char mpeg3packet_read_char(mpeg3_demuxer_t *demuxer)
18{
19 unsigned char result = demuxer->raw_data[demuxer->raw_offset++];
20 return result;
21}
22
23static inline unsigned int mpeg3packet_read_int16(mpeg3_demuxer_t *demuxer)
24{
25 unsigned int a, b, result;
26 a = demuxer->raw_data[demuxer->raw_offset++];
27 b = demuxer->raw_data[demuxer->raw_offset++];
28 result = (a << 8) | b;
29
30 return result;
31}
32
33static inline unsigned int mpeg3packet_next_int24(mpeg3_demuxer_t *demuxer)
34{
35 unsigned int a, b, c, result;
36 a = demuxer->raw_data[demuxer->raw_offset];
37 b = demuxer->raw_data[demuxer->raw_offset + 1];
38 c = demuxer->raw_data[demuxer->raw_offset + 2];
39 result = (a << 16) | (b << 8) | c;
40
41 return result;
42}
43
44static inline unsigned int mpeg3packet_read_int24(mpeg3_demuxer_t *demuxer)
45{
46 unsigned int a, b, c, result;
47 a = demuxer->raw_data[demuxer->raw_offset++];
48 b = demuxer->raw_data[demuxer->raw_offset++];
49 c = demuxer->raw_data[demuxer->raw_offset++];
50 result = (a << 16) | (b << 8) | c;
51
52 return result;
53}
54
55static inline unsigned int mpeg3packet_read_int32(mpeg3_demuxer_t *demuxer)
56{
57 unsigned int a, b, c, d, result;
58 a = demuxer->raw_data[demuxer->raw_offset++];
59 b = demuxer->raw_data[demuxer->raw_offset++];
60 c = demuxer->raw_data[demuxer->raw_offset++];
61 d = demuxer->raw_data[demuxer->raw_offset++];
62 result = (a << 24) | (b << 16) | (c << 8) | d;
63
64 return result;
65}
66
67static inline unsigned int mpeg3packet_skip(mpeg3_demuxer_t *demuxer, long length)
68{
69 demuxer->raw_offset += length;
70 return 0;
71}
72
73int mpeg3_get_adaptation_field(mpeg3_demuxer_t *demuxer)
74{
75 long length;
76 int pcr_flag;
77
78 demuxer->adaptation_fields++;
79/* get adaptation field length */
80 length = mpeg3packet_read_char(demuxer);
81/* get first byte */
82 pcr_flag = (mpeg3packet_read_char(demuxer) >> 4) & 1;
83
84 if(pcr_flag)
85 {
86 unsigned long clk_ref_base = mpeg3packet_read_int32(demuxer);
87 unsigned int clk_ref_ext = mpeg3packet_read_int16(demuxer);
88
89 if (clk_ref_base > 0x7fffffff)
90 { /* correct for invalid numbers */
91 clk_ref_base = 0; /* ie. longer than 32 bits when multiplied by 2 */
92 clk_ref_ext = 0; /* multiplied by 2 corresponds to shift left 1 (<<=1) */
93 }
94 else
95 {
96 clk_ref_base <<= 1; /* Create space for bit */
97 clk_ref_base |= (clk_ref_ext >> 15); /* Take bit */
98 clk_ref_ext &= 0x01ff; /* Only lower 9 bits */
99 }
100 demuxer->time = clk_ref_base + clk_ref_ext / 300;
101 if(length) mpeg3packet_skip(demuxer, length - 7);
102 }
103 else
104 mpeg3packet_skip(demuxer, length - 1);
105
106 return 0;
107}
108
109int mpeg3_get_program_association_table(mpeg3_demuxer_t *demuxer)
110{
111 demuxer->program_association_tables++;
112 demuxer->table_id = mpeg3packet_read_char(demuxer);
113 demuxer->section_length = mpeg3packet_read_int16(demuxer) & 0xfff;
114 demuxer->transport_stream_id = mpeg3packet_read_int16(demuxer);
115 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
116 return 0;
117}
118
119int mpeg3packet_get_data_buffer(mpeg3_demuxer_t *demuxer)
120{
121 while(demuxer->raw_offset < demuxer->raw_size && demuxer->data_size < demuxer->data_allocated)
122 {
123 demuxer->data_buffer[demuxer->data_size++] = demuxer->raw_data[demuxer->raw_offset++];
124 }
125 return 0;
126}
127
128int mpeg3_get_pes_packet_header(mpeg3_demuxer_t *demuxer, unsigned long *pts, unsigned long *dts)
129{
130 unsigned int pes_header_bytes = 0;
131 unsigned int pts_dts_flags;
132 int pes_header_data_length;
133
134/* drop first 8 bits */
135 mpeg3packet_read_char(demuxer);
136 pts_dts_flags = (mpeg3packet_read_char(demuxer) >> 6) & 0x3;
137 pes_header_data_length = mpeg3packet_read_char(demuxer);
138
139/* Get Presentation Time stamps and Decoding Time Stamps */
140 if(pts_dts_flags == 2)
141 {
142 *pts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
143 *pts <<= 15;
144 *pts |= (mpeg3packet_read_int16(demuxer) >> 1);
145 *pts <<= 15;
146 *pts |= (mpeg3packet_read_int16(demuxer) >> 1);
147 pes_header_bytes += 5;
148 }
149 else if(pts_dts_flags == 3)
150 {
151 *pts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
152 *pts <<= 15;
153 *pts |= (mpeg3packet_read_int16(demuxer) >> 1);
154 *pts <<= 15;
155 *pts |= (mpeg3packet_read_int16(demuxer) >> 1);
156 *dts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
157 *dts <<= 15;
158 *dts |= (mpeg3packet_read_int16(demuxer) >> 1);
159 *dts <<= 15;
160 *dts |= (mpeg3packet_read_int16(demuxer) >> 1);
161 pes_header_bytes += 10;
162 }
163/* extract other stuff here! */
164
165 mpeg3packet_skip(demuxer, pes_header_data_length - pes_header_bytes);
166 return 0;
167}
168
169int get_unknown_data(mpeg3_demuxer_t *demuxer)
170{
171 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
172 return 0;
173}
174
175int mpeg3_get_pes_packet_data(mpeg3_demuxer_t *demuxer, unsigned int stream_id)
176{
177 unsigned long pts = 0, dts = 0;
178
179 if((stream_id >> 4) == 12 || (stream_id >> 4) == 13)
180 {
181/* Just pick the first available stream if no ID is set */
182 if(demuxer->astream == -1)
183 demuxer->astream = (stream_id & 0x0f);
184
185 if((stream_id & 0x0f) == demuxer->astream && demuxer->do_audio)
186 {
187 mpeg3_get_pes_packet_header(demuxer, &pts, &dts);
188 demuxer->pes_audio_time = pts;
189 demuxer->audio_pid = demuxer->pid;
190 return mpeg3packet_get_data_buffer(demuxer);
191 }
192 }
193 else
194 if((stream_id >> 4)==14)
195 {
196/* Just pick the first available stream if no ID is set */
197 if(demuxer->vstream == -1)
198 demuxer->vstream = (stream_id & 0x0f);
199
200 if((stream_id & 0x0f) == demuxer->vstream && demuxer->do_video)
201 {
202 mpeg3_get_pes_packet_header(demuxer, &pts, &dts);
203 demuxer->pes_video_time = pts;
204 demuxer->video_pid = demuxer->pid;
205 return mpeg3packet_get_data_buffer(demuxer);
206 }
207 }
208 else
209 {
210 return get_unknown_data(demuxer);
211 }
212
213 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
214
215 return 0;
216}
217
218int mpeg3_get_pes_packet(mpeg3_demuxer_t *demuxer)
219{
220 unsigned int stream_id;
221
222 demuxer->pes_packets++;
223 stream_id = mpeg3packet_read_char(demuxer);
224/* Skip startcode */
225 mpeg3packet_read_int24(demuxer);
226/* Skip pes packet length */
227 mpeg3packet_read_int16(demuxer);
228
229 if(stream_id != MPEG3_PRIVATE_STREAM_2 && stream_id != MPEG3_PADDING_STREAM)
230 {
231 return mpeg3_get_pes_packet_data(demuxer, stream_id);
232 }
233 else
234 if(stream_id == MPEG3_PRIVATE_STREAM_2)
235 {
236/* Dump private data! */
237 fprintf(stderr, "stream_id == MPEG3_PRIVATE_STREAM_2\n");
238 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
239 return 0;
240 }
241 else
242 if(stream_id == MPEG3_PADDING_STREAM)
243 {
244 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
245 return 0;
246 }
247 else
248 {
249 fprintf(stderr, "unknown stream_id in pes packet");
250 return 1;
251 }
252 return 0;
253}
254
255int mpeg3_get_payload(mpeg3_demuxer_t *demuxer)
256{
257 if(demuxer->payload_unit_start_indicator)
258 {
259 if(demuxer->pid==0) mpeg3_get_program_association_table(demuxer);
260 else
261 if(mpeg3packet_next_int24(demuxer) == MPEG3_PACKET_START_CODE_PREFIX) mpeg3_get_pes_packet(demuxer);
262 else
263 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
264 }
265 else
266 {
267 if(demuxer->pid == demuxer->audio_pid && demuxer->do_audio)
268 {
269 mpeg3packet_get_data_buffer(demuxer);
270 }
271 else
272 if(demuxer->pid == demuxer->video_pid && demuxer->do_video)
273 {
274 mpeg3packet_get_data_buffer(demuxer);
275 }
276 else
277 mpeg3packet_skip(demuxer, demuxer->raw_size - demuxer->raw_offset);
278 }
279 return 0;
280}
281
282/* Read a transport packet */
283int mpeg3_read_transport(mpeg3_demuxer_t *demuxer)
284{
285 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
286 int result = mpeg3io_read_data(demuxer->raw_data, demuxer->packet_size, title->fs);
287 unsigned int bits;
288 int table_entry;
289
290 demuxer->raw_size = demuxer->packet_size;
291 demuxer->raw_offset = 0;
292 if(result)
293 {
294 perror("mpeg3_read_transport");
295 return 1;
296 }
297
298/* Sync byte */
299 if(mpeg3packet_read_char(demuxer) != MPEG3_SYNC_BYTE)
300 {
301 fprintf(stderr, "mpeg3packet_read_char(demuxer) != MPEG3_SYNC_BYTE\n");
302 return 1;
303 }
304
305 /* bits = mpeg3packet_read_int24(demuxer) & 0x0000ffff; */
306 /* demuxer->transport_error_indicator = bits >> 15; */
307 /* demuxer->payload_unit_start_indicator = (bits >> 14) & 1; */
308 /* demuxer->pid = bits & 0x00001fff; */
309 /* demuxer->transport_scrambling_control = (mpeg3packet_next_char(demuxer) >> 6) & 0x3; */
310 /* demuxer->adaptation_field_control = (mpeg3packet_next_char(demuxer) >> 4) & 0x3; */
311 /* demuxer->continuity_counter = (mpeg3packet_read_char(demuxer) & 0xf); */
312
313 bits = mpeg3packet_read_int24(demuxer) & 0x00ffffff;
314 demuxer->transport_error_indicator = (bits >> 23) & 0x1;
315 demuxer->payload_unit_start_indicator = (bits >> 22) & 0x1;
316 demuxer->pid = (bits >> 8) & 0x00001fff;
317 demuxer->transport_scrambling_control = (bits >> 6) & 0x3;
318 demuxer->adaptation_field_control = (bits >> 4) & 0x3;
319 demuxer->continuity_counter = bits & 0xf;
320
321 if(demuxer->transport_error_indicator)
322 {
323 fprintf(stderr, "demuxer->transport_error_indicator\n");
324 return 1;
325 }
326
327 if (demuxer->pid == 0x1fff)
328 {
329 demuxer->is_padding = 1; /* padding; just go to next */
330 return 0;
331 }
332 else
333 {
334 demuxer->is_padding = 0;
335 }
336
337/* Get pid */
338 for(table_entry = 0, result = 0; table_entry < demuxer->total_pids; table_entry++)
339 {
340 if(demuxer->pid == demuxer->pid_table[table_entry])
341 {
342 result = 1;
343 break;
344 }
345 }
346
347/* Not in pid table */
348 if(!result)
349 {
350 demuxer->pid_table[table_entry] = demuxer->pid;
351 demuxer->continuity_counters[table_entry] = demuxer->continuity_counter; /* init */
352 demuxer->total_pids++;
353 }
354 result = 0;
355
356/* Check counters */
357 if(demuxer->pid != MPEG3_PROGRAM_ASSOCIATION_TABLE &&
358 demuxer->pid != MPEG3_CONDITIONAL_ACCESS_TABLE &&
359 (demuxer->adaptation_field_control == 1 || demuxer->adaptation_field_control == 3))
360 {
361 if(demuxer->continuity_counters[table_entry] != demuxer->continuity_counter)
362 {
363 fprintf(stderr, "demuxer->continuity_counters[table_entry] != demuxer->continuity_counter\n");
364/* Reset it */
365 demuxer->continuity_counters[table_entry] = demuxer->continuity_counter;
366 }
367 if(++(demuxer->continuity_counters[table_entry]) > 15) demuxer->continuity_counters[table_entry] = 0;
368 }
369
370 if(demuxer->adaptation_field_control == 2 || demuxer->adaptation_field_control == 3)
371 result = mpeg3_get_adaptation_field(demuxer);
372
373 if(demuxer->adaptation_field_control == 1 || demuxer->adaptation_field_control == 3)
374 result = mpeg3_get_payload(demuxer);
375
376 return result;
377}
378
379int mpeg3_get_system_header(mpeg3_demuxer_t *demuxer)
380{
381 int length = mpeg3packet_read_int16(demuxer);
382 mpeg3packet_skip(demuxer, length);
383 return 0;
384}
385
386unsigned long mpeg3_get_timestamp(mpeg3_demuxer_t *demuxer)
387{
388 unsigned long timestamp;
389/* Only low 4 bits (7==1111) */
390 timestamp = (mpeg3packet_read_char(demuxer) >> 1) & 7;
391 timestamp <<= 15;
392 timestamp |= (mpeg3packet_read_int16(demuxer) >> 1);
393 timestamp <<= 15;
394 timestamp |= (mpeg3packet_read_int16(demuxer) >> 1);
395 return timestamp;
396}
397
398int mpeg3_get_pack_header(mpeg3_demuxer_t *demuxer, unsigned int *header)
399{
400 unsigned long i, j;
401 unsigned long clock_ref, clock_ref_ext;
402
403/* Get the time code */
404 if((mpeg3packet_next_char(demuxer) >> 4) == 2)
405 {
406/* MPEG-1 */
407 demuxer->time = (double)mpeg3_get_timestamp(demuxer) / 90000;
408/* Skip 3 bytes */
409 mpeg3packet_read_int24(demuxer);
410 }
411 else
412 if(mpeg3packet_next_char(demuxer) & 0x40)
413 {
414 i = mpeg3packet_read_int32(demuxer);
415 j = mpeg3packet_read_int16(demuxer);
416 if(i & 0x40000000 || (i >> 28) == 2)
417 {
418 clock_ref = ((i & 0x31000000) << 3);
419 clock_ref |= ((i & 0x03fff800) << 4);
420 clock_ref |= ((i & 0x000003ff) << 5);
421 clock_ref |= ((j & 0xf800) >> 11);
422 clock_ref_ext = (j >> 1) & 0x1ff;
423
424 demuxer->time = (double)(clock_ref + clock_ref_ext / 300) / 90000;
425/* Skip 3 bytes */
426 mpeg3packet_read_int24(demuxer);
427 i = mpeg3packet_read_char(demuxer) & 0x7;
428
429/* stuffing */
430 mpeg3packet_skip(demuxer, i);
431 }
432 }
433 else
434 {
435 mpeg3packet_skip(demuxer, 2);
436 }
437
438 *header = mpeg3packet_read_int32(demuxer);
439 if(*header == MPEG3_SYSTEM_START_CODE)
440 {
441 mpeg3_get_system_header(demuxer);
442 *header = mpeg3packet_read_int32(demuxer);
443 }
444 return 0;
445}
446
447/* Program packet reading core */
448int mpeg3_get_ps_pes_packet(mpeg3_demuxer_t *demuxer, unsigned int *header)
449{
450 unsigned long pts = 0, dts = 0;
451 int stream_id;
452 int pes_packet_length;
453 int pes_packet_start;
454 int i;
455 mpeg3_t *file = demuxer->file;
456
457 stream_id = *header & 0xff;
458 pes_packet_length = mpeg3packet_read_int16(demuxer);
459 pes_packet_start = demuxer->raw_offset;
460
461 if(stream_id != MPEG3_PRIVATE_STREAM_2 &&
462 stream_id != MPEG3_PADDING_STREAM)
463 {
464 if((mpeg3packet_next_char(demuxer) >> 6) == 0x02)
465 {
466/* Get MPEG-2 packet */
467 int pes_header_bytes = 0;
468 int scrambling = (mpeg3packet_read_char(demuxer) >> 4) & 0x3;
469 int pts_dts_flags = (mpeg3packet_read_char(demuxer) >> 6) & 0x3;
470 int pes_header_data_length = mpeg3packet_read_char(demuxer);
471
472 if(scrambling && (demuxer->do_audio || demuxer->do_video))
473 {
474/* Decrypt it */
475 if(mpeg3_decrypt_packet(demuxer->titles[demuxer->current_title]->fs->css,
476 demuxer->raw_data))
477 {
478 fprintf(stderr, "mpeg3_get_ps_pes_packet: Decryption not available\n");
479 return 1;
480 }
481 }
482
483/* Get Presentation and Decoding Time Stamps */
484 if(pts_dts_flags == 2)
485 {
486 pts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
487 pts <<= 15;
488 pts |= (mpeg3packet_read_int16(demuxer) >> 1);
489 pts <<= 15;
490 pts |= (mpeg3packet_read_int16(demuxer) >> 1);
491 pes_header_bytes += 5;
492 }
493 else
494 if(pts_dts_flags == 3)
495 {
496 pts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
497 pts <<= 15;
498 pts |= (mpeg3packet_read_int16(demuxer) >> 1);
499 pts <<= 15;
500 pts |= (mpeg3packet_read_int16(demuxer) >> 1);
501 dts = (mpeg3packet_read_char(demuxer) >> 1) & 7; /* Only low 4 bits (7==1111) */
502 dts <<= 15;
503 dts |= (mpeg3packet_read_int16(demuxer) >> 1);
504 dts <<= 15;
505 dts |= (mpeg3packet_read_int16(demuxer) >> 1);
506 pes_header_bytes += 10;
507 }
508
509/* Skip unknown */
510 mpeg3packet_skip(demuxer, pes_header_data_length - pes_header_bytes);
511 }
512 else
513 {
514 int pts_dts_flags;
515/* Get MPEG-1 packet */
516 while(mpeg3packet_next_char(demuxer) == 0xff)
517 {
518 mpeg3packet_read_char(demuxer);
519 }
520
521/* Skip STD buffer scale */
522 if((mpeg3packet_next_char(demuxer) & 0x40) == 0x40)
523 {
524 mpeg3packet_skip(demuxer, 2);
525 }
526
527/* Decide which timestamps are available */
528 pts_dts_flags = mpeg3packet_next_char(demuxer);
529
530 if(pts_dts_flags >= 0x30)
531 {
532/* Get the presentation and decoding time stamp */
533 pts = mpeg3_get_timestamp(demuxer);
534 dts = mpeg3_get_timestamp(demuxer);
535 }
536 else
537 if(pts_dts_flags >= 0x20)
538 {
539/* Get just the presentation time stamp */
540 pts = mpeg3_get_timestamp(demuxer);
541 }
542 else
543 if(pts_dts_flags == 0x0f)
544 {
545/* End of timestamps */
546 mpeg3packet_read_char(demuxer);
547 }
548 else
549 {
550 return 1; /* Error */
551 }
552 }
553
554/* Now extract the payload. */
555 if((stream_id >> 4) == 0xc || (stream_id >> 4) == 0xd)
556 {
557/* Audio data */
558/* Take first stream ID if -1 */
559 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
560 if(!demuxer->do_audio && !demuxer->do_video)
561 demuxer->astream_table[stream_id & 0x0f] = AUDIO_MPEG;
562 else
563 if(demuxer->astream == -1)
564 demuxer->astream = stream_id & 0x0f;
565
566 if((stream_id & 0x0f) == demuxer->astream && demuxer->do_audio)
567 {
568 if(pts) demuxer->pes_audio_time = pts;
569
570 memcpy(&demuxer->data_buffer[demuxer->data_size],
571 &demuxer->raw_data[demuxer->raw_offset],
572 pes_packet_length);
573 demuxer->data_size += pes_packet_length;
574 demuxer->raw_offset += pes_packet_length;
575 }
576 else
577 {
578 mpeg3packet_skip(demuxer, pes_packet_length);
579 }
580 }
581 else
582 if((stream_id >> 4) == 0xe)
583 {
584/* Video data */
585/* Take first stream ID if -1 */
586 if(!demuxer->do_audio && !demuxer->do_video)
587 demuxer->vstream_table[stream_id & 0x0f] = 1;
588 else
589 if(demuxer->vstream == -1)
590 demuxer->vstream = stream_id & 0x0f;
591
592 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
593 if((stream_id & 0x0f) == demuxer->vstream && demuxer->do_video)
594 {
595 if(pts) demuxer->pes_video_time = pts;
596
597 memcpy(&demuxer->data_buffer[demuxer->data_size],
598 &demuxer->raw_data[demuxer->raw_offset],
599 pes_packet_length);
600 demuxer->data_size += pes_packet_length;
601 demuxer->raw_offset += pes_packet_length;
602 }
603 else
604 {
605 mpeg3packet_skip(demuxer, pes_packet_length);
606 }
607 }
608 else
609 if(stream_id == 0xbd && demuxer->raw_data[demuxer->raw_offset] != 0xff)
610 {
611/* DVD audio data */
612/* Get the audio format */
613 int format;
614 if((demuxer->raw_data[demuxer->raw_offset] & 0xf0) == 0xa0)
615 format = AUDIO_PCM;
616 else
617 format = AUDIO_AC3;
618
619 stream_id = demuxer->raw_data[demuxer->raw_offset] - 0x80;
620
621/* Take first stream ID if not building TOC. */
622 if(!demuxer->do_audio && !demuxer->do_video)
623 demuxer->astream_table[stream_id] = format;
624 else
625 if(demuxer->astream == -1)
626 demuxer->astream = stream_id;
627
628 if(stream_id == demuxer->astream && demuxer->do_audio)
629 {
630 demuxer->aformat = format;
631 if(pts) demuxer->pes_audio_time = pts;
632 mpeg3packet_read_int32(demuxer);
633 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
634
635 memcpy(&demuxer->data_buffer[demuxer->data_size],
636 &demuxer->raw_data[demuxer->raw_offset],
637 pes_packet_length);
638 demuxer->data_size += pes_packet_length;
639 demuxer->raw_offset += pes_packet_length;
640 }
641 else
642 {
643 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
644 mpeg3packet_skip(demuxer, pes_packet_length);
645 }
646 }
647 else
648 if(stream_id == 0xbc || 1)
649 {
650 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
651 mpeg3packet_skip(demuxer, pes_packet_length);
652 }
653 }
654 else
655 if(stream_id == MPEG3_PRIVATE_STREAM_2 || stream_id == MPEG3_PADDING_STREAM)
656 {
657 pes_packet_length -= demuxer->raw_offset - pes_packet_start;
658 mpeg3packet_skip(demuxer, pes_packet_length);
659 }
660
661 while(demuxer->raw_offset + 4 < demuxer->raw_size)
662 {
663 *header = mpeg3packet_read_int32(demuxer);
664 if((*header >> 8) != MPEG3_PACKET_START_CODE_PREFIX)
665 demuxer->raw_offset -= 3;
666 else
667 break;
668 }
669
670 return 0;
671}
672
673int mpeg3_read_program(mpeg3_demuxer_t *demuxer)
674{
675 int result = 0, count = 0;
676 mpeg3_t *file = demuxer->file;
677 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
678 unsigned int header;
679 demuxer->raw_size = demuxer->packet_size;
680 demuxer->raw_offset = 0;
681 demuxer->data_size = 0;
682
683/* Search backward for it. */
684 header = mpeg3io_read_int32(title->fs);
685 result = mpeg3io_eof(title->fs);
686
687 if(!result) result = mpeg3io_seek_relative(title->fs, -4);
688
689// Search backwards for header
690 while(header != MPEG3_PACK_START_CODE && !result && count < demuxer->packet_size)
691 {
692 result = mpeg3io_seek_relative(title->fs, -1);
693 if(!result)
694 {
695 header >>= 8;
696 header |= mpeg3io_read_char(title->fs) << 24;
697 result = mpeg3io_seek_relative(title->fs, -1);
698 }
699 count++;
700 }
701
702 if(result)
703 {
704// couldn't find MPEG3_PACK_START_CODE
705 return 1;
706 }
707
708 result = mpeg3io_read_data(demuxer->raw_data, demuxer->packet_size, title->fs);
709
710 if(result)
711 {
712 perror("mpeg3_read_program");
713 return 1;
714 }
715
716 header = mpeg3packet_read_int32(demuxer);
717 while(demuxer->raw_offset + 4 < demuxer->raw_size && !result)
718 {
719 if(header == MPEG3_PACK_START_CODE)
720 {
721 result = mpeg3_get_pack_header(demuxer, &header);
722 }
723 else
724 if((header >> 8) == MPEG3_PACKET_START_CODE_PREFIX)
725 {
726 result = mpeg3_get_ps_pes_packet(demuxer, &header);
727 }
728 }
729 return result;
730}
731
732double mpeg3_lookup_time_offset(mpeg3_demuxer_t *demuxer, long byte)
733{
734 int i;
735 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
736
737 if(!title->timecode_table_size) return 0;
738
739 for(i = title->timecode_table_size - 1;
740 i >= 0 && title->timecode_table[i].start_byte > byte;
741 i--)
742 ;
743 if(i < 0) i = 0;
744 return title->timecode_table[i].absolute_start_time - title->timecode_table[i].start_time;
745}
746
747int mpeg3_advance_timecode(mpeg3_demuxer_t *demuxer, int reverse)
748{
749 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
750 int result = 0;
751 int do_seek = 0;
752
753/* Skip timecode advancing when constructing timecode table */
754 if(!title->timecode_table ||
755 !title->timecode_table_size ||
756 demuxer->generating_timecode) return 0;
757
758 if(!reverse)
759 {
760/* Get inside the current timecode */
761 if(mpeg3io_tell(title->fs) < title->timecode_table[demuxer->current_timecode].start_byte)
762 {
763 mpeg3io_seek(title->fs, title->timecode_table[demuxer->current_timecode].start_byte);
764 }
765
766/* Get the next timecode */
767 while(!result &&
768 (mpeg3io_tell(title->fs) >= title->timecode_table[demuxer->current_timecode].end_byte ||
769 demuxer->current_program != title->timecode_table[demuxer->current_timecode].program))
770 {
771
772/*
773 * printf("mpeg3_advance_timecode %d %d %d %d\n", mpeg3io_tell(title->fs), title->timecode_table[demuxer->current_timecode].end_byte,
774 * demuxer->current_program, title->timecode_table[demuxer->current_timecode].program);
775 */
776
777 demuxer->current_timecode++;
778 if(demuxer->current_timecode >= title->timecode_table_size)
779 {
780 demuxer->current_timecode = 0;
781 if(demuxer->current_title + 1 < demuxer->total_titles)
782 {
783 mpeg3demux_open_title(demuxer, demuxer->current_title + 1);
784 do_seek = 1;
785 }
786 else
787 {
788 mpeg3io_seek(title->fs, mpeg3io_total_bytes(title->fs));
789 result = 1;
790 }
791 }
792 title = demuxer->titles[demuxer->current_title];
793 }
794
795 if(!result && do_seek)
796 {
797 mpeg3io_seek(title->fs, title->timecode_table[demuxer->current_timecode].start_byte);
798 }
799 }
800 else
801 {
802/* Get the previous timecode */
803 while(!result &&
804 (mpeg3io_tell(title->fs) < title->timecode_table[demuxer->current_timecode].start_byte ||
805 demuxer->current_program != title->timecode_table[demuxer->current_timecode].program))
806 {
807/*
808 * if(demuxer->do_audio) printf("mpeg3_reverse_timecode %d %d %d %d\n", mpeg3io_tell(title->fs), title->timecode_table[demuxer->current_timecode].end_byte,
809 * demuxer->current_program, title->timecode_table[demuxer->current_timecode].program);
810 */
811 demuxer->current_timecode--;
812 if(demuxer->current_timecode < 0)
813 {
814 if(demuxer->current_title > 0)
815 {
816 mpeg3demux_open_title(demuxer, demuxer->current_title - 1);
817 title = demuxer->titles[demuxer->current_title];
818 demuxer->current_timecode = title->timecode_table_size - 1;
819 do_seek = 1;
820 }
821 else
822 {
823 mpeg3io_seek(title->fs, 0);
824 demuxer->current_timecode = 0;
825 result = 1;
826 }
827 }
828 }
829
830 if(!result && do_seek)
831 mpeg3io_seek(title->fs, title->timecode_table[demuxer->current_timecode].start_byte);
832 }
833
834 return result;
835}
836
837/* Read packet in the forward direction */
838int mpeg3_read_next_packet(mpeg3_demuxer_t *demuxer)
839{
840 int result = 0;
841 long current_position;
842 mpeg3_t *file = demuxer->file;
843 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
844 demuxer->data_size = 0;
845 demuxer->data_position = 0;
846
847/* Flip the file descriptor back to the end of the packet for forward */
848/* reading. */
849 if(demuxer->reverse)
850 {
851 result = mpeg3io_seek_relative(title->fs, demuxer->packet_size);
852 demuxer->reverse = 0;
853 }
854
855/* Read packets until the output buffer is full */
856 if(!result)
857 {
858 do
859 {
860 result = mpeg3_advance_timecode(demuxer, 0);
861
862 if(!result)
863 {
864 demuxer->time_offset = mpeg3_lookup_time_offset(demuxer, mpeg3io_tell(title->fs));
865
866 if(file->is_transport_stream)
867 {
868 result = mpeg3_read_transport(demuxer);
869 }
870 else
871 if(file->is_program_stream)
872 {
873 result = mpeg3_read_program(demuxer);
874 }
875 else
876 {
877/* Read elementary stream. */
878 result = mpeg3io_read_data(demuxer->data_buffer, demuxer->packet_size, title->fs);
879 if(!result) demuxer->data_size = demuxer->packet_size;
880 }
881 }
882 }while(!result && demuxer->data_size == 0 && (demuxer->do_audio || demuxer->do_video));
883 }
884
885 return result;
886}
887
888/* Read the packet right before the packet we're currently on. */
889int mpeg3_read_prev_packet(mpeg3_demuxer_t *demuxer)
890{
891 int result = 0;
892 mpeg3_t *file = demuxer->file;
893 long current_position;
894 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
895
896 demuxer->data_size = 0;
897 demuxer->data_position = 0;
898
899 do
900 {
901/* Rewind to the start of the packet to be read. */
902 result = mpeg3io_seek_relative(title->fs, -demuxer->packet_size);
903
904 if(!result) result = mpeg3_advance_timecode(demuxer, 1);
905 if(!result) demuxer->time_offset = mpeg3_lookup_time_offset(demuxer, mpeg3io_tell(title->fs));
906
907 if(file->is_transport_stream && !result)
908 {
909 result = mpeg3_read_transport(demuxer);
910 if(!mpeg3io_bof(title->fs))
911 /* if(!result) */result = mpeg3io_seek_relative(title->fs, -demuxer->packet_size);
912 }
913 else
914 if(file->is_program_stream && !result)
915 {
916
917 result = mpeg3_read_program(demuxer);
918 if(!mpeg3io_bof(title->fs))
919 /* if(!result) */result = mpeg3io_seek_relative(title->fs, -demuxer->packet_size);
920 }
921 else
922 if(!result)
923 {
924/* Elementary stream */
925/* Read the packet forwards and seek back to the start */
926 result = mpeg3io_read_data(demuxer->data_buffer, demuxer->packet_size, title->fs);
927 if(!result)
928 {
929 demuxer->data_size = demuxer->packet_size;
930 result = mpeg3io_seek_relative(title->fs, -demuxer->packet_size);
931 }
932 }
933 }while(!result && demuxer->data_size == 0 && (demuxer->do_audio || demuxer->do_video));
934
935/* Remember that the file descriptor is at the beginning of the packet just read. */
936 demuxer->reverse = 1;
937 demuxer->error_flag = result;
938 return result;
939}
940
941
942/* Used for audio */
943int mpeg3demux_read_data(mpeg3_demuxer_t *demuxer,
944 unsigned char *output,
945 long size)
946{
947 long i;
948 int result = 0;
949 mpeg3_t *file = demuxer->file;
950 demuxer->error_flag = 0;
951
952 if(demuxer->data_position >= 0)
953 {
954/* Read forwards */
955 for(i = 0; i < size && !result; )
956 {
957 int fragment_size = size - i;
958 if(fragment_size > demuxer->data_size - demuxer->data_position)
959 fragment_size = demuxer->data_size - demuxer->data_position;
960 memcpy(output + i, demuxer->data_buffer + demuxer->data_position, fragment_size);
961 demuxer->data_position += fragment_size;
962 i += fragment_size;
963
964 if(i < size)
965 {
966 result = mpeg3_read_next_packet(demuxer);
967 }
968 }
969 }
970 else
971 {
972/* Read backwards a full packet. */
973/* Only good for reading less than the size of a full packet, but */
974/* this routine should only be used for searching for previous markers. */
975 long current_position = demuxer->data_position;
976 result = mpeg3_read_prev_packet(demuxer);
977 if(!result) demuxer->data_position = demuxer->data_size + current_position;
978 memcpy(output, demuxer->data_buffer + demuxer->data_position, size);
979 demuxer->data_position += size;
980 }
981
982 demuxer->error_flag = result;
983 return result;
984}
985
986unsigned int mpeg3demux_read_char_packet(mpeg3_demuxer_t *demuxer)
987{
988 demuxer->error_flag = 0;
989 if(demuxer->data_position >= demuxer->data_size)
990 demuxer->error_flag = mpeg3_read_next_packet(demuxer);
991 demuxer->next_char = demuxer->data_buffer[demuxer->data_position++];
992 return demuxer->next_char;
993}
994
995unsigned int mpeg3demux_read_prev_char_packet(mpeg3_demuxer_t *demuxer)
996{
997 demuxer->error_flag = 0;
998 demuxer->data_position--;
999 if(demuxer->data_position < 0)
1000 {
1001 demuxer->error_flag = mpeg3_read_prev_packet(demuxer);
1002 if(!demuxer->error_flag) demuxer->data_position = demuxer->data_size - 1;
1003 }
1004 demuxer->next_char = demuxer->data_buffer[demuxer->data_position];
1005 return demuxer->next_char;
1006}
1007
1008mpeg3demux_timecode_t* mpeg3_append_timecode(mpeg3_demuxer_t *demuxer,
1009 mpeg3_title_t *title,
1010 long prev_byte,
1011 double prev_time,
1012 long next_byte,
1013 double next_time,
1014 int dont_store)
1015{
1016 mpeg3demux_timecode_t *new_table;
1017 mpeg3demux_timecode_t *new_timecode, *old_timecode;
1018 long i;
1019
1020 if(!title->timecode_table ||
1021 title->timecode_table_allocation <= title->timecode_table_size)
1022 {
1023 if(title->timecode_table_allocation == 0)
1024 title->timecode_table_allocation = 1;
1025 else
1026 title->timecode_table_allocation *= 2;
1027
1028 new_table = (mpeg3demux_timecode_t*)calloc(1, sizeof(mpeg3demux_timecode_t) * title->timecode_table_allocation);
1029 if(title->timecode_table)
1030 {
1031 for(i = 0; i < title->timecode_table_size; i++)
1032 {
1033 new_table[i] = title->timecode_table[i];
1034 }
1035
1036 free(title->timecode_table);
1037 }
1038 title->timecode_table = new_table;
1039 }
1040
1041 if(!dont_store)
1042 {
1043 new_timecode = &title->timecode_table[title->timecode_table_size];
1044 new_timecode->start_byte = next_byte;
1045 new_timecode->start_time = next_time;
1046 new_timecode->absolute_start_time = 0;
1047
1048 if(title->timecode_table_size > 0)
1049 {
1050 old_timecode = &title->timecode_table[title->timecode_table_size - 1];
1051 old_timecode->end_byte = prev_byte;
1052 old_timecode->end_time = prev_time;
1053 new_timecode->absolute_start_time =
1054 prev_time -
1055 old_timecode->start_time +
1056 old_timecode->absolute_start_time;
1057 new_timecode->absolute_end_time = next_time;
1058 }
1059 }
1060
1061 title->timecode_table_size++;
1062 return new_timecode;
1063}
1064
1065mpeg3demux_timecode_t* mpeg3demux_next_timecode(mpeg3_demuxer_t *demuxer,
1066 int *current_title,
1067 int *current_timecode,
1068 int current_program)
1069{
1070 int done = 0;
1071 while(!done)
1072 {
1073/* Increase timecode number */
1074 if(*current_timecode < demuxer->titles[*current_title]->timecode_table_size - 1)
1075 {
1076 (*current_timecode)++;
1077 if(demuxer->titles[*current_title]->timecode_table[*current_timecode].program == current_program)
1078 return &(demuxer->titles[*current_title]->timecode_table[*current_timecode]);
1079 }
1080 else
1081/* Increase title number */
1082 if(*current_title < demuxer->total_titles - 1)
1083 {
1084 (*current_title)++;
1085 (*current_timecode) = 0;
1086 if(demuxer->titles[*current_title]->timecode_table[*current_timecode].program == current_program)
1087 return &(demuxer->titles[*current_title]->timecode_table[*current_timecode]);
1088 }
1089 else
1090/* End of disk */
1091 done = 1;
1092 }
1093 return 0;
1094}
1095
1096mpeg3demux_timecode_t* mpeg3demux_prev_timecode(mpeg3_demuxer_t *demuxer,
1097 int *current_title,
1098 int *current_timecode,
1099 int current_program)
1100{
1101 int done = 0;
1102 while(!done)
1103 {
1104/* Increase timecode number */
1105 if(*current_timecode > 0)
1106 {
1107 (*current_timecode)--;
1108 if(demuxer->titles[*current_title]->timecode_table[*current_timecode].program == current_program)
1109 return &(demuxer->titles[*current_title]->timecode_table[*current_timecode]);
1110 }
1111 else
1112/* Increase title number */
1113 if(*current_title > 0)
1114 {
1115 (*current_title)--;
1116 (*current_timecode) = demuxer->titles[*current_title]->timecode_table_size - 1;
1117 if(demuxer->titles[*current_title]->timecode_table[*current_timecode].program == current_program)
1118 return &(demuxer->titles[*current_title]->timecode_table[*current_timecode]);
1119 }
1120 else
1121/* End of disk */
1122 done = 1;
1123
1124 }
1125 return 0;
1126}
1127
1128int mpeg3demux_open_title(mpeg3_demuxer_t *demuxer, int title_number)
1129{
1130 mpeg3_title_t *title;
1131
1132 if(title_number < demuxer->total_titles)
1133 {
1134 if(demuxer->current_title >= 0)
1135 {
1136 mpeg3io_close_file(demuxer->titles[demuxer->current_title]->fs);
1137 demuxer->current_title = -1;
1138 }
1139
1140 title = demuxer->titles[title_number];
1141 if(mpeg3io_open_file(title->fs))
1142 {
1143 demuxer->error_flag = 1;
1144 perror("mpeg3demux_open_title");
1145 }
1146 else
1147 {
1148 demuxer->current_title = title_number;
1149 }
1150 }
1151
1152 demuxer->current_timecode = 0;
1153
1154 return demuxer->error_flag;
1155}
1156
1157/* Assign program numbers to interleaved programs */
1158int mpeg3demux_assign_programs(mpeg3_demuxer_t *demuxer)
1159{
1160 int current_program = 0;
1161 int current_title = 0, previous_title;
1162 int current_timecode = 0, previous_timecode;
1163 double current_time, current_length;
1164 int done = 0;
1165 int interleaved = 0;
1166 mpeg3demux_timecode_t *timecode1, *timecode2;
1167 double program_times[MPEG3_MAX_STREAMS];
1168 int total_programs = 1;
1169 int i, j;
1170 int program_exists, last_program_assigned = 0;
1171 int total_timecodes;
1172 mpeg3_title_t **titles = demuxer->titles;
1173
1174 for(i = 0, total_timecodes = 0; i < demuxer->total_titles; i++)
1175 total_timecodes += demuxer->titles[i]->timecode_table_size;
1176
1177 //if(total_timecodes < 3) return 0;
1178
1179/*
1180 * // Assign programs based on length of contiguous timecode
1181 * timecode1 = demuxer->titles[current_title]->timecode_table;
1182 * while(!done)
1183 * {
1184 * if(!timecode1) done = 1;
1185 * else
1186 * if(timecode1->end_time - timecode1->start_time < MPEG3_PROGRAM_THRESHOLD)
1187 * {
1188 * // Got interleaved section
1189 * interleaved = 1;
1190 * program_times[0] = timecode1->end_time;
1191 *
1192 * while(interleaved && !done)
1193 * {
1194 * timecode2 = mpeg3demux_next_timecode(demuxer,
1195 * &current_title,
1196 * &current_timecode,
1197 * 0);
1198 *
1199 * if(!timecode2) done = 1;
1200 * else
1201 * {
1202 * // Another segment of interleaved data
1203 * if(timecode2->end_time - timecode2->start_time < MPEG3_PROGRAM_THRESHOLD)
1204 * {
1205 * // Search program times for where the previous instance of the program left off
1206 * for(program_exists = 0, i = 0;
1207 * i < total_programs && !program_exists;
1208 * i++)
1209 * {
1210 * // Got a previous instance of the program
1211 * if(program_times[i] + 0.5 > timecode2->start_time &&
1212 * program_times[i] - 0.5 < timecode2->start_time)
1213 * {
1214 * program_times[i] = timecode2->end_time;
1215 * timecode2->program = i;
1216 * program_exists = 1;
1217 *
1218 * // Programs must always start at 0 for an interleaved section
1219 * if(i < last_program_assigned && i != 0)
1220 * {
1221 * // Shift programs in the interleaved section down until they start at 0
1222 * for(j = 0; j < total_programs - 1; j++)
1223 * program_times[j] = program_times[j + 1];
1224 *
1225 * for(previous_title = current_title, previous_timecode = current_timecode;
1226 * titles[previous_title]->timecode_table[previous_timecode].program > 0 &&
1227 * (previous_title >= 0 || previous_timecode >= 0); )
1228 * {
1229 * titles[previous_title]->timecode_table[previous_timecode].program--;
1230 * previous_timecode--;
1231 * if(previous_timecode < 0 && previous_title > 0)
1232 * {
1233 * previous_title--;
1234 * previous_timecode = titles[previous_title]->timecode_table_size - 1;
1235 * }
1236 * }
1237 * }
1238 * }
1239 * }
1240 *
1241 * // Didn't get one
1242 * if(!program_exists)
1243 * {
1244 * program_times[total_programs] = timecode2->end_time;
1245 * timecode2->program = total_programs++;
1246 * }
1247 * last_program_assigned = timecode2->program;
1248 * }
1249 * // No more interleaved section
1250 * else
1251 * {
1252 * interleaved = 0;
1253 * // Restart program table from the beginning
1254 * total_programs = 1;
1255 * last_program_assigned = 0;
1256 * timecode1 = mpeg3demux_next_timecode(demuxer,
1257 * &current_title,
1258 * &current_timecode,
1259 * 0);
1260 * }
1261 * }
1262 * }
1263 * }
1264 * else
1265 * // Get next timecode
1266 * timecode1 = mpeg3demux_next_timecode(demuxer,
1267 * &current_title,
1268 * &current_timecode,
1269 * 0);
1270 * }
1271 *
1272 * demuxer->total_programs = total_programs;
1273 */
1274
1275/* Assign absolute timecodes in each program. */
1276 for(current_program = 0;
1277 current_program < total_programs;
1278 current_program++)
1279 {
1280 current_time = 0;
1281 current_title = 0;
1282 current_timecode = -1;
1283 while(timecode1 = mpeg3demux_next_timecode(demuxer,
1284 &current_title,
1285 &current_timecode,
1286 current_program))
1287 {
1288 timecode1->absolute_start_time = current_time;
1289 current_time += timecode1->end_time - timecode1->start_time;
1290 timecode1->absolute_end_time = current_time;
1291 }
1292 }
1293//for(i = 0; i < demuxer->total_titles; i++) mpeg3_dump_title(demuxer->titles[i]);
1294 demuxer->current_program = 0;
1295 return 0;
1296}
1297
1298/* ==================================================================== */
1299/* Entry points */
1300/* ==================================================================== */
1301
1302mpeg3_demuxer_t* mpeg3_new_demuxer(mpeg3_t *file, int do_audio, int do_video, int stream_id)
1303{
1304 mpeg3_demuxer_t *demuxer = (mpeg3_demuxer_t*)calloc(1, sizeof(mpeg3_demuxer_t));
1305 int i;
1306
1307/* The demuxer will change the default packet size for its own use. */
1308 demuxer->file = file;
1309 demuxer->packet_size = file->packet_size;
1310 demuxer->do_audio = do_audio;
1311 demuxer->do_video = do_video;
1312
1313/* Allocate buffer + padding */
1314 demuxer->raw_data = (unsigned char*)calloc(1, MPEG3_MAX_PACKSIZE);
1315 demuxer->data_buffer = (unsigned char*)calloc(1, MPEG3_MAX_PACKSIZE);
1316 demuxer->data_allocated = MPEG3_MAX_PACKSIZE;
1317/* System specific variables */
1318 demuxer->audio_pid = stream_id;
1319 demuxer->video_pid = stream_id;
1320 demuxer->astream = stream_id;
1321 demuxer->vstream = stream_id;
1322 demuxer->current_title = -1;
1323 return demuxer;
1324}
1325
1326int mpeg3_delete_demuxer(mpeg3_demuxer_t *demuxer)
1327{
1328 int i;
1329
1330 if(demuxer->current_title >= 0)
1331 {
1332 mpeg3io_close_file(demuxer->titles[demuxer->current_title]->fs);
1333 }
1334
1335 for(i = 0; i < demuxer->total_titles; i++)
1336 {
1337 mpeg3_delete_title(demuxer->titles[i]);
1338 }
1339
1340 if(demuxer->data_buffer) free(demuxer->data_buffer);
1341 free(demuxer->raw_data);
1342 free(demuxer);
1343}
1344
1345/* Create a title. */
1346/* Build a table of timecodes contained in the program stream. */
1347/* If toc is 0 just read the first and last timecode. */
1348int mpeg3demux_create_title(mpeg3_demuxer_t *demuxer, int timecode_search, FILE *toc)
1349{
1350 int result = 0, done = 0, counter_start, counter;
1351 mpeg3_t *file = demuxer->file;
1352 long next_byte, prev_byte;
1353 double next_time, prev_time, absolute_time;
1354 long i;
1355 mpeg3_title_t *title;
1356 unsigned long test_header = 0;
1357 mpeg3demux_timecode_t *timecode = 0;
1358
1359 demuxer->error_flag = 0;
1360 demuxer->generating_timecode = 1;
1361
1362/* Create a single title */
1363 if(!demuxer->total_titles)
1364 {
1365 demuxer->titles[0] = mpeg3_new_title(file, file->fs->path);
1366 demuxer->total_titles = 1;
1367 mpeg3demux_open_title(demuxer, 0);
1368 }
1369 title = demuxer->titles[0];
1370 title->total_bytes = mpeg3io_total_bytes(title->fs);
1371
1372
1373/* Get the packet size from the file */
1374 if(file->is_program_stream)
1375 {
1376 mpeg3io_seek(title->fs, 4);
1377 for(i = 0; i < MPEG3_MAX_PACKSIZE &&
1378 test_header != MPEG3_PACK_START_CODE; i++)
1379 {
1380 test_header <<= 8;
1381 test_header |= mpeg3io_read_char(title->fs);
1382 }
1383 if(i < MPEG3_MAX_PACKSIZE) demuxer->packet_size = i;
1384 mpeg3io_seek(title->fs, 0);
1385 }
1386 else
1387 demuxer->packet_size = file->packet_size;
1388
1389/* Get timecodes for the title */
1390 if(file->is_transport_stream || file->is_program_stream)
1391 {
1392 mpeg3io_seek(title->fs, 0);
1393 while(!done && !result && !mpeg3io_eof(title->fs))
1394 {
1395 next_byte = mpeg3io_tell(title->fs);
1396 result = mpeg3_read_next_packet(demuxer);
1397
1398 if(!result)
1399 {
1400 next_time = demuxer->time;
1401//printf("%f %f\n", next_time, prev_time);
1402 if(next_time < prev_time ||
1403 next_time - prev_time > MPEG3_CONTIGUOUS_THRESHOLD ||
1404 !title->timecode_table_size)
1405 {
1406/* Discontinuous */
1407 timecode = mpeg3_append_timecode(demuxer,
1408 title,
1409 prev_byte,
1410 prev_time,
1411 next_byte,
1412 next_time,
1413 0);
1414/*
1415 * printf("timecode: %ld %ld %f %f\n",
1416 * timecode->start_byte,
1417 * timecode->end_byte,
1418 * timecode->start_time,
1419 * timecode->end_time);
1420 */
1421
1422 counter_start = (int)next_time;
1423 }
1424 prev_time = next_time;
1425 prev_byte = next_byte;
1426 counter = (int)next_time;
1427 }
1428
1429/* Just get the first bytes if not building a toc to get the stream ID's. */
1430 if(next_byte > 0x100000 &&
1431 (!timecode_search || !toc)) done = 1;
1432 }
1433
1434/* Get the last timecode */
1435 if(!toc || !timecode_search)
1436 {
1437 result = mpeg3io_seek(title->fs, title->total_bytes);
1438 if(!result) result = mpeg3_read_prev_packet(demuxer);
1439 }
1440
1441 if(title->timecode_table && timecode)
1442 {
1443 timecode->end_byte = title->total_bytes;
1444 // timecode->end_byte = mpeg3io_tell(title->fs)/* + demuxer->packet_size */;
1445 timecode->end_time = demuxer->time;
1446 timecode->absolute_end_time = timecode->end_time - timecode->start_time;
1447 }
1448 }
1449
1450 mpeg3io_seek(title->fs, 0);
1451 demuxer->generating_timecode = 0;
1452 return 0;
1453}
1454
1455int mpeg3demux_print_timecodes(mpeg3_title_t *title, FILE *output)
1456{
1457 mpeg3demux_timecode_t *timecode;
1458 int i;
1459
1460 if(title->timecode_table)
1461 {
1462 for(i = 0; i < title->timecode_table_size; i++)
1463 {
1464 timecode = &title->timecode_table[i];
1465
1466 fprintf(output, "REGION: %ld %ld %f %f\n",
1467 timecode->start_byte,
1468 timecode->end_byte,
1469 timecode->start_time,
1470 timecode->end_time);
1471 }
1472 }
1473 return 0;
1474}
1475
1476/* Read the title information from a toc */
1477int mpeg3demux_read_titles(mpeg3_demuxer_t *demuxer)
1478{
1479 char string1[MPEG3_STRLEN], string2[MPEG3_STRLEN];
1480 long start_byte, end_byte;
1481 float start_time, end_time;
1482 mpeg3_title_t *title = 0;
1483 mpeg3_t *file = demuxer->file;
1484
1485// Eventually use IFO file to generate titles
1486 while(!feof(file->fs->fd))
1487 {
1488 fscanf(file->fs->fd, "%s %s %ld %f %f %f",
1489 string1,
1490 string2,
1491 &end_byte,
1492 &start_time,
1493 &end_time);
1494
1495 if(!strncasecmp(string1, "PATH:", 5))
1496 {
1497 title = demuxer->titles[demuxer->total_titles++] = mpeg3_new_title(file, string2);
1498
1499 if(demuxer->current_title < 0)
1500 mpeg3demux_open_title(demuxer, 0);
1501 }
1502 else
1503 if(title)
1504 {
1505 start_byte = atol(string2);
1506 if(!strcasecmp(string1, "REGION:"))
1507 {
1508 mpeg3_append_timecode(demuxer,
1509 title,
1510 0,
1511 0,
1512 0,
1513 0,
1514 1);
1515 title->timecode_table[title->timecode_table_size - 1].start_byte = start_byte;
1516 title->timecode_table[title->timecode_table_size - 1].end_byte = end_byte;
1517 title->timecode_table[title->timecode_table_size - 1].start_time = start_time;
1518 title->timecode_table[title->timecode_table_size - 1].end_time = end_time;
1519 }
1520 else
1521 if(!strcasecmp(string1, "ASTREAM:"))
1522 demuxer->astream_table[start_byte] = end_byte;
1523 else
1524 if(!strcasecmp(string1, "VSTREAM:"))
1525 demuxer->vstream_table[start_byte] = end_byte;
1526 else
1527 if(!strcasecmp(string1, "SIZE:"))
1528 title->total_bytes = start_byte;
1529 else
1530 if(!strcasecmp(string1, "PACKETSIZE:"))
1531 demuxer->packet_size = start_byte;
1532 }
1533 }
1534
1535 mpeg3demux_assign_programs(demuxer);
1536 return 0;
1537}
1538
1539int mpeg3demux_copy_titles(mpeg3_demuxer_t *dst, mpeg3_demuxer_t *src)
1540{
1541 long i;
1542 mpeg3_t *file = dst->file;
1543 mpeg3_title_t *dst_title, *src_title;
1544
1545 dst->packet_size = src->packet_size;
1546 dst->total_titles = src->total_titles;
1547 dst->total_programs = src->total_programs;
1548 for(i = 0; i < MPEG3_MAX_STREAMS; i++)
1549 {
1550 dst->astream_table[i] = src->astream_table[i];
1551 dst->vstream_table[i] = src->vstream_table[i];
1552 }
1553 for(i = 0; i < src->total_titles; i++)
1554 {
1555 src_title = src->titles[i];
1556 dst_title = dst->titles[i] = mpeg3_new_title(file, src->titles[i]->fs->path);
1557 mpeg3_copy_title(dst_title, src_title);
1558 }
1559
1560 mpeg3demux_open_title(dst, src->current_title);
1561 return 0;
1562}
1563
1564int mpeg3demux_print_streams(mpeg3_demuxer_t *demuxer, FILE *toc)
1565{
1566 int i;
1567/* Print the stream information */
1568 for(i = 0; i < MPEG3_MAX_STREAMS; i++)
1569 {
1570 if(demuxer->astream_table[i])
1571 fprintf(toc, "ASTREAM: %d %d\n", i, demuxer->astream_table[i]);
1572
1573 if(demuxer->vstream_table[i])
1574 fprintf(toc, "VSTREAM: %d %d\n", i, demuxer->vstream_table[i]);
1575 }
1576 return 0;
1577}
1578
1579/* Need a timecode table to do this */
1580double mpeg3demux_length(mpeg3_demuxer_t *demuxer)
1581{
1582 mpeg3_title_t *title;
1583 int i, j;
1584 double length;
1585
1586 for(i = demuxer->total_titles - 1; i >= 0; i--)
1587 {
1588 title = demuxer->titles[i];
1589 for(j = title->timecode_table_size - 1; j >= 0; j--)
1590 {
1591 if(title->timecode_table[j].program == demuxer->current_program)
1592 {
1593 return title->timecode_table[j].end_time -
1594 title->timecode_table[j].start_time +
1595 title->timecode_table[j].absolute_start_time;
1596 }
1597 }
1598 }
1599
1600 return 1;
1601}
1602
1603int mpeg3demux_eof(mpeg3_demuxer_t *demuxer)
1604{
1605 if(demuxer->current_title >= 0)
1606 {
1607 if(mpeg3io_eof(demuxer->titles[demuxer->current_title]->fs) &&
1608 demuxer->current_title >= demuxer->total_titles - 1)
1609 return 1;
1610 }
1611
1612 return 0;
1613}
1614
1615int mpeg3demux_bof(mpeg3_demuxer_t *demuxer)
1616{
1617 if(demuxer->current_title >= 0)
1618 {
1619 if(mpeg3io_bof(demuxer->titles[demuxer->current_title]->fs) &&
1620 demuxer->current_title <= 0)
1621 return 1;
1622 }
1623 return 0;
1624}
1625
1626
1627/* For elemental streams seek to a byte */
1628int mpeg3demux_seek_byte(mpeg3_demuxer_t *demuxer, long byte)
1629{
1630 long current_position;
1631 mpeg3_t *file = demuxer->file;
1632 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
1633
1634 demuxer->data_position = 0;
1635 demuxer->data_size = 0;
1636
1637 demuxer->error_flag = mpeg3io_seek(title->fs, byte);
1638
1639 if(!demuxer->error_flag && (file->is_transport_stream || file->is_program_stream))
1640 {
1641/* Get on a packet boundary only for system streams. */
1642 current_position = mpeg3io_tell(title->fs);
1643 if(byte % demuxer->packet_size)
1644 {
1645 demuxer->error_flag |= mpeg3io_seek(title->fs, current_position - (current_position % demuxer->packet_size));
1646 }
1647 }
1648 return demuxer->error_flag;
1649}
1650
1651/* For programs streams and toc seek to a time */
1652int mpeg3demux_seek_time(mpeg3_demuxer_t *demuxer, double new_time)
1653{
1654 int i, j, done = 0, result = 0;
1655 double byte_offset, new_byte_offset;
1656 double guess = 0, minimum = 65535;
1657 mpeg3_title_t *title;
1658 mpeg3demux_timecode_t *timecode;
1659
1660 demuxer->error_flag = 0;
1661
1662 i = 0;
1663 j = 0;
1664 title = demuxer->titles[i];
1665 timecode = &title->timecode_table[j];
1666
1667/* Get the title and timecode of the new position */
1668 while(!demuxer->error_flag &&
1669 !(timecode->absolute_start_time <= new_time &&
1670 timecode->absolute_end_time > new_time &&
1671 timecode->program == demuxer->current_program))
1672 {
1673/* Next timecode */
1674 j++;
1675 if(j >= title->timecode_table_size)
1676 {
1677 i++;
1678 j = 0;
1679 if(i >= demuxer->total_titles)
1680 {
1681 demuxer->error_flag = 1;
1682 return 1;
1683 }
1684 else
1685 {
1686 mpeg3demux_open_title(demuxer, i);
1687 }
1688 }
1689
1690 title = demuxer->titles[i];
1691 timecode = &title->timecode_table[j];
1692 }
1693
1694/* Guess the new byte position */
1695 demuxer->current_timecode = j;
1696
1697 byte_offset = ((new_time - timecode->absolute_start_time) /
1698 (timecode->absolute_end_time - timecode->absolute_start_time) *
1699 (timecode->end_byte - timecode->start_byte) +
1700 timecode->start_byte);
1701//printf("mpeg3demux_seek_time %f %f\n", new_time, byte_offset);
1702
1703 while(!done && !result && byte_offset >= 0)
1704 {
1705 result = mpeg3demux_seek_byte(demuxer, (long)byte_offset);
1706//printf("seek_time 0 byte %.0f want %f result %d\n", byte_offset, new_time, result);
1707
1708 if(!result)
1709 {
1710 result = mpeg3_read_next_packet(demuxer);
1711// printf("seek_time 1 guess %f want %f\n", guess, new_time);
1712 guess = demuxer->time + demuxer->time_offset;
1713
1714 if(fabs(new_time - guess) >= fabs(minimum)) done = 1;
1715 else
1716 {
1717 minimum = guess - new_time;
1718 new_byte_offset = byte_offset + ((new_time - guess) /
1719 (timecode->end_time - timecode->start_time) *
1720 (timecode->end_byte - timecode->start_byte));
1721 if(labs((long)new_byte_offset - (long)byte_offset) < demuxer->packet_size) done = 1;
1722 byte_offset = new_byte_offset;
1723 }
1724 }
1725 }
1726
1727/* Get one packet before the packet just read */
1728 if(!result && byte_offset > demuxer->packet_size && minimum > 0)
1729 {
1730 mpeg3_read_prev_packet(demuxer);
1731 mpeg3_read_prev_packet(demuxer);
1732 }
1733//printf("seek_time %d %d %d\n", demuxer->current_title, demuxer->current_timecode, mpeg3demux_tell(demuxer));
1734 demuxer->error_flag = result;
1735 return result;
1736}
1737
1738int mpeg3demux_seek_percentage(mpeg3_demuxer_t *demuxer, double percentage)
1739{
1740 double total_bytes = 0;
1741 double absolute_position;
1742 long relative_position;
1743 int i, new_title;
1744 mpeg3_title_t *title;
1745
1746 demuxer->error_flag = 0;
1747
1748/* Get the absolute byte position; */
1749 for(i = 0; i < demuxer->total_titles; i++)
1750 total_bytes += demuxer->titles[i]->total_bytes;
1751
1752 absolute_position = percentage * total_bytes;
1753
1754/* Get the title the byte is inside */
1755 for(new_title = 0, total_bytes = 0; new_title < demuxer->total_titles; new_title++)
1756 {
1757 total_bytes += demuxer->titles[new_title]->total_bytes;
1758 if(absolute_position < total_bytes) break;
1759 }
1760
1761 if(new_title >= demuxer->total_titles)
1762 {
1763 new_title = demuxer->total_titles - 1;
1764 }
1765
1766/* Got a title */
1767 title = demuxer->titles[new_title];
1768 total_bytes -= title->total_bytes;
1769 relative_position = (long)(absolute_position - total_bytes);
1770
1771/* Get the timecode the byte is inside */
1772 for(demuxer->current_timecode = 0;
1773 demuxer->current_timecode < title->timecode_table_size;
1774 demuxer->current_timecode++)
1775 {
1776 if(title->timecode_table[demuxer->current_timecode].start_byte <= relative_position &&
1777 title->timecode_table[demuxer->current_timecode].end_byte > relative_position)
1778 {
1779 break;
1780 }
1781 }
1782
1783 if(demuxer->current_timecode >= title->timecode_table_size)
1784 demuxer->current_timecode = title->timecode_table_size - 1;
1785
1786/* Get the nearest timecode in the same program */
1787 while(demuxer->current_timecode < title->timecode_table_size - 1 &&
1788 title->timecode_table[demuxer->current_timecode].program != demuxer->current_program)
1789 {
1790 demuxer->current_timecode++;
1791 }
1792
1793/* Open the new title and seek to the correct byte */
1794 if(new_title != demuxer->current_title)
1795 {
1796 demuxer->error_flag = mpeg3demux_open_title(demuxer, new_title);
1797 }
1798
1799 if(!demuxer->error_flag)
1800 demuxer->error_flag = mpeg3io_seek(title->fs, relative_position);
1801
1802 return demuxer->error_flag;
1803}
1804
1805double mpeg3demux_tell_percentage(mpeg3_demuxer_t *demuxer)
1806{
1807 double total_bytes = 0;
1808 double position = 0;
1809 int i;
1810
1811 demuxer->error_flag = 0;
1812 position = mpeg3io_tell(demuxer->titles[demuxer->current_title]->fs);
1813 for(i = 0; i < demuxer->total_titles; i++)
1814 {
1815 if(i == demuxer->current_title)
1816 {
1817 position += total_bytes;
1818 }
1819 total_bytes += demuxer->titles[i]->total_bytes;
1820 }
1821 return position / total_bytes;
1822}
1823
1824double mpeg3demux_get_time(mpeg3_demuxer_t *demuxer)
1825{
1826 return demuxer->time;
1827}
1828
1829long mpeg3demux_tell(mpeg3_demuxer_t *demuxer)
1830{
1831 return mpeg3io_tell(demuxer->titles[demuxer->current_title]->fs);
1832}
1833
1834long mpeg3demuxer_total_bytes(mpeg3_demuxer_t *demuxer)
1835{
1836 mpeg3_title_t *title = demuxer->titles[demuxer->current_title];
1837 return title->total_bytes;
1838}
1839
1840mpeg3_demuxer_t* mpeg3_get_demuxer(mpeg3_t *file)
1841{
1842 if(file->is_program_stream || file->is_transport_stream)
1843 {
1844 if(file->has_audio) return file->atrack[0]->demuxer;
1845 else
1846 if(file->has_video) return file->vtrack[0]->demuxer;
1847 }
1848 return 0;
1849}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3demux.h b/core/multimedia/opieplayer/libmpeg3/mpeg3demux.h
new file mode 100644
index 0000000..9dfd182
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3demux.h
@@ -0,0 +1,118 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3DEMUX_H
21#define MPEG3DEMUX_H
22
23#include "mpeg3title.h"
24#include <stdio.h>
25
26typedef struct
27{
28 struct mpeg3_rec* file;
29/* Data consisting of the multiplexed packet */
30 unsigned char *raw_data;
31 long raw_offset;
32 int raw_size;
33 long packet_size;
34/* Only one is on depending on which track owns the demultiplexer. */
35 int do_audio;
36 int do_video;
37/* Data consisting of the elementary stream */
38 unsigned char *data_buffer;
39 long data_size;
40 long data_position;
41 long data_allocated;
42/* Remember when the file descriptor is at the beginning of the packet just read. */
43 int reverse;
44/* Set to 1 when eof or attempt to read before beginning */
45 int error_flag;
46/* Temp variables for returning */
47 unsigned char next_char;
48/* Correction factor for time discontinuity */
49 double time_offset;
50 int generating_timecode;
51
52/* Titles */
53 mpeg3_title_t *titles[MPEG3_MAX_STREAMS];
54 int total_titles;
55 int current_title;
56
57/* Tables of every stream ID encountered */
58 int astream_table[MPEG3_MAX_STREAMS]; /* macro of audio format if audio */
59 int vstream_table[MPEG3_MAX_STREAMS]; /* 1 if video */
60
61/* Programs */
62 int total_programs;
63 int current_program;
64
65/* Timecode in the current title */
66 int current_timecode;
67
68/* Byte position in the current title */
69 long current_byte;
70
71 int transport_error_indicator;
72 int payload_unit_start_indicator;
73 int pid;
74 int transport_scrambling_control;
75 int adaptation_field_control;
76 int continuity_counter;
77 int is_padding;
78 int pid_table[MPEG3_PIDMAX];
79 int continuity_counters[MPEG3_PIDMAX];
80 int total_pids;
81 int adaptation_fields;
82 double time; /* Time in seconds */
83 int audio_pid;
84 int video_pid;
85 int astream; /* Video stream ID being decoded. -1 = select first ID in stream */
86 int vstream; /* Audio stream ID being decoded. -1 = select first ID in stream */
87 int aformat; /* format of the audio derived from multiplexing codes */
88 long program_association_tables;
89 int table_id;
90 int section_length;
91 int transport_stream_id;
92 long pes_packets;
93 double pes_audio_time; /* Presentation Time stamps */
94 double pes_video_time; /* Presentation Time stamps */
95} mpeg3_demuxer_t;
96
97/* ========================================================================= */
98/* Entry points */
99/* ========================================================================= */
100
101#define mpeg3demux_error(demuxer) (((mpeg3_demuxer_t *)(demuxer))->error_flag)
102
103#define mpeg3demux_time_offset(demuxer) (((mpeg3_demuxer_t *)(demuxer))->time_offset)
104
105#define mpeg3demux_current_time(demuxer) (((mpeg3_demuxer_t *)(demuxer))->time + ((mpeg3_demuxer_t *)(demuxer))->time_offset)
106
107#define mpeg3demux_read_char(demuxer) \
108 ((((mpeg3_demuxer_t *)(demuxer))->data_position < ((mpeg3_demuxer_t *)(demuxer))->data_size) ? \
109 ((mpeg3_demuxer_t *)(demuxer))->data_buffer[((mpeg3_demuxer_t *)(demuxer))->data_position++] : \
110 mpeg3demux_read_char_packet(demuxer))
111
112#define mpeg3demux_read_prev_char(demuxer) \
113 ((((mpeg3_demuxer_t *)(demuxer))->data_position != 0) ? \
114 ((mpeg3_demuxer_t *)(demuxer))->data_buffer[((mpeg3_demuxer_t *)(demuxer))->data_position--] : \
115 mpeg3demux_read_prev_char_packet(demuxer))
116
117
118#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.c b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
new file mode 100644
index 0000000..c5807a7
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.c
@@ -0,0 +1,127 @@
1#include "mpeg3private.h"
2#include "mpeg3protos.h"
3
4#ifndef _WIN32
5#include <mntent.h>
6#else
7
8#endif
9#include <sys/stat.h>
10#include <stdlib.h>
11#include <string.h>
12
13mpeg3_fs_t* mpeg3_new_fs(char *path)
14{
15 mpeg3_fs_t *fs = (mpeg3_fs_t*)calloc(1, sizeof(mpeg3_fs_t));
16 fs->css = mpeg3_new_css();
17 strcpy(fs->path, path);
18 return fs;
19}
20
21int mpeg3_delete_fs(mpeg3_fs_t *fs)
22{
23 mpeg3_delete_css(fs->css);
24 free(fs);
25 return 0;
26}
27
28int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src)
29{
30 strcpy(dst->path, src->path);
31 dst->current_byte = 0;
32 return 0;
33}
34
35long mpeg3io_get_total_bytes(mpeg3_fs_t *fs)
36{
37/*
38 * struct stat st;
39 * if(stat(fs->path, &st) < 0) return 0;
40 * return (long)st.st_size;
41 */
42
43 fseek(fs->fd, 0, SEEK_END);
44 fs->total_bytes = ftell(fs->fd);
45 fseek(fs->fd, 0, SEEK_SET);
46 return fs->total_bytes;
47}
48
49int mpeg3io_open_file(mpeg3_fs_t *fs)
50{
51/* Need to perform authentication before reading a single byte. */
52 mpeg3_get_keys(fs->css, fs->path);
53
54 if(!(fs->fd = fopen(fs->path, "rb")))
55 {
56 perror("mpeg3io_open_file");
57 return 1;
58 }
59
60 fs->total_bytes = mpeg3io_get_total_bytes(fs);
61
62 if(!fs->total_bytes)
63 {
64 fclose(fs->fd);
65 return 1;
66 }
67 fs->current_byte = 0;
68 return 0;
69}
70
71int mpeg3io_close_file(mpeg3_fs_t *fs)
72{
73 if(fs->fd) fclose(fs->fd);
74 fs->fd = 0;
75 return 0;
76}
77
78int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs)
79{
80 int result = 0;
81//printf("read %d bytes\n",bytes);
82 result = !fread(buffer, 1, bytes, fs->fd);
83 fs->current_byte += bytes;
84 return (result && bytes);
85}
86
87int mpeg3io_device(char *path, char *device)
88{
89 struct stat file_st, device_st;
90 struct mntent *mnt;
91 FILE *fp;
92
93 if(stat(path, &file_st) < 0)
94 {
95 perror("mpeg3io_device");
96 return 1;
97 }
98
99#ifndef _WIN32
100 fp = setmntent(MOUNTED, "r");
101 while(fp && (mnt = getmntent(fp)))
102 {
103 if(stat(mnt->mnt_fsname, &device_st) < 0) continue;
104 if(device_st.st_rdev == file_st.st_dev)
105 {
106 strncpy(device, mnt->mnt_fsname, MPEG3_STRLEN);
107 break;
108 }
109 }
110 endmntent(fp);
111#endif
112
113 return 0;
114}
115
116int mpeg3io_seek(mpeg3_fs_t *fs, long byte)
117{
118 fs->current_byte = byte;
119 return fseek(fs->fd, byte, SEEK_SET);
120}
121
122int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes)
123{
124 fs->current_byte += bytes;
125 return fseek(fs->fd, fs->current_byte, SEEK_SET);
126}
127
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3io.h b/core/multimedia/opieplayer/libmpeg3/mpeg3io.h
new file mode 100644
index 0000000..092e411
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3io.h
@@ -0,0 +1,74 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3IO_H
21#define MPEG3IO_H
22
23
24#include <stdio.h>
25#include "mpeg3css.h"
26#include "mpeg3private.inc"
27
28/* Filesystem structure */
29
30typedef struct
31{
32 FILE *fd;
33 mpeg3_css_t *css; /* Encryption object */
34 char path[MPEG3_STRLEN];
35/* Hypothetical position of file pointer */
36 long current_byte;
37 long total_bytes;
38} mpeg3_fs_t;
39
40#define mpeg3io_tell(fs) (((mpeg3_fs_t *)(fs))->current_byte)
41
42// End of file
43#define mpeg3io_eof(fs) (((mpeg3_fs_t *)(fs))->current_byte >= ((mpeg3_fs_t *)(fs))->total_bytes)
44
45// Beginning of file
46 #define mpeg3io_bof(fs)(((mpeg3_fs_t *)(fs))->current_byte < 0)
47
48
49#define mpeg3io_total_bytes(fs) (((mpeg3_fs_t *)(fs))->total_bytes)
50
51extern inline unsigned int mpeg3io_read_int32(mpeg3_fs_t *fs)
52{
53 int a, b, c, d;
54 unsigned int result;
55/* Do not fread. This breaks byte ordering. */
56 a = (unsigned char)fgetc(fs->fd);
57 b = (unsigned char)fgetc(fs->fd);
58 c = (unsigned char)fgetc(fs->fd);
59 d = (unsigned char)fgetc(fs->fd);
60 result = ((int)a << 24) |
61 ((int)b << 16) |
62 ((int)c << 8) |
63 ((int)d);
64 fs->current_byte += 4;
65 return result;
66}
67
68extern inline unsigned int mpeg3io_read_char(mpeg3_fs_t *fs)
69{
70 fs->current_byte++;
71 return fgetc(fs->fd);
72}
73
74#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3private.h b/core/multimedia/opieplayer/libmpeg3/mpeg3private.h
new file mode 100644
index 0000000..f0e11aa
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3private.h
@@ -0,0 +1,62 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3PRIVATE_H
21#define MPEG3PRIVATE_H
22
23#include "mpeg3atrack.h"
24#include "mpeg3css.h"
25#include "mpeg3io.h"
26#include "mpeg3private.inc"
27#include "mpeg3title.h"
28#include "mpeg3vtrack.h"
29
30struct mpeg3_rec
31{
32 mpeg3_fs_t *fs; /* Store entry path here */
33 mpeg3_demuxer_t *demuxer; /* Master tables */
34
35/* Media specific */
36 int has_audio;
37 int has_video;
38 int total_astreams;
39 int total_vstreams;
40 mpeg3_atrack_t *atrack[MPEG3_MAX_STREAMS];
41 mpeg3_vtrack_t *vtrack[MPEG3_MAX_STREAMS];
42
43/* Only one of these is set to 1 to specify what kind of stream we have. */
44 int is_transport_stream;
45 int is_program_stream;
46 int is_audio_stream; /* Elemental stream */
47 int is_video_stream; /* Elemental stream */
48 long packet_size;
49/* Type and stream for getting current percentage */
50 int last_type_read; /* 1 - audio 2 - video */
51 int last_stream_read;
52
53 int program; /* Number of program to play */
54 int cpus;
55 int have_mmx;
56};
57
58typedef struct mpeg3_rec mpeg3_t;
59
60
61
62#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3private.inc b/core/multimedia/opieplayer/libmpeg3/mpeg3private.inc
new file mode 100644
index 0000000..7e56e7f
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3private.inc
@@ -0,0 +1,110 @@
1#ifndef LIBMPEG3_INC
2#define LIBMPEG3_INC
3
4#ifdef _WIN32
5
6// Disable some compiler warnings that happen a lot but don't matter
7#pragma warning( disable : 4003 ) // not enough parameters for macro
8#pragma warning( disable : 4305 ) // truncation frm double to float
9#pragma warning( disable : 4715 ) // not all control paths return a value
10#pragma warning( disable : 4716 ) // must return a value
11
12#ifdef LIBMPEG_EXPORTS
13 #define LIBMPEG_EXPORT __declspec( dllexport )
14#else
15 #define LIBMPEG_EXPORT __declspec( dllimport )
16#endif
17
18#ifdef ERROR
19#undef ERROR
20#include <windows.h>
21#undef ERROR
22#define ERROR (-1)
23#else
24#include <windows.h>
25#undef ERROR
26#endif
27
28 #define inline __inline
29 #define M_PI 3.14159265358979323846
30 #define M_SQRT2 1.41421356237309504880
31
32 #define pthread_mutexattr_t int
33#define pthread_mutexattr_init(a) // Nothing
34 #define pthread_mutex_t CRITICAL_SECTION
35 #define pthread_mutex_init(a,b) InitializeCriticalSection(a)
36 #define pthread_mutex_lock(a) EnterCriticalSection(a)
37 #define pthread_mutex_unlock(a) LeaveCriticalSection(a)
38#define pthread_mutex_destroy(a) //DeleteCriticalSection(a)
39
40 #define pthread_attr_t int
41 #define pthread_attr_init(a) // Nothing
42 #define pthread_t unsigned long
43 #define pthread_create(a,b,c,d) *(a) = _beginthread(c,0,d)
44 //#define pthread_join(a,b) _endthread(b)
45 //#define pthread_join(a,b) _cwait(NULL,b,NULL)
46#define pthread_join(a,b)
47
48 #define strncasecmp(a,b,c) _strnicmp(a,b,c)
49 #define strcasecmp(a,b) _stricmp(a,b)
50 #define bzero(a,b) memset(a,0,b)
51
52#else
53
54 #define LONGLONG long long
55 #define ULONGLONG unsigned long long
56
57#endif
58
59#ifndef LIBMPEG_EXPORT
60#define LIBMPEG_EXPORT
61#endif
62
63#define MPEG3_FLOAT32 mpeg3_real_t
64#define MPEG3_INT16 short int
65#define MPEG3_INT32 int
66#define MPEG3_INT64 long
67
68#define MPEG3_TOC_PREFIX 0x544f4356
69#define MPEG3_TOC_PREFIXLOWER 0x746f6376
70#define MPEG3_ID3_PREFIX 0x494433
71#define MPEG3_RIFF_CODE 0x52494646
72#define MPEG3_PROC_CPUINFO "/proc/cpuinfo"
73#define MPEG3_TS_PACKET_SIZE 188
74#define MPEG3_DVD_PACKET_SIZE 0x800
75#define MPEG3_SYNC_BYTE 0x47
76#define MPEG3_PACK_START_CODE 0x000001ba
77#define MPEG3_SEQUENCE_START_CODE 0x000001b3
78#define MPEG3_SEQUENCE_END_CODE 0x000001b7
79#define MPEG3_SYSTEM_START_CODE 0x000001bb
80#define MPEG3_STRLEN 1024
81#define MPEG3_PIDMAX 20 /* Maximum number of PIDs in one stream */
82#define MPEG3_PROGRAM_ASSOCIATION_TABLE 0x00
83#define MPEG3_CONDITIONAL_ACCESS_TABLE 0x01
84#define MPEG3_PACKET_START_CODE_PREFIX 0x000001
85#define MPEG3_PRIVATE_STREAM_2 0xbf
86#define MPEG3_PADDING_STREAM 0xbe
87#define MPEG3_GOP_START_CODE 0x000001b8
88#define MPEG3_PICTURE_START_CODE 0x00000100
89#define MPEG3_EXT_START_CODE 0x000001b5
90#define MPEG3_USER_START_CODE 0x000001b2
91#define MPEG3_SLICE_MIN_START 0x00000101
92#define MPEG3_SLICE_MAX_START 0x000001af
93#define MPEG3_AC3_START_CODE 0x0b77
94#define MPEG3_PCM_START_CODE 0x0180
95#define MPEG3_MAX_CPUS 256
96#define MPEG3_MAX_STREAMS 256
97#define MPEG3_MAX_PACKSIZE 262144
98#define MPEG3_CONTIGUOUS_THRESHOLD 10 /* Positive difference before declaring timecodes discontinuous */
99#define MPEG3_PROGRAM_THRESHOLD 5 /* Minimum number of seconds before interleaving programs */
100#define MPEG3_SEEK_THRESHOLD 16 /* Number of frames difference before absolute seeking */
101
102/* Values for audio format */
103#define AUDIO_UNKNOWN 0
104#define AUDIO_MPEG 1
105#define AUDIO_AC3 2
106#define AUDIO_PCM 3
107#define AUDIO_AAC 4
108#define AUDIO_JESUS 5
109
110#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3protos.h b/core/multimedia/opieplayer/libmpeg3/mpeg3protos.h
new file mode 100644
index 0000000..631336b
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3protos.h
@@ -0,0 +1,278 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3PROTOS_H
21#define MPEG3PROTOS_H
22
23#if defined(__cplusplus)
24extern "C" {
25#endif
26
27/* CSS */
28
29mpeg3_css_t* mpeg3_new_css();
30
31/* DEMUX */
32
33mpeg3_demuxer_t* mpeg3_new_demuxer(mpeg3_t *file, int do_audio, int do_video, int stream_id);
34int mpeg3_delete_demuxer(mpeg3_demuxer_t *demuxer);
35int mpeg3demux_read_data(mpeg3_demuxer_t *demuxer, unsigned char *output, long size);
36unsigned int mpeg3demux_read_int32(mpeg3_demuxer_t *demuxer);
37unsigned int mpeg3demux_read_int24(mpeg3_demuxer_t *demuxer);
38unsigned int mpeg3demux_read_int16(mpeg3_demuxer_t *demuxer);
39double mpeg3demux_length(mpeg3_demuxer_t *demuxer);
40mpeg3_demuxer_t* mpeg3_get_demuxer(mpeg3_t *file);
41long mpeg3demux_tell(mpeg3_demuxer_t *demuxer);
42double mpeg3demux_tell_percentage(mpeg3_demuxer_t *demuxer);
43double mpeg3demux_get_time(mpeg3_demuxer_t *demuxer);
44int mpeg3demux_eof(mpeg3_demuxer_t *demuxer);
45int mpeg3demux_bof(mpeg3_demuxer_t *demuxer);
46int mpeg3demux_copy_titles(mpeg3_demuxer_t *dst, mpeg3_demuxer_t *src);
47int mpeg3demux_create_title(mpeg3_demuxer_t *demuxer, int timecode_search, FILE *toc);
48long mpeg3demuxer_total_bytes(mpeg3_demuxer_t *demuxer);
49int mpeg3demux_seek_byte(mpeg3_demuxer_t *demuxer, long byte);
50int mpeg3demux_seek_time(mpeg3_demuxer_t *demuxer, double new_time);
51int mpeg3demux_seek_percentage(mpeg3_demuxer_t *demuxer, double percentage);
52int mpeg3demux_print_streams(mpeg3_demuxer_t *demuxer, FILE *toc);
53int mpeg3demux_print_timecodes(mpeg3_title_t *title, FILE *output);
54int mpeg3demux_read_titles(mpeg3_demuxer_t *demuxer);
55int mpeg3demux_open_title(mpeg3_demuxer_t *demuxer, int title_number);
56
57/* TITLE */
58
59mpeg3_title_t* mpeg3_new_title(mpeg3_t *file, char *path);
60int mpeg3_delete_title(mpeg3_title_t *title);
61int mpeg3_copy_title(mpeg3_title_t *dst, mpeg3_title_t *src);
62
63
64/* ATRACK */
65
66mpeg3_atrack_t* mpeg3_new_atrack(mpeg3_t *file, int stream_id, int is_ac3, mpeg3_demuxer_t *demuxer);
67int mpeg3_delete_atrack(mpeg3_t *file, mpeg3_atrack_t *atrack);
68
69/* VTRACK */
70
71mpeg3_vtrack_t* mpeg3_new_vtrack(mpeg3_t *file, int stream_id, mpeg3_demuxer_t *demuxer);
72int mpeg3_delete_vtrack(mpeg3_t *file, mpeg3_vtrack_t *vtrack);
73
74/* AUDIO */
75mpeg3audio_t* mpeg3audio_new(mpeg3_t *file, mpeg3_atrack_t *track, int is_ac3);
76int mpeg3audio_delete(mpeg3audio_t *audio);
77int mpeg3audio_seek_sample(mpeg3audio_t *audio, long sample);
78int mpeg3audio_seek_percentage(mpeg3audio_t *audio, double percentage);
79int mpeg3audio_decode_audio(mpeg3audio_t *audio,
80 mpeg3_real_t *output_f,
81 short *output_i, int sampleSpacing,
82 int channel,
83 long start_position,
84 long len);
85int mpeg3audio_read_raw(mpeg3audio_t *audio, unsigned char *output, long *size, long max_size);
86int mpeg3audio_read_ac3_header(mpeg3audio_t *audio);
87int mpeg3audio_read_pcm_header(mpeg3audio_t *audio);
88int mpeg3audio_synth_mono(mpeg3audio_t *audio, mpeg3_real_t *bandPtr, mpeg3_real_t *samples, int *pnt);
89int mpeg3audio_synth_stereo(mpeg3audio_t *audio, mpeg3_real_t *bandPtr, int channel, mpeg3_real_t *out, int *pnt);
90int mpeg3audio_replace_buffer(mpeg3audio_t *audio, long new_allocation);
91int mpeg3audio_ac3_exponent_unpack(mpeg3audio_t *audio,
92 mpeg3_ac3bsi_t *bsi,
93 mpeg3_ac3audblk_t *audblk);
94int mpeg3audio_ac3_bit_allocate(mpeg3audio_t *audio,
95 unsigned int fscod,
96 mpeg3_ac3bsi_t *bsi,
97 mpeg3_ac3audblk_t *audblk);
98int mpeg3audio_ac3_coeff_unpack(mpeg3audio_t *audio,
99 mpeg3_ac3bsi_t *bsi,
100 mpeg3_ac3audblk_t *audblk,
101 mpeg3ac3_stream_samples_t samples);
102int mpeg3audio_ac3_imdct(mpeg3audio_t *audio,
103 mpeg3_ac3bsi_t *bsi,
104 mpeg3_ac3audblk_t *audblk,
105 mpeg3ac3_stream_samples_t samples);
106int mpeg3audio_replace_buffer(mpeg3audio_t *audio, long new_allocation);
107int mpeg3audio_dct36(mpeg3_real_t *inbuf, mpeg3_real_t *o1, mpeg3_real_t *o2, mpeg3_real_t *wintab, mpeg3_real_t *tsbuf);
108int mpeg3audio_dct12(mpeg3_real_t *in,mpeg3_real_t *rawout1,mpeg3_real_t *rawout2,register mpeg3_real_t *wi,register mpeg3_real_t *ts);
109int mpeg3audio_read_header(mpeg3audio_t *audio);
110int mpeg3audio_do_ac3(mpeg3audio_t *audio);
111int mpeg3audio_dolayer2(mpeg3audio_t *audio);
112int mpeg3audio_dolayer3(mpeg3audio_t *audio);
113int mpeg3audio_do_pcm(mpeg3audio_t *audio);
114int mpeg3audio_dct64(mpeg3_real_t *a, mpeg3_real_t *b, mpeg3_real_t *c);
115int mpeg3audio_reset_synths(mpeg3audio_t *audio);
116int mpeg3audio_prev_header(mpeg3audio_t *audio);
117int mpeg3audio_read_layer3_frame(mpeg3audio_t *audio);
118int mpeg3audio_new_decode_tables(mpeg3audio_t *audio);
119int mpeg3audio_imdct_init(mpeg3audio_t *audio);
120
121
122/* VIDEO */
123mpeg3video_t* mpeg3video_new(mpeg3_t *file, mpeg3_vtrack_t *track);
124int mpeg3video_delete(mpeg3video_t *video);
125int mpeg3video_read_frame(mpeg3video_t *video,
126 long frame_number,
127 unsigned char **output_rows,
128 int in_x,
129 int in_y,
130 int in_w,
131 int in_h,
132 int out_w,
133 int out_h,
134 int color_model);
135int mpeg3video_set_cpus(mpeg3video_t *video, int cpus);
136int mpeg3video_set_mmx(mpeg3video_t *video, int use_mmx);
137int mpeg3video_seek(mpeg3video_t *video);
138int mpeg3video_seek_frame(mpeg3video_t *video, long frame);
139int mpeg3video_seek_percentage(mpeg3video_t *video, double percentage);
140int mpeg3video_previous_frame(mpeg3video_t *video);
141int mpeg3video_drop_frames(mpeg3video_t *video, long frames);
142int mpeg3video_read_yuvframe(mpeg3video_t *video,
143 long frame_number,
144 char *y_output,
145 char *u_output,
146 char *v_output,
147 int in_x,
148 int in_y,
149 int in_w,
150 int in_h);
151int mpeg3video_read_raw(mpeg3video_t *video, unsigned char *output, long *size, long max_size);
152int mpeg3video_display_second_field(mpeg3video_t *video);
153int mpeg3video_init_output();
154int mpeg3video_get_header(mpeg3video_t *video, int dont_repeat);
155int mpeg3video_getpicture(mpeg3video_t *video, int framenum);
156int mpeg3video_match_refframes(mpeg3video_t *video);
157int mpeg3video_next_code(mpeg3_bits_t* stream, unsigned int code);
158int mpeg3video_prev_code(mpeg3_bits_t* stream, unsigned int code);
159int mpeg3video_getgophdr(mpeg3video_t *video);
160int mpeg3video_present_frame(mpeg3video_t *video);
161int mpeg3video_read_frame_backend(mpeg3video_t *video, int skip_bframes);
162int mpeg3video_getslicehdr(mpeg3_slice_t *slice, mpeg3video_t *video);
163int mpeg3video_get_macroblock_address(mpeg3_slice_t *slice);
164int mpeg3video_macroblock_modes(mpeg3_slice_t *slice,
165 mpeg3video_t *video,
166 int *pmb_type,
167 int *pstwtype,
168 int *pstwclass,
169 int *pmotion_type,
170 int *pmv_count,
171 int *pmv_format,
172 int *pdmv,
173 int *pmvscale,
174 int *pdct_type);
175int mpeg3video_motion_vectors(mpeg3_slice_t *slice,
176 mpeg3video_t *video,
177 int PMV[2][2][2],
178 int dmvector[2],
179 int mv_field_sel[2][2],
180 int s,
181 int mv_count,
182 int mv_format,
183 int h_r_size,
184 int v_r_size,
185 int dmv,
186 int mvscale);
187void mpeg3video_motion_vector(mpeg3_slice_t *slice,
188 mpeg3video_t *video,
189 int *PMV,
190 int *dmvector,
191 int h_r_size,
192 int v_r_size,
193 int dmv,
194 int mvscale,
195 int full_pel_vector);
196int mpeg3video_get_cbp(mpeg3_slice_t *slice);
197int mpeg3video_clearblock(mpeg3_slice_t *slice, int comp, int size);
198int mpeg3video_getmpg2intrablock(mpeg3_slice_t *slice,
199 mpeg3video_t *video,
200 int comp,
201 int dc_dct_pred[]);
202int mpeg3video_getintrablock(mpeg3_slice_t *slice,
203 mpeg3video_t *video,
204 int comp,
205 int dc_dct_pred[]);
206int mpeg3video_getmpg2interblock(mpeg3_slice_t *slice,
207 mpeg3video_t *video,
208 int comp);
209int mpeg3video_getinterblock(mpeg3_slice_t *slice,
210 mpeg3video_t *video,
211 int comp);
212int mpeg3video_reconstruct(mpeg3video_t *video,
213 int bx,
214 int by,
215 int mb_type,
216 int motion_type,
217 int PMV[2][2][2],
218 int mv_field_sel[2][2],
219 int dmvector[2],
220 int stwtype);
221void mpeg3video_calc_dmv(mpeg3video_t *video,
222 int DMV[][2],
223 int *dmvector,
224 int mvx,
225 int mvy);
226
227
228/* FILESYSTEM */
229
230mpeg3_fs_t* mpeg3_new_fs(char *path);
231int mpeg3_delete_fs(mpeg3_fs_t *fs);
232int mpeg3io_open_file(mpeg3_fs_t *fs);
233int mpeg3io_close_file(mpeg3_fs_t *fs);
234int mpeg3io_read_data(unsigned char *buffer, long bytes, mpeg3_fs_t *fs);
235
236/* BITSTREAM */
237mpeg3_bits_t* mpeg3bits_new_stream(mpeg3_t *file, mpeg3_demuxer_t *demuxer);
238unsigned int mpeg3bits_getbits(mpeg3_bits_t* stream, int n);
239int mpeg3bits_read_buffer(mpeg3_bits_t* stream, unsigned char *buffer, int bytes);
240int mpeg3bits_use_ptr(mpeg3_bits_t* stream, unsigned char *buffer);
241int mpeg3bits_use_demuxer(mpeg3_bits_t* stream);
242int mpeg3bits_refill(mpeg3_bits_t* stream);
243int mpeg3bits_getbitoffset(mpeg3_bits_t *stream);
244void mpeg3bits_start_reverse(mpeg3_bits_t* stream);
245void mpeg3bits_start_forward(mpeg3_bits_t* stream);
246int mpeg3bits_delete_stream(mpeg3_bits_t* stream);
247int mpeg3bits_byte_align(mpeg3_bits_t *stream);
248int mpeg3bits_seek_start(mpeg3_bits_t* stream);
249int mpeg3bits_seek_time(mpeg3_bits_t* stream, double time_position);
250int mpeg3bits_seek_byte(mpeg3_bits_t* stream, long position);
251int mpeg3bits_seek_percentage(mpeg3_bits_t* stream, double percentage);
252unsigned int mpeg3bits_next_startcode(mpeg3_bits_t* stream);
253int mpeg3bits_seek_end(mpeg3_bits_t* stream);
254
255/* MISC */
256int mpeg3_read_toc(mpeg3_t *file);
257int mpeg3_generate_toc(FILE *output, char *path, int timecode_search, int print_streams);
258int mpeg3_mmx_test();
259int mpeg3io_seek(mpeg3_fs_t *fs, long byte);
260int mpeg3io_seek_relative(mpeg3_fs_t *fs, long bytes);
261int mpeg3io_device(char *path, char *device);
262int mpeg3_decrypt_packet(mpeg3_css_t *css, unsigned char *sector);
263int mpeg3_delete_css(mpeg3_css_t *css);
264int mpeg3_get_keys(mpeg3_css_t *css, char *path);
265int mpeg3_copy_fs(mpeg3_fs_t *dst, mpeg3_fs_t *src);
266int mpeg3_min(int x, int y);
267int mpeg3_max(int x, int y);
268int mpeg3_new_slice_buffer(mpeg3_slice_buffer_t *slice_buffer);
269int mpeg3_expand_slice_buffer(mpeg3_slice_buffer_t *slice_buffer);
270int mpeg3_delete_slice_decoder(mpeg3_slice_t *slice);
271int mpeg3_new_slice_decoder(mpeg3video_t *video, mpeg3_slice_t *slice);
272int mpeg3_delete_slice_buffer(mpeg3_slice_buffer_t *slice_buffer);
273
274#if defined(__cplusplus)
275}
276#endif
277
278#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3title.c b/core/multimedia/opieplayer/libmpeg3/mpeg3title.c
new file mode 100644
index 0000000..0c93363
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3title.c
@@ -0,0 +1,63 @@
1#include "mpeg3private.h"
2#include "mpeg3protos.h"
3#include "mpeg3title.h"
4
5
6#include <stdlib.h>
7
8
9mpeg3_title_t* mpeg3_new_title(mpeg3_t *file, char *path)
10{
11 mpeg3_title_t *title = (mpeg3_title_t*)calloc(1, sizeof(mpeg3_title_t));
12 title->fs = mpeg3_new_fs(path);
13 title->file = file;
14 return title;
15}
16
17int mpeg3_delete_title(mpeg3_title_t *title)
18{
19 mpeg3_delete_fs(title->fs);
20 if(title->timecode_table_size)
21 {
22 free(title->timecode_table);
23 }
24 free(title);
25 return 0;
26}
27
28
29int mpeg3_copy_title(mpeg3_title_t *dst, mpeg3_title_t *src)
30{
31 int i;
32
33 mpeg3_copy_fs(dst->fs, src->fs);
34 dst->total_bytes = src->total_bytes;
35
36 if(src->timecode_table_size)
37 {
38 dst->timecode_table_allocation = src->timecode_table_allocation;
39 dst->timecode_table_size = src->timecode_table_size;
40 dst->timecode_table = (mpeg3demux_timecode_t*)calloc(1, sizeof(mpeg3demux_timecode_t) * dst->timecode_table_allocation);
41
42 for(i = 0; i < dst->timecode_table_size; i++)
43 {
44 dst->timecode_table[i] = src->timecode_table[i];
45 }
46 }
47}
48
49int mpeg3_dump_title(mpeg3_title_t *title)
50{
51 int i;
52
53 for(i = 0; i < title->timecode_table_size; i++)
54 {
55 printf("%f: %d - %d %f %f %d\n",
56 title->timecode_table[i].absolute_start_time,
57 title->timecode_table[i].start_byte,
58 title->timecode_table[i].end_byte,
59 title->timecode_table[i].start_time,
60 title->timecode_table[i].end_time,
61 title->timecode_table[i].program);
62 }
63}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3title.h b/core/multimedia/opieplayer/libmpeg3/mpeg3title.h
new file mode 100644
index 0000000..a853217
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3title.h
@@ -0,0 +1,47 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3TITLE_H
21#define MPEG3TITLE_H
22
23#include "mpeg3io.h"
24
25typedef struct
26{
27 long start_byte;
28 double start_time;
29 double absolute_start_time;
30 double absolute_end_time;
31 long end_byte;
32 double end_time;
33 int program;
34} mpeg3demux_timecode_t;
35
36typedef struct
37{
38 struct mpeg3_rec *file;
39 mpeg3_fs_t *fs;
40 long total_bytes; /* Total bytes in file. Critical for seeking and length. */
41/* Timecode table */
42 mpeg3demux_timecode_t *timecode_table;
43 long timecode_table_size; /* Number of entries */
44 long timecode_table_allocation; /* Number of available slots */
45} mpeg3_title_t;
46
47#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c b/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c
new file mode 100644
index 0000000..84b31cb
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3toc.c
@@ -0,0 +1,81 @@
1#include "libmpeg3.h"
2#include "mpeg3protos.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <sys/stat.h>
8#include <stdlib.h>
9
10int main(int argc, char *argv[])
11{
12 int i;
13 /*FILE *output; */
14 char new_path[1024], *ext;
15 struct stat st;
16 long size;
17 int timecode_search = 0;
18
19 if(argc < 2)
20 {
21 fprintf(stderr, "Create a table of contents for a DVD.\n"
22 "Usage: mpeg3toc [-t] <filename>...\n"
23 "-t Perform timecode search.\n"
24 "\n"
25 "The filenames should be absolute paths unless you plan\n"
26 "to always run your movie player from the same directory\n"
27 "as the filename. Alternatively you can edit the toc by\n"
28 "hand.\n"
29 "The timecode search allows XMovie to play the Matrix.\n"
30 "Example: mpeg3toc /cd2/video_ts/vts_01_*.vob > titanic.toc\n");
31 exit(1);
32 }
33
34 for(i = 1; i < argc; i++)
35 {
36 if(!strcmp(argv[i], "-t"))
37 {
38 timecode_search = 1;
39 }
40 else
41 {
42/* Get just name */
43 ext = strrchr(argv[i], '/');
44 if(ext)
45 {
46 ext++;
47 strcpy(new_path, ext);
48 }
49 else
50 strcpy(new_path, argv[i]);
51
52
53/* Replace suffix */
54 ext = strrchr(new_path, '.');
55 if(ext)
56 {
57 sprintf(ext, ".toc");
58 }
59 else
60 strcat(new_path, ".toc");
61
62 /* fprintf(stderr, "Creating %s\n", new_path); */
63
64 stat(argv[i], &st);
65 size = (long)st.st_size;
66
67 if(!size)
68 {
69 fprintf(stderr, "%s is 0 length. Skipping\n", new_path);
70 }
71 else
72 {
73/* Just want the first title's streams */
74 if(mpeg3_generate_toc(stdout, argv[i], timecode_search, i == argc - 1))
75 {
76 fprintf(stderr, "Skipping %s\n", argv[i]);
77 }
78 }
79 }
80 }
81}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.c b/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.c
new file mode 100644
index 0000000..dffe9d0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.c
@@ -0,0 +1,33 @@
1#include "libmpeg3.h"
2#include "mpeg3protos.h"
3
4#include <stdlib.h>
5
6mpeg3_vtrack_t* mpeg3_new_vtrack(mpeg3_t *file, int stream_id, mpeg3_demuxer_t *demuxer)
7{
8 int result = 0;
9 mpeg3_vtrack_t *new_vtrack;
10 new_vtrack = (mpeg3_vtrack_t*)calloc(1, sizeof(mpeg3_vtrack_t));
11 new_vtrack->demuxer = mpeg3_new_demuxer(file, 0, 1, stream_id);
12 if(demuxer) mpeg3demux_copy_titles(new_vtrack->demuxer, demuxer);
13 new_vtrack->current_position = 0;
14
15/* Get information about the track here. */
16 new_vtrack->video = mpeg3video_new(file, new_vtrack);
17 if(!new_vtrack->video)
18 {
19/* Failed */
20 mpeg3_delete_vtrack(file, new_vtrack);
21 new_vtrack = 0;
22 }
23 return new_vtrack;
24}
25
26int mpeg3_delete_vtrack(mpeg3_t *file, mpeg3_vtrack_t *vtrack)
27{
28 if(vtrack->video)
29 mpeg3video_delete(vtrack->video);
30 if(vtrack->demuxer)
31 mpeg3_delete_demuxer(vtrack->demuxer);
32 free(vtrack);
33}
diff --git a/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.h b/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.h
new file mode 100644
index 0000000..9a3c13d
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/mpeg3vtrack.h
@@ -0,0 +1,39 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3_VTRACK_H
21#define MPEG3_VTRACK_H
22
23#include "mpeg3demux.h"
24#include "video/mpeg3video.h"
25
26struct mpeg3_vtrack_rec
27{
28 int width;
29 int height;
30 float frame_rate;
31 mpeg3_demuxer_t *demuxer;
32 mpeg3video_t *video;
33 long current_position; /* Number of next frame to be played */
34 long total_frames; /* Total frames in the file */
35};
36
37typedef struct mpeg3_vtrack_rec mpeg3_vtrack_t;
38
39#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/ronin_narrow.toc b/core/multimedia/opieplayer/libmpeg3/ronin_narrow.toc
new file mode 100644
index 0000000..07cbbf8
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/ronin_narrow.toc
@@ -0,0 +1,26 @@
1TOCVERSION 2
2PATH: /cdrom/video_ts/vts_01_1.vob
3ASTREAM: 0 2
4VSTREAM: 0 1
5ASTREAM: 1 2
6ASTREAM: 2 2
7SIZE: 1073709056
8PACKETSIZE: 2048
9REGION: 0 35557376 0.000000 51.643256
10REGION: 35559424 307005440 0.000000 440.561122
11REGION: 307007488 556705792 0.000000 423.698289
12REGION: 556707840 792827904 0.000000 423.877622
13REGION: 792829952 967956480 0.000000 292.754122
14REGION: 967958528 1073709056 0.000000 191.720711
15TOCVERSION 2
16PATH: /cdrom/video_ts/vts_01_2.vob
17ASTREAM: 0 2
18VSTREAM: 0 1
19ASTREAM: 1 2
20ASTREAM: 2 2
21SIZE: 1073709056
22PACKETSIZE: 2048
23REGION: 0 268423168 191.722344 632.760000
24REGION: 268425216 539189248 0.000000 448.729167
25REGION: 539191296 823230464 0.000000 374.061122
26REGION: 823232512 1073709056 0.000000 421.215667
diff --git a/core/multimedia/opieplayer/libmpeg3/ronin_wide.toc b/core/multimedia/opieplayer/libmpeg3/ronin_wide.toc
new file mode 100644
index 0000000..a638304
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/ronin_wide.toc
@@ -0,0 +1,47 @@
1TOCVERSION 2
2PATH: /cdrom/video_ts/vts_01_1.vob
3SIZE: 1073709056
4PACKETSIZE: 2048
5REGION: 0 33830912 0.000000 51.643256
6REGION: 33832960 321945600 0.000000 440.561122
7REGION: 321947648 566126592 0.000000 423.698289
8REGION: 566128640 804149248 0.000000 423.877622
9REGION: 804151296 979050496 0.000000 292.754122
10REGION: 979052544 1073709056 0.000000 170.331700
11TOCVERSION 2
12PATH: /cdrom/video_ts/vts_01_2.vob
13SIZE: 1073709056
14PACKETSIZE: 2048
15REGION: 0 274845696 170.333322 632.760000
16REGION: 274847744 539138048 0.000000 448.729167
17REGION: 539140096 818880512 0.000000 374.061122
18REGION: 818882560 1073709056 0.000000 431.104722
19TOCVERSION 2
20PATH: /cdrom/video_ts/vts_01_3.vob
21SIZE: 1073709056
22PACKETSIZE: 2048
23REGION: 0 3602432 431.122100 437.362056
24REGION: 3604480 316528640 0.000000 508.150422
25REGION: 316530688 562409472 0.000000 446.758722
26REGION: 562411520 728014848 0.000000 317.737689
27REGION: 728016896 943480832 0.000000 401.809556
28REGION: 943482880 1073709056 0.000000 177.871922
29TOCVERSION 2
30PATH: /cdrom/video_ts/vts_01_4.vob
31SIZE: 1073709056
32PACKETSIZE: 2048
33REGION: 0 224798720 177.873544 496.357422
34REGION: 224800768 469219328 0.000000 431.833522
35REGION: 469221376 718004224 0.000000 426.048756
36REGION: 718006272 978356224 0.000000 411.668422
37REGION: 978358272 1073709056 0.000000 154.534211
38TOCVERSION 2
39PATH: /cdrom/video_ts/vts_01_5.vob
40ASTREAM: 0 2
41VSTREAM: 0 1
42ASTREAM: 1 2
43ASTREAM: 2 2
44SIZE: 78041088
45PACKETSIZE: 2048
46REGION: 0 78028800 154.545878 312.853122
47REGION: 78030848 78041088 0.000000 0.006500
diff --git a/core/multimedia/opieplayer/libmpeg3/timecode.h b/core/multimedia/opieplayer/libmpeg3/timecode.h
new file mode 100644
index 0000000..21e51e5
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/timecode.h
@@ -0,0 +1,31 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef TIMECODE_H
21#define TIMECODE_H
22
23typedef struct
24{
25 long hour;
26 long minute;
27 long second;
28 long frame;
29} mpeg3_timecode_t;
30
31#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/Makefile b/core/multimedia/opieplayer/libmpeg3/video/Makefile
new file mode 100644
index 0000000..46d8407
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/Makefile
@@ -0,0 +1,32 @@
1include ../global_config
2export CFLAGS
3export CFLAGS_lessopt
4
5OBJS = \
6 getpicture.o \
7 headers.o \
8 idct.o \
9 macroblocks.o \
10 mmxtest.o \
11 motion.o \
12 mpeg3video.o \
13 output.o \
14 reconstruct.o \
15 seek.o \
16 slice.o \
17 vlc.o
18
19
20all: $(OBJS) $(MMXOBJS2)
21
22.c.o:
23 $(CC) -c `./c_flags` -o $@ $<
24
25.s.o:
26 $(NASM) -f elf $*.s
27
28.S.o:
29 $(CC) -S `./c_flags` $*.S
30
31clean:
32 rm -f *.o
diff --git a/core/multimedia/opieplayer/libmpeg3/video/c_flags b/core/multimedia/opieplayer/libmpeg3/video/c_flags
new file mode 100755
index 0000000..d7943d0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/c_flags
@@ -0,0 +1 @@
echo $CFLAGS
diff --git a/core/multimedia/opieplayer/libmpeg3/video/getpicture.c b/core/multimedia/opieplayer/libmpeg3/video/getpicture.c
new file mode 100644
index 0000000..4f67484
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/getpicture.c
@@ -0,0 +1,767 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include "vlc.h"
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <string.h>
9
10int mpeg3video_get_cbp(mpeg3_slice_t *slice)
11{
12 int code;
13 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
14
15 if((code = mpeg3slice_showbits9(slice_buffer)) >= 128)
16 {
17 code >>= 4;
18 mpeg3slice_flushbits(slice_buffer, mpeg3_CBPtab0[code].len);
19 return mpeg3_CBPtab0[code].val;
20 }
21
22 if(code >= 8)
23 {
24 code >>= 1;
25 mpeg3slice_flushbits(slice_buffer, mpeg3_CBPtab1[code].len);
26 return mpeg3_CBPtab1[code].val;
27 }
28
29 if(code < 1)
30 {
31 /* fprintf(stderr,"mpeg3video_get_cbp: invalid coded_block_pattern code\n"); */
32 slice->fault = 1;
33 return 0;
34 }
35
36 mpeg3slice_flushbits(slice_buffer, mpeg3_CBPtab2[code].len);
37 return mpeg3_CBPtab2[code].val;
38}
39
40
41/* set block to zero */
42int mpeg3video_clearblock(mpeg3_slice_t *slice, int comp, int size)
43{
44 slice->sparse[comp] = 1;
45
46/* Compiler error */
47/*
48 * for(i = 0; i < size; i++)
49 * {
50 * bzero(slice->block[comp] + sizeof(short) * 64 * i, sizeof(short) * 64);
51 * }
52 */
53
54 if(size == 6)
55 {
56 bzero(slice->block[comp], sizeof(short) * 64 * 6);
57 }
58 else
59 {
60printf("mpeg3video_clearblock size = %d\n", size);
61 memset(slice->block[comp], 0, sizeof(short) * 64 * size);
62 }
63 return 0;
64}
65
66static inline int mpeg3video_getdclum(mpeg3_slice_buffer_t *slice_buffer)
67{
68 int code, size, val;
69/* decode length */
70 code = mpeg3slice_showbits5(slice_buffer);
71
72 if(code < 31)
73 {
74 size = mpeg3_DClumtab0[code].val;
75 mpeg3slice_flushbits(slice_buffer, mpeg3_DClumtab0[code].len);
76 }
77 else
78 {
79 code = mpeg3slice_showbits9(slice_buffer) - 0x1f0;
80 size = mpeg3_DClumtab1[code].val;
81 mpeg3slice_flushbits(slice_buffer, mpeg3_DClumtab1[code].len);
82 }
83
84 if(size == 0) val = 0;
85 else
86 {
87 val = mpeg3slice_getbits(slice_buffer, size);
88 if((val & (1 << (size - 1))) == 0) val -= (1 << size) - 1;
89 }
90
91 return val;
92}
93
94
95int mpeg3video_getdcchrom(mpeg3_slice_buffer_t *slice_buffer)
96{
97 int code, size, val;
98
99/* decode length */
100 code = mpeg3slice_showbits5(slice_buffer);
101
102 if(code < 31)
103 {
104 size = mpeg3_DCchromtab0[code].val;
105 mpeg3slice_flushbits(slice_buffer, mpeg3_DCchromtab0[code].len);
106 }
107 else
108 {
109 code = mpeg3slice_showbits(slice_buffer, 10) - 0x3e0;
110 size = mpeg3_DCchromtab1[code].val;
111 mpeg3slice_flushbits(slice_buffer, mpeg3_DCchromtab1[code].len);
112 }
113
114 if(size == 0) val = 0;
115 else
116 {
117 val = mpeg3slice_getbits(slice_buffer, size);
118 if((val & (1 << (size - 1))) == 0) val -= (1 << size) - 1;
119 }
120
121 return val;
122}
123
124
125/* decode one intra coded MPEG-1 block */
126
127int mpeg3video_getintrablock(mpeg3_slice_t *slice,
128 mpeg3video_t *video,
129 int comp,
130 int dc_dct_pred[])
131{
132 int val, i, j, sign;
133 unsigned int code;
134 mpeg3_DCTtab_t *tab = 0;
135 short *bp = slice->block[comp];
136 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
137
138/* decode DC coefficients */
139 if(comp < 4)
140 bp[0] = (dc_dct_pred[0] += mpeg3video_getdclum(slice_buffer)) << 3;
141 else
142 if(comp == 4)
143 bp[0] = (dc_dct_pred[1] += mpeg3video_getdcchrom(slice_buffer)) << 3;
144 else
145 bp[0] = (dc_dct_pred[2] += mpeg3video_getdcchrom(slice_buffer)) << 3;
146
147#ifdef HAVE_MMX
148 if(video->have_mmx)
149 bp[0] <<= 4;
150#endif
151
152 if(slice->fault) return 1;
153
154/* decode AC coefficients */
155 for(i = 1; ; i++)
156 {
157 code = mpeg3slice_showbits16(slice_buffer);
158 if(code >= 16384)
159 tab = &mpeg3_DCTtabnext[(code >> 12) - 4];
160 else
161 if(code >= 1024) tab = &mpeg3_DCTtab0[(code >> 8) - 4];
162 else
163 if(code >= 512) tab = &mpeg3_DCTtab1[(code >> 6) - 8];
164 else
165 if(code >= 256) tab = &mpeg3_DCTtab2[(code >> 4) - 16];
166 else
167 if(code >= 128) tab = &mpeg3_DCTtab3[(code >> 3) - 16];
168 else
169 if(code >= 64) tab = &mpeg3_DCTtab4[(code >> 2) - 16];
170 else
171 if(code >= 32) tab = &mpeg3_DCTtab5[(code >> 1) - 16];
172 else
173 if(code >= 16) tab = &mpeg3_DCTtab6[code - 16];
174 else
175 {
176 /* fprintf(stderr, "mpeg3video_getintrablock: invalid Huffman code\n"); */
177 slice->fault = 1;
178 return 1;
179 }
180
181 mpeg3slice_flushbits(slice_buffer, tab->len);
182
183 if(tab->run == 64) break; /* end_of_block */
184
185 if(tab->run == 65)
186 {
187/* escape */
188 i += mpeg3slice_getbits(slice_buffer, 6);
189
190 if((val = mpeg3slice_getbits(slice_buffer, 8)) == 0)
191 val = mpeg3slice_getbits(slice_buffer, 8);
192 else
193 if(val == 128)
194 val = mpeg3slice_getbits(slice_buffer, 8) - 256;
195 else
196 if(val > 128)
197 val -= 256;
198
199 if((sign = (val < 0)) != 0) val= -val;
200 }
201 else
202 {
203 i += tab->run;
204 val = tab->level;
205 sign = mpeg3slice_getbit(slice_buffer);
206 }
207
208 if(i < 64)
209 j = video->mpeg3_zigzag_scan_table[i];
210 else
211 {
212 slice->fault = 1;
213 return 1;
214 }
215
216
217#ifdef HAVE_MMX
218 if(video->have_mmx)
219 {
220 val = (val * slice->quant_scale * video->intra_quantizer_matrix[j]) << 1;
221 val = (val - 16) | 16;
222 }
223 else
224#endif
225 {
226 val = (val * slice->quant_scale * video->intra_quantizer_matrix[j]) >> 3;
227 val = (val - 1) | 1;
228 }
229
230 bp[j] = sign ? -val : val;
231 }
232
233 if(j != 0)
234 {
235/* not a sparse matrix ! */
236 slice->sparse[comp] = 0;
237 }
238 return 0;
239}
240
241
242/* decode one non-intra coded MPEG-1 block */
243
244int mpeg3video_getinterblock(mpeg3_slice_t *slice,
245 mpeg3video_t *video,
246 int comp)
247{
248 int val, i, j, sign;
249 unsigned int code;
250 mpeg3_DCTtab_t *tab;
251 short *bp = slice->block[comp];
252 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
253
254/* decode AC coefficients */
255 for(i = 0; ; i++)
256 {
257 code = mpeg3slice_showbits16(slice_buffer);
258 if(code >= 16384)
259 {
260 if(i == 0)
261 tab = &mpeg3_DCTtabfirst[(code >> 12) - 4];
262 else
263 tab = &mpeg3_DCTtabnext[(code >> 12) - 4];
264 }
265 else
266 if(code >= 1024) tab = &mpeg3_DCTtab0[(code >> 8) - 4];
267 else
268 if(code >= 512) tab = &mpeg3_DCTtab1[(code >> 6) - 8];
269 else
270 if(code >= 256) tab = &mpeg3_DCTtab2[(code >> 4) - 16];
271 else
272 if(code >= 128) tab = &mpeg3_DCTtab3[(code >> 3) - 16];
273 else
274 if(code >= 64) tab = &mpeg3_DCTtab4[(code >> 2) - 16];
275 else
276 if(code >= 32) tab = &mpeg3_DCTtab5[(code >> 1) - 16];
277 else
278 if(code >= 16) tab = &mpeg3_DCTtab6[code - 16];
279 else
280 {
281// invalid Huffman code
282 slice->fault = 1;
283 return 1;
284 }
285
286 mpeg3slice_flushbits(slice_buffer, tab->len);
287
288/* end of block */
289 if(tab->run == 64)
290 break;
291
292 if(tab->run == 65)
293 {
294/* escape */
295 i += mpeg3slice_getbits(slice_buffer, 6);
296 if((val = mpeg3slice_getbits(slice_buffer, 8)) == 0)
297 val = mpeg3slice_getbits(slice_buffer, 8);
298 else
299 if(val == 128)
300 val = mpeg3slice_getbits(slice_buffer, 8) - 256;
301 else
302 if(val > 128)
303 val -= 256;
304
305 if((sign = (val < 0)) != 0) val = -val;
306 }
307 else
308 {
309 i += tab->run;
310 val = tab->level;
311 sign = mpeg3slice_getbit(slice_buffer);
312 }
313
314 j = video->mpeg3_zigzag_scan_table[i];
315
316#ifdef HAVE_MMX
317 if(video->have_mmx)
318 {
319 val = (((val << 1)+1) * slice->quant_scale * video->non_intra_quantizer_matrix[j]);
320 val = (val - 16) | 16;
321 }
322 else
323#endif
324 {
325 val = (((val << 1)+1) * slice->quant_scale * video->non_intra_quantizer_matrix[j]) >> 4;
326 val = (val - 1) | 1;
327 }
328
329 bp[j] = sign ? -val : val;
330 }
331
332 if(j != 0)
333 {
334/* not a sparse matrix ! */
335 slice->sparse[comp] = 0;
336 }
337 return 0;
338}
339
340
341/* decode one intra coded MPEG-2 block */
342int mpeg3video_getmpg2intrablock(mpeg3_slice_t *slice,
343 mpeg3video_t *video,
344 int comp,
345 int dc_dct_pred[])
346{
347 int val, i, j, sign, nc;
348 unsigned int code;
349 mpeg3_DCTtab_t *tab;
350 short *bp;
351 int *qmat;
352 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
353
354/* with data partitioning, data always goes to base layer */
355 bp = slice->block[comp];
356
357 qmat = (comp < 4 || video->chroma_format == CHROMA420)
358 ? video->intra_quantizer_matrix
359 : video->chroma_intra_quantizer_matrix;
360
361/* decode DC coefficients */
362 if(comp < 4)
363 val = (dc_dct_pred[0] += mpeg3video_getdclum(slice_buffer));
364 else
365 if((comp & 1) == 0)
366 val = (dc_dct_pred[1] += mpeg3video_getdcchrom(slice_buffer));
367 else
368 val = (dc_dct_pred[2] += mpeg3video_getdcchrom(slice_buffer));
369
370 if(slice->fault) return 1;
371#ifdef HAVE_MMX
372 if(video->have_mmx)
373 bp[0] = val << (7 - video->dc_prec);
374 else
375#endif
376 bp[0] = val << (3 - video->dc_prec);
377
378 nc = 0;
379
380/* decode AC coefficients */
381 for(i = 1; ; i++)
382 {
383 code = mpeg3slice_showbits16(slice_buffer);
384
385 if(code >= 16384 && !video->intravlc)
386 tab = &mpeg3_DCTtabnext[(code >> 12) - 4];
387 else
388 if(code >= 1024)
389 {
390 if(video->intravlc)
391 tab = &mpeg3_DCTtab0a[(code >> 8) - 4];
392 else
393 tab = &mpeg3_DCTtab0[(code >> 8) - 4];
394 }
395 else
396 if(code >= 512)
397 {
398 if(video->intravlc)
399 tab = &mpeg3_DCTtab1a[(code >> 6) - 8];
400 else
401 tab = &mpeg3_DCTtab1[(code >> 6) - 8];
402 }
403 else
404 if(code >= 256) tab = &mpeg3_DCTtab2[(code >> 4) - 16];
405 else
406 if(code >= 128) tab = &mpeg3_DCTtab3[(code >> 3) - 16];
407 else
408 if(code >= 64) tab = &mpeg3_DCTtab4[(code >> 2) - 16];
409 else
410 if(code >= 32) tab = &mpeg3_DCTtab5[(code >> 1) - 16];
411 else
412 if(code >= 16) tab = &mpeg3_DCTtab6[code - 16];
413 else
414 {
415 /* fprintf(stderr,"mpeg3video_getmpg2intrablock: invalid Huffman code\n"); */
416 slice->fault = 1;
417 return 1;
418 }
419
420 mpeg3slice_flushbits(slice_buffer, tab->len);
421
422/* end_of_block */
423 if(tab->run == 64)
424 break;
425
426 if(tab->run == 65)
427 {
428/* escape */
429 i += mpeg3slice_getbits(slice_buffer, 6);
430
431 val = mpeg3slice_getbits(slice_buffer, 12);
432 if((val & 2047) == 0)
433 {
434// invalid signed_level (escape)
435 slice->fault = 1;
436 return 1;
437 }
438 if((sign = (val >= 2048)) != 0) val = 4096 - val;
439 }
440 else
441 {
442 i += tab->run;
443 val = tab->level;
444 sign = mpeg3slice_getbit(slice_buffer);
445 }
446
447 j = (video->altscan ? video->mpeg3_alternate_scan_table : video->mpeg3_zigzag_scan_table)[i];
448
449#ifdef HAVE_MMX
450 if(video->have_mmx)
451 val = (val * slice->quant_scale * qmat[j]);
452 else
453#endif
454 val = (val * slice->quant_scale * qmat[j]) >> 4;
455
456 bp[j] = sign ? -val : val;
457 nc++;
458 }
459
460 if(j != 0)
461 {
462/* not a sparse matrix ! */
463 slice->sparse[comp] = 0;
464 }
465 return 1;
466}
467
468
469/* decode one non-intra coded MPEG-2 block */
470
471int mpeg3video_getmpg2interblock(mpeg3_slice_t *slice,
472 mpeg3video_t *video,
473 int comp)
474{
475 int val, i, j, sign, nc;
476 unsigned int code;
477 mpeg3_DCTtab_t *tab;
478 short *bp;
479 int *qmat;
480 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
481
482/* with data partitioning, data always goes to base layer */
483 bp = slice->block[comp];
484
485 qmat = (comp < 4 || video->chroma_format == CHROMA420)
486 ? video->non_intra_quantizer_matrix
487 : video->chroma_non_intra_quantizer_matrix;
488
489 nc = 0;
490
491/* decode AC coefficients */
492 for(i = 0; ; i++)
493 {
494 code = mpeg3slice_showbits16(slice_buffer);
495 if(code >= 16384)
496 {
497 if(i == 0) tab = &mpeg3_DCTtabfirst[(code >> 12) - 4];
498 else tab = &mpeg3_DCTtabnext[(code >> 12) - 4];
499 }
500 else
501 if(code >= 1024) tab = &mpeg3_DCTtab0[(code >> 8) - 4];
502 else
503 if(code >= 512) tab = &mpeg3_DCTtab1[(code >> 6) - 8];
504 else
505 if(code >= 256) tab = &mpeg3_DCTtab2[(code >> 4) - 16];
506 else
507 if(code >= 128) tab = &mpeg3_DCTtab3[(code >> 3) - 16];
508 else
509 if(code >= 64) tab = &mpeg3_DCTtab4[(code >> 2) - 16];
510 else
511 if(code >= 32) tab = &mpeg3_DCTtab5[(code >> 1) - 16];
512 else
513 if(code >= 16) tab = &mpeg3_DCTtab6[code - 16];
514 else
515 {
516// invalid Huffman code
517 slice->fault = 1;
518 return 1;
519 }
520
521 mpeg3slice_flushbits(slice_buffer, tab->len);
522
523/* end_of_block */
524 if(tab->run == 64)
525 break;
526
527 if(tab->run == 65)
528 {
529/* escape */
530 i += mpeg3slice_getbits(slice_buffer, 6);
531 val = mpeg3slice_getbits(slice_buffer, 12);
532 if((val & 2047) == 0)
533 {
534 /* fprintf(stderr, "mpeg3video_getmpg2interblock: invalid signed_level (escape)\n"); */
535 slice->fault = 1;
536 return 1;
537 }
538 if((sign = (val >= 2048)) != 0) val = 4096 - val;
539 }
540 else
541 {
542 i += tab->run;
543 val = tab->level;
544 sign = mpeg3slice_getbit(slice_buffer);
545 }
546
547 j = (video->altscan ? video->mpeg3_alternate_scan_table : video->mpeg3_zigzag_scan_table)[i];
548
549#ifdef HAVE_MMX
550 if(video->have_mmx)
551 val = (((val << 1)+1) * slice->quant_scale * qmat[j]) >> 1;
552 else
553#endif
554 val = (((val << 1)+1) * slice->quant_scale * qmat[j]) >> 5;
555
556 bp[j] = sign ? (-val) : val ;
557 nc++;
558 }
559
560 if(j != 0)
561 {
562 slice->sparse[comp] = 0;
563 }
564 return 0;
565}
566
567
568/* decode all macroblocks of the current picture */
569int mpeg3video_get_macroblocks(mpeg3video_t *video, int framenum)
570{
571 unsigned int code;
572 mpeg3_slice_buffer_t *slice_buffer; /* Buffer being loaded */
573 int i;
574 int current_buffer;
575 mpeg3_bits_t *vstream = video->vstream;
576
577/* Load every slice into a buffer array */
578 video->total_slice_buffers = 0;
579 current_buffer = 0;
580 while(!mpeg3bits_eof(vstream) &&
581 mpeg3bits_showbits32_noptr(vstream) >= MPEG3_SLICE_MIN_START &&
582 mpeg3bits_showbits32_noptr(vstream) <= MPEG3_SLICE_MAX_START)
583 {
584/* Initialize the buffer */
585 if(current_buffer >= video->slice_buffers_initialized)
586 mpeg3_new_slice_buffer(&(video->slice_buffers[video->slice_buffers_initialized++]));
587 slice_buffer = &(video->slice_buffers[current_buffer]);
588 slice_buffer->buffer_size = 0;
589 slice_buffer->current_position = 0;
590 slice_buffer->bits_size = 0;
591 slice_buffer->done = 0;
592
593/* Read the slice into the buffer including the slice start code */
594 do
595 {
596/* Expand buffer */
597 if(slice_buffer->buffer_allocation <= slice_buffer->buffer_size)
598 mpeg3_expand_slice_buffer(slice_buffer);
599
600/* Load 1 char into buffer */
601 slice_buffer->data[slice_buffer->buffer_size++] = mpeg3bits_getbyte_noptr(vstream);
602 }while(!mpeg3bits_eof(vstream) &&
603 mpeg3bits_showbits24_noptr(vstream) != MPEG3_PACKET_START_CODE_PREFIX);
604
605/* Pad the buffer to get the last macroblock */
606 if(slice_buffer->buffer_allocation <= slice_buffer->buffer_size + 4)
607 mpeg3_expand_slice_buffer(slice_buffer);
608
609 slice_buffer->data[slice_buffer->buffer_size++] = 0;
610 slice_buffer->data[slice_buffer->buffer_size++] = 0;
611 slice_buffer->data[slice_buffer->buffer_size++] = 1;
612 slice_buffer->data[slice_buffer->buffer_size++] = 0;
613 slice_buffer->bits_size = 0;
614
615 pthread_mutex_lock(&(slice_buffer->completion_lock)); fflush(stdout);
616 current_buffer++;
617 video->total_slice_buffers++;
618 }
619
620/* Run the slice decoders */
621 if(video->total_slice_buffers > 0)
622 {
623 for(i = 0; i < video->total_slice_decoders; i++)
624 {
625 if(i == 0 && video->total_slice_decoders > 1)
626 {
627 video->slice_decoders[i].current_buffer = 0;
628 video->slice_decoders[i].buffer_step = 1;
629 video->slice_decoders[i].last_buffer = (video->total_slice_buffers - 1);
630 }
631 else
632 if(i == 1)
633 {
634 video->slice_decoders[i].current_buffer = video->total_slice_buffers - 1;
635 video->slice_decoders[i].buffer_step = -1;
636 video->slice_decoders[i].last_buffer = 0;
637 }
638 else
639 {
640 video->slice_decoders[i].current_buffer = i;
641 video->slice_decoders[i].buffer_step = 1;
642 video->slice_decoders[i].last_buffer = video->total_slice_buffers - 1;
643 }
644 pthread_mutex_unlock(&(video->slice_decoders[i].input_lock));
645 }
646 }
647
648/* Wait for the slice decoders to finish */
649 if(video->total_slice_buffers > 0)
650 {
651 for(i = 0; i < video->total_slice_buffers; i++)
652 {
653 pthread_mutex_lock(&(video->slice_buffers[i].completion_lock));
654 pthread_mutex_unlock(&(video->slice_buffers[i].completion_lock));
655 }
656 }
657 return 0;
658}
659
660int mpeg3video_allocate_decoders(mpeg3video_t *video, int decoder_count)
661{
662 int i;
663 mpeg3_t *file = video->file;
664/* Get the slice decoders */
665 if(video->total_slice_decoders != file->cpus)
666 {
667 for(i = 0; i < video->total_slice_decoders; i++)
668 {
669 mpeg3_delete_slice_decoder(&video->slice_decoders[i]);
670 }
671
672 for(i = 0; i < file->cpus && i < MPEG3_MAX_CPUS; i++)
673 {
674 mpeg3_new_slice_decoder(video, &(video->slice_decoders[i]));
675 video->slice_decoders[i].thread_number = i;
676 }
677
678 video->total_slice_decoders = file->cpus;
679 }
680 return 0;
681}
682
683/* decode one frame or field picture */
684
685int mpeg3video_getpicture(mpeg3video_t *video, int framenum)
686{
687 int i, result = 0;
688 mpeg3_t *file = video->file;
689
690 if(video->pict_struct == FRAME_PICTURE && video->secondfield)
691 {
692/* recover from illegal number of field pictures */
693 video->secondfield = 0;
694 }
695
696 if(!video->mpeg2)
697 {
698 video->current_repeat = video->repeat_count = 0;
699 }
700
701 mpeg3video_allocate_decoders(video, file->cpus);
702
703 for(i = 0; i < 3; i++)
704 {
705 if(video->pict_type == B_TYPE)
706 {
707 video->newframe[i] = video->auxframe[i];
708 }
709 else
710 {
711 if(!video->secondfield && !video->current_repeat)
712 {
713/* Swap refframes for I frames */
714 unsigned char* tmp = video->oldrefframe[i];
715 video->oldrefframe[i] = video->refframe[i];
716 video->refframe[i] = tmp;
717 }
718
719 video->newframe[i] = video->refframe[i];
720 }
721
722 if(video->pict_struct == BOTTOM_FIELD)
723 {
724/* Only used if fields are in different pictures */
725 video->newframe[i] += (i == 0) ? video->coded_picture_width : video->chrom_width;
726 }
727 }
728
729/* The problem is when a B frame lands on the first repeat and is skipped, */
730/* the second repeat goes for the same bitmap as the skipped repeat, */
731/* so it picks up a frame from 3 frames back. */
732/* The first repeat must consititutively read a B frame if its B frame is going to be */
733/* used in a later repeat. */
734 if(!video->current_repeat)
735 if(!(video->skip_bframes && video->pict_type == B_TYPE) ||
736 (video->repeat_count >= 100 + 100 * video->skip_bframes))
737 result = mpeg3video_get_macroblocks(video, framenum);
738
739/* Set the frame to display */
740 video->output_src = 0;
741 if(framenum > -1 && !result)
742 {
743 if(video->pict_struct == FRAME_PICTURE || video->secondfield)
744 {
745 if(video->pict_type == B_TYPE)
746 {
747 video->output_src = video->auxframe;
748 }
749 else
750 {
751 video->output_src = video->oldrefframe;
752 }
753 }
754 else
755 {
756 mpeg3video_display_second_field(video);
757 }
758 }
759
760 if(video->mpeg2)
761 {
762 video->current_repeat += 100;
763 }
764
765 if(video->pict_struct != FRAME_PICTURE) video->secondfield = !video->secondfield;
766 return result;
767}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/headers.c b/core/multimedia/opieplayer/libmpeg3/video/headers.c
new file mode 100644
index 0000000..5274530
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/headers.c
@@ -0,0 +1,492 @@
1#include "../mpeg3demux.h"
2#include "../libmpeg3.h"
3#include "../mpeg3protos.h"
4#include "mpeg3video.h"
5
6#include <stdio.h>
7#include <stdlib.h>
8
9int mpeg3video_getseqhdr(mpeg3video_t *video)
10{
11 int i;
12 mpeg3_t *file = video->file;
13
14 int aspect_ratio, picture_rate, vbv_buffer_size;
15 int constrained_parameters_flag;
16 int load_intra_quantizer_matrix, load_non_intra_quantizer_matrix;
17
18 video->horizontal_size = mpeg3bits_getbits(video->vstream, 12);
19 video->vertical_size = mpeg3bits_getbits(video->vstream, 12);
20 aspect_ratio = mpeg3bits_getbits(video->vstream, 4);
21 video->framerate_code = mpeg3bits_getbits(video->vstream, 4);
22 video->bitrate = mpeg3bits_getbits(video->vstream, 18);
23 mpeg3bits_getbit_noptr(video->vstream); /* marker bit (=1) */
24 vbv_buffer_size = mpeg3bits_getbits(video->vstream, 10);
25 constrained_parameters_flag = mpeg3bits_getbit_noptr(video->vstream);
26 video->frame_rate = mpeg3_frame_rate_table[video->framerate_code];
27
28 load_intra_quantizer_matrix = mpeg3bits_getbit_noptr(video->vstream);
29 if(load_intra_quantizer_matrix)
30 {
31 for(i = 0; i < 64; i++)
32 video->intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]] = mpeg3bits_getbyte_noptr(video->vstream);
33 }
34 else
35 {
36 for(i = 0; i < 64; i++)
37 video->intra_quantizer_matrix[i] = mpeg3_default_intra_quantizer_matrix[i];
38 }
39
40 load_non_intra_quantizer_matrix = mpeg3bits_getbit_noptr(video->vstream);
41 if(load_non_intra_quantizer_matrix)
42 {
43 for(i = 0; i < 64; i++)
44 video->non_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]] = mpeg3bits_getbyte_noptr(video->vstream);
45 }
46 else
47 {
48 for(i = 0; i < 64; i++)
49 video->non_intra_quantizer_matrix[i] = 16;
50 }
51
52/* copy luminance to chrominance matrices */
53 for(i = 0; i < 64; i++)
54 {
55 video->chroma_intra_quantizer_matrix[i] = video->intra_quantizer_matrix[i];
56 video->chroma_non_intra_quantizer_matrix[i] = video->non_intra_quantizer_matrix[i];
57 }
58
59 return 0;
60}
61
62
63/* decode sequence extension */
64
65int mpeg3video_sequence_extension(mpeg3video_t *video)
66{
67 int prof_lev;
68 int horizontal_size_extension, vertical_size_extension;
69 int bit_rate_extension, vbv_buffer_size_extension, low_delay;
70 int frame_rate_extension_n, frame_rate_extension_d;
71 int pos = 0;
72
73 video->mpeg2 = 1;
74 video->scalable_mode = SC_NONE; /* unless overwritten by seq. scal. ext. */
75 prof_lev = mpeg3bits_getbyte_noptr(video->vstream);
76 video->prog_seq = mpeg3bits_getbit_noptr(video->vstream);
77 video->chroma_format = mpeg3bits_getbits(video->vstream, 2);
78 horizontal_size_extension = mpeg3bits_getbits(video->vstream, 2);
79 vertical_size_extension = mpeg3bits_getbits(video->vstream, 2);
80 bit_rate_extension = mpeg3bits_getbits(video->vstream, 12);
81 mpeg3bits_getbit_noptr(video->vstream);
82 vbv_buffer_size_extension = mpeg3bits_getbyte_noptr(video->vstream);
83 low_delay = mpeg3bits_getbit_noptr(video->vstream);
84 frame_rate_extension_n = mpeg3bits_getbits(video->vstream, 2);
85 frame_rate_extension_d = mpeg3bits_getbits(video->vstream, 5);
86 video->horizontal_size = (horizontal_size_extension << 12) | (video->horizontal_size & 0x0fff);
87 video->vertical_size = (vertical_size_extension << 12) | (video->vertical_size & 0x0fff);
88}
89
90
91/* decode sequence display extension */
92
93int mpeg3video_sequence_display_extension(mpeg3video_t *video)
94{
95 int colour_primaries = 0, transfer_characteristics = 0;
96 int display_horizontal_size, display_vertical_size;
97 int pos = 0;
98 int video_format = mpeg3bits_getbits(video->vstream, 3);
99 int colour_description = mpeg3bits_getbit_noptr(video->vstream);
100
101 if(colour_description)
102 {
103 colour_primaries = mpeg3bits_getbyte_noptr(video->vstream);
104 transfer_characteristics = mpeg3bits_getbyte_noptr(video->vstream);
105 video->matrix_coefficients = mpeg3bits_getbyte_noptr(video->vstream);
106 }
107
108 display_horizontal_size = mpeg3bits_getbits(video->vstream, 14);
109 mpeg3bits_getbit_noptr(video->vstream);
110 display_vertical_size = mpeg3bits_getbits(video->vstream, 14);
111}
112
113
114/* decode quant matrix entension */
115
116int mpeg3video_quant_matrix_extension(mpeg3video_t *video)
117{
118 int i;
119 int load_intra_quantiser_matrix, load_non_intra_quantiser_matrix;
120 int load_chroma_intra_quantiser_matrix;
121 int load_chroma_non_intra_quantiser_matrix;
122 int pos = 0;
123
124 if((load_intra_quantiser_matrix = mpeg3bits_getbit_noptr(video->vstream)) != 0)
125 {
126 for(i = 0; i < 64; i++)
127 {
128 video->chroma_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]]
129 = video->intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]]
130 = mpeg3bits_getbyte_noptr(video->vstream);
131 }
132 }
133
134 if((load_non_intra_quantiser_matrix = mpeg3bits_getbit_noptr(video->vstream)) != 0)
135 {
136 for (i = 0; i < 64; i++)
137 {
138 video->chroma_non_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]]
139 = video->non_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]]
140 = mpeg3bits_getbyte_noptr(video->vstream);
141 }
142 }
143
144 if((load_chroma_intra_quantiser_matrix = mpeg3bits_getbit_noptr(video->vstream)) != 0)
145 {
146 for(i = 0; i < 64; i++)
147 video->chroma_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]] = mpeg3bits_getbyte_noptr(video->vstream);
148 }
149
150 if((load_chroma_non_intra_quantiser_matrix = mpeg3bits_getbit_noptr(video->vstream)) != 0)
151 {
152 for(i = 0; i < 64; i++)
153 video->chroma_non_intra_quantizer_matrix[video->mpeg3_zigzag_scan_table[i]] = mpeg3bits_getbyte_noptr(video->vstream);
154 }
155}
156
157
158/* decode sequence scalable extension */
159
160int mpeg3video_sequence_scalable_extension(mpeg3video_t *video)
161{
162 int layer_id;
163
164 video->scalable_mode = mpeg3bits_getbits(video->vstream, 2) + 1; /* add 1 to make SC_DP != SC_NONE */
165 layer_id = mpeg3bits_getbits(video->vstream, 4);
166
167 if(video->scalable_mode == SC_SPAT)
168 {
169 video->llw = mpeg3bits_getbits(video->vstream, 14); /* lower_layer_prediction_horizontal_size */
170 mpeg3bits_getbit_noptr(video->vstream);
171 video->llh = mpeg3bits_getbits(video->vstream, 14); /* lower_layer_prediction_vertical_size */
172 video->hm = mpeg3bits_getbits(video->vstream, 5);
173 video->hn = mpeg3bits_getbits(video->vstream, 5);
174 video->vm = mpeg3bits_getbits(video->vstream, 5);
175 video->vn = mpeg3bits_getbits(video->vstream, 5);
176 }
177
178 if(video->scalable_mode == SC_TEMP)
179 fprintf(stderr, "mpeg3video_sequence_scalable_extension: temporal scalability not implemented\n");
180}
181
182
183/* decode picture display extension */
184
185int mpeg3video_picture_display_extension(mpeg3video_t *video)
186{
187 int n, i;
188 short frame_centre_horizontal_offset[3];
189 short frame_centre_vertical_offset[3];
190
191 if(video->prog_seq || video->pict_struct != FRAME_PICTURE)
192 n = 1;
193 else
194 n = video->repeatfirst ? 3 : 2;
195
196 for(i = 0; i < n; i++)
197 {
198 frame_centre_horizontal_offset[i] = (short)mpeg3bits_getbits(video->vstream, 16);
199 mpeg3bits_getbit_noptr(video->vstream);
200 frame_centre_vertical_offset[i] = (short)mpeg3bits_getbits(video->vstream, 16);
201 mpeg3bits_getbit_noptr(video->vstream);
202 }
203}
204
205
206/* decode picture coding extension */
207
208int mpeg3video_picture_coding_extension(mpeg3video_t *video)
209{
210 int chroma_420_type, composite_display_flag;
211 int v_axis = 0, field_sequence = 0, sub_carrier = 0, burst_amplitude = 0, sub_carrier_phase = 0;
212
213 video->h_forw_r_size = mpeg3bits_getbits(video->vstream, 4) - 1;
214 video->v_forw_r_size = mpeg3bits_getbits(video->vstream, 4) - 1;
215 video->h_back_r_size = mpeg3bits_getbits(video->vstream, 4) - 1;
216 video->v_back_r_size = mpeg3bits_getbits(video->vstream, 4) - 1;
217 video->dc_prec = mpeg3bits_getbits(video->vstream, 2);
218 video->pict_struct = mpeg3bits_getbits(video->vstream, 2);
219 video->topfirst = mpeg3bits_getbit_noptr(video->vstream);
220 video->frame_pred_dct = mpeg3bits_getbit_noptr(video->vstream);
221 video->conceal_mv = mpeg3bits_getbit_noptr(video->vstream);
222 video->qscale_type = mpeg3bits_getbit_noptr(video->vstream);
223 video->intravlc = mpeg3bits_getbit_noptr(video->vstream);
224 video->altscan = mpeg3bits_getbit_noptr(video->vstream);
225 video->repeatfirst = mpeg3bits_getbit_noptr(video->vstream);
226 chroma_420_type = mpeg3bits_getbit_noptr(video->vstream);
227 video->prog_frame = mpeg3bits_getbit_noptr(video->vstream);
228
229 if(video->repeat_count > 100)
230 video->repeat_count = 0;
231 video->repeat_count += 100;
232
233 video->current_repeat = 0;
234
235 if(video->prog_seq)
236 {
237 if(video->repeatfirst)
238 {
239 if(video->topfirst)
240 video->repeat_count += 200;
241 else
242 video->repeat_count += 100;
243 }
244 }
245 else
246 if(video->prog_frame)
247 {
248 if(video->repeatfirst)
249 {
250 video->repeat_count += 50;
251 }
252 }
253
254/*printf("mpeg3video_picture_coding_extension %d\n", video->repeat_count); */
255 composite_display_flag = mpeg3bits_getbit_noptr(video->vstream);
256
257 if(composite_display_flag)
258 {
259 v_axis = mpeg3bits_getbit_noptr(video->vstream);
260 field_sequence = mpeg3bits_getbits(video->vstream, 3);
261 sub_carrier = mpeg3bits_getbit_noptr(video->vstream);
262 burst_amplitude = mpeg3bits_getbits(video->vstream, 7);
263 sub_carrier_phase = mpeg3bits_getbyte_noptr(video->vstream);
264 }
265}
266
267
268/* decode picture spatial scalable extension */
269
270int mpeg3video_picture_spatial_scalable_extension(mpeg3video_t *video)
271{
272 video->pict_scal = 1; /* use spatial scalability in this picture */
273
274 video->lltempref = mpeg3bits_getbits(video->vstream, 10);
275 mpeg3bits_getbit_noptr(video->vstream);
276 video->llx0 = mpeg3bits_getbits(video->vstream, 15);
277 if(video->llx0 >= 16384) video->llx0 -= 32768;
278 mpeg3bits_getbit_noptr(video->vstream);
279 video->lly0 = mpeg3bits_getbits(video->vstream, 15);
280 if(video->lly0 >= 16384) video->lly0 -= 32768;
281 video->stwc_table_index = mpeg3bits_getbits(video->vstream, 2);
282 video->llprog_frame = mpeg3bits_getbit_noptr(video->vstream);
283 video->llfieldsel = mpeg3bits_getbit_noptr(video->vstream);
284}
285
286
287/* decode picture temporal scalable extension
288 *
289 * not implemented
290 *
291 */
292
293int mpeg3video_picture_temporal_scalable_extension(mpeg3video_t *video)
294{
295 fprintf(stderr, "mpeg3video_picture_temporal_scalable_extension: temporal scalability not supported\n");
296}
297
298
299/* decode extension and user data */
300
301int mpeg3video_ext_user_data(mpeg3video_t *video)
302{
303 int code = mpeg3bits_next_startcode(video->vstream);
304
305
306 while(code == MPEG3_EXT_START_CODE || code == MPEG3_USER_START_CODE &&
307 !mpeg3bits_eof(video->vstream))
308 {
309 mpeg3bits_refill(video->vstream);
310
311 if(code == MPEG3_EXT_START_CODE)
312 {
313 int ext_id = mpeg3bits_getbits(video->vstream, 4);
314 switch(ext_id)
315 {
316 case SEQ_ID:
317 mpeg3video_sequence_extension(video);
318 break;
319 case DISP_ID:
320 mpeg3video_sequence_display_extension(video);
321 break;
322 case QUANT_ID:
323 mpeg3video_quant_matrix_extension(video);
324 break;
325 case SEQSCAL_ID:
326 mpeg3video_sequence_scalable_extension(video);
327 break;
328 case PANSCAN_ID:
329 mpeg3video_picture_display_extension(video);
330 break;
331 case CODING_ID:
332 mpeg3video_picture_coding_extension(video);
333 break;
334 case SPATSCAL_ID:
335 mpeg3video_picture_spatial_scalable_extension(video);
336 break;
337 case TEMPSCAL_ID:
338 mpeg3video_picture_temporal_scalable_extension(video);
339 break;
340 default:
341 fprintf(stderr,"mpeg3video_ext_user_data: reserved extension start code ID %d\n", ext_id);
342 break;
343 }
344 }
345 code = mpeg3bits_next_startcode(video->vstream);
346 }
347}
348
349
350/* decode group of pictures header */
351
352int mpeg3video_getgophdr(mpeg3video_t *video)
353{
354 int drop_flag, closed_gop, broken_link;
355
356 drop_flag = mpeg3bits_getbit_noptr(video->vstream);
357 video->gop_timecode.hour = mpeg3bits_getbits(video->vstream, 5);
358 video->gop_timecode.minute = mpeg3bits_getbits(video->vstream, 6);
359 mpeg3bits_getbit_noptr(video->vstream);
360 video->gop_timecode.second = mpeg3bits_getbits(video->vstream, 6);
361 video->gop_timecode.frame = mpeg3bits_getbits(video->vstream, 6);
362 closed_gop = mpeg3bits_getbit_noptr(video->vstream);
363 broken_link = mpeg3bits_getbit_noptr(video->vstream);
364
365/*
366 * printf("%d:%d:%d:%d %d %d %d\n", video->gop_timecode.hour, video->gop_timecode.minute, video->gop_timecode.second, video->gop_timecode.frame,
367 * drop_flag, closed_gop, broken_link);
368 */
369 return mpeg3bits_error(video->vstream);
370}
371
372/* decode picture header */
373
374int mpeg3video_getpicturehdr(mpeg3video_t *video)
375{
376 int temp_ref, vbv_delay;
377
378 video->pict_scal = 0; /* unless overwritten by pict. spat. scal. ext. */
379
380 temp_ref = mpeg3bits_getbits(video->vstream, 10);
381 video->pict_type = mpeg3bits_getbits(video->vstream, 3);
382 vbv_delay = mpeg3bits_getbits(video->vstream, 16);
383
384 if(video->pict_type == P_TYPE || video->pict_type == B_TYPE)
385 {
386 video->full_forw = mpeg3bits_getbit_noptr(video->vstream);
387 video->forw_r_size = mpeg3bits_getbits(video->vstream, 3) - 1;
388 }
389
390 if(video->pict_type == B_TYPE)
391 {
392 video->full_back = mpeg3bits_getbit_noptr(video->vstream);
393 video->back_r_size = mpeg3bits_getbits(video->vstream, 3) - 1;
394 }
395
396/* get extra bit picture */
397 while(mpeg3bits_getbit_noptr(video->vstream) &&
398 !mpeg3bits_eof(video->vstream)) mpeg3bits_getbyte_noptr(video->vstream);
399 return 0;
400}
401
402
403int mpeg3video_get_header(mpeg3video_t *video, int dont_repeat)
404{
405 unsigned int code;
406
407/* a sequence header should be found before returning from `getheader' the */
408/* first time (this is to set horizontal/vertical size properly) */
409
410/* Repeat the frame until it's less than 1 count from repeat_count */
411 if(video->repeat_count - video->current_repeat >= 100 && !dont_repeat)
412 {
413 return 0;
414 }
415
416 if(dont_repeat)
417 {
418 video->repeat_count = 0;
419 video->current_repeat = 0;
420 }
421 else
422 video->repeat_count -= video->current_repeat;
423
424 while(1)
425 {
426/* look for startcode */
427 code = mpeg3bits_next_startcode(video->vstream);
428 if(mpeg3bits_eof(video->vstream)) return 1;
429 if(code != MPEG3_SEQUENCE_END_CODE) mpeg3bits_refill(video->vstream);
430
431 switch(code)
432 {
433 case MPEG3_SEQUENCE_START_CODE:
434 video->found_seqhdr = 1;
435 mpeg3video_getseqhdr(video);
436 mpeg3video_ext_user_data(video);
437 break;
438
439 case MPEG3_GOP_START_CODE:
440 mpeg3video_getgophdr(video);
441 mpeg3video_ext_user_data(video);
442 break;
443
444 case MPEG3_PICTURE_START_CODE:
445 mpeg3video_getpicturehdr(video);
446 mpeg3video_ext_user_data(video);
447 if(video->found_seqhdr) return 0; /* Exit here */
448 break;
449
450 case MPEG3_SEQUENCE_END_CODE:
451// Continue until the end
452 mpeg3bits_refill(video->vstream);
453 break;
454
455 default:
456 break;
457 }
458 }
459 return 1; /* Shouldn't be reached. */
460}
461
462int mpeg3video_ext_bit_info(mpeg3_slice_buffer_t *slice_buffer)
463{
464 while(mpeg3slice_getbit(slice_buffer)) mpeg3slice_getbyte(slice_buffer);
465 return 0;
466}
467
468/* decode slice header */
469int mpeg3video_getslicehdr(mpeg3_slice_t *slice, mpeg3video_t *video)
470{
471 int slice_vertical_position_extension, intra_slice;
472 int qs;
473
474 slice_vertical_position_extension = (video->mpeg2 && video->vertical_size > 2800) ?
475 mpeg3slice_getbits(slice->slice_buffer, 3) : 0;
476
477 if(video->scalable_mode == SC_DP) slice->pri_brk = mpeg3slice_getbits(slice->slice_buffer, 7);
478
479 qs = mpeg3slice_getbits(slice->slice_buffer, 5);
480 slice->quant_scale = video->mpeg2 ? (video->qscale_type ? mpeg3_non_linear_mquant_table[qs] : (qs << 1)) : qs;
481
482 if(mpeg3slice_getbit(slice->slice_buffer))
483 {
484 intra_slice = mpeg3slice_getbit(slice->slice_buffer);
485 mpeg3slice_getbits(slice->slice_buffer, 7);
486 mpeg3video_ext_bit_info(slice->slice_buffer);
487 }
488 else
489 intra_slice = 0;
490
491 return slice_vertical_position_extension;
492}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/idct.c b/core/multimedia/opieplayer/libmpeg3/video/idct.c
new file mode 100644
index 0000000..c79f90a
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/idct.c
@@ -0,0 +1,160 @@
1#include "idct.h"
2#include <stdlib.h>
3
4/**********************************************************/
5/* inverse two dimensional DCT, Chen-Wang algorithm */
6/* (cf. IEEE ASSP-32, pp. 803-816, Aug. 1984) */
7/* 32-bit integer arithmetic (8 bit coefficients) */
8/* 11 mults, 29 adds per DCT */
9/* sE, 18.8.91 */
10/**********************************************************/
11/* coefficients extended to 12 bit for IEEE1180-1990 */
12/* compliance sE, 2.1.94 */
13/**********************************************************/
14
15/* this code assumes >> to be a two's-complement arithmetic */
16/* right shift: (-2)>>1 == -1 , (-3)>>1 == -2 */
17
18#define W1 2841 /* 2048*sqrt(2)*cos(1*pi/16) */
19#define W2 2676 /* 2048*sqrt(2)*cos(2*pi/16) */
20#define W3 2408 /* 2048*sqrt(2)*cos(3*pi/16) */
21#define W5 1609 /* 2048*sqrt(2)*cos(5*pi/16) */
22#define W6 1108 /* 2048*sqrt(2)*cos(6*pi/16) */
23#define W7 565 /* 2048*sqrt(2)*cos(7*pi/16) */
24
25/* row (horizontal) IDCT
26 *
27 * 7 pi 1
28 * dst[k] = sum c[l] * src[l] * cos( -- * ( k + - ) * l )
29 * l=0 8 2
30 *
31 * where: c[0] = 128
32 * c[1..7] = 128*sqrt(2)
33 */
34
35int mpeg3video_idctrow(short *blk)
36{
37 int x0, x1, x2, x3, x4, x5, x6, x7, x8;
38
39 /* shortcut */
40 if (!((x1 = blk[4]<<11) | (x2 = blk[6]) | (x3 = blk[2]) |
41 (x4 = blk[1]) | (x5 = blk[7]) | (x6 = blk[5]) | (x7 = blk[3])))
42 {
43 blk[0]=blk[1]=blk[2]=blk[3]=blk[4]=blk[5]=blk[6]=blk[7]=blk[0]<<3;
44 return 0;
45 }
46
47 x0 = (blk[0]<<11) + 128; /* for proper rounding in the fourth stage */
48
49 /* first stage */
50 x8 = W7*(x4+x5);
51 x4 = x8 + (W1-W7)*x4;
52 x5 = x8 - (W1+W7)*x5;
53 x8 = W3*(x6+x7);
54 x6 = x8 - (W3-W5)*x6;
55 x7 = x8 - (W3+W5)*x7;
56
57 /* second stage */
58 x8 = x0 + x1;
59 x0 -= x1;
60 x1 = W6*(x3+x2);
61 x2 = x1 - (W2+W6)*x2;
62 x3 = x1 + (W2-W6)*x3;
63 x1 = x4 + x6;
64 x4 -= x6;
65 x6 = x5 + x7;
66 x5 -= x7;
67
68 /* third stage */
69 x7 = x8 + x3;
70 x8 -= x3;
71 x3 = x0 + x2;
72 x0 -= x2;
73 x2 = (181*(x4+x5)+128)>>8;
74 x4 = (181*(x4-x5)+128)>>8;
75
76 /* fourth stage */
77 blk[0] = (x7+x1)>>8;
78 blk[1] = (x3+x2)>>8;
79 blk[2] = (x0+x4)>>8;
80 blk[3] = (x8+x6)>>8;
81 blk[4] = (x8-x6)>>8;
82 blk[5] = (x0-x4)>>8;
83 blk[6] = (x3-x2)>>8;
84 blk[7] = (x7-x1)>>8;
85
86 return 1;
87}
88
89/* column (vertical) IDCT
90 *
91 * 7 pi 1
92 * dst[8*k] = sum c[l] * src[8*l] * cos( -- * ( k + - ) * l )
93 * l=0 8 2
94 *
95 * where: c[0] = 1/1024
96 * c[1..7] = (1/1024)*sqrt(2)
97 */
98
99int mpeg3video_idctcol(short *blk)
100{
101 int x0, x1, x2, x3, x4, x5, x6, x7, x8;
102
103 /* shortcut */
104 if (!((x1 = (blk[8 * 4]<<8)) | (x2 = blk[8 * 6]) | (x3 = blk[8 * 2]) |
105 (x4 = blk[8*1]) | (x5 = blk[8 * 7]) | (x6 = blk[8 * 5]) | (x7 = blk[8 * 3]))){
106 blk[8*0]=blk[8*1]=blk[8 * 2]=blk[8 * 3]=blk[8 * 4]=blk[8 * 5]=blk[8 * 6]=blk[8 * 7]=
107 (blk[8*0]+32)>>6;
108 return 0;
109 }
110
111 x0 = (blk[8*0]<<8) + 8192;
112
113 /* first stage */
114 x8 = W7*(x4+x5) + 4;
115 x4 = (x8+(W1-W7)*x4)>>3;
116 x5 = (x8-(W1+W7)*x5)>>3;
117 x8 = W3*(x6+x7) + 4;
118 x6 = (x8-(W3-W5)*x6)>>3;
119 x7 = (x8-(W3+W5)*x7)>>3;
120
121 /* second stage */
122 x8 = x0 + x1;
123 x0 -= x1;
124 x1 = W6*(x3+x2) + 4;
125 x2 = (x1-(W2+W6)*x2)>>3;
126 x3 = (x1+(W2-W6)*x3)>>3;
127 x1 = x4 + x6;
128 x4 -= x6;
129 x6 = x5 + x7;
130 x5 -= x7;
131
132 /* third stage */
133 x7 = x8 + x3;
134 x8 -= x3;
135 x3 = x0 + x2;
136 x0 -= x2;
137 x2 = (181 * (x4 + x5) + 128) >> 8;
138 x4 = (181 * (x4 - x5) + 128) >> 8;
139
140 /* fourth stage */
141 blk[8 * 0] = (x7 + x1) >> 14;
142 blk[8 * 1] = (x3 + x2) >> 14;
143 blk[8 * 2] = (x0 + x4) >> 14;
144 blk[8 * 3] = (x8 + x6) >> 14;
145 blk[8 * 4] = (x8 - x6) >> 14;
146 blk[8 * 5] = (x0 - x4) >> 14;
147 blk[8 * 6] = (x3 - x2) >> 14;
148 blk[8 * 7] = (x7 - x1) >> 14;
149
150 return 1;
151}
152
153
154/* two dimensional inverse discrete cosine transform */
155void mpeg3video_idct_conversion(short* block)
156{
157 int i;
158 for(i = 0; i < 8; i++) mpeg3video_idctrow(block + 8 * i);
159 for(i = 0; i < 8; i++) mpeg3video_idctcol(block + i);
160}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/idct.h b/core/multimedia/opieplayer/libmpeg3/video/idct.h
new file mode 100644
index 0000000..f0aa1d8
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/idct.h
@@ -0,0 +1,24 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef IDCT_H
21#define IDCT_H
22
23
24#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/layerdata.h b/core/multimedia/opieplayer/libmpeg3/video/layerdata.h
new file mode 100644
index 0000000..3ef0f90
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/layerdata.h
@@ -0,0 +1,35 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef LAYERDATA_H
21#define LAYERDATA_H
22
23typedef struct
24{
25/* sequence header */
26 int intra_quantizer_matrix[64], non_intra_quantizer_matrix[64];
27 int chroma_intra_quantizer_matrix[64], chroma_non_intra_quantizer_matrix[64];
28 int mpeg2;
29 int qscale_type, altscan; /* picture coding extension */
30 int pict_scal; /* picture spatial scalable extension */
31 int scalable_mode; /* sequence scalable extension */
32} mpeg3_layerdata_t;
33
34
35#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/macroblocks.c b/core/multimedia/opieplayer/libmpeg3/video/macroblocks.c
new file mode 100644
index 0000000..11e17c1
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/macroblocks.c
@@ -0,0 +1,338 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include "slice.h"
5#include "vlc.h"
6
7#include <stdio.h>
8
9int mpeg3video_get_macroblock_address(mpeg3_slice_t *slice)
10{
11 int code, val = 0;
12 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
13
14 while((code = mpeg3slice_showbits(slice_buffer, 11)) < 24)
15 {
16/* Is not macroblock_stuffing */
17 if(code != 15)
18 {
19/* Is macroblock_escape */
20 if(code == 8)
21 {
22 val += 33;
23 }
24 else
25 {
26 /* fprintf(stderr, "mpeg3video_get_macroblock_address: invalid macroblock_address_increment code\n"); */
27 slice->fault = 1;
28 return 1;
29 }
30 }
31
32 mpeg3slice_flushbits(slice_buffer, 11);
33 }
34
35 if(code >= 1024)
36 {
37 mpeg3slice_flushbit(slice_buffer);
38 return val + 1;
39 }
40
41 if(code >= 128)
42 {
43 code >>= 6;
44 mpeg3slice_flushbits(slice_buffer, mpeg3_MBAtab1[code].len);
45 return val + mpeg3_MBAtab1[code].val;
46 }
47
48 code -= 24;
49 mpeg3slice_flushbits(slice_buffer, mpeg3_MBAtab2[code].len);
50
51 return val + mpeg3_MBAtab2[code].val;
52}
53
54/* macroblock_type for pictures with spatial scalability */
55
56static inline int mpeg3video_getsp_imb_type(mpeg3_slice_t *slice)
57{
58// ### This looks wrong.
59// slice_buffer is used without being initialised and slice is not used
60 //mpeg3_slice_buffer_t *slice_buffer = slice_buffer;
61// I think this would make more sense and might be what is intended
62 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
63 unsigned int code = mpeg3slice_showbits(slice_buffer, 4);
64 if(!code)
65 {
66 /* fprintf(stderr,"mpeg3video_getsp_imb_type: invalid macroblock_type code\n"); */
67 slice->fault = 1;
68 return 0;
69 }
70
71 mpeg3slice_flushbits(slice_buffer, mpeg3_spIMBtab[code].len);
72 return mpeg3_spIMBtab[code].val;
73}
74
75static inline int mpeg3video_getsp_pmb_type(mpeg3_slice_t *slice)
76{
77 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
78 int code = mpeg3slice_showbits(slice_buffer, 7);
79 if(code < 2)
80 {
81 /* fprintf(stderr,"mpeg3video_getsp_pmb_type: invalid macroblock_type code\n"); */
82 slice->fault = 1;
83 return 0;
84 }
85
86 if(code >= 16)
87 {
88 code >>= 3;
89 mpeg3slice_flushbits(slice_buffer, mpeg3_spPMBtab0[code].len);
90
91 return mpeg3_spPMBtab0[code].val;
92 }
93
94 mpeg3slice_flushbits(slice_buffer, mpeg3_spPMBtab1[code].len);
95 return mpeg3_spPMBtab1[code].val;
96}
97
98static inline int mpeg3video_getsp_bmb_type(mpeg3_slice_t *slice)
99{
100 mpeg3_VLCtab_t *p;
101 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
102 int code = mpeg3slice_showbits9(slice_buffer);
103
104 if(code >= 64)
105 p = &mpeg3_spBMBtab0[(code >> 5) - 2];
106 else
107 if(code >= 16)
108 p = &mpeg3_spBMBtab1[(code >> 2) - 4];
109 else
110 if(code >= 8)
111 p = &mpeg3_spBMBtab2[code - 8];
112 else
113 {
114 /* fprintf(stderr,"mpeg3video_getsp_bmb_type: invalid macroblock_type code\n"); */
115 slice->fault = 1;
116 return 0;
117 }
118
119 mpeg3slice_flushbits(slice_buffer, p->len);
120 return p->val;
121}
122
123static inline int mpeg3video_get_imb_type(mpeg3_slice_t *slice)
124{
125 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
126 if(mpeg3slice_getbit(slice_buffer))
127 {
128 return 1;
129 }
130
131 if(!mpeg3slice_getbit(slice_buffer))
132 {
133 /* fprintf(stderr,"mpeg3video_get_imb_type: invalid macroblock_type code\n"); */
134 slice->fault = 1;
135 }
136
137 return 17;
138}
139
140static inline int mpeg3video_get_pmb_type(mpeg3_slice_t *slice)
141{
142 int code;
143 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
144
145 if((code = mpeg3slice_showbits(slice_buffer, 6)) >= 8)
146 {
147 code >>= 3;
148 mpeg3slice_flushbits(slice_buffer, mpeg3_PMBtab0[code].len);
149 return mpeg3_PMBtab0[code].val;
150 }
151
152 if(code == 0)
153 {
154 /* fprintf(stderr,"mpeg3video_get_pmb_type: invalid macroblock_type code\n"); */
155 slice->fault = 1;
156 return 0;
157 }
158
159 mpeg3slice_flushbits(slice_buffer, mpeg3_PMBtab1[code].len);
160 return mpeg3_PMBtab1[code].val;
161}
162
163static inline int mpeg3video_get_bmb_type(mpeg3_slice_t *slice)
164{
165 int code;
166 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
167
168 if((code = mpeg3slice_showbits(slice_buffer, 6)) >= 8)
169 {
170 code >>= 2;
171 mpeg3slice_flushbits(slice_buffer, mpeg3_BMBtab0[code].len);
172 return mpeg3_BMBtab0[code].val;
173 }
174
175 if(code == 0)
176 {
177 /* fprintf(stderr,"mpeg3video_get_bmb_type: invalid macroblock_type code\n"); */
178 slice->fault = 1;
179 return 0;
180 }
181
182 mpeg3slice_flushbits(slice_buffer, mpeg3_BMBtab1[code].len);
183
184 return mpeg3_BMBtab1[code].val;
185}
186
187static inline int mpeg3video_get_dmb_type(mpeg3_slice_t *slice)
188{
189 if(!mpeg3slice_getbit(slice->slice_buffer))
190 {
191 /* fprintf(stderr,"mpeg3video_get_dmb_type: invalid macroblock_type code\n"); */
192 slice->fault=1;
193 }
194
195 return 1;
196}
197
198
199static inline int mpeg3video_get_snrmb_type(mpeg3_slice_t *slice)
200{
201 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
202 int code = mpeg3slice_showbits(slice_buffer, 3);
203
204 if(code == 0)
205 {
206/* fprintf(stderr,"mpeg3video_get_snrmb_type: invalid macroblock_type code\n"); */
207 slice->fault = 1;
208 return 0;
209 }
210
211 mpeg3slice_flushbits(slice_buffer, mpeg3_SNRMBtab[code].len);
212 return mpeg3_SNRMBtab[code].val;
213}
214
215int mpeg3video_get_mb_type(mpeg3_slice_t *slice, mpeg3video_t *video)
216{
217 if(video->scalable_mode == SC_SNR)
218 {
219 return mpeg3video_get_snrmb_type(slice);
220 }
221 else
222 {
223 switch(video->pict_type)
224 {
225 case I_TYPE: return video->pict_scal ? mpeg3video_getsp_imb_type(slice) : mpeg3video_get_imb_type(slice);
226 case P_TYPE: return video->pict_scal ? mpeg3video_getsp_pmb_type(slice) : mpeg3video_get_pmb_type(slice);
227 case B_TYPE: return video->pict_scal ? mpeg3video_getsp_bmb_type(slice) : mpeg3video_get_bmb_type(slice);
228 case D_TYPE: return mpeg3video_get_dmb_type(slice);
229 default:
230 /*fprintf(stderr, "mpeg3video_getmbtype: unknown coding type\n"); */
231 break;
232/* MPEG-1 only, not implemented */
233 }
234 }
235
236 return 0;
237}
238
239int mpeg3video_macroblock_modes(mpeg3_slice_t *slice,
240 mpeg3video_t *video,
241 int *pmb_type,
242 int *pstwtype,
243 int *pstwclass,
244 int *pmotion_type,
245 int *pmv_count,
246 int *pmv_format,
247 int *pdmv,
248 int *pmvscale,
249 int *pdct_type)
250{
251 int mb_type;
252 int stwtype, stwcode, stwclass;
253 int motion_type = 0, mv_count, mv_format, dmv, mvscale;
254 int dct_type;
255 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
256 static unsigned char stwc_table[3][4]
257 = { {6,3,7,4}, {2,1,5,4}, {2,5,7,4} };
258 static unsigned char stwclass_table[9]
259 = {0, 1, 2, 1, 1, 2, 3, 3, 4};
260
261/* get macroblock_type */
262 mb_type = mpeg3video_get_mb_type(slice, video);
263
264 if(slice->fault) return 1;
265
266/* get spatial_temporal_weight_code */
267 if(mb_type & MB_WEIGHT)
268 {
269 if(video->stwc_table_index == 0)
270 stwtype = 4;
271 else
272 {
273 stwcode = mpeg3slice_getbits2(slice_buffer);
274 stwtype = stwc_table[video->stwc_table_index - 1][stwcode];
275 }
276 }
277 else
278 stwtype = (mb_type & MB_CLASS4) ? 8 : 0;
279
280/* derive spatial_temporal_weight_class (Table 7-18) */
281 stwclass = stwclass_table[stwtype];
282
283/* get frame/field motion type */
284 if(mb_type & (MB_FORWARD | MB_BACKWARD))
285 {
286 if(video->pict_struct == FRAME_PICTURE)
287 {
288/* frame_motion_type */
289 motion_type = video->frame_pred_dct ? MC_FRAME : mpeg3slice_getbits2(slice_buffer);
290 }
291 else
292 {
293/* field_motion_type */
294 motion_type = mpeg3slice_getbits2(slice_buffer);
295 }
296 }
297 else
298 if((mb_type & MB_INTRA) && video->conceal_mv)
299 {
300/* concealment motion vectors */
301 motion_type = (video->pict_struct == FRAME_PICTURE) ? MC_FRAME : MC_FIELD;
302 }
303
304/* derive mv_count, mv_format and dmv, (table 6-17, 6-18) */
305 if(video->pict_struct == FRAME_PICTURE)
306 {
307 mv_count = (motion_type == MC_FIELD && stwclass < 2) ? 2 : 1;
308 mv_format = (motion_type == MC_FRAME) ? MV_FRAME : MV_FIELD;
309 }
310 else
311 {
312 mv_count = (motion_type == MC_16X8) ? 2 : 1;
313 mv_format = MV_FIELD;
314 }
315
316 dmv = (motion_type == MC_DMV); /* dual prime */
317
318/* field mv predictions in frame pictures have to be scaled */
319 mvscale = ((mv_format == MV_FIELD) && (video->pict_struct == FRAME_PICTURE));
320
321/* get dct_type (frame DCT / field DCT) */
322 dct_type = (video->pict_struct == FRAME_PICTURE) &&
323 (!video->frame_pred_dct) &&
324 (mb_type & (MB_PATTERN | MB_INTRA)) ?
325 mpeg3slice_getbit(slice_buffer) : 0;
326
327/* return values */
328 *pmb_type = mb_type;
329 *pstwtype = stwtype;
330 *pstwclass = stwclass;
331 *pmotion_type = motion_type;
332 *pmv_count = mv_count;
333 *pmv_format = mv_format;
334 *pdmv = dmv;
335 *pmvscale = mvscale;
336 *pdct_type = dct_type;
337 return 0;
338}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/mmxidct.S b/core/multimedia/opieplayer/libmpeg3/video/mmxidct.S
new file mode 100644
index 0000000..9c3bebe
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/mmxidct.S
@@ -0,0 +1,675 @@
1/*
2 * the input data is tranposed and each 16 bit element in the 8x8 matrix
3 * is left aligned:
4 * for example in 11...1110000 format
5 * If the iDCT is of I macroblock then 0.5 needs to be added to the;DC Component
6 * (element[0][0] of the matrix)
7 */
8
9/* extrn re_matrix */
10
11/* constants */
12
13.data
14 .align 16
15 .type preSC, @object
16preSC: .short 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520
17 .short 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270
18 .short 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906
19 .short 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315
20 .short 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520
21 .short 12873, 17855, 16819, 15137, 25746, 20228, 13933, 7103
22 .short 17734, 24598, 23170, 20853, 17734, 13933, 9597, 4892
23 .short 18081, 25080, 23624, 21261, 18081, 14206, 9785, 4988
24 .sizepreSC, 128
25 .align 8
26 .typex0005000200010001, @object
27 .sizex0005000200010001, 8
28x0005000200010001:
29 .long0x00010001, 0x00050002
30 .align 8
31 .typex0040000000000000, @object
32 .sizex0040000000000000, 8
33x0040000000000000:
34 .long0, 0x00400000
35 .align 8
36 .typex5a825a825a825a82, @object
37 .sizex5a825a825a825a82, 8
38x5a825a825a825a82:
39 .long0x5a825a82, 0x5a825a82
40 .align 8
41 .typex539f539f539f539f, @object
42 .sizex539f539f539f539f, 8
43x539f539f539f539f:
44 .long0x539f539f, 0x539f539f
45 .align 8
46 .typex4546454645464546, @object
47 .sizex4546454645464546, 8
48x4546454645464546:
49 .long0x45464546, 0x45464546
50 .align 8
51 .typex61f861f861f861f8, @object
52 .sizex61f861f861f861f8, 8
53x61f861f861f861f8:
54 .long0x61f861f8, 0x61f861f8
55/* Static variables */
56 .align 8
57 .type x0, @object
58 .size x0, 8
59x0:
60 .long 0, 0
61/* Procedure */
62
63
64 .align 8
65.text
66 .align 4
67.globl IDCT_mmx
68 .type IDCT_mmx, @function
69IDCT_mmx:
70 pushl %ebp
71 movl %esp, %ebp
72 pushl %ebx
73 pushl %ecx
74 pushl %edx
75 pushl %esi
76 pushl %edi
77
78 pushl $0 /* allocate the temp variables */
79 pushl $0
80 pushl $0
81 pushl $0
82 pushl $0
83 pushl $0
84 pushl $0
85 pushl $0
86
87 movl 8(%ebp), %esi /* source matrix */
88 leal preSC, %ecx
89/* column 0: even part
90 * use V4, V12, V0, V8 to produce V22..V25
91 */
92 movq 8*12(%ecx), %mm0 /* maybe the first mul can be done together */
93 /* with the dequantization in iHuff module */
94 pmulhw 8*12(%esi), %mm0 /* V12 */
95 movq 8*4(%ecx), %mm1
96 pmulhw 8*4(%esi), %mm1 /* V4 */
97 movq (%ecx), %mm3
98 psraw $1, %mm0 /* t64=t66 */
99 pmulhw (%esi), %mm3 /* V0 */
100 movq 8*8(%ecx), %mm5 /* duplicate V4 */
101 movq %mm1, %mm2 /* added 11/1/96 */
102 pmulhw 8*8(%esi),%mm5 /* V8 */
103 psubsw %mm0, %mm1 /* V16 */
104 pmulhw x5a825a825a825a82, %mm1/* 23170 ->V18 */
105 paddsw %mm0, %mm2 /* V17 */
106 movq %mm2, %mm0 /* duplicate V17 */
107 psraw $1, %mm2 /* t75=t82 */
108 psraw $2, %mm0 /* t72 */
109 movq %mm3, %mm4 /* duplicate V0 */
110 paddsw %mm5, %mm3 /* V19 */
111 psubsw %mm5, %mm4 /* V20 ;mm5 free */
112/* moved from the block below */
113 movq 8*10(%ecx), %mm7
114 psraw $1, %mm3 /* t74=t81 */
115 movq %mm3, %mm6 /* duplicate t74=t81 */
116 psraw $2, %mm4 /* t77=t79 */
117 psubsw %mm0, %mm1 /* V21 ; mm0 free */
118 paddsw %mm2, %mm3 /* V22 */
119 movq %mm1, %mm5 /* duplicate V21 */
120 paddsw %mm4, %mm1 /* V23 */
121 movq %mm3, 8*4(%esi) /* V22 */
122 psubsw %mm5, %mm4 /* V24; mm5 free */
123 movq %mm1, 8*12(%esi) /* V23 */
124 psubsw %mm2, %mm6 /* V25; mm2 free */
125 movq %mm4, (%esi) /* V24 */
126/* keep mm6 alive all along the next block */
127 /* movq %mm6, 8*8(%esi) V25 */
128/* column 0: odd part
129 * use V2, V6, V10, V14 to produce V31, V39, V40, V41
130 */
131/* moved above: movq 8*10(%ecx), %mm7 */
132
133 pmulhw 8*10(%esi), %mm7 /* V10 */
134 movq 8*6(%ecx), %mm0
135 pmulhw 8*6(%esi), %mm0 /* V6 */
136 movq 8*2(%ecx), %mm5
137 movq %mm7, %mm3 /* duplicate V10 */
138 pmulhw 8*2(%esi), %mm5 /* V2 */
139 movq 8*14(%ecx), %mm4
140 psubsw %mm0, %mm7 /* V26 */
141 pmulhw 8*14(%esi), %mm4 /* V14 */
142 paddsw %mm0, %mm3 /* V29 ; free mm0 */
143 movq %mm7, %mm1 /* duplicate V26 */
144 psraw $1, %mm3 /* t91=t94 */
145 pmulhw x539f539f539f539f,%mm7/* V33 */
146 psraw $1, %mm1 /* t96 */
147 movq %mm5, %mm0 /* duplicate V2 */
148 psraw $2, %mm4 /* t85=t87 */
149 paddsw %mm4,%mm5 /* V27 */
150 psubsw %mm4, %mm0 /* V28 ; free mm4 */
151 movq %mm0, %mm2 /* duplicate V28 */
152 psraw $1, %mm5 /* t90=t93 */
153 pmulhw x4546454645464546,%mm0/* V35 */
154 psraw $1, %mm2 /* t97 */
155 movq %mm5, %mm4 /* duplicate t90=t93 */
156 psubsw %mm2, %mm1 /* V32 ; free mm2 */
157 pmulhw x61f861f861f861f8,%mm1/* V36 */
158 psllw $1, %mm7 /* t107 */
159 paddsw %mm3, %mm5 /* V31 */
160 psubsw %mm3, %mm4 /* V30 ; free mm3 */
161 pmulhw x5a825a825a825a82,%mm4/* V34 */
162 nop
163 psubsw %mm1, %mm0 /* V38 */
164 psubsw %mm7, %mm1 /* V37 ; free mm7 */
165 psllw $1, %mm1 /* t114 */
166/* move from the next block */
167 movq %mm6, %mm3 /* duplicate V25 */
168/* move from the next block */
169 movq 8*4(%esi), %mm7 /* V22 */
170 psllw $1, %mm0 /* t110 */
171 psubsw %mm5, %mm0 /* V39 (mm5 needed for next block) */
172 psllw $2, %mm4 /* t112 */
173/* moved from the next block */
174 movq 8*12(%esi), %mm2 /* V23 */
175 psubsw %mm0, %mm4 /* V40 */
176 paddsw %mm4, %mm1 /* V41; free mm0 */
177/* moved from the next block */
178 psllw $1, %mm2 /* t117=t125 */
179/* column 0: output butterfly */
180/* moved above:
181 * movq %mm6, %mm3 duplicate V25
182 * movq 8*4(%esi), %mm7 V22
183 * movq 8*12(%esi), %mm2 V23
184 * psllw $1, %mm2 t117=t125
185 */
186 psubsw %mm1, %mm6 /* tm6 */
187 paddsw %mm1, %mm3 /* tm8; free mm1 */
188 movq %mm7, %mm1 /* duplicate V22 */
189 paddsw %mm5, %mm7 /* tm0 */
190 movq %mm3, 8*8(%esi) /* tm8; free mm3 */
191 psubsw %mm5, %mm1 /* tm14; free mm5 */
192 movq %mm6, 8*6(%esi) /* tm6; free mm6 */
193 movq %mm2, %mm3 /* duplicate t117=t125 */
194 movq (%esi), %mm6 /* V24 */
195 paddsw %mm0, %mm2 /* tm2 */
196 movq %mm7, (%esi) /* tm0; free mm7 */
197 psubsw %mm0, %mm3 /* tm12; free mm0 */
198 movq %mm1, 8*14(%esi) /* tm14; free mm1 */
199 psllw $1, %mm6 /* t119=t123 */
200 movq %mm2, 8*2(%esi) /* tm2; free mm2 */
201 movq %mm6, %mm0 /* duplicate t119=t123 */
202 movq %mm3, 8*12(%esi) /* tm12; free mm3 */
203 paddsw %mm4, %mm6 /* tm4 */
204/* moved from next block */
205 movq 8*5(%ecx), %mm1
206 psubsw %mm4, %mm0 /* tm10; free mm4 */
207/* moved from next block */
208 pmulhw 8*5(%esi), %mm1 /* V5 */
209 movq %mm6, 8*4(%esi) /* tm4; free mm6 */
210 movq %mm0, 8*10(%esi) /* tm10; free mm0 */
211/* column 1: even part
212 * use V5, V13, V1, V9 to produce V56..V59
213 */
214/* moved to prev block:
215 *movq 8*5(%ecx), %mm1
216 * pmulhw 8*5(%esi), %mm1 V5
217 */
218 movq 8*13(%ecx), %mm7
219 psllw $1, %mm1 /* t128=t130 */
220 pmulhw 8*13(%esi), %mm7 /* V13 */
221 movq %mm1, %mm2 /* duplicate t128=t130 */
222 movq 8(%ecx), %mm3
223 pmulhw 8(%esi), %mm3 /* V1 */
224 movq 8*9(%ecx), %mm5
225 psubsw %mm7, %mm1 /* V50 */
226 pmulhw 8*9(%esi), %mm5 /* V9 */
227 paddsw %mm7, %mm2 /* V51 */
228 pmulhw x5a825a825a825a82, %mm1/* 23170 ->V52 */
229 movq %mm2, %mm6 /* duplicate V51 */
230 psraw $1, %mm2 /* t138=t144 */
231 movq %mm3, %mm4 /* duplicate V1 */
232 psraw $2, %mm6 /* t136 */
233 paddsw %mm5, %mm3 /* V53 */
234 psubsw %mm5, %mm4 /* V54 ;mm5 free */
235 movq %mm3, %mm7 /* duplicate V53 */
236/* moved from next block */
237 movq 8*11(%ecx), %mm0
238 psraw $1, %mm4 /* t140=t142 */
239 psubsw %mm6, %mm1 /* V55 ; mm6 free */
240 paddsw %mm2, %mm3 /* V56 */
241 movq %mm4, %mm5 /* duplicate t140=t142 */
242 paddsw %mm1, %mm4 /* V57 */
243 movq %mm3, 8*5(%esi) /* V56 */
244 psubsw %mm1, %mm5 /* V58; mm1 free */
245 movq %mm4, 8*13(%esi) /* V57 */
246 psubsw %mm2, %mm7 /* V59; mm2 free */
247 movq %mm5, 8*9(%esi) /* V58 */
248/* keep mm7 alive all along the next block
249 * movq %mm7, 8(%esi) V59
250 * moved above
251 *movq 8*11(%ecx), %mm0
252 */
253 pmulhw 8*11(%esi), %mm0 /* V11 */
254 movq 8*7(%ecx), %mm6
255 pmulhw 8*7(%esi), %mm6 /* V7 */
256 movq 8*15(%ecx), %mm4
257 movq %mm0, %mm3 /* duplicate V11 */
258 pmulhw 8*15(%esi), %mm4 /* V15 */
259 movq 8*3(%ecx), %mm5
260 psllw $1, %mm6 /* t146=t152 */
261 pmulhw 8*3(%esi), %mm5 /* V3 */
262 paddsw %mm6, %mm0 /* V63 */
263/* note that V15 computation has a correction step:
264 * this is a 'magic' constant that rebiases the results to be closer to the
265 * expected result. this magic constant can be refined to reduce the error
266 * even more by doing the correction step in a later stage when the number
267 * is actually multiplied by 16
268 */
269 paddw x0005000200010001, %mm4
270 psubsw %mm6, %mm3 /* V60 ; free mm6 */
271 psraw $1, %mm0 /* t154=t156 */
272 movq %mm3, %mm1 /* duplicate V60 */
273 pmulhw x539f539f539f539f, %mm1/* V67 */
274 movq %mm5, %mm6 /* duplicate V3 */
275 psraw $2, %mm4 /* t148=t150 */
276 paddsw %mm4, %mm5 /* V61 */
277 psubsw %mm4, %mm6 /* V62 ; free mm4 */
278 movq %mm5, %mm4 /* duplicate V61 */
279 psllw $1, %mm1 /* t169 */
280 paddsw %mm0, %mm5 /* V65 -> result */
281 psubsw %mm0, %mm4 /* V64 ; free mm0 */
282 pmulhw x5a825a825a825a82, %mm4/* V68 */
283 psraw $1, %mm3 /* t158 */
284 psubsw %mm6, %mm3 /* V66 */
285 movq %mm5, %mm2 /* duplicate V65 */
286 pmulhw x61f861f861f861f8, %mm3/* V70 */
287 psllw $1, %mm6 /* t165 */
288 pmulhw x4546454645464546, %mm6/* V69 */
289 psraw $1, %mm2 /* t172 */
290/* moved from next block */
291 movq 8*5(%esi), %mm0 /* V56 */
292 psllw $1, %mm4 /* t174 */
293/* moved from next block */
294 psraw $1, %mm0 /* t177=t188 */
295 nop
296 psubsw %mm3, %mm6 /* V72 */
297 psubsw %mm1, %mm3 /* V71 ; free mm1 */
298 psubsw %mm2, %mm6 /* V73 ; free mm2 */
299/* moved from next block */
300 psraw $1, %mm5 /* t178=t189 */
301 psubsw %mm6, %mm4 /* V74 */
302/* moved from next block */
303 movq %mm0, %mm1 /* duplicate t177=t188 */
304 paddsw %mm4, %mm3 /* V75 */
305/* moved from next block */
306 paddsw %mm5, %mm0 /* tm1 */
307/* location
308 * 5 - V56
309 * 13 - V57
310 * 9 - V58
311 * X - V59, mm7
312 * X - V65, mm5
313 * X - V73, mm6
314 * X - V74, mm4
315 * X - V75, mm3
316 * free mm0, mm1 & mm2
317 * moved above
318 * movq 8*5(%esi), %mm0 V56
319 * psllw $1, %mm0 t177=t188 ! new !!
320 * psllw $1, %mm5 t178=t189 ! new !!
321 * movq %mm0, %mm1 duplicate t177=t188
322 * paddsw %mm5, %mm0 tm1
323 */
324 movq 8*13(%esi), %mm2 /* V57 */
325 psubsw %mm5, %mm1 /* tm15; free mm5 */
326 movq %mm0, 8(%esi) /* tm1; free mm0 */
327 psraw $1, %mm7 /* t182=t184 ! new !! */
328/* save the store as used directly in the transpose
329 * movq %mm1, 120(%esi) tm15; free mm1
330 */
331 movq %mm7, %mm5 /* duplicate t182=t184 */
332 psubsw %mm3, %mm7 /* tm7 */
333 paddsw %mm3, %mm5 /* tm9; free mm3 */
334 movq 8*9(%esi), %mm0 /* V58 */
335 movq %mm2, %mm3 /* duplicate V57 */
336 movq %mm7, 8*7(%esi) /* tm7; free mm7 */
337 psubsw %mm6, %mm3 /* tm13 */
338 paddsw %mm6, %mm2 /* tm3 ; free mm6 */
339/* moved up from the transpose */
340 movq %mm3, %mm7
341/* moved up from the transpose */
342 punpcklwd %mm1, %mm3
343 movq %mm0, %mm6 /* duplicate V58 */
344 movq %mm2, 8*3(%esi) /* tm3; free mm2 */
345 paddsw %mm4, %mm0 /* tm5 */
346 psubsw %mm4, %mm6 /* tm11; free mm4 */
347/* moved up from the transpose */
348 punpckhwd %mm1, %mm7
349 movq %mm0, 8*5(%esi) /* tm5; free mm0 */
350/* moved up from the transpose */
351 movq %mm5, %mm2
352/* transpose - M4 part
353 * --------- ---------
354 * | M1 | M2 | | M1'| M3'|
355 * --------- --> ---------
356 * | M3 | M4 | | M2'| M4'|
357 * --------- ---------
358 * Two alternatives: use full mmword approach so the following code can be
359 * scheduled before the transpose is done without stores, or use the faster
360 * half mmword stores (when possible)
361 */
362 movd %mm3, 8*9+4(%esi) /* MS part of tmt9 */
363 punpcklwd %mm6, %mm5
364 movd %mm7, 8*13+4(%esi) /* MS part of tmt13 */
365 punpckhwd %mm6, %mm2
366 movd %mm5, 8*9(%esi) /* LS part of tmt9 */
367 punpckhdq %mm3, %mm5 /* free mm3 */
368 movd %mm2, 8*13(%esi) /* LS part of tmt13 */
369 punpckhdq %mm7, %mm2 /* free mm7 */
370/* moved up from the M3 transpose */
371 movq 8*8(%esi), %mm0
372/* moved up from the M3 transpose */
373 movq 8*10(%esi), %mm1
374/* moved up from the M3 transpose */
375 movq %mm0, %mm3
376/* shuffle the rest of the data, and write it with 2 mmword writes */
377 movq %mm5, 8*11(%esi) /* tmt11 */
378/* moved up from the M3 transpose */
379 punpcklwd %mm1, %mm0
380 movq %mm2, 8*15(%esi) /* tmt15 */
381/* moved up from the M3 transpose */
382 punpckhwd %mm1, %mm3
383/* transpose - M3 part
384 * moved up to previous code section
385 *movq 8*8(%esi), %mm0
386 *movq 8*10(%esi), %mm1
387 *movq %mm0, %mm3
388 *punpcklwd %mm1, %mm0
389 *punpckhwd %mm1, %mm3
390 */
391 movq 8*12(%esi), %mm6
392 movq 8*14(%esi), %mm4
393 movq %mm6, %mm2
394/* shuffle the data and write the lower parts of the transposed in 4 dwords */
395 punpcklwd %mm4, %mm6
396 movq %mm0, %mm1
397 punpckhdq %mm6, %mm1
398 movq %mm3, %mm7
399 punpckhwd %mm4, %mm2 /* free mm4 */
400 punpckldq %mm6, %mm0 /* free mm6 */
401/* moved from next block */
402 movq 8*13(%esi), %mm4 /* tmt13 */
403 punpckldq %mm2, %mm3
404 punpckhdq %mm2, %mm7 /* free mm2 */
405/* moved from next block */
406 movq %mm3, %mm5 /* duplicate tmt5 */
407/* column 1: even part (after transpose)
408* moved above
409 * movq %mm3, %mm5 duplicate tmt5
410 * movq 8*13(%esi), %mm4 tmt13
411*/
412 psubsw %mm4, %mm3 /* V134 */
413 pmulhw x5a825a825a825a82, %mm3/* 23170 ->V136 */
414 movq 8*9(%esi), %mm6 /* tmt9 */
415 paddsw %mm4, %mm5 /* V135 ; mm4 free */
416 movq %mm0, %mm4 /* duplicate tmt1 */
417 paddsw %mm6, %mm0 /* V137 */
418 psubsw %mm6, %mm4 /* V138 ; mm6 free */
419 psllw $2, %mm3 /* t290 */
420 psubsw %mm5, %mm3 /* V139 */
421 movq %mm0, %mm6 /* duplicate V137 */
422 paddsw %mm5, %mm0 /* V140 */
423 movq %mm4, %mm2 /* duplicate V138 */
424 paddsw %mm3, %mm2 /* V141 */
425 psubsw %mm3, %mm4 /* V142 ; mm3 free */
426 movq %mm0, 8*9(%esi) /* V140 */
427 psubsw %mm5, %mm6 /* V143 ; mm5 free */
428/* moved from next block */
429 movq 8*11(%esi), %mm0 /* tmt11 */
430 movq %mm2, 8*13(%esi) /* V141 */
431/* moved from next block */
432 movq %mm0, %mm2 /* duplicate tmt11 */
433/* column 1: odd part (after transpose) */
434/* moved up to the prev block
435 * movq 8*11(%esi), %mm0 tmt11
436 * movq %mm0, %mm2 duplicate tmt11
437 */
438 movq 8*15(%esi), %mm5 /* tmt15 */
439 psubsw %mm7, %mm0 /* V144 */
440 movq %mm0, %mm3 /* duplicate V144 */
441 paddsw %mm7, %mm2 /* V147 ; free mm7 */
442 pmulhw x539f539f539f539f, %mm0/* 21407-> V151 */
443 movq %mm1, %mm7 /* duplicate tmt3 */
444 paddsw %mm5, %mm7 /* V145 */
445 psubsw %mm5, %mm1 /* V146 ; free mm5 */
446 psubsw %mm1, %mm3 /* V150 */
447 movq %mm7, %mm5 /* duplicate V145 */
448 pmulhw x4546454645464546, %mm1/* 17734-> V153 */
449 psubsw %mm2, %mm5 /* V148 */
450 pmulhw x61f861f861f861f8, %mm3/* 25080-> V154 */
451 psllw $2, %mm0 /* t311 */
452 pmulhw x5a825a825a825a82, %mm5/* 23170-> V152 */
453 paddsw %mm2, %mm7 /* V149 ; free mm2 */
454 psllw $1, %mm1 /* t313 */
455 nop/* without the nop - freeze here for one clock */
456 movq %mm3, %mm2 /* duplicate V154 */
457 psubsw %mm0, %mm3 /* V155 ; free mm0 */
458 psubsw %mm2, %mm1 /* V156 ; free mm2 */
459/* moved from the next block */
460 movq %mm6, %mm2 /* duplicate V143 */
461/* moved from the next block */
462 movq 8*13(%esi), %mm0 /* V141 */
463 psllw $1, %mm1 /* t315 */
464 psubsw %mm7, %mm1 /* V157 (keep V149) */
465 psllw $2, %mm5 /* t317 */
466 psubsw %mm1, %mm5 /* V158 */
467 psllw $1, %mm3 /* t319 */
468 paddsw %mm5, %mm3 /* V159 */
469/* column 1: output butterfly (after transform)
470 * moved to the prev block
471 * movq %mm6, %mm2 duplicate V143
472 * movq 8*13(%esi), %mm0 V141
473 */
474 psubsw %mm3, %mm2 /* V163 */
475 paddsw %mm3, %mm6 /* V164 ; free mm3 */
476 movq %mm4, %mm3 /* duplicate V142 */
477 psubsw %mm5, %mm4 /* V165 ; free mm5 */
478 movq %mm2, (%esp) /* out7 */
479 psraw $4, %mm6
480 psraw $4, %mm4
481 paddsw %mm5, %mm3 /* V162 */
482 movq 8*9(%esi), %mm2 /* V140 */
483 movq %mm0, %mm5 /* duplicate V141 */
484/* in order not to perculate this line up,
485 * we read 72(%esi) very near to this location
486 */
487 movq %mm6, 8*9(%esi) /* out9 */
488 paddsw %mm1, %mm0 /* V161 */
489 movq %mm3, 8(%esp) /* out5 */
490 psubsw %mm1, %mm5 /* V166 ; free mm1 */
491 movq %mm4, 8*11(%esi) /* out11 */
492 psraw $4, %mm5
493 movq %mm0, 16(%esp) /* out3 */
494 movq %mm2, %mm4 /* duplicate V140 */
495 movq %mm5, 8*13(%esi) /* out13 */
496 paddsw %mm7, %mm2 /* V160 */
497/* moved from the next block */
498 movq 8(%esi), %mm0
499 psubsw %mm7, %mm4 /* V167 ; free mm7 */
500/* moved from the next block */
501 movq 8*3(%esi), %mm7
502 psraw $4, %mm4
503 movq %mm2, 24(%esp) /* out1 */
504/* moved from the next block */
505 movq %mm0, %mm1
506 movq %mm4, 8*15(%esi) /* out15 */
507/* moved from the next block */
508 punpcklwd %mm7, %mm0
509/* transpose - M2 parts
510 * moved up to the prev block
511 *movq 8(%esi), %mm0
512 *movq 8*3(%esi), %mm7
513 *movq %mm0, %mm1
514 *punpcklwd %mm7, %mm0
515 */
516 movq 8*5(%esi), %mm5
517 punpckhwd %mm7, %mm1
518 movq 8*7(%esi), %mm4
519 movq %mm5, %mm3
520/* shuffle the data and write the lower parts of the trasposed in 4 dwords */
521 movd %mm0, 8*8(%esi) /* LS part of tmt8 */
522 punpcklwd %mm4, %mm5
523 movd %mm1, 8*12(%esi) /* LS part of tmt12 */
524 punpckhwd %mm4, %mm3
525 movd %mm5, 8*8+4(%esi) /* MS part of tmt8 */
526 punpckhdq %mm5, %mm0 /* tmt10 */
527 movd %mm3, 8*12+4(%esi) /* MS part of tmt12 */
528 punpckhdq %mm3, %mm1 /* tmt14 */
529/* transpose - M1 parts */
530 movq (%esi), %mm7
531 movq 8*2(%esi), %mm2
532 movq %mm7, %mm6
533 movq 8*4(%esi), %mm5
534 punpcklwd %mm2, %mm7
535 movq 8*6(%esi), %mm4
536 punpckhwd %mm2, %mm6 /* free mm2 */
537 movq %mm5, %mm3
538 punpcklwd %mm4, %mm5
539 punpckhwd %mm4, %mm3 /* free mm4 */
540 movq %mm7, %mm2
541 movq %mm6, %mm4
542 punpckldq %mm5, %mm7 /* tmt0 */
543 punpckhdq %mm5, %mm2 /* tmt2 ; free mm5 */
544/* shuffle the rest of the data, and write it with 2 mmword writes */
545 punpckldq %mm3, %mm6 /* tmt4 */
546/* moved from next block */
547 movq %mm2, %mm5 /* duplicate tmt2 */
548 punpckhdq %mm3, %mm4 /* tmt6 ; free mm3 */
549/* moved from next block */
550 movq %mm0, %mm3 /* duplicate tmt10 */
551/* column 0: odd part (after transpose)
552 *moved up to prev block
553 * movq %mm0, %mm3 duplicate tmt10
554 * movq %mm2, %mm5 duplicate tmt2
555 */
556 psubsw %mm4, %mm0 /* V110 */
557 paddsw %mm4, %mm3 /* V113 ; free mm4 */
558 movq %mm0, %mm4 /* duplicate V110 */
559 paddsw %mm1, %mm2 /* V111 */
560 pmulhw x539f539f539f539f, %mm0/* 21407-> V117 */
561 psubsw %mm1, %mm5 /* V112 ; free mm1 */
562 psubsw %mm5, %mm4 /* V116 */
563 movq %mm2, %mm1 /* duplicate V111 */
564 pmulhw x4546454645464546, %mm5/* 17734-> V119 */
565 psubsw %mm3, %mm2 /* V114 */
566 pmulhw x61f861f861f861f8, %mm4/* 25080-> V120 */
567 paddsw %mm3, %mm1 /* V115 ; free mm3 */
568 pmulhw x5a825a825a825a82, %mm2/* 23170-> V118 */
569 psllw $2, %mm0 /* t266 */
570 movq %mm1, (%esi) /* save V115 */
571 psllw $1, %mm5 /* t268 */
572 psubsw %mm4, %mm5 /* V122 */
573 psubsw %mm0, %mm4 /* V121 ; free mm0 */
574 psllw $1, %mm5 /* t270 */
575 psubsw %mm1, %mm5 /* V123 ; free mm1 */
576 psllw $2, %mm2 /* t272 */
577 psubsw %mm5, %mm2 /* V124 (keep V123) */
578 psllw $1, %mm4 /* t274 */
579 movq %mm5, 8*2(%esi) /* save V123 ; free mm5 */
580 paddsw %mm2, %mm4 /* V125 (keep V124) */
581/* column 0: even part (after transpose) */
582 movq 8*12(%esi), %mm0 /* tmt12 */
583 movq %mm6, %mm3 /* duplicate tmt4 */
584 psubsw %mm0, %mm6 /* V100 */
585 paddsw %mm0, %mm3 /* V101 ; free mm0 */
586 pmulhw x5a825a825a825a82, %mm6/* 23170 ->V102 */
587 movq %mm7, %mm5 /* duplicate tmt0 */
588 movq 8*8(%esi), %mm1 /* tmt8 */
589 paddsw %mm1, %mm7 /* V103 */
590 psubsw %mm1, %mm5 /* V104 ; free mm1 */
591 movq %mm7, %mm0 /* duplicate V103 */
592 psllw $2, %mm6 /* t245 */
593 paddsw %mm3, %mm7 /* V106 */
594 movq %mm5, %mm1 /* duplicate V104 */
595 psubsw %mm3, %mm6 /* V105 */
596 psubsw %mm3, %mm0 /* V109; free mm3 */
597 paddsw %mm6, %mm5 /* V107 */
598 psubsw %mm6, %mm1 /* V108 ; free mm6 */
599/* column 0: output butterfly (after transform) */
600 movq %mm1, %mm3 /* duplicate V108 */
601 paddsw %mm2, %mm1 /* out4 */
602 psraw $4, %mm1
603 psubsw %mm2, %mm3 /* out10 ; free mm2 */
604 psraw $4, %mm3
605 movq %mm0, %mm6 /* duplicate V109 */
606 movq %mm1, 8*4(%esi) /* out4 ; free mm1 */
607 psubsw %mm4, %mm0 /* out6 */
608 movq %mm3, 8*10(%esi) /* out10 ; free mm3 */
609 psraw $4, %mm0
610 paddsw %mm4, %mm6 /* out8 ; free mm4 */
611 movq %mm7, %mm1 /* duplicate V106 */
612 movq %mm0, 8*6(%esi) /* out6 ; free mm0 */
613 psraw $4, %mm6
614 movq (%esi), %mm4 /* V115 */
615 movq %mm6, 8*8(%esi) /* out8 ; free mm6 */
616 movq %mm5, %mm2 /* duplicate V107 */
617 movq 8*2(%esi), %mm3 /* V123 */
618 paddsw %mm4, %mm7 /* out0 */
619/* moved up from next block */
620 movq 16(%esp), %mm0
621 psraw $4, %mm7
622/* moved up from next block */
623 movq 8(%esp), %mm6
624 psubsw %mm4, %mm1 /* out14 ; free mm4 */
625 paddsw %mm3, %mm5 /* out2 */
626 psraw $4, %mm1
627 movq %mm7, (%esi) /* out0 ; free mm7 */
628 psraw $4, %mm5
629 movq %mm1, 8*14(%esi) /* out14 ; free mm1 */
630 psubsw %mm3, %mm2 /* out12 ; free mm3 */
631 movq %mm5, 8*2(%esi) /* out2 ; free mm5 */
632 psraw $4, %mm2
633/* moved up to the prev block */
634 movq (%esp), %mm4
635/* moved up to the prev block */
636 psraw $4, %mm0
637 movq %mm2, 8*12(%esi) /* out12 ; free mm2 */
638/* moved up to the prev block */
639 psraw $4, %mm6
640/* move back the data to its correct place
641* moved up to the prev block
642 *movq 16(%esp), %mm0
643 *movq 8(%esp), %mm6
644 *movq (%esp), %mm4
645 *psraw $4, %mm0
646 *psraw $4, %mm6
647*/
648 movq 24(%esp), %mm1
649 psraw $4, %mm4
650 movq %mm0, 8*3(%esi) /* out3 */
651 psraw $4, %mm1
652 movq %mm6, 8*5(%esi) /* out5 */
653 movq %mm4, 8*7(%esi) /* out7 */
654 movq %mm1, 8(%esi) /* out1 */
655
656 popl %edi /* Pop off the temp variables */
657 popl %edi
658 popl %edi
659 popl %edi
660 popl %edi
661 popl %edi
662 popl %edi
663 popl %edi
664
665 popl %edi /* Pop off the old variables */
666 popl %esi
667 popl %edx
668 popl %ecx
669 popl %ebx
670 movl %ebp, %esp
671 popl %ebp
672
673 ret
674.Lfe1:
675 .size IDCT_mmx,.Lfe1-IDCT_mmx
diff --git a/core/multimedia/opieplayer/libmpeg3/video/mmxtest.c b/core/multimedia/opieplayer/libmpeg3/video/mmxtest.c
new file mode 100644
index 0000000..567f139
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/mmxtest.c
@@ -0,0 +1,35 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3
4#include <stdio.h>
5#include <string.h>
6
7int mpeg3_mmx_test()
8{
9 int result = 0;
10 FILE *proc;
11 char string[MPEG3_STRLEN];
12
13
14#ifdef HAVE_MMX
15 if(!(proc = fopen(MPEG3_PROC_CPUINFO, "r")))
16 {
17 return 0;
18 }
19
20 while(!feof(proc))
21 {
22 fgets(string, MPEG3_STRLEN, proc);
23/* Got the flags line */
24 if(!strncmp(string, "flags", 5))
25 {
26 char *needle;
27 needle = strstr(string, "mmx");
28 if(!needle) return 0;
29 if(!strncmp(needle, "mmx", 3)) return 1;
30 }
31 }
32#endif
33
34 return 0;
35}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/motion.c b/core/multimedia/opieplayer/libmpeg3/video/motion.c
new file mode 100644
index 0000000..4d2f681
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/motion.c
@@ -0,0 +1,230 @@
1#include "mpeg3video.h"
2#include "../libmpeg3.h"
3#include "../mpeg3protos.h"
4#include "vlc.h"
5
6#include <stdio.h>
7
8
9/* calculate motion vector component */
10
11static inline void mpeg3video_calc_mv(int *pred, int r_size, int motion_code, int motion_r, int full_pel_vector)
12{
13 int lim = 16 << r_size;
14 int vec = full_pel_vector ? (*pred >> 1) : (*pred);
15
16 if(motion_code > 0)
17 {
18 vec += ((motion_code - 1) << r_size) + motion_r + 1;
19 if(vec >= lim) vec -= lim + lim;
20 }
21 else
22 if(motion_code < 0)
23 {
24 vec -= ((-motion_code - 1) << r_size) + motion_r + 1;
25 if(vec < -lim) vec += lim + lim;
26 }
27 *pred = full_pel_vector ? (vec << 1) : vec;
28}
29
30
31/*
32int *dmvector, * differential motion vector *
33int mvx, int mvy * decoded mv components (always in field format) *
34*/
35void mpeg3video_calc_dmv(mpeg3video_t *video,
36 int DMV[][2],
37 int *dmvector,
38 int mvx,
39 int mvy)
40{
41 if(video->pict_struct == FRAME_PICTURE)
42 {
43 if(video->topfirst)
44 {
45/* vector for prediction of top field from bottom field */
46 DMV[0][0] = ((mvx + (mvx>0)) >> 1) + dmvector[0];
47 DMV[0][1] = ((mvy + (mvy>0)) >> 1) + dmvector[1] - 1;
48
49/* vector for prediction of bottom field from top field */
50 DMV[1][0] = ((3 * mvx + (mvx > 0)) >> 1) + dmvector[0];
51 DMV[1][1] = ((3 * mvy + (mvy > 0)) >> 1) + dmvector[1] + 1;
52 }
53 else
54 {
55/* vector for prediction of top field from bottom field */
56 DMV[0][0] = ((3 * mvx + (mvx>0)) >> 1) + dmvector[0];
57 DMV[0][1] = ((3 * mvy + (mvy>0)) >> 1) + dmvector[1] - 1;
58
59/* vector for prediction of bottom field from top field */
60 DMV[1][0] = ((mvx + (mvx>0)) >> 1) + dmvector[0];
61 DMV[1][1] = ((mvy + (mvy>0)) >> 1) + dmvector[1] + 1;
62 }
63 }
64 else
65 {
66/* vector for prediction from field of opposite 'parity' */
67 DMV[0][0] = ((mvx + (mvx > 0)) >> 1) + dmvector[0];
68 DMV[0][1] = ((mvy + (mvy > 0)) >> 1) + dmvector[1];
69
70/* correct for vertical field shift */
71 if(video->pict_struct == TOP_FIELD)
72 DMV[0][1]--;
73 else
74 DMV[0][1]++;
75 }
76}
77
78static inline int mpeg3video_get_mv(mpeg3_slice_t *slice)
79{
80 int code;
81 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
82
83 if(mpeg3slice_getbit(slice_buffer))
84 {
85 return 0;
86 }
87
88 if((code = mpeg3slice_showbits9(slice_buffer)) >= 64)
89 {
90 code >>= 6;
91 mpeg3slice_flushbits(slice_buffer, mpeg3_MVtab0[code].len);
92 return mpeg3slice_getbit(slice_buffer) ? -mpeg3_MVtab0[code].val : mpeg3_MVtab0[code].val;
93 }
94
95 if(code >= 24)
96 {
97 code >>= 3;
98 mpeg3slice_flushbits(slice_buffer, mpeg3_MVtab1[code].len);
99 return mpeg3slice_getbit(slice_buffer) ? -mpeg3_MVtab1[code].val : mpeg3_MVtab1[code].val;
100 }
101
102 if((code -= 12) < 0)
103 {
104 /* fprintf(stdout,"mpeg3video_get_mv: invalid motion_vector code\n"); */
105 slice->fault = 1;
106 return 1;
107 }
108
109 mpeg3slice_flushbits(slice_buffer, mpeg3_MVtab2[code].len);
110 return mpeg3slice_getbit(slice_buffer) ? -mpeg3_MVtab2[code].val : mpeg3_MVtab2[code].val;
111}
112
113/* get differential motion vector (for dual prime prediction) */
114
115static inline int mpeg3video_get_dmv(mpeg3_slice_t *slice)
116{
117 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
118 if(mpeg3slice_getbit(slice_buffer))
119 {
120 return mpeg3slice_getbit(slice_buffer) ? -1 : 1;
121 }
122 else
123 {
124 return 0;
125 }
126}
127
128
129
130/* get and decode motion vector and differential motion vector */
131
132void mpeg3video_motion_vector(mpeg3_slice_t *slice,
133 mpeg3video_t *video,
134 int *PMV,
135 int *dmvector,
136 int h_r_size,
137 int v_r_size,
138 int dmv,
139 int mvscale,
140 int full_pel_vector)
141{
142 int motion_r;
143 int motion_code = mpeg3video_get_mv(slice);
144 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
145
146 if(slice->fault) return;
147 motion_r = (h_r_size != 0 && motion_code != 0) ? mpeg3slice_getbits(slice_buffer, h_r_size) : 0;
148
149 mpeg3video_calc_mv(&PMV[0], h_r_size, motion_code, motion_r, full_pel_vector);
150
151 if(dmv) dmvector[0] = mpeg3video_get_dmv(slice);
152
153 motion_code = mpeg3video_get_mv(slice);
154 if(slice->fault) return;
155 motion_r = (v_r_size != 0 && motion_code != 0) ? mpeg3slice_getbits(slice_buffer, v_r_size) : 0;
156
157/* DIV 2 */
158 if(mvscale) PMV[1] >>= 1;
159
160 mpeg3video_calc_mv(&PMV[1], v_r_size, motion_code, motion_r, full_pel_vector);
161
162 if(mvscale) PMV[1] <<= 1;
163 if(dmv) dmvector[1] = mpeg3video_get_dmv(slice);
164}
165
166int mpeg3video_motion_vectors(mpeg3_slice_t *slice,
167 mpeg3video_t *video,
168 int PMV[2][2][2],
169 int dmvector[2],
170 int mv_field_sel[2][2],
171 int s,
172 int mv_count,
173 int mv_format,
174 int h_r_size,
175 int v_r_size,
176 int dmv,
177 int mvscale)
178{
179 int result = 0;
180 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
181 if(mv_count == 1)
182 {
183 if(mv_format == MV_FIELD && !dmv)
184 {
185 mv_field_sel[1][s] = mv_field_sel[0][s] = mpeg3slice_getbit(slice_buffer);
186 }
187
188 mpeg3video_motion_vector(slice,
189 video,
190 PMV[0][s],
191 dmvector,
192 h_r_size,
193 v_r_size,
194 dmv,
195 mvscale,
196 0);
197 if(slice->fault) return 1;
198
199/* update other motion vector predictors */
200 PMV[1][s][0] = PMV[0][s][0];
201 PMV[1][s][1] = PMV[0][s][1];
202 }
203 else
204 {
205 mv_field_sel[0][s] = mpeg3slice_getbit(slice_buffer);
206 mpeg3video_motion_vector(slice,
207 video,
208 PMV[0][s],
209 dmvector,
210 h_r_size,
211 v_r_size,
212 dmv,
213 mvscale,
214 0);
215 if(slice->fault) return 1;
216
217 mv_field_sel[1][s] = mpeg3slice_getbit(slice_buffer);
218 mpeg3video_motion_vector(slice,
219 video,
220 PMV[1][s],
221 dmvector,
222 h_r_size,
223 v_r_size,
224 dmv,
225 mvscale,
226 0);
227 if(slice->fault) return 1;
228 }
229 return 0;
230}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.c b/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.c
new file mode 100644
index 0000000..a9f113e
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.c
@@ -0,0 +1,597 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include "mpeg3videoprotos.h"
5#include <stdlib.h>
6
7unsigned char mpeg3_zig_zag_scan_mmx[64] =
8{
9 0*8+0 /* 0*/, 1*8+0 /* 1*/, 0*8+1 /* 8*/, 0*8+2 /*16*/, 1*8+1 /* 9*/, 2*8+0 /* 2*/, 3*8+0 /* 3*/, 2*8+1 /*10*/,
10 1*8+2 /*17*/, 0*8+3 /*24*/, 0*8+4 /*32*/, 1*8+3 /*25*/, 2*8+2 /*18*/, 3*8+1 /*11*/, 4*8+0 /* 4*/, 5*8+0 /* 5*/,
11 4*8+1 /*12*/, 5*8+2 /*19*/, 2*8+3 /*26*/, 1*8+4 /*33*/, 0*8+5 /*40*/, 0*8+6 /*48*/, 1*8+5 /*41*/, 2*8+4 /*34*/,
12 3*8+3 /*27*/, 4*8+2 /*20*/, 5*8+1 /*13*/, 6*8+0 /* 6*/, 7*8+0 /* 7*/, 6*8+1 /*14*/, 5*8+2 /*21*/, 4*8+3 /*28*/,
13 3*8+4 /*35*/, 2*8+5 /*42*/, 1*8+6 /*49*/, 0*8+7 /*56*/, 1*8+7 /*57*/, 2*8+6 /*50*/, 3*8+5 /*43*/, 4*8+4 /*36*/,
14 5*8+3 /*29*/, 6*8+2 /*22*/, 7*8+1 /*15*/, 7*8+2 /*23*/, 6*8+3 /*30*/, 5*8+4 /*37*/, 4*8+5 /*44*/, 3*8+6 /*51*/,
15 2*8+7 /*58*/, 3*8+7 /*59*/, 4*8+6 /*52*/, 5*8+5 /*45*/, 6*8+4 /*38*/, 7*8+3 /*31*/, 7*8+4 /*39*/, 6*8+5 /*46*/,
16 7*8+6 /*53*/, 4*8+7 /*60*/, 5*8+7 /*61*/, 6*8+6 /*54*/, 7*8+5 /*47*/, 7*8+6 /*55*/, 6*8+7 /*62*/, 7*8+7 /*63*/
17};
18
19/* alternate scan */
20unsigned char mpeg3_alternate_scan_mmx[64] =
21{
22 0*8+0 /*0 */, 0*8+1 /* 8*/, 0*8+2 /*16*/, 0*8+3 /*24*/, 1*8+0 /* 1*/, 1*8+1 /* 9*/, 2*8+0 /* 2*/, 2*8+1 /*10*/,
23 1*8+2 /*17*/, 1*8+3 /*25*/, 0*8+4 /*32*/, 0*8+5 /*40*/, 0*8+6 /*48*/, 0*8+7 /*56*/, 1*8+7 /*57*/, 1*8+6 /*49*/,
24 1*8+5 /*41*/, 1*8+4 /*33*/, 2*8+3 /*26*/, 2*8+2 /*18*/, 3*8+0 /* 3*/, 3*8+1 /*11*/, 4*8+0 /* 4*/, 4*8+1 /*12*/,
25 3*8+2 /*19*/, 3*8+3 /*27*/, 2*8+4 /*34*/, 2*8+5 /*42*/, 2*8+6 /*50*/, 2*8+7 /*58*/, 3*8+4 /*35*/, 3*8+5 /*43*/,
26 3*8+6 /*51*/, 3*8+7 /*59*/, 4*8+2 /*20*/, 4*8+3 /*28*/, 5*8+0 /* 5*/, 5*8+1 /*13*/, 6*8+0 /* 6*/, 6*8+1 /*14*/,
27 5*8+2 /*21*/, 5*8+3 /*29*/, 4*8+4 /*36*/, 4*8+5 /*44*/, 4*8+6 /*52*/, 4*8+7 /*60*/, 5*8+4 /*37*/, 5*8+5 /*45*/,
28 5*8+6 /*53*/, 5*8+7 /*61*/, 6*8+2 /*22*/, 6*8+3 /*30*/, 7*8+0 /* 7*/, 7*8+1 /*15*/, 7*8+2 /*23*/, 7*8+3 /*31*/,
29 6*8+4 /*38*/, 6*8+5 /*46*/, 6*8+6 /*54*/, 6*8+7 /*62*/, 7*8+4 /*39*/, 7*8+5 /*47*/, 7*8+6 /*55*/, 7*8+6 /*63*/
30};
31
32
33
34/* zig-zag scan */
35unsigned char mpeg3_zig_zag_scan_nommx[64] =
36{
37 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5,
38 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28,
39 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
40 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
41};
42
43/* alternate scan */
44unsigned char mpeg3_alternate_scan_nommx[64] =
45{
46 0, 8, 16, 24, 1, 9, 2, 10, 17, 25, 32, 40, 48, 56, 57, 49,
47 41, 33, 26, 18, 3, 11, 4, 12, 19, 27, 34, 42, 50, 58, 35, 43,
48 51, 59, 20, 28, 5, 13, 6, 14, 21, 29, 36, 44, 52, 60, 37, 45,
49 53, 61, 22, 30, 7, 15, 23, 31, 38, 46, 54, 62, 39, 47, 55, 63
50};
51
52/* default intra quantization matrix */
53unsigned char mpeg3_default_intra_quantizer_matrix[64] =
54{
55 8, 16, 19, 22, 26, 27, 29, 34,
56 16, 16, 22, 24, 27, 29, 34, 37,
57 19, 22, 26, 27, 29, 34, 34, 38,
58 22, 22, 26, 27, 29, 34, 37, 40,
59 22, 26, 27, 29, 32, 35, 40, 48,
60 26, 27, 29, 32, 35, 40, 48, 58,
61 26, 27, 29, 34, 38, 46, 56, 69,
62 27, 29, 35, 38, 46, 56, 69, 83
63};
64
65unsigned char mpeg3_non_linear_mquant_table[32] =
66{
67 0, 1, 2, 3, 4, 5, 6, 7,
68 8, 10, 12, 14, 16, 18, 20, 22,
69 24, 28, 32, 36, 40, 44, 48, 52,
70 56, 64, 72, 80, 88, 96, 104, 112
71};
72
73double mpeg3_frame_rate_table[16] =
74{
75 0.0, /* Pad */
76 24000.0/1001.0, /* Official frame rates */
77 24.0,
78 25.0,
79 30000.0/1001.0,
80 30.0,
81 50.0,
82 ((60.0*1000.0)/1001.0),
83 60.0,
84
85 1, /* Unofficial economy rates */
86 5,
87 10,
88 12,
89 15,
90 0,
91 0,
92};
93
94int mpeg3video_initdecoder(mpeg3video_t *video)
95{
96 int blk_cnt_tab[3] = {6, 8, 12};
97 int cc;
98 int i;
99 long size[4], padding[2]; /* Size of Y, U, and V buffers */
100
101 if(!video->mpeg2)
102 {
103/* force MPEG-1 parameters */
104 video->prog_seq = 1;
105 video->prog_frame = 1;
106 video->pict_struct = FRAME_PICTURE;
107 video->frame_pred_dct = 1;
108 video->chroma_format = CHROMA420;
109 video->matrix_coefficients = 5;
110 }
111
112/* Get dimensions rounded to nearest multiple of coded macroblocks */
113 video->mb_width = (video->horizontal_size + 15) / 16;
114 video->mb_height = (video->mpeg2 && !video->prog_seq) ?
115 (2 * ((video->vertical_size + 31) / 32)) :
116 ((video->vertical_size + 15) / 16);
117 video->coded_picture_width = 16 * video->mb_width;
118 video->coded_picture_height = 16 * video->mb_height;
119 video->chrom_width = (video->chroma_format == CHROMA444) ?
120 video->coded_picture_width :
121 (video->coded_picture_width >> 1);
122 video->chrom_height = (video->chroma_format != CHROMA420) ?
123 video->coded_picture_height :
124 (video->coded_picture_height >> 1);
125 video->blk_cnt = blk_cnt_tab[video->chroma_format - 1];
126
127/* Get sizes of YUV buffers */
128 padding[0] = 16 * video->coded_picture_width;
129 size[0] = video->coded_picture_width * video->coded_picture_height + padding[0] * 2;
130
131 padding[1] = 16 * video->chrom_width;
132 size[1] = video->chrom_width * video->chrom_height + 2 * padding[1];
133
134 size[2] = (video->llw * video->llh);
135 size[3] = (video->llw * video->llh) / 4;
136
137/* Allocate contiguous fragments for YUV buffers for hardware YUV decoding */
138 video->yuv_buffer[0] = (unsigned char*)calloc(1, (size[0] + padding[0]) + 2 * (size[1] + padding[1]));
139 video->yuv_buffer[1] = (unsigned char*)calloc(1, (size[0] + padding[0]) + 2 * (size[1] + padding[1]));
140 video->yuv_buffer[2] = (unsigned char*)calloc(1, (size[0] + padding[0]) + 2 * (size[1] + padding[1]));
141
142 if(video->scalable_mode == SC_SPAT)
143 {
144 video->yuv_buffer[3] = (unsigned char*)calloc(1, size[2] + 2 * size[3]);
145 video->yuv_buffer[4] = (unsigned char*)calloc(1, size[2] + 2 * size[3]);
146 }
147
148 /* Direct pointers to areas of contiguous fragments in YVU order per Microsoft */
149 for(cc = 0; cc < 3; cc++)
150 {
151 video->llframe0[cc] = 0;
152 video->llframe1[cc] = 0;
153 video->newframe[cc] = 0;
154 }
155
156 video->refframe[0] = video->yuv_buffer[0];
157 video->oldrefframe[0] = video->yuv_buffer[1];
158 video->auxframe[0] = video->yuv_buffer[2];
159 video->refframe[2] = video->yuv_buffer[0] + size[0] + padding[0];
160 video->oldrefframe[2] = video->yuv_buffer[1] + size[0] + padding[0];
161 video->auxframe[2] = video->yuv_buffer[2] + size[0] + padding[0];
162 video->refframe[1] = video->yuv_buffer[0] + size[0] + padding[0] + size[1] + padding[1];
163 video->oldrefframe[1] = video->yuv_buffer[1] + size[0] + padding[0] + size[1] + padding[1];
164 video->auxframe[1] = video->yuv_buffer[2] + size[0] + padding[0] + size[1] + padding[1];
165
166 if(video->scalable_mode == SC_SPAT)
167 {
168/* this assumes lower layer is 4:2:0 */
169 video->llframe0[0] = video->yuv_buffer[3] + padding[0] ;
170 video->llframe1[0] = video->yuv_buffer[4] + padding[0] ;
171 video->llframe0[2] = video->yuv_buffer[3] + padding[1] + size[2] ;
172 video->llframe1[2] = video->yuv_buffer[4] + padding[1] + size[2] ;
173 video->llframe0[1] = video->yuv_buffer[3] + padding[1] + size[2] + size[3];
174 video->llframe1[1] = video->yuv_buffer[4] + padding[1] + size[2] + size[3];
175 }
176
177/* Initialize the YUV tables for software YUV decoding */
178 video->cr_to_r = (long*)malloc(sizeof(long) * 256);
179 video->cr_to_g = (long*)malloc(sizeof(long) * 256);
180 video->cb_to_g = (long*)malloc(sizeof(long) * 256);
181 video->cb_to_b = (long*)malloc(sizeof(long) * 256);
182 video->cr_to_r_ptr = video->cr_to_r + 128;
183 video->cr_to_g_ptr = video->cr_to_g + 128;
184 video->cb_to_g_ptr = video->cb_to_g + 128;
185 video->cb_to_b_ptr = video->cb_to_b + 128;
186
187 for(i = -128; i < 128; i++)
188 {
189 video->cr_to_r_ptr[i] = (long)( 1.371 * 65536 * i);
190 video->cr_to_g_ptr[i] = (long)(-0.698 * 65536 * i);
191 video->cb_to_g_ptr[i] = (long)(-0.336 * 65536 * i);
192 video->cb_to_b_ptr[i] = (long)( 1.732 * 65536 * i);
193 }
194
195 return 0;
196}
197
198int mpeg3video_deletedecoder(mpeg3video_t *video)
199{
200 int i, padding;
201
202 free(video->yuv_buffer[0]);
203 free(video->yuv_buffer[1]);
204 free(video->yuv_buffer[2]);
205
206 if(video->llframe0[0])
207 {
208 free(video->yuv_buffer[3]);
209 free(video->yuv_buffer[4]);
210 }
211
212 free(video->cr_to_r);
213 free(video->cr_to_g);
214 free(video->cb_to_g);
215 free(video->cb_to_b);
216 return 0;
217}
218
219void mpeg3video_init_scantables(mpeg3video_t *video)
220{
221#ifdef HAVE_MMX
222 if(video->have_mmx)
223 {
224 video->mpeg3_zigzag_scan_table = mpeg3_zig_zag_scan_mmx;
225 video->mpeg3_alternate_scan_table = mpeg3_alternate_scan_mmx;
226 }
227 else
228#endif
229 {
230 video->mpeg3_zigzag_scan_table = mpeg3_zig_zag_scan_nommx;
231 video->mpeg3_alternate_scan_table = mpeg3_alternate_scan_nommx;
232 }
233}
234
235mpeg3video_t* mpeg3video_allocate_struct(mpeg3_t *file, mpeg3_vtrack_t *track)
236{
237 int i;
238 mpeg3video_t *video = (mpeg3video_t*)calloc(1, sizeof(mpeg3video_t));
239 pthread_mutexattr_t mutex_attr;
240
241 video->file = file;
242 video->track = track;
243 video->vstream = mpeg3bits_new_stream(file, track->demuxer);
244 video->last_number = -1;
245
246/* First frame is all green */
247 video->framenum = -1;
248 video->have_mmx = file->have_mmx;
249
250 video->percentage_seek = -1;
251 video->frame_seek = -1;
252
253 mpeg3video_init_scantables(video);
254 mpeg3video_init_output();
255
256 pthread_mutexattr_init(&mutex_attr);
257 pthread_mutex_init(&(video->test_lock), &mutex_attr);
258 pthread_mutex_init(&(video->slice_lock), &mutex_attr);
259 return video;
260}
261
262int mpeg3video_delete_struct(mpeg3video_t *video)
263{
264 int i;
265 mpeg3bits_delete_stream(video->vstream);
266 pthread_mutex_destroy(&(video->test_lock));
267 pthread_mutex_destroy(&(video->slice_lock));
268 if(video->x_table)
269 {
270 free(video->x_table);
271 free(video->y_table);
272 }
273 if(video->total_slice_decoders)
274 {
275 for(i = 0; i < video->total_slice_decoders; i++)
276 mpeg3_delete_slice_decoder(&video->slice_decoders[i]);
277 }
278 for(i = 0; i < video->slice_buffers_initialized; i++)
279 mpeg3_delete_slice_buffer(&(video->slice_buffers[i]));
280
281 free(video);
282}
283
284
285int mpeg3video_read_frame_backend(mpeg3video_t *video, int skip_bframes)
286{
287 int result = 0;
288
289 if(mpeg3bits_eof(video->vstream)) result = 1;
290
291 if(!result) result = mpeg3video_get_header(video, 0);
292
293//printf("frame type %d\n", video->pict_type);
294/* skip_bframes is the number of bframes we can skip successfully. */
295/* This is in case a skipped B-frame is repeated and the second repeat happens */
296/* to be a B frame we need. */
297 video->skip_bframes = skip_bframes;
298
299 if(!result)
300 result = mpeg3video_getpicture(video, video->framenum);
301
302#ifdef HAVE_MMX
303 if(video->have_mmx)
304 __asm__ __volatile__ ("emms");
305#endif
306
307 if(!result)
308 {
309 video->last_number = video->framenum;
310 video->framenum++;
311 }
312 return result;
313}
314
315int* mpeg3video_get_scaletable(int input_w, int output_w)
316{
317 int *result = (int*)malloc(sizeof(int) * output_w);
318 float i;
319 float scale = (float)input_w / output_w;
320 for(i = 0; i < output_w; i++)
321 {
322 result[(int)i] = (int)(scale * i);
323 }
324 return result;
325}
326
327/* Get the first frame read. */
328int mpeg3video_get_firstframe(mpeg3video_t *video)
329{
330 int result = 0;
331 if(video->framenum < 0)
332 {
333 video->repeat_count = video->current_repeat = 0;
334 result = mpeg3video_read_frame_backend(video, 0);
335 mpeg3bits_seek_byte(video->vstream, 0);
336 mpeg3video_match_refframes(video);
337 }
338 return result;
339}
340
341
342/* ======================================================================= */
343/* ENTRY POINTS */
344/* ======================================================================= */
345
346
347
348mpeg3video_t* mpeg3video_new(mpeg3_t *file, mpeg3_vtrack_t *track)
349{
350 mpeg3video_t *video;
351 int result = 0;
352
353 video = mpeg3video_allocate_struct(file, track);
354 result = mpeg3video_get_header(video, 1);
355
356 if(!result)
357 {
358 int hour, minute, second, frame;
359 int gop_found;
360
361 mpeg3video_initdecoder(video);
362 video->decoder_initted = 1;
363 track->width = video->horizontal_size;
364 track->height = video->vertical_size;
365 track->frame_rate = video->frame_rate;
366
367/* Get the length of the file from an elementary stream */
368 if(file->is_video_stream)
369 {
370/* Load the first GOP */
371 mpeg3bits_seek_start(video->vstream);
372 result = mpeg3video_next_code(video->vstream, MPEG3_GOP_START_CODE);
373 if(!result) mpeg3bits_getbits(video->vstream, 32);
374 if(!result) result = mpeg3video_getgophdr(video);
375
376 hour = video->gop_timecode.hour;
377 minute = video->gop_timecode.minute;
378 second = video->gop_timecode.second;
379 frame = video->gop_timecode.frame;
380 video->first_frame = (long)(hour * 3600 * video->frame_rate +
381 minute * 60 * video->frame_rate +
382 second * video->frame_rate +
383 frame);
384
385/* GOPs always have 16 frames */
386 video->frames_per_gop = 16;
387
388/* Read the last GOP in the file by seeking backward. */
389 mpeg3bits_seek_end(video->vstream);
390 mpeg3bits_start_reverse(video->vstream);
391 result = mpeg3video_prev_code(video->vstream, MPEG3_GOP_START_CODE);
392 mpeg3bits_start_forward(video->vstream);
393 mpeg3bits_getbits(video->vstream, 8);
394 if(!result) result = mpeg3video_getgophdr(video);
395
396 hour = video->gop_timecode.hour;
397 minute = video->gop_timecode.minute;
398 second = video->gop_timecode.second;
399 frame = video->gop_timecode.frame;
400
401 video->last_frame = (long)(hour * 3600 * video->frame_rate +
402 minute * 60 * video->frame_rate +
403 second * video->frame_rate +
404 frame);
405
406/* Count number of frames to end */
407 while(!result)
408 {
409 result = mpeg3video_next_code(video->vstream, MPEG3_PICTURE_START_CODE);
410 if(!result)
411 {
412 mpeg3bits_getbyte_noptr(video->vstream);
413 video->last_frame++;
414 }
415 }
416
417 track->total_frames = video->last_frame - video->first_frame + 1;
418 mpeg3bits_seek_start(video->vstream);
419 }
420 else
421 {
422/* Gross approximation from a multiplexed file. */
423 video->first_frame = 0;
424 track->total_frames = video->last_frame =
425 (long)(mpeg3demux_length(video->vstream->demuxer) *
426 video->frame_rate);
427 video->first_frame = 0;
428 }
429
430 video->maxframe = track->total_frames;
431 mpeg3bits_seek_start(video->vstream);
432 }
433 else
434 {
435 mpeg3video_delete(video);
436 video = 0;
437 }
438
439 return video;
440}
441
442int mpeg3video_delete(mpeg3video_t *video)
443{
444 if(video->decoder_initted)
445 {
446 mpeg3video_deletedecoder(video);
447 }
448 mpeg3video_delete_struct(video);
449 return 0;
450}
451
452int mpeg3video_set_cpus(mpeg3video_t *video, int cpus)
453{
454 return 0;
455}
456
457int mpeg3video_set_mmx(mpeg3video_t *video, int use_mmx)
458{
459 video->have_mmx = use_mmx;
460 mpeg3video_init_scantables(video);
461 return 0;
462}
463
464int mpeg3video_seek_percentage(mpeg3video_t *video, double percentage)
465{
466 video->percentage_seek = percentage;
467 return 0;
468}
469
470int mpeg3video_previous_frame(mpeg3video_t *video)
471{
472 if(mpeg3bits_tell_percentage(video->vstream) <= 0) return 1;
473 mpeg3bits_start_reverse(video->vstream);
474 mpeg3video_prev_code(video->vstream, MPEG3_PICTURE_START_CODE);
475 mpeg3bits_getbits_reverse(video->vstream, 32);
476
477 if(mpeg3bits_bof(video->vstream)) mpeg3bits_seek_percentage(video->vstream, 0);
478 mpeg3bits_start_forward(video->vstream);
479 video->repeat_count = 0;
480 return 0;
481}
482
483int mpeg3video_seek_frame(mpeg3video_t *video, long frame)
484{
485 video->frame_seek = frame;
486 return 0;
487}
488
489/* Read all the way up to and including the next picture start code */
490int mpeg3video_read_raw(mpeg3video_t *video, unsigned char *output, long *size, long max_size)
491{
492 unsigned MPEG3_INT32 code = 0;
493 mpeg3_bits_t *vstream = video->vstream;
494
495 *size = 0;
496 while(code != MPEG3_PICTURE_START_CODE &&
497 code != MPEG3_SEQUENCE_END_CODE &&
498 *size < max_size &&
499 !mpeg3bits_eof(vstream))
500 {
501 code <<= 8;
502 *output = mpeg3bits_getbyte_noptr(vstream);
503 code |= *output++;
504 (*size)++;
505 }
506 return mpeg3bits_eof(vstream);
507}
508
509int mpeg3video_read_frame(mpeg3video_t *video,
510 long frame_number,
511 unsigned char **output_rows,
512 int in_x,
513 int in_y,
514 int in_w,
515 int in_h,
516 int out_w,
517 int out_h,
518 int color_model)
519{
520 int result = 0;
521
522 video->want_yvu = 0;
523 video->output_rows = output_rows;
524 video->color_model = color_model;
525
526/* Get scaling tables */
527 if(video->out_w != out_w || video->out_h != out_h ||
528 video->in_w != in_w || video->in_h != in_h ||
529 video->in_x != in_x || video->in_y != in_y)
530 {
531 if(video->x_table)
532 {
533 free(video->x_table);
534 free(video->y_table);
535 video->x_table = 0;
536 video->y_table = 0;
537 }
538 }
539
540 video->out_w = out_w;
541 video->out_h = out_h;
542 video->in_w = in_w;
543 video->in_h = in_h;
544 video->in_x = in_x;
545 video->in_y = in_y;
546
547 if(!video->x_table)
548 {
549 video->x_table = mpeg3video_get_scaletable(video->in_w, video->out_w);
550 video->y_table = mpeg3video_get_scaletable(video->in_h, video->out_h);
551 }
552
553 mpeg3video_get_firstframe(video);
554
555 if(!result) result = mpeg3video_seek(video);
556
557 if(!result) result = mpeg3video_read_frame_backend(video, 0);
558
559 if(video->output_src) mpeg3video_present_frame(video);
560
561 video->percentage_seek = -1;
562 return result;
563}
564
565int mpeg3video_read_yuvframe(mpeg3video_t *video,
566 long frame_number,
567 char *y_output,
568 char *u_output,
569 char *v_output,
570 int in_x,
571 int in_y,
572 int in_w,
573 int in_h)
574{
575 int result = 0;
576
577 video->want_yvu = 1;
578 video->y_output = y_output;
579 video->u_output = u_output;
580 video->v_output = v_output;
581 video->in_x = in_x;
582 video->in_y = in_y;
583 video->in_w = in_w;
584 video->in_h = in_h;
585
586 mpeg3video_get_firstframe(video);
587
588 if(!result) result = mpeg3video_seek(video);
589
590 if(!result) result = mpeg3video_read_frame_backend(video, 0);
591
592 if(video->output_src) mpeg3video_present_frame(video);
593
594 video->want_yvu = 0;
595 video->percentage_seek = -1;
596 return result;
597}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.h b/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.h
new file mode 100644
index 0000000..2db62b0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/mpeg3video.h
@@ -0,0 +1,180 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEGVIDEO_H
21#define MPEGVIDEO_H
22
23#include "../bitstream.h"
24#include "../mpeg3private.inc"
25#include "idct.h"
26#include "slice.h"
27#include "../timecode.h"
28
29/* zig-zag scan */
30extern unsigned char mpeg3_zig_zag_scan_nommx[64];
31extern unsigned char mpeg3_zig_zag_scan_mmx[64];
32
33/* alternate scan */
34extern unsigned char mpeg3_alternate_scan_nommx[64];
35extern unsigned char mpeg3_alternate_scan_mmx[64];
36
37/* default intra quantization matrix */
38extern unsigned char mpeg3_default_intra_quantizer_matrix[64];
39
40/* Frame rate table must agree with the one in the encoder */
41extern double mpeg3_frame_rate_table[16];
42
43/* non-linear quantization coefficient table */
44extern unsigned char mpeg3_non_linear_mquant_table[32];
45
46#define CHROMA420 1 /* chroma_format */
47#define CHROMA422 2
48#define CHROMA444 3
49
50#define TOP_FIELD 1 /* picture structure */
51#define BOTTOM_FIELD 2
52#define FRAME_PICTURE 3
53
54#define SEQ_ID 1 /* extension start code IDs */
55#define DISP_ID 2
56#define QUANT_ID 3
57#define SEQSCAL_ID 5
58#define PANSCAN_ID 7
59#define CODING_ID 8
60#define SPATSCAL_ID 9
61#define TEMPSCAL_ID 10
62
63#define ERROR (-1)
64
65#define SC_NONE 0 /* scalable_mode */
66#define SC_DP 1
67#define SC_SPAT 2
68#define SC_SNR 3
69#define SC_TEMP 4
70
71#define I_TYPE 1 /* picture coding type */
72#define P_TYPE 2
73#define B_TYPE 3
74#define D_TYPE 4
75
76 #define MB_INTRA 1 /* macroblock type */
77#define MB_PATTERN 2
78#define MB_BACKWARD 4
79#define MB_FORWARD 8
80#define MB_QUANT 16
81#define MB_WEIGHT 32
82#define MB_CLASS4 64
83
84#define MC_FIELD 1 /* motion_type */
85#define MC_FRAME 2
86#define MC_16X8 2
87#define MC_DMV 3
88
89#define MV_FIELD 0 /* mv_format */
90#define MV_FRAME 1
91
92#define CLIP(x) ((x) >= 0 ? ((x) < 255 ? (x) : 255) : 0)
93
94/* Statically allocate as little as possible so a fake video struct */
95/* can be used for reading the GOP headers. */
96
97struct mpeg3video_rec
98{
99 struct mpeg3_rec* file;
100 struct mpeg3_vtrack_rec* track;
101
102/* ================================= Seeking variables ========================= */
103 mpeg3_bits_t *vstream;
104 int decoder_initted;
105 unsigned char **output_rows; /* Output frame buffer supplied by user */
106 int in_x, in_y, in_w, in_h, out_w, out_h; /* Output dimensions */
107 int *x_table, *y_table; /* Location of every output pixel in the input */
108 int color_model;
109 int want_yvu; /* Want to return a YUV frame */
110 char *y_output, *u_output, *v_output; /* Output pointers for a YUV frame */
111
112 mpeg3_slice_t slice_decoders[MPEG3_MAX_CPUS]; /* One slice decoder for every CPU */
113 int total_slice_decoders; /* Total slice decoders in use */
114 mpeg3_slice_buffer_t slice_buffers[MPEG3_MAX_CPUS]; /* Buffers for holding the slice data */
115 int total_slice_buffers; /* Total buffers in the array to be decompressed */
116 int slice_buffers_initialized; /* Total buffers initialized in the array */
117 pthread_mutex_t slice_lock; /* Lock slice array while getting the next buffer */
118 pthread_mutex_t test_lock;
119
120 int blockreadsize;
121 long maxframe; /* Max value of frame num to read */
122 double percentage_seek; /* Perform a percentage seek before the next frame is read */
123 int frame_seek; /* Perform a frame seek before the next frame is read */
124 long framenum; /* Number of the next frame to be decoded */
125 long last_number; /* Last framenum rendered */
126 int found_seqhdr;
127 long bitrate;
128 mpeg3_timecode_t gop_timecode; /* Timecode for the last GOP header read. */
129
130/* These are only available from elementary streams. */
131 long frames_per_gop; /* Frames per GOP after the first GOP. */
132 long first_gop_frames; /* Frames in the first GOP. */
133 long first_frame; /* Number of first frame stored in timecode */
134 long last_frame; /* Last frame in file */
135
136/* ================================= Compression variables ===================== */
137/* Malloced frame buffers. 2 refframes are swapped in and out. */
138/* while only 1 auxframe is used. */
139 unsigned char *yuv_buffer[5]; /* Make YVU buffers contiguous for all frames */
140 unsigned char *oldrefframe[3], *refframe[3], *auxframe[3];
141 unsigned char *llframe0[3], *llframe1[3];
142 unsigned char *mpeg3_zigzag_scan_table;
143 unsigned char *mpeg3_alternate_scan_table;
144// Source for the next frame presentation
145 unsigned char **output_src;
146/* Pointers to frame buffers. */
147 unsigned char *newframe[3];
148 int horizontal_size, vertical_size, mb_width, mb_height;
149 int coded_picture_width, coded_picture_height;
150 int chroma_format, chrom_width, chrom_height, blk_cnt;
151 int pict_type;
152 int forw_r_size, back_r_size, full_forw, full_back;
153 int prog_seq, prog_frame;
154 int h_forw_r_size, v_forw_r_size, h_back_r_size, v_back_r_size;
155 int dc_prec, pict_struct, topfirst, frame_pred_dct, conceal_mv;
156 int intravlc;
157 int repeatfirst;
158 int repeat_count; /* Number of times to repeat the current frame * 100 since floating point is impossible in MMX */
159 int current_repeat; /* Number of times the current frame has been repeated * 100 */
160 int secondfield;
161 int skip_bframes;
162 int stwc_table_index, llw, llh, hm, hn, vm, vn;
163 int lltempref, llx0, lly0, llprog_frame, llfieldsel;
164 int matrix_coefficients;
165 int framerate_code;
166 float frame_rate;
167 long *cr_to_r, *cr_to_g, *cb_to_g, *cb_to_b;
168 long *cr_to_r_ptr, *cr_to_g_ptr, *cb_to_g_ptr, *cb_to_b_ptr;
169 int have_mmx;
170 int intra_quantizer_matrix[64], non_intra_quantizer_matrix[64];
171 int chroma_intra_quantizer_matrix[64], chroma_non_intra_quantizer_matrix[64];
172 int mpeg2;
173 int qscale_type, altscan; /* picture coding extension */
174 int pict_scal; /* picture spatial scalable extension */
175 int scalable_mode; /* sequence scalable extension */
176};
177
178typedef struct mpeg3video_rec mpeg3video_t;
179
180#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/mpeg3videoprotos.h b/core/multimedia/opieplayer/libmpeg3/video/mpeg3videoprotos.h
new file mode 100644
index 0000000..e48d6cd
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/mpeg3videoprotos.h
@@ -0,0 +1,26 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef MPEG3VIDEOPROTOS_H
21#define MPEG3VIDEOPROTOS_H
22
23void mpeg3video_idct_conversion(short* block);
24unsigned int mpeg3slice_showbits(mpeg3_slice_buffer_t *slice_buffer, int bits);
25
26#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/output.c b/core/multimedia/opieplayer/libmpeg3/video/output.c
new file mode 100644
index 0000000..919a0ff
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/output.c
@@ -0,0 +1,993 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include <string.h>
5
6static LONGLONG mpeg3_MMX_0 = 0L;
7static unsigned long mpeg3_MMX_10w[] = {0x00100010, 0x00100010}; /*dd 00010 0010h, 000100010h */
8static unsigned long mpeg3_MMX_80w[] = {0x00800080, 0x00800080}; /*dd 00080 0080h, 000800080h */
9
10static unsigned long mpeg3_MMX_00FFw[] = {0x00ff00ff, 0x00ff00ff}; /*dd 000FF 00FFh, 000FF00FFh */
11
12static unsigned short mpeg3_MMX_Ublucoeff[] = {0x81, 0x81, 0x81, 0x81}; /*dd 00081 0081h, 000810081h */
13static unsigned short mpeg3_MMX_Vredcoeff[] = {0x66, 0x66, 0x66, 0x66}; /*dd 00066 0066h, 000660066h */
14
15static unsigned short mpeg3_MMX_Ugrncoeff[] = {0xffe8, 0xffe8, 0xffe8, 0xffe8}; /*dd 0FFE7 FFE7h, 0FFE7FFE7h */
16static unsigned short mpeg3_MMX_Vgrncoeff[] = {0xffcd, 0xffcd, 0xffcd, 0xffcd}; /*dd 0FFCC FFCCh, 0FFCCFFCCh */
17
18static unsigned short mpeg3_MMX_Ycoeff[] = {0x4a, 0x4a, 0x4a, 0x4a}; /*dd 0004A 004Ah, 0004A004Ah */
19
20static unsigned short mpeg3_MMX_redmask[] = {0xf800, 0xf800, 0xf800, 0xf800}; /*dd 07c00 7c00h, 07c007c00h */
21
22static unsigned short mpeg3_MMX_grnmask[] = {0x7e0, 0x7e0, 0x7e0, 0x7e0}; /*dd 003e0 03e0h, 003e003e0h */
23
24static unsigned char mpeg3_601_to_rgb[256];
25
26/* Algorithm */
27 /* r = (int)(*y + 1.371 * (*cr - 128)); */
28 /* g = (int)(*y - 0.698 * (*cr - 128) - 0.336 * (*cb - 128)); */
29 /* b = (int)(*y + 1.732 * (*cb - 128)); */
30
31#ifdef HAVE_MMX
32inline void mpeg3video_rgb16_mmx(unsigned char *lum,
33 unsigned char *cr,
34 unsigned char *cb,
35 unsigned char *out,
36 int rows,
37 int cols,
38 int mod)
39{
40 unsigned short *row1;
41 int x;
42 unsigned char *y;
43 int col1;
44
45 row1 = (unsigned short *)out;
46 col1 = cols + mod;
47 mod += cols + mod;
48 mod *= 2;
49 y = lum + cols * rows;
50 x = 0;
51
52 __asm__ __volatile__(
53 ".align 8\n"
54 "1:\n"
55 "movd (%1), %%mm0\n" /* 4 Cb 0 0 0 0 u3 u2 u1 u0 */
56 "pxor %%mm7, %%mm7\n"
57 "movd (%0), %%mm1\n" /* 4 Cr 0 0 0 0 v3 v2 v1 v0 */
58 "punpcklbw %%mm7, %%mm0\n" /* 4 W cb 0 u3 0 u2 0 u1 0 u0 */
59 "punpcklbw %%mm7, %%mm1\n" /* 4 W cr 0 v3 0 v2 0 v1 0 v0 */
60
61 "psubw mpeg3_MMX_80w, %%mm0\n"
62 "psubw mpeg3_MMX_80w, %%mm1\n"
63 "movq %%mm0, %%mm2\n" /* Cb 0 u3 0 u2 0 u1 0 u0 */
64 "movq %%mm1, %%mm3\n" /* Cr */
65 "pmullw mpeg3_MMX_Ugrncoeff, %%mm2\n" /* Cb2green 0 R3 0 R2 0 R1 0 R0 */
66 "movq (%2), %%mm6\n" /* L1 l7 L6 L5 L4 L3 L2 L1 L0 */
67 "pmullw mpeg3_MMX_Ublucoeff, %%mm0\n" /* Cb2blue */
68 "pand mpeg3_MMX_00FFw, %%mm6\n" /* L1 00 L6 00 L4 00 L2 00 L0 */
69 "pmullw mpeg3_MMX_Vgrncoeff, %%mm3\n" /* Cr2green */
70 "movq (%2), %%mm7\n" /* L2 */
71 "pmullw mpeg3_MMX_Vredcoeff, %%mm1\n" /* Cr2red */
72 "psrlw $8, %%mm7\n" /* L2 00 L7 00 L5 00 L3 00 L1 */
73 "pmullw mpeg3_MMX_Ycoeff, %%mm6\n" /* lum1 */
74 "paddw %%mm3, %%mm2\n" /* Cb2green + Cr2green == green */
75 "pmullw mpeg3_MMX_Ycoeff, %%mm7\n" /* lum2 */
76
77 "movq %%mm6, %%mm4\n" /* lum1 */
78 "paddw %%mm0, %%mm6\n" /* lum1 +blue 00 B6 00 B4 00 B2 00 B0 */
79 "movq %%mm4, %%mm5\n" /* lum1 */
80 "paddw %%mm1, %%mm4\n" /* lum1 +red 00 R6 00 R4 00 R2 00 R0 */
81 "paddw %%mm2, %%mm5\n" /* lum1 +green 00 G6 00 G4 00 G2 00 G0 */
82 "psraw $6, %%mm4\n" /* R1 0 .. 64 */
83 "movq %%mm7, %%mm3\n" /* lum2 00 L7 00 L5 00 L3 00 L1 */
84 "psraw $6, %%mm5\n" /* G1 - .. + */
85 "paddw %%mm0, %%mm7\n" /* Lum2 +blue 00 B7 00 B5 00 B3 00 B1 */
86 "psraw $6, %%mm6\n" /* B1 0 .. 64 */
87 "packuswb %%mm4, %%mm4\n" /* R1 R1 */
88 "packuswb %%mm5, %%mm5\n" /* G1 G1 */
89 "packuswb %%mm6, %%mm6\n" /* B1 B1 */
90 "punpcklbw %%mm4, %%mm4\n"
91 "punpcklbw %%mm5, %%mm5\n"
92
93 "pand mpeg3_MMX_redmask, %%mm4\n"
94 "psllw $3, %%mm5\n" /* GREEN 1 */
95 "punpcklbw %%mm6, %%mm6\n"
96 "pand mpeg3_MMX_grnmask, %%mm5\n"
97 "pand mpeg3_MMX_redmask, %%mm6\n"
98 "por %%mm5, %%mm4\n" /* */
99 "psrlw $11, %%mm6\n" /* BLUE 1 */
100 "movq %%mm3, %%mm5\n" /* lum2 */
101 "paddw %%mm1, %%mm3\n" /* lum2 +red 00 R7 00 R5 00 R3 00 R1 */
102 "paddw %%mm2, %%mm5\n" /* lum2 +green 00 G7 00 G5 00 G3 00 G1 */
103 "psraw $6, %%mm3\n" /* R2 */
104 "por %%mm6, %%mm4\n" /* MM4 */
105 "psraw $6, %%mm5\n" /* G2 */
106 "movq (%2, %3), %%mm6\n" /* L3 */
107 "psraw $6, %%mm7\n"
108 "packuswb %%mm3, %%mm3\n"
109 "packuswb %%mm5, %%mm5\n"
110 "packuswb %%mm7, %%mm7\n"
111 "pand mpeg3_MMX_00FFw, %%mm6\n" /* L3 */
112 "punpcklbw %%mm3, %%mm3\n"
113 "punpcklbw %%mm5, %%mm5\n"
114 "pmullw mpeg3_MMX_Ycoeff, %%mm6\n" /* lum3 */
115 "punpcklbw %%mm7, %%mm7\n"
116 "psllw $3, %%mm5\n" /* GREEN 2 */
117 "pand mpeg3_MMX_redmask, %%mm7\n"
118 "pand mpeg3_MMX_redmask, %%mm3\n"
119 "psrlw $11, %%mm7\n" /* BLUE 2 */
120 "pand mpeg3_MMX_grnmask, %%mm5\n"
121 "por %%mm7, %%mm3\n"
122 "movq (%2,%3), %%mm7\n" /* L4 */
123 "por %%mm5, %%mm3\n" /* */
124 "psrlw $8, %%mm7\n" /* L4 */
125 "movq %%mm4, %%mm5\n"
126 "punpcklwd %%mm3, %%mm4\n"
127 "pmullw mpeg3_MMX_Ycoeff, %%mm7\n" /* lum4 */
128 "punpckhwd %%mm3, %%mm5\n"
129
130 "movq %%mm4, (%4)\n"
131 "movq %%mm5, 8(%4)\n"
132
133 "movq %%mm6, %%mm4\n" /* Lum3 */
134 "paddw %%mm0, %%mm6\n" /* Lum3 +blue */
135
136 "movq %%mm4, %%mm5\n" /* Lum3 */
137 "paddw %%mm1, %%mm4\n" /* Lum3 +red */
138 "paddw %%mm2, %%mm5\n" /* Lum3 +green */
139 "psraw $6, %%mm4\n"
140 "movq %%mm7, %%mm3\n"/* Lum4 */
141 "psraw $6, %%mm5\n"
142 "paddw %%mm0, %%mm7\n" /* Lum4 +blue */
143 "psraw $6, %%mm6\n" /* Lum3 +blue */
144 "movq %%mm3, %%mm0\n" /* Lum4 */
145 "packuswb %%mm4, %%mm4\n"
146 "paddw %%mm1, %%mm3\n" /* Lum4 +red */
147 "packuswb %%mm5, %%mm5\n"
148 "paddw %%mm2, %%mm0\n" /* Lum4 +green */
149 "packuswb %%mm6, %%mm6\n"
150 "punpcklbw %%mm4, %%mm4\n"
151 "punpcklbw %%mm5, %%mm5\n"
152 "punpcklbw %%mm6, %%mm6\n"
153 "psllw $3, %%mm5\n" /* GREEN 3 */
154 "pand mpeg3_MMX_redmask, %%mm4\n"
155 "psraw $6, %%mm3\n" /* psr 6 */
156 "psraw $6, %%mm0\n"
157 "pand mpeg3_MMX_redmask, %%mm6\n" /* BLUE */
158 "pand mpeg3_MMX_grnmask, %%mm5\n"
159 "psrlw $11, %%mm6\n" /* BLUE 3 */
160 "por %%mm5, %%mm4\n"
161 "psraw $6, %%mm7\n"
162 "por %%mm6, %%mm4\n"
163 "packuswb %%mm3, %%mm3\n"
164 "packuswb %%mm0, %%mm0\n"
165 "packuswb %%mm7, %%mm7\n"
166 "punpcklbw %%mm3, %%mm3\n"
167 "punpcklbw %%mm0, %%mm0\n"
168 "punpcklbw %%mm7, %%mm7\n"
169 "pand mpeg3_MMX_redmask, %%mm3\n"
170 "pand mpeg3_MMX_redmask, %%mm7\n" /* BLUE */
171 "psllw $3, %%mm0\n" /* GREEN 4 */
172 "psrlw $11, %%mm7\n"
173 "pand mpeg3_MMX_grnmask, %%mm0\n"
174 "por %%mm7, %%mm3\n"
175 "addl $8, %6\n"
176 "por %%mm0, %%mm3\n"
177
178 "movq %%mm4, %%mm5\n"
179
180 "punpcklwd %%mm3, %%mm4\n"
181 "punpckhwd %%mm3, %%mm5\n"
182
183 "movq %%mm4, (%4,%5,2)\n"
184 "movq %%mm5, 8(%4,%5,2)\n"
185
186 "addl $8, %2\n"
187 "addl $4, %0\n"
188 "addl $4, %1\n"
189 "cmpl %3, %6\n"
190 "leal 16(%4), %4\n"
191 "jl 1b\n"
192 "addl %3, %2\n" /* lum += cols */
193 "addl %7, %4\n" /* row1 += mod */
194 "movl $0, %6\n"
195 "cmpl %8, %2\n"
196 "jl 1b\n"
197 : : "r" (cr),
198 "r" (cb),
199 "r" (lum),
200 "r" (cols),
201 "r" (row1) ,
202 "r" (col1),
203 "m" (x),
204 "m" (mod),
205 "m" (y)
206 );
207}
208
209static unsigned LONGLONG mpeg3_MMX_U_80 = 0x0000008000800000LL;
210static unsigned LONGLONG mpeg3_MMX_V_80 = 0x0000000000800080LL;
211static LONGLONG mpeg3_MMX_U_COEF = 0x00000058ffd30000LL;
212static LONGLONG mpeg3_MMX_V_COEF = 0x00000000ffea006fLL;
213static LONGLONG mpeg3_MMX_601_Y_COEF = 0x0000004800480048LL;
214static LONGLONG mpeg3_MMX_601_Y_DIFF = 0x0000000000000010LL;
215
216inline void mpeg3_bgra32_mmx(unsigned long y,
217 unsigned long u,
218 unsigned long v,
219 unsigned long *output)
220{
221asm("
222/* Output will be 0x00rrggbb with the 00 trailing so this can also be used */
223/* for bgr24. */
224 movd (%0), %%mm0; /* Load y 0x00000000000000yy */
225 movd (%1), %%mm1; /* Load u 0x00000000000000cr */
226 movq %%mm0, %%mm3; /* Copy y to temp */
227 psllq $16, %%mm1; /* Shift u 0x0000000000cr0000 */
228 movd (%2), %%mm2; /* Load v 0x00000000000000cb */
229 psllq $16, %%mm3; /* Shift y */
230 movq %%mm1, %%mm4; /* Copy u to temp */
231 por %%mm3, %%mm0; /* Overlay new y byte 0x0000000000yy00yy */
232 psllq $16, %%mm4; /* Shift u */
233 movq %%mm2, %%mm5; /* Copy v to temp */
234 psllq $16, %%mm3; /* Shift y */
235 por %%mm4, %%mm1; /* Overlay new u byte 0x000000cr00cr0000 */
236 psllq $16, %%mm5; /* Shift v */
237 por %%mm3, %%mm0; /* Overlay new y byte 0x000000yy00yy00yy */
238 por %%mm5, %%mm2; /* Overlay new v byte 0x0000000000cb00cb */
239
240/* mm0: 0x000000yy00yy00yy mm1: 0x000000uu00uu0000 mm2: 0x0000000000vv00vv */
241 psubw mpeg3_MMX_U_80, %%mm1; /* Subtract 128 from u 0x000000uu00uu0000 */
242 pmullw mpeg3_MMX_U_COEF, %%mm1; /* Multiply u coeffs 0x0000uuuuuuuu0000 */
243 psllw $6, %%mm0; /* Shift y coeffs 0x0000yyy0yyy0yyy0 */
244 psubw mpeg3_MMX_V_80, %%mm2; /* Subtract 128 from v 0x0000000000cb00cb */
245 pmullw mpeg3_MMX_V_COEF, %%mm2; /* Multiply v coeffs 0x0000crcrcrcrcrcr */
246
247/* mm0: 0x000000yy00yy00yy mm1: 0x0000uuuuuuuu0000 mm2: 0x00000000vvvvvvvv */
248 paddsw %%mm1, %%mm0; /* Add u to result */
249 paddsw %%mm2, %%mm0; /* Add v to result 0x0000rrrrggggbbbb */
250 psraw $6, %%mm0; /* Demote precision */
251 packuswb %%mm0, %%mm0; /* Pack into ARGB 0x0000000000rrggbb */
252 movd %%mm0, (%3); /* Store output */
253 "
254:
255: "r" (&y), "r" (&u), "r" (&v), "r" (output));
256}
257
258inline void mpeg3_601_bgra32_mmx(unsigned long y,
259 unsigned long u,
260 unsigned long v,
261 unsigned long *output)
262{
263asm("
264/* Output will be 0x00rrggbb with the 00 trailing so this can also be used */
265/* for bgr24. */
266 movd (%0), %%mm0; /* Load y 0x00000000000000yy */
267 psubsw mpeg3_MMX_601_Y_DIFF, %%mm0; /* Subtract 16 from y */
268 movd (%1), %%mm1; /* Load u 0x00000000000000cr */
269 movq %%mm0, %%mm3; /* Copy y to temp */
270 psllq $16, %%mm1; /* Shift u 0x0000000000cr0000 */
271 movd (%2), %%mm2; /* Load v 0x00000000000000cb */
272 psllq $16, %%mm3; /* Shift y */
273 movq %%mm1, %%mm4; /* Copy u to temp */
274 por %%mm3, %%mm0; /* Overlay new y byte 0x0000000000yy00yy */
275 psllq $16, %%mm4; /* Shift u */
276 movq %%mm2, %%mm5; /* Copy v to temp */
277 psllq $16, %%mm3; /* Shift y */
278 por %%mm4, %%mm1; /* Overlay new u byte 0x000000cr00cr0000 */
279 psllq $16, %%mm5; /* Shift v */
280 por %%mm3, %%mm0; /* Overlay new y byte 0x000000yy00yy00yy */
281 por %%mm5, %%mm2; /* Overlay new v byte 0x0000000000cb00cb */
282
283/* mm0: 0x000000yy00yy00yy mm1: 0x000000uu00uu0000 mm2: 0x0000000000vv00vv */
284 pmullw mpeg3_MMX_601_Y_COEF, %%mm0; /* Scale and shift y coeffs */
285 psubw mpeg3_MMX_U_80, %%mm1; /* Subtract 128 from u 0x000000uu00uu0000 */
286 pmullw mpeg3_MMX_U_COEF, %%mm1; /* Multiply u coeffs 0x0000uuuuuuuu0000 */
287 psubw mpeg3_MMX_V_80, %%mm2; /* Subtract 128 from v 0x0000000000cb00cb */
288 pmullw mpeg3_MMX_V_COEF, %%mm2; /* Multiply v coeffs 0x0000crcrcrcrcrcr */
289
290/* mm0: 0x000000yy00yy00yy mm1: 0x0000uuuuuuuu0000 mm2: 0x00000000vvvvvvvv */
291 paddsw %%mm1, %%mm0; /* Add u to result */
292 paddsw %%mm2, %%mm0; /* Add v to result 0x0000rrrrggggbbbb */
293 psraw $6, %%mm0; /* Demote precision */
294 packuswb %%mm0, %%mm0; /* Pack into ARGB 0x0000000000rrggbb */
295 movd %%mm0, (%3); /* Store output */
296 "
297:
298: "r" (&y), "r" (&u), "r" (&v), "r" (output));
299}
300
301static unsigned LONGLONG mpeg3_MMX_U_80_RGB = 0x0000000000800080LL;
302static unsigned LONGLONG mpeg3_MMX_V_80_RGB = 0x0000008000800000LL;
303static LONGLONG mpeg3_MMX_U_COEF_RGB = 0x00000000ffd30058LL;
304static LONGLONG mpeg3_MMX_V_COEF_RGB = 0x0000006fffea0000LL;
305
306inline void mpeg3_rgba32_mmx(unsigned long y,
307 unsigned long u,
308 unsigned long v,
309 unsigned long *output)
310{
311asm("
312/* Output will be 0x00bbggrr with the 00 trailing so this can also be used */
313/* for rgb24. */
314 movd (%0), %%mm0; /* Load y 0x00000000000000yy */
315 movd (%1), %%mm1; /* Load v 0x00000000000000vv */
316 movq %%mm0, %%mm3; /* Copy y to temp */
317 psllq $16, %%mm1; /* Shift v 0x0000000000vv0000 */
318 movd (%2), %%mm2; /* Load u 0x00000000000000uu */
319 psllq $16, %%mm3; /* Shift y */
320 movq %%mm1, %%mm4; /* Copy v to temp */
321 por %%mm3, %%mm0; /* Overlay new y byte 0x0000000000yy00yy */
322 psllq $16, %%mm4; /* Shift v */
323 movq %%mm2, %%mm5; /* Copy u to temp */
324 psllq $16, %%mm3; /* Shift y */
325 por %%mm4, %%mm1; /* Overlay new v byte 0x000000vv00vv0000 */
326 psllq $16, %%mm5; /* Shift u */
327 por %%mm3, %%mm0; /* Overlay new y byte 0x000000yy00yy00yy */
328 por %%mm5, %%mm2; /* Overlay new u byte 0x0000000000uu00uu */
329
330/* mm0: 0x000000yy00yy00yy mm1: 0x000000vv00vv0000 mm2: 0x0000000000uu00uu */
331 psubw mpeg3_MMX_V_80_RGB, %%mm1; /* Subtract 128 from v 0x000000vv00vv0000 */
332 pmullw mpeg3_MMX_V_COEF_RGB, %%mm1; /* Multiply v coeffs 0x0000vvvvvvvv0000 */
333 psllw $6, %%mm0; /* Shift y coeffs 0x0000yyy0yyy0yyy0 */
334 psubw mpeg3_MMX_U_80_RGB, %%mm2; /* Subtract 128 from u 0x0000000000uu00uu */
335 pmullw mpeg3_MMX_U_COEF_RGB, %%mm2; /* Multiply u coeffs 0x0000uuuuuuuuuuuu */
336
337/* mm0: 0x000000yy00yy00yy mm1: 0x0000vvvvvvvv0000 mm2: 0x00000000uuuuuuuu */
338 paddsw %%mm1, %%mm0; /* Add v to result */
339 paddsw %%mm2, %%mm0; /* Add u to result 0x0000bbbbggggrrrr */
340 psraw $6, %%mm0; /* Demote precision */
341 packuswb %%mm0, %%mm0; /* Pack into RGBA 0x0000000000bbggrr */
342 movd %%mm0, (%3); /* Store output */
343 "
344:
345: "r" (&y), "r" (&v), "r" (&u), "r" (output));
346}
347
348inline void mpeg3_601_rgba32_mmx(unsigned long y,
349 unsigned long u,
350 unsigned long v,
351 unsigned long *output)
352{
353asm("
354/* Output will be 0x00bbggrr with the 00 trailing so this can also be used */
355/* for rgb24. */
356 movd (%0), %%mm0; /* Load y 0x00000000000000yy */
357 psubsw mpeg3_MMX_601_Y_DIFF, %%mm0; /* Subtract 16 from y */
358 movd (%1), %%mm1; /* Load v 0x00000000000000vv */
359 movq %%mm0, %%mm3; /* Copy y to temp */
360 psllq $16, %%mm1; /* Shift v 0x0000000000vv0000 */
361 movd (%2), %%mm2; /* Load u 0x00000000000000uu */
362 psllq $16, %%mm3; /* Shift y */
363 movq %%mm1, %%mm4; /* Copy v to temp */
364 por %%mm3, %%mm0; /* Overlay new y byte 0x0000000000yy00yy */
365 psllq $16, %%mm4; /* Shift v */
366 movq %%mm2, %%mm5; /* Copy u to temp */
367 psllq $16, %%mm3; /* Shift y */
368 por %%mm4, %%mm1; /* Overlay new v byte 0x000000vv00vv0000 */
369 psllq $16, %%mm5; /* Shift u */
370 por %%mm3, %%mm0; /* Overlay new y byte 0x000000yy00yy00yy */
371 por %%mm5, %%mm2; /* Overlay new u byte 0x0000000000uu00uu */
372
373/* mm0: 0x000000yy00yy00yy mm1: 0x000000vv00vv0000 mm2: 0x0000000000uu00uu */
374 pmullw mpeg3_MMX_601_Y_COEF, %%mm0; /* Scale y coeffs */
375 psubw mpeg3_MMX_V_80_RGB, %%mm1; /* Subtract 128 from v 0x000000vv00vv0000 */
376 pmullw mpeg3_MMX_V_COEF_RGB, %%mm1; /* Multiply v coeffs 0x0000vvvvvvvv0000 */
377 psubw mpeg3_MMX_U_80_RGB, %%mm2; /* Subtract 128 from u 0x0000000000uu00uu */
378 pmullw mpeg3_MMX_U_COEF_RGB, %%mm2; /* Multiply u coeffs 0x0000uuuuuuuuuuuu */
379
380/* mm0: 0x000000yy00yy00yy mm1: 0x0000vvvvvvvv0000 mm2: 0x00000000uuuuuuuu */
381 paddsw %%mm1, %%mm0; /* Add v to result */
382 paddsw %%mm2, %%mm0; /* Add u to result 0x0000bbbbggggrrrr */
383 psraw $6, %%mm0; /* Demote precision */
384 packuswb %%mm0, %%mm0; /* Pack into RGBA 0x0000000000bbggrr */
385 movd %%mm0, (%3); /* Store output */
386 "
387:
388: "r" (&y), "r" (&v), "r" (&u), "r" (output));
389}
390
391#endif
392
393#define DITHER_ROW_HEAD \
394 for(h = 0; h < video->out_h; h++) \
395 { \
396 y_in = &src[0][(video->y_table[h] + video->in_y) * video->coded_picture_width] + video->in_x; \
397 cb_in = &src[1][((video->y_table[h] + video->in_y) >> 1) * video->chrom_width] + (video->in_x >> 2); \
398 cr_in = &src[2][((video->y_table[h] + video->in_y) >> 1) * video->chrom_width] + (video->in_x >> 1); \
399 data = output_rows[h];
400
401#define DITHER_ROW_TAIL \
402 }
403
404#define DITHER_SCALE_HEAD \
405 for(w = 0; w < video->out_w; w++) \
406 { \
407 uv_subscript = video->x_table[w] / 2; \
408 y_l = y_in[video->x_table[w]]; \
409 y_l <<= 16; \
410 r_l = (y_l + video->cr_to_r[cr_in[uv_subscript]]) >> 16; \
411 g_l = (y_l + video->cr_to_g[cr_in[uv_subscript]] + video->cb_to_g[cb_in[uv_subscript]]) >> 16; \
412 b_l = (y_l + video->cb_to_b[cb_in[uv_subscript]]) >> 16;
413
414#define DITHER_SCALE_601_HEAD \
415 for(w = 0; w < video->out_w; w++) \
416 { \
417 uv_subscript = video->x_table[w] / 2; \
418 y_l = mpeg3_601_to_rgb[y_in[video->x_table[w]]]; \
419 y_l <<= 16; \
420 r_l = (y_l + video->cr_to_r[cr_in[uv_subscript]]) >> 16; \
421 g_l = (y_l + video->cr_to_g[cr_in[uv_subscript]] + video->cb_to_g[cb_in[uv_subscript]]) >> 16; \
422 b_l = (y_l + video->cb_to_b[cb_in[uv_subscript]]) >> 16;
423
424#define DITHER_SCALE_TAIL \
425 }
426
427#define DITHER_MMX_SCALE_HEAD \
428 for(w = 0; w < video->out_w; w++) \
429 { \
430 uv_subscript = video->x_table[w] / 2;
431
432#define DITHER_MMX_SCALE_TAIL \
433 data += step; \
434 }
435
436#define DITHER_MMX_HEAD \
437 for(w = 0; w < video->out_w; w += 2) \
438 {
439
440#define DITHER_MMX_TAIL \
441 data += step; \
442 cr_in++; \
443 cb_in++; \
444 }
445
446#define DITHER_HEAD \
447 for(w = 0; w < video->horizontal_size; w++) \
448 { \
449 y_l = *y_in++; \
450 y_l <<= 16; \
451 r_l = (y_l + video->cr_to_r[*cr_in]) >> 16; \
452 g_l = (y_l + video->cr_to_g[*cr_in] + video->cb_to_g[*cb_in]) >> 16; \
453 b_l = (y_l + video->cb_to_b[*cb_in]) >> 16;
454
455#define DITHER_601_HEAD \
456 for(w = 0; w < video->horizontal_size; w++) \
457 { \
458 y_l = mpeg3_601_to_rgb[*y_in++]; \
459 y_l <<= 16; \
460 r_l = (y_l + video->cr_to_r[*cr_in]) >> 16; \
461 g_l = (y_l + video->cr_to_g[*cr_in] + video->cb_to_g[*cb_in]) >> 16; \
462 b_l = (y_l + video->cb_to_b[*cb_in]) >> 16;
463
464#define DITHER_TAIL \
465 if(w & 1) \
466 { \
467 cr_in++; \
468 cb_in++; \
469 } \
470 }
471
472
473#define STORE_PIXEL_BGR888 \
474 *data++ = CLIP(b_l); \
475 *data++ = CLIP(g_l); \
476 *data++ = CLIP(r_l);
477
478#define STORE_PIXEL_BGRA8888 \
479 *data++ = CLIP(b_l); \
480 *data++ = CLIP(g_l); \
481 *data++ = CLIP(r_l); \
482 *data++ = 0;
483
484#define STORE_PIXEL_RGB565 \
485 *((unsigned short*)data)++ = \
486 ((CLIP(r_l) & 0xf8) << 8) | \
487 ((CLIP(g_l) & 0xfc) << 3) | \
488 ((CLIP(b_l) & 0xf8) >> 3);
489
490#define STORE_PIXEL_RGB888 \
491 *data++ = CLIP(r_l); \
492 *data++ = CLIP(g_l); \
493 *data++ = CLIP(b_l);
494
495#define STORE_PIXEL_RGBA8888 \
496 *data++ = CLIP(r_l); \
497 *data++ = CLIP(g_l); \
498 *data++ = CLIP(b_l); \
499 *data++ = 0;
500
501#define STORE_PIXEL_RGBA16161616 \
502 *data_s++ = CLIP(r_l); \
503 *data_s++ = CLIP(g_l); \
504 *data_s++ = CLIP(b_l); \
505 *data_s++ = 0;
506
507
508
509/* Only good for YUV 4:2:0 */
510int mpeg3video_ditherframe(mpeg3video_t *video, unsigned char **src, unsigned char **output_rows)
511{
512 int h = 0;
513 register unsigned char *y_in, *cb_in, *cr_in;
514 long y_l, r_l, b_l, g_l;
515 register unsigned char *data;
516 register int uv_subscript, step, w = -1;
517
518#ifdef HAVE_MMX
519/* =================================== MMX ===================================== */
520 if(video->have_mmx &&
521 video->out_w == video->horizontal_size &&
522 video->out_h == video->vertical_size &&
523 video->in_w == video->out_w &&
524 video->in_h == video->out_h &&
525 video->in_x == 0 &&
526 video->in_y == 0 &&
527 (video->color_model == MPEG3_RGB565 || video->color_model == MPEG3_601_RGB565))
528 {
529/* Unscaled 16 bit */
530 mpeg3video_rgb16_mmx(src[0],
531 src[2],
532 src[1],
533 output_rows[0],
534 video->out_h,
535 video->out_w,
536 (output_rows[1] - output_rows[0]) / 2 - video->out_w);
537 }
538 else
539 if(video->have_mmx &&
540 (video->color_model == MPEG3_BGRA8888 ||
541 video->color_model == MPEG3_BGR888 ||
542 /* video->color_model == MPEG3_RGB888 || */
543 video->color_model == MPEG3_RGBA8888 ||
544 video->color_model == MPEG3_601_BGR888 ||
545 video->color_model == MPEG3_601_BGRA8888 ||
546 video->color_model == MPEG3_601_RGB888 ||
547 video->color_model == MPEG3_601_RGBA8888))
548 {
549/* Original MMX */
550 if(video->color_model == MPEG3_BGRA8888 ||
551 video->color_model == MPEG3_RGBA8888 ||
552 video->color_model == MPEG3_601_BGRA8888 ||
553 video->color_model == MPEG3_601_RGBA8888) step = 4;
554 else
555 if(video->color_model == MPEG3_BGR888 ||
556 video->color_model == MPEG3_RGB888 ||
557 video->color_model == MPEG3_601_BGR888 ||
558 video->color_model == MPEG3_601_RGB888) step = 3;
559
560 DITHER_ROW_HEAD
561/* Transfer row with scaling */
562 if(video->out_w != video->horizontal_size)
563 {
564 switch(video->color_model)
565 {
566 case MPEG3_BGRA8888:
567 case MPEG3_BGR888:
568 DITHER_MMX_SCALE_HEAD
569 mpeg3_bgra32_mmx(y_in[video->x_table[w]],
570 cr_in[uv_subscript],
571 cb_in[uv_subscript],
572 (unsigned long*)data);
573 DITHER_MMX_SCALE_TAIL
574 break;
575
576 case MPEG3_601_BGRA8888:
577 case MPEG3_601_BGR888:
578 DITHER_MMX_SCALE_HEAD
579 mpeg3_601_bgra32_mmx(y_in[video->x_table[w]],
580 cr_in[uv_subscript],
581 cb_in[uv_subscript],
582 (unsigned long*)data);
583 DITHER_MMX_SCALE_TAIL
584 break;
585
586 case MPEG3_RGBA8888:
587 case MPEG3_RGB888:
588 DITHER_MMX_SCALE_HEAD
589 mpeg3_rgba32_mmx(y_in[video->x_table[w]],
590 cr_in[uv_subscript],
591 cb_in[uv_subscript],
592 (unsigned long*)data);
593 DITHER_MMX_SCALE_TAIL
594 break;
595
596 case MPEG3_601_RGBA8888:
597 case MPEG3_601_RGB888:
598 DITHER_MMX_SCALE_HEAD
599 mpeg3_601_rgba32_mmx(y_in[video->x_table[w]],
600 cr_in[uv_subscript],
601 cb_in[uv_subscript],
602 (unsigned long*)data);
603 DITHER_MMX_SCALE_TAIL
604 break;
605 }
606 }
607 else
608/* Transfer row unscaled */
609 {
610 switch(video->color_model)
611 {
612/* MMX byte swap 24 and 32 bit */
613 case MPEG3_BGRA8888:
614 case MPEG3_BGR888:
615 DITHER_MMX_HEAD
616 mpeg3_bgra32_mmx(*y_in++,
617 *cr_in,
618 *cb_in,
619 (unsigned long*)data);
620 data += step;
621 mpeg3_bgra32_mmx(*y_in++,
622 *cr_in,
623 *cb_in,
624 (unsigned long*)data);
625 DITHER_MMX_TAIL
626 break;
627
628/* MMX 601 byte swap 24 and 32 bit */
629 case MPEG3_601_BGRA8888:
630 case MPEG3_601_BGR888:
631 DITHER_MMX_HEAD
632 mpeg3_601_bgra32_mmx(*y_in++,
633 *cr_in,
634 *cb_in,
635 (unsigned long*)data);
636 data += step;
637 mpeg3_601_bgra32_mmx(*y_in++,
638 *cr_in,
639 *cb_in,
640 (unsigned long*)data);
641 DITHER_MMX_TAIL
642 break;
643
644/* MMX 24 and 32 bit no byte swap */
645 case MPEG3_RGBA8888:
646 case MPEG3_RGB888:
647 DITHER_MMX_HEAD
648 mpeg3_rgba32_mmx(*y_in++,
649 *cr_in,
650 *cb_in,
651 (unsigned long*)data);
652 data += step;
653 mpeg3_rgba32_mmx(*y_in++,
654 *cr_in,
655 *cb_in,
656 (unsigned long*)data);
657 DITHER_MMX_TAIL
658 break;
659
660/* MMX 601 24 and 32 bit no byte swap */
661 case MPEG3_601_RGBA8888:
662 case MPEG3_601_RGB888:
663 DITHER_MMX_HEAD
664 mpeg3_601_rgba32_mmx(*y_in++,
665 *cr_in,
666 *cb_in,
667 (unsigned long*)data);
668 data += step;
669 mpeg3_601_rgba32_mmx(*y_in++,
670 *cr_in,
671 *cb_in,
672 (unsigned long*)data);
673 DITHER_MMX_TAIL
674 break;
675 }
676 }
677 DITHER_ROW_TAIL
678 }
679 else
680#endif
681/* ================================== NO MMX ==================================== */
682 {
683 DITHER_ROW_HEAD
684/* Transfer row with scaling */
685 if(video->out_w != video->horizontal_size)
686 {
687 switch(video->color_model)
688 {
689 case MPEG3_BGR888:
690 DITHER_SCALE_HEAD
691 STORE_PIXEL_BGR888
692 DITHER_SCALE_TAIL
693 break;
694 case MPEG3_BGRA8888:
695 DITHER_SCALE_HEAD
696 STORE_PIXEL_BGRA8888
697 DITHER_SCALE_TAIL
698 break;
699 case MPEG3_RGB565:
700 DITHER_SCALE_HEAD
701 STORE_PIXEL_RGB565
702 DITHER_SCALE_TAIL
703 break;
704 case MPEG3_RGB888:
705 DITHER_SCALE_HEAD
706 STORE_PIXEL_RGB888
707 DITHER_SCALE_TAIL
708 break;
709 case MPEG3_RGBA8888:
710 DITHER_SCALE_HEAD
711 STORE_PIXEL_RGBA8888
712 DITHER_SCALE_TAIL
713 break;
714 case MPEG3_601_BGR888:
715 DITHER_SCALE_601_HEAD
716 STORE_PIXEL_BGR888
717 DITHER_SCALE_TAIL
718 break;
719 case MPEG3_601_BGRA8888:
720 DITHER_SCALE_601_HEAD
721 STORE_PIXEL_BGRA8888
722 DITHER_SCALE_TAIL
723 break;
724 case MPEG3_601_RGB565:
725 DITHER_SCALE_601_HEAD
726 STORE_PIXEL_RGB565
727 DITHER_SCALE_TAIL
728 break;
729 case MPEG3_601_RGB888:
730 DITHER_SCALE_601_HEAD
731 STORE_PIXEL_RGB888
732 DITHER_SCALE_TAIL
733 break;
734 case MPEG3_601_RGBA8888:
735 DITHER_SCALE_601_HEAD
736 STORE_PIXEL_RGBA8888
737 DITHER_SCALE_TAIL
738 break;
739 case MPEG3_RGBA16161616:
740 {
741 register unsigned short *data_s = (unsigned short*)data;
742 DITHER_SCALE_HEAD
743 STORE_PIXEL_RGBA16161616
744 DITHER_SCALE_TAIL
745 }
746 break;
747 }
748 }
749 else
750 {
751/* Transfer row unscaled */
752 switch(video->color_model)
753 {
754 case MPEG3_BGR888:
755 DITHER_HEAD
756 STORE_PIXEL_BGR888
757 DITHER_TAIL
758 break;
759 case MPEG3_BGRA8888:
760 DITHER_HEAD
761 STORE_PIXEL_BGRA8888
762 DITHER_TAIL
763 break;
764 case MPEG3_RGB565:
765 DITHER_HEAD
766 STORE_PIXEL_RGB565
767 DITHER_TAIL
768 break;
769 case MPEG3_RGB888:
770 DITHER_HEAD
771 STORE_PIXEL_RGB888
772 DITHER_TAIL
773 break;
774 case MPEG3_RGBA8888:
775 DITHER_HEAD
776 STORE_PIXEL_RGBA8888
777 DITHER_TAIL
778 break;
779 case MPEG3_601_BGR888:
780 DITHER_601_HEAD
781 STORE_PIXEL_BGR888
782 DITHER_TAIL
783 break;
784 case MPEG3_601_BGRA8888:
785 DITHER_601_HEAD
786 STORE_PIXEL_RGB565
787 DITHER_TAIL
788 break;
789 case MPEG3_601_RGB565:
790 DITHER_601_HEAD
791 STORE_PIXEL_RGB565
792 DITHER_TAIL
793 break;
794 case MPEG3_601_RGB888:
795 DITHER_601_HEAD
796 STORE_PIXEL_RGB888
797 DITHER_TAIL
798 break;
799 case MPEG3_601_RGBA8888:
800 DITHER_601_HEAD
801 STORE_PIXEL_RGBA8888
802 DITHER_TAIL
803 break;
804 case MPEG3_RGBA16161616:
805 {
806 register unsigned short *data_s = (unsigned short*)data;
807 DITHER_HEAD
808 STORE_PIXEL_RGBA16161616
809 DITHER_TAIL
810 }
811 break;
812 }
813 }
814 DITHER_ROW_TAIL
815 } /* End of non-MMX */
816
817#ifdef HAVE_MMX
818 if(video->have_mmx)
819 __asm__ __volatile__ ("emms");
820#endif
821 return 0;
822}
823
824int mpeg3video_ditherframe444(mpeg3video_t *video, unsigned char *src[])
825{
826 return 0;
827}
828
829int mpeg3video_dithertop(mpeg3video_t *video, unsigned char *src[])
830{
831 return mpeg3video_ditherframe(video, src, video->output_rows);
832}
833
834int mpeg3video_dithertop444(mpeg3video_t *video, unsigned char *src[])
835{
836 return 0;
837}
838
839int mpeg3video_ditherbot(mpeg3video_t *video, unsigned char *src[])
840{
841 return 0;
842}
843
844int mpeg3video_ditherbot444(mpeg3video_t *video, unsigned char *src[])
845{
846 return 0;
847}
848
849void memcpy_fast(unsigned char *output, unsigned char *input, long len)
850{
851 int i, len2;
852/* 8 byte alignment */
853/*
854 * if(!((long)input & 0x7))
855 * {
856 * len2 = len >> 4;
857 * for(i = 0; i < len2; )
858 * {
859 * ((MPEG3_INT64*)output)[i] = ((MPEG3_INT64*)input)[i];
860 * i++;
861 * ((MPEG3_INT64*)output)[i] = ((MPEG3_INT64*)input)[i];
862 * i++;
863 * }
864 *
865 * for(i *= 16; i < len; i++)
866 * {
867 * output[i] = input[i];
868 * }
869 * }
870 * else
871 */
872 memcpy(output, input, len);
873}
874
875int mpeg3video_init_output()
876{
877 int i, value;
878 for(i = 0; i < 256; i++)
879 {
880 value = (int)(1.1644 * i - 255 * 0.0627 + 0.5);
881 if(value < 0) value = 0;
882 else
883 if(value > 255) value = 255;
884 mpeg3_601_to_rgb[i] = value;
885 }
886 return 0;
887}
888
889int mpeg3video_present_frame(mpeg3video_t *video)
890{
891 int i, j, k, l;
892 unsigned char **src = video->output_src;
893
894/* Copy YUV buffers */
895 if(video->want_yvu)
896 {
897 long size[2];
898 long offset[2];
899
900/* Drop a frame */
901 if(!video->y_output) return 0;
902
903/* Copy a frame */
904 if(video->in_x == 0 &&
905 video->in_w >= video->coded_picture_width)
906 {
907 size[0] = video->coded_picture_width * video->in_h;
908 size[1] = video->chrom_width * (int)((float)video->in_h / 2 + 0.5);
909 offset[0] = video->coded_picture_width * video->in_y;
910 offset[1] = video->chrom_width * (int)((float)video->in_y / 2 + 0.5);
911
912/*
913 * if(video->in_y > 0)
914 * {
915 * offset[1] += video->chrom_width / 2;
916 * size[1] += video->chrom_width / 2;
917 * }
918 */
919
920 memcpy(video->y_output, src[0] + offset[0], size[0]);
921 memcpy(video->u_output, src[1] + offset[1], size[1]);
922 memcpy(video->v_output, src[2] + offset[1], size[1]);
923 }
924 else
925 {
926 for(i = 0, j = video->in_y; i < video->in_h; i++, j++)
927 {
928 memcpy(video->y_output + i * video->in_w,
929 src[0] + j * video->coded_picture_width + video->in_x,
930 video->in_w);
931 memcpy(video->u_output + i * video->in_w / 4,
932 src[1] + j * video->chrom_width / 2 + video->in_x / 4,
933 video->in_w / 4);
934 memcpy(video->v_output + i * video->in_w / 4,
935 src[2] + j * video->chrom_width / 2 + video->in_x / 4,
936 video->in_w / 4);
937 }
938 }
939
940 return 0;
941 }
942
943/* Want RGB buffer */
944/* Copy the frame to the output with YUV to RGB conversion */
945 if(video->prog_seq)
946 {
947 if(video->chroma_format != CHROMA444)
948 {
949 mpeg3video_ditherframe(video, src, video->output_rows);
950 }
951 else
952 mpeg3video_ditherframe444(video, src);
953 }
954 else
955 {
956 if((video->pict_struct == FRAME_PICTURE && video->topfirst) ||
957 video->pict_struct == BOTTOM_FIELD)
958 {
959/* top field first */
960 if(video->chroma_format != CHROMA444)
961 {
962 mpeg3video_dithertop(video, src);
963 mpeg3video_ditherbot(video, src);
964 }
965 else
966 {
967 mpeg3video_dithertop444(video, src);
968 mpeg3video_ditherbot444(video, src);
969 }
970 }
971 else
972 {
973/* bottom field first */
974 if(video->chroma_format != CHROMA444)
975 {
976 mpeg3video_ditherbot(video, src);
977 mpeg3video_dithertop(video, src);
978 }
979 else
980 {
981 mpeg3video_ditherbot444(video, src);
982 mpeg3video_dithertop444(video, src);
983 }
984 }
985 }
986 return 0;
987}
988
989int mpeg3video_display_second_field(mpeg3video_t *video)
990{
991/* Not used */
992 return 0;
993}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/reconmmx.s b/core/multimedia/opieplayer/libmpeg3/video/reconmmx.s
new file mode 100644
index 0000000..1bb98ef
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/reconmmx.s
@@ -0,0 +1,301 @@
1 ADD_1: dd 01010101h, 01010101h
2 MASK_AND:dd 7f7f7f7fh, 7f7f7f7fh
3 PLUS_384:dd 01800180h, 01800180h
4 PLUS_128:dd 00800080h, 00800080h
5
6%assign LocalFrameSize 0
7%assign RegisterStorageSize 16
8
9; Arguments:
10%assign source LocalFrameSize + RegisterStorageSize + 4
11%assign dest LocalFrameSize + RegisterStorageSize + 8
12%assign lx2 LocalFrameSize + RegisterStorageSize + 12
13%assign h LocalFrameSize + RegisterStorageSize + 16
14
15; Locals (on local stack frame)
16
17
18; extern void C rec_mmx (
19; unsigned char *source,
20; unsigned char *dest,
21; int lx2,
22; int h
23;
24; The local variables are on the stack,
25;
26
27global recva_mmx
28global recvac_mmx
29global rech_mmx
30global rechc_mmx
31global add_block_mmx
32global set_block_mmx
33
34
35 align 16
36rech_mmx:
37 push esi
38 push edi
39 push ecx
40 push ebx
41 mov esi, [esp+source]
42 mov edi, [esp+dest]
43 mov ecx, [esp+h]
44 mov ebx, [esp+lx2]
45 movq mm5, [MASK_AND]
46 movq mm6, [ADD_1]
47.rech1:
48 movq mm0,[esi]
49 movq mm1,[esi+1]
50 movq mm2,[esi+8]
51 movq mm3,[esi+9]
52 psrlw mm0,1
53 psrlw mm1,1
54 psrlw mm2,1
55 psrlw mm3,1
56 pand mm0,mm5
57 pand mm1,mm5
58 pand mm2,mm5
59 pand mm3,mm5
60 paddusb mm0,mm1
61 paddusb mm2,mm3
62 paddusb mm0,mm6
63 paddusb mm2,mm6
64 movq [edi],mm0
65 add esi,ebx
66 movq [edi+8],mm2
67 add edi,ebx
68 dec ecx
69 jnz .rech1
70 emms
71 pop ebx
72 pop ecx
73 pop edi
74 pop esi
75 ret
76
77 align 16
78rechc_mmx:
79 push esi
80 push edi
81 push ecx
82 push ebx
83; sub esp, LocalFrameSize
84 mov esi, [esp+source]
85 mov edi, [esp+dest]
86 mov ecx, [esp+h]
87 mov ebx, [esp+lx2]
88 movq mm5, [MASK_AND]
89 movq mm6, [ADD_1]
90.rechc1:
91 movq mm0,[esi]
92 movq mm1,[esi+1]
93 psrlw mm0,1
94 psrlw mm1,1
95 pand mm0,mm5
96 pand mm1,mm5
97 paddusb mm0,mm1
98 paddusb mm0,mm6
99 movq [edi],mm0
100 add edi,ebx
101 add esi,ebx
102 dec ecx
103 jnz .rechc1
104 emms
105; add esp, LocalFrameSize
106 pop ebx
107 pop ecx
108 pop edi
109 pop esi
110 ret
111
112
113
114%assign RegisterStorageSize 20
115%assign source LocalFrameSize + RegisterStorageSize + 4
116%assign dest LocalFrameSize + RegisterStorageSize + 8
117%assign lx LocalFrameSize + RegisterStorageSize + 12
118%assign lx2 LocalFrameSize + RegisterStorageSize + 16
119%assign h LocalFrameSize + RegisterStorageSize + 20
120
121 align 16
122recva_mmx:
123 push esi
124 push edi
125 push ecx
126 push ebx
127 push edx
128 mov esi, [esp+source]
129 mov edi, [esp+dest]
130 mov ecx, [esp+h]
131 mov ebx, [esp+lx2]
132 mov edx, [esp+lx]
133 movq mm7, [MASK_AND]
134 movq mm6, [ADD_1]
135.recva1:
136 movq mm0,[esi]
137 movq mm1,[esi+edx]
138 movq mm2,[esi+8]
139 movq mm3,[esi+edx+8]
140 movq mm4,[edi]
141 movq mm5,[edi+8]
142 psrlw mm0,1
143 psrlw mm1,1
144 psrlw mm2,1
145 psrlw mm3,1
146 psrlw mm4,1
147 psrlw mm5,1
148 pand mm0,mm7
149 pand mm1,mm7
150 pand mm2,mm7
151 pand mm3,mm7
152 pand mm4,mm7
153 pand mm5,mm7
154 paddusb mm0,mm1
155 paddusb mm2,mm3
156 paddusb mm0,mm6
157 paddusb mm2,mm6
158 psrlw mm0,1
159 psrlw mm2,1
160 pand mm0,mm7
161 pand mm2,mm7
162 paddusb mm4,mm0
163 paddusb mm5,mm2
164 paddusb mm4,mm6
165 paddusb mm5,mm6
166 movq [edi],mm4
167 movq [edi+8],mm5
168 add edi,ebx
169 add esi,ebx
170 dec ecx
171 jnz near .recva1
172 emms
173 pop edx
174 pop ebx
175 pop ecx
176 pop edi
177 pop esi
178 ret
179
180 align 16
181recvac_mmx:
182 push esi
183 push edi
184 push ecx
185 push ebx
186 push edx
187 mov esi, [esp+source]
188 mov edi, [esp+dest]
189 mov ecx, [esp+h]
190 mov ebx, [esp+lx2]
191 mov edx, [esp+lx]
192 movq mm5, [MASK_AND]
193 movq mm6, [ADD_1]
194.recvac1:
195 movq mm0,[esi]
196 movq mm1,[esi+edx]
197 movq mm4,[edi]
198 psrlw mm0,1
199 psrlw mm1,1
200 psrlw mm4,1
201 pand mm0,mm5
202 pand mm1,mm5
203 pand mm4,mm5
204 paddusb mm0,mm1
205 paddusb mm0,mm6
206 psrlw mm0,1
207 pand mm0,mm5
208 paddusb mm4,mm0
209 paddusb mm4,mm6
210 movq [edi],mm4
211 add edi,ebx
212 add esi,ebx
213 dec ecx
214 jnz .recvac1
215 emms
216 pop edx
217 pop ebx
218 pop ecx
219 pop edi
220 pop esi
221 ret
222
223%assign RegisterStorageSize 20
224%assign rfp LocalFrameSize + RegisterStorageSize + 4
225%assign bp LocalFrameSize + RegisterStorageSize + 8
226%assign iincr LocalFrameSize + RegisterStorageSize + 12
227
228; FIXME clipping needs to be done
229
230 align 16
231add_block_mmx:
232 push esi
233 push edi
234 push ecx
235 push ebx
236 push edx
237 mov esi, [esp+bp]
238 mov edi, [esp+rfp]
239 mov ebx, [esp+iincr]
240; movq mm7, [PLUS_384]
241 mov ecx,8
242 pxor mm2,mm2 ; clear
243%rep 8
244 movq mm0, [edi] ; get dest
245 movq mm1,mm0
246 punpcklbw mm0,mm2
247 punpckhbw mm1,mm2
248 paddsw mm0, [esi]
249 paddsw mm1, [esi+8]
250; paddsw mm0, mm7
251; paddsw mm1, mm7
252 packuswb mm0,mm1
253 movq [edi], mm0
254 add edi,ebx
255 add esi,16
256%endrep
257 emms
258 pop edx
259 pop ebx
260 pop ecx
261 pop edi
262 pop esi
263 ret
264
265 align 16
266set_block_mmx:
267 push esi
268 push edi
269 push ecx
270 push ebx
271 push edx
272 mov esi, [esp+bp]
273 mov edi, [esp+rfp]
274 mov ebx, [esp+iincr]
275 movq mm7, [PLUS_128]
276%rep 4
277 movq mm0, [esi]
278 movq mm1, [esi+8]
279 paddsw mm0, mm7
280 movq mm2, [esi+16]
281 paddsw mm1, mm7
282 movq mm3, [esi+24]
283 paddsw mm2, mm7
284 packuswb mm0, mm1
285 paddsw mm3, mm7
286 movq [edi], mm0
287 packuswb mm2, mm3
288 add edi, ebx
289 add esi, 32
290 movq [edi], mm2
291 add edi, ebx
292%endrep
293 emms
294 pop edx
295 pop ebx
296 pop ecx
297 pop edi
298 pop esi
299 ret
300
301
diff --git a/core/multimedia/opieplayer/libmpeg3/video/reconstruct.c b/core/multimedia/opieplayer/libmpeg3/video/reconstruct.c
new file mode 100644
index 0000000..531f9c0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/reconstruct.c
@@ -0,0 +1,1290 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include <stdio.h>
5
6#ifdef HAVE_MMX
7
8#ifdef HAVE_3Dnow
9static inline void recva_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
10{
11 __asm__(
12 ".align8\n"
13 "1:"
14 "movq (%1),%%mm0\n" /* 8 s */
15 "movq 8(%1),%%mm1\n" /* 8 s */
16 "movq (%4),%%mm2\n" /* 8 s +lx */
17 "movq 8(%4),%%mm3\n" /* 8 s +lx **/
18
19 "pavgusb %%mm2, %%mm0\n"
20 "addl %3, %1\n"
21 "pavgusb %%mm3, %%mm1\n"
22
23 "movq (%2),%%mm2\n" /* 8 d */
24 "movq 8(%2),%%mm3\n" /* 8 d */
25 "pavgusb %%mm2, %%mm0\n"
26 "addl %3, %4\n"
27 "pavgusb %%mm3, %%mm1\n"
28
29 "movq %%mm0,(%2)\n"
30 "movq %%mm1,8(%2)\n"
31 "addl %3, %2\n"
32 "loop 1b\n"
33 :
34 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
35 );
36}
37
38static inline void recvac_mmx(unsigned char *s, unsigned char *d, int lx,int lx2, int h)
39{
40 __asm__(
41 ".align8\n"
42 "1:"
43 "movq (%1),%%mm0\n" /* 8 s */
44 "movq (%4),%%mm2\n" /* 8 s +lx */
45 "addl %3, %1\n"
46 "pavgusb %%mm2, %%mm0\n"
47 "movq (%2),%%mm3\n" /* 8 d */
48 "addl %3, %4\n"
49 "pavgusb %%mm3, %%mm0\n"
50 "movq %%mm0,(%2)\n"
51 "addl %3, %2\n"
52 "loop 1b\n"
53 :
54 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
55 );
56}
57
58static inline void rech_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
59{
60 __asm__ (
61 ".align8\n"
62 "1:"
63 "movq (%1),%%mm0\n" /* 8 s */
64 "movq 8(%1),%%mm1\n" /* 8 s */
65 "movq 1(%1),%%mm2\n" /* 8 s */
66 "movq 9(%1),%%mm3\n" /* 8 s */
67
68 "pavgusb %%mm2, %%mm0\n"
69 "addl %3, %1\n"
70 "pavgusb %%mm3, %%mm1\n"
71
72 "movq %%mm0,(%2)\n"
73 "movq %%mm1,8(%2)\n"
74 "addl %3, %2\n"
75 "loop 1b\n"
76 :
77 : "c" (h), "r" (s), "r" (d), "r" (lx2)
78 );
79}
80
81static inline void rechc_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
82{
83 __asm__ (
84 ".align8\n"
85 "1:"
86 "movq (%1),%%mm0\n" /* 8 s */
87 "movq 1(%1),%%mm2\n" /* 8 s +1 */
88 "addl %3, %1\n"
89 "pavgusb %%mm2, %%mm0\n"
90 "movq %%mm0,(%2)\n"
91 "addl %3, %2\n"
92 "loop 1b\n"
93 :
94 : "c" (h), "r" (s), "r" (d), "r" (lx2)
95 );
96}
97
98static inline void recha_mmx(unsigned char *s, unsigned char *d,int lx2, int h)
99{
100 __asm__ (
101 ".align8\n"
102 "1:"
103 "movq (%1),%%mm0\n" /* 8 s */
104 "movq 8(%1),%%mm1\n" /* 8 s */
105 "movq 1(%1),%%mm2\n" /* 8 s */
106 "movq 9(%1),%%mm3\n" /* 8 s */
107
108 "pavgusb %%mm2, %%mm0\n"
109 "addl %3, %1\n"
110 "pavgusb %%mm3, %%mm1\n"
111
112 "movq (%2),%%mm2\n" /* 8 d */
113 "movq 8(%2),%%mm3\n" /* 8 d */
114 "pavgusb %%mm2, %%mm0\n"
115 "pavgusb %%mm3, %%mm1\n"
116
117 "movq %%mm0,(%2)\n"
118 "movq %%mm1,8(%2)\n"
119 "addl %3, %2\n"
120 "loop 1b\n"
121 :
122 : "c" (h), "r" (s), "r" (d), "r" (lx2)
123 );
124}
125
126static inline void rechac_mmx(unsigned char *s,unsigned char *d, int lx2, int h)
127{
128 __asm__ (
129 ".align8\n"
130 "1:"
131 "movq (%1),%%mm0\n" /* 8 s */
132 "movq 1(%1),%%mm2\n" /* 8 s */
133
134 "addl %3, %1\n"
135 "pavgusb %%mm2, %%mm0\n"
136
137 "movq (%2),%%mm1\n" /* 8 d */
138 "pavgusb %%mm1, %%mm0\n"
139
140 "movq %%mm0,(%2)\n"
141 "addl %3, %2\n"
142 "loop 1b\n"
143 :
144 : "c" (h), "r" (s), "r" (d), "r" (lx2)
145 );
146}
147
148static inline void rec4_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
149{
150 __asm__ __volatile__(
151 "movq (%1),%%mm0\n" /* 8 s */
152 "movq 8(%1),%%mm1\n" /* 8 s */
153 "movq 1(%1),%%mm2\n" /* 8 s +1*/
154 "movq 9(%1),%%mm3\n" /* 8 s +1*/
155 ".align 8\n"
156 "1:"
157 "movq (%4),%%mm4\n" /* 8 s+lx */
158 "pavgusb %%mm2, %%mm0\n"
159 "movq 8(%4),%%mm5\n" /* 8 s+lx */
160 "pavgusb %%mm3, %%mm1\n"
161
162 "movq 1(%4),%%mm6\n" /* 8 s+lx +1*/
163 "pavgusb %%mm4, %%mm0\n"
164 "movq 9(%4),%%mm7\n" /* 8 s+lx +1*/
165 "pavgusb %%mm5, %%mm1\n"
166
167 "pavgusb %%mm6, %%mm0\n"
168 "addl %3, %4\n"
169 "pavgusb %%mm7, %%mm1\n"
170 "movq %%mm0,(%2)\n"
171 "movq %%mm6,%%mm2\n"
172 "movq %%mm7,%%mm3\n"
173 "movq %%mm1,8(%2)\n"
174 "movq %%mm4,%%mm0\n"
175 "movq %%mm5,%%mm1\n"
176 "addl %3, %2\n"
177 "loop 1b\n"
178 :
179 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
180 );
181}
182
183static inline void rec4c_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
184{
185 __asm__ __volatile__(
186 "movq (%1),%%mm0\n" /* 8 s */
187 "movq 1(%1),%%mm2\n" /* 8 s +1*/
188 ".align 8\n"
189 "1:"
190 "movq (%4),%%mm4\n" /* 8 s+lx */
191 "pavgusb %%mm2, %%mm0\n"
192
193 "movq 1(%4),%%mm6\n" /* 8 s+lx +1*/
194 "pavgusb %%mm4, %%mm0\n"
195
196 "addl %3, %4\n"
197 "pavgusb %%mm6, %%mm0\n"
198 "movq %%mm0,(%2)\n"
199 "movq %%mm6,%%mm2\n"
200 "movq %%mm4,%%mm0\n"
201 "addl %3, %2\n"
202 "loop 1b\n"
203 :
204 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
205 );
206}
207
208static inline void rec4a_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
209{
210 __asm__ __volatile__(
211 "movq (%1),%%mm0\n" /* 8 s */
212 "movq 8(%1),%%mm1\n" /* 8 s */
213 "movq 1(%1),%%mm2\n" /* 8 s +1*/
214 "movq 9(%1),%%mm3\n" /* 8 s +1*/
215 ".align 8\n"
216 "1:"
217 "movq (%4),%%mm4\n" /* 8 s+lx */
218 "pavgusb %%mm2, %%mm0\n"
219 "movq 8(%4),%%mm5\n" /* 8 s+lx */
220 "pavgusb %%mm3, %%mm1\n"
221
222 "movq 1(%4),%%mm6\n" /* 8 s+lx +1*/
223 "pavgusb %%mm4, %%mm0\n"
224 "movq 9(%4),%%mm7\n" /* 8 s+lx +1*/
225 "pavgusb %%mm5, %%mm1\n"
226 "movq (%2),%%mm2\n"
227 "pavgusb %%mm6, %%mm0\n"
228 "movq 8(%2),%%mm3\n"
229
230 "pavgusb %%mm2, %%mm0\n"
231 "addl %3, %4\n"
232 "pavgusb %%mm3, %%mm1\n"
233 "movq %%mm0,(%2)\n"
234
235 "pavgusb %%mm7, %%mm1\n"
236 "movq %%mm6,%%mm2\n"
237 "movq %%mm7,%%mm3\n"
238 "movq %%mm1,8(%2)\n"
239 "movq %%mm4,%%mm0\n"
240 "movq %%mm5,%%mm1\n"
241 "addl %3, %2\n"
242 "loop 1b\n"
243 :
244 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
245 );
246}
247
248static inline void rec4ac_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
249{
250 __asm__ __volatile__(
251 "movq (%1),%%mm0\n" /* 8 s */
252 "movq 1(%1),%%mm2\n" /* 8 s +1*/
253 ".align 8\n"
254 "1:"
255 "movq (%4),%%mm4\n" /* 8 s+lx */
256 "pavgusb %%mm2, %%mm0\n"
257
258 "movq 1(%4),%%mm6\n" /* 8 s+lx +1*/
259 "pavgusb %%mm4, %%mm0\n"
260 "movq (%2),%%mm1\n" /* 8 d */
261 "pavgusb %%mm6, %%mm0\n"
262 "addl %3, %4\n"
263 "pavgusb %%mm1, %%mm0\n"
264 "movq %%mm6,%%mm2\n"
265 "movq %%mm0,(%2)\n"
266 "movq %%mm4,%%mm0\n"
267 "addl %3, %2\n"
268 "loop 1b\n"
269 :
270 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
271 );
272}
273
274#else // HAVE_3DNOW
275 static LONGLONG ADD_1 =0x0101010101010101LL;
276 static LONGLONG MASK_AND = 0x7f7f7f7f7f7f7f7fLL;
277#endif
278
279static inline void rec_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
280{
281 __asm__ __volatile__(
282 ".align 8\n"
283 "1:\t"
284 "movq ( %1 ), %%mm0\n" /* 8 s */
285 "movq 8( %1 ), %%mm2\n" /* 16 s */
286 "movq %%mm0, ( %2 )\n"
287 "addl %3, %1\n"
288 "movq %%mm2, 8( %2 )\n"
289 "decl %0\n"
290 "leal (%2, %3), %2\n"
291 "jnz 1b"
292 :
293 : "c" (h), "r" (s), "r" (d), "r" (lx2)
294 );
295}
296
297
298static inline void recc_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
299{
300 __asm__ __volatile__(
301 ".align 8\n"
302 "1:\t"
303 "movq ( %1 ), %%mm0\n"
304 "addl %3, %1\n"
305 "movq %%mm0, ( %2 )\n"
306 "decl %0\n"
307 "leal (%2, %3), %2\n"
308 "jnz 1b"
309 :
310 : "c" (h), "r" (s), "r" (d), "r" (lx2)
311 );
312}
313
314
315static inline void reca_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
316{
317#ifdef HAVE_3Dnow
318 __asm__ (
319 ".align8\n"
320 "1:"
321 "movq (%1),%%mm0\n" /* 8 s */
322 "movq (%2),%%mm2\n" /* 8 d */
323 "movq 8(%1),%%mm1\n" /* 8 s */
324 "movq 8(%2),%%mm3\n" /* 8 d */
325 "pavgusb %%mm2, %%mm0\n"
326 "addl %3, %1\n"
327 "pavgusb %%mm3, %%mm1\n"
328
329 "movq %%mm0,(%2)\n"
330 "movq %%mm1,8(%2)\n"
331 "addl %3, %2\n"
332 "loop 1b\n"
333 :
334 : "c" (h), "r" (s), "r" (d), "r" (lx2)
335 );
336#else /* No 3dnow */
337 __asm__ (
338 "movq MASK_AND, %%mm5\n"
339 "movq ADD_1, %%mm6\n"
340 "1:\t"
341 "movq (%1),%%mm0\n" /* Load 16 pixels from each row */
342 "movq (%2),%%mm1\n"
343 "movq 8(%1),%%mm2\n"
344 "movq 8(%2),%%mm3\n"
345 "psrlw $1,%%mm0\n" /* Shift pixels down */
346 "psrlw $1,%%mm1\n"
347 "pand %%mm5,%%mm0\n" /* Zero out significant bit */
348 "psrlw $1,%%mm2\n"
349 "pand %%mm5,%%mm1\n"
350 "psrlw $1,%%mm3\n"
351 "pand %%mm5,%%mm2\n"
352 "paddusb %%mm1,%%mm0\n" /* Add pixels */
353 "pand %%mm5,%%mm3\n"
354 "paddusb %%mm3,%%mm2\n"
355 "paddusb %%mm6,%%mm0\n" /* Add 1 to results */
356 "paddusb %%mm6,%%mm2\n"
357 "movq %%mm0,(%2)\n"
358 "addl %3,%1\n"
359 "movq %%mm2, 8(%2)\n"
360 "decl %0\n"
361 "leal (%2, %3), %2\n"
362 "jnz 1b\n"
363 :
364 : "c" (h), "r" (s), "r" (d), "r" (lx2)
365 );
366#endif
367}
368
369
370static inline void recac_mmx(unsigned char *s, unsigned char *d, int lx2, int h)
371{
372#ifdef HAVE_3Dnow
373 __asm__ (
374 ".align8\n"
375 "1:"
376 "movq (%1),%%mm0\n" /* 8 s */
377 "movq (%2),%%mm2\n" /* 8 d */
378 "pavgusb %%mm2, %%mm0\n"
379 "addl %3, %1\n"
380 "movq %%mm0,(%2)\n"
381 "addl %3, %2\n"
382 "loop 1b\n"
383 :
384 : "c" (h), "r" (s), "r" (d), "r" (lx2)
385 );
386#else /* No 3dnow */
387 __asm__ (
388 "movq MASK_AND, %%mm5\n"
389 "movq ADD_1, %%mm6\n"
390 "1:\t"
391 "movq (%1),%%mm0\n"
392 "movq (%2),%%mm1\n"
393 "psrlw $1,%%mm0\n"
394 "psrlw $1,%%mm1\n"
395 "pand %%mm5,%%mm0\n"
396 "pand %%mm5,%%mm1\n"
397 "paddusb %%mm1,%%mm0\n"
398 "paddusb %%mm6,%%mm0\n"
399 "addl %3,%1\n"
400 "movq %%mm0,(%2)\n"
401 "decl %0\n"
402 "leal (%2, %3), %2\n"
403 "jnz 1b\n"
404 :
405 : "c" (h), "r" (s), "r" (d), "r" (lx2)
406 );
407#endif
408}
409
410
411static inline void recv_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
412{
413#ifdef HAVE_3Dnow
414 __asm__(
415 ".align8\n"
416 "1:"
417 "movq (%1),%%mm0\n" /* 8 s */
418 "movq (%4),%%mm2\n" /* 8 s +lx */
419 "movq 8(%1),%%mm1\n" /* 8 s */
420 "movq 8(%4),%%mm3\n" /* 8 s +lx **/
421
422 "pavgusb %%mm2, %%mm0\n"
423 "addl %3, %1\n"
424 "pavgusb %%mm3, %%mm1\n"
425
426 "movq %%mm0,(%2)\n"
427 "addl %3, %4\n"
428 "movq %%mm1,8(%2)\n"
429 "addl %3, %2\n"
430 "loop 1b\n"
431 :
432 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
433 );
434#else
435 __asm__ (
436 "movq MASK_AND, %%mm5\n"
437 "movq ADD_1, %%mm6\n"
438 "1:\t"
439 "movq (%1),%%mm0\n" /* 8 s */
440 "movq (%4),%%mm1\n" /* 8 s +lx */
441 "movq 8(%1),%%mm2\n" /* 8 s */
442 "movq 8(%4),%%mm3\n" /* 8 s +lx **/
443 "psrlw $1,%%mm0\n"
444 "psrlw $1,%%mm1\n"
445 "pand %%mm5,%%mm0\n"
446 "psrlw $1,%%mm2\n"
447 "pand %%mm5,%%mm1\n"
448 "psrlw $1,%%mm3\n"
449 "pand %%mm5,%%mm2\n"
450 "paddusb %%mm1,%%mm0\n"
451 "pand %%mm5,%%mm3\n"
452 "paddusb %%mm3,%%mm2\n"
453 "paddusb %%mm6,%%mm0\n"
454 "paddusb %%mm6,%%mm2\n"
455 "movq %%mm0,(%2)\n"
456 "addl %3,%1\n"
457 "movq %%mm2, 8(%2)\n"
458 "addl %3,%4\n"
459 "decl %0\n"
460 "leal (%2, %3), %2\n"
461 "jnz 1b\n"
462 :
463 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
464 );
465#endif
466}
467
468
469static inline void recvc_mmx(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
470{
471#ifdef HAVE_3Dnow
472 __asm__(
473 ".align8\n"
474 "1:"
475 "movq (%1),%%mm0\n" /* 8 s */
476 "movq (%4),%%mm2\n" /* 8 s +lx */
477 "addl %3, %1\n"
478 "pavgusb %%mm2, %%mm0\n"
479 "addl %3, %4\n"
480 "movq %%mm0,(%2)\n"
481 "addl %3, %2\n"
482 "loop 1b\n"
483 :
484 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
485 );
486#else
487 __asm__ (
488 "movq MASK_AND, %%mm5\n"
489 "movq ADD_1, %%mm6\n"
490 "1:\t"
491 "movq (%1),%%mm0\n" /* 8 s */
492 "movq (%4),%%mm1\n" /* 8 s +lx */
493 "psrlw $1,%%mm0\n"
494 "psrlw $1,%%mm1\n"
495 "pand %%mm5,%%mm0\n"
496 "pand %%mm5,%%mm1\n"
497 "paddusb %%mm1,%%mm0\n"
498 "addl %3,%1\n"
499 "paddusb %%mm6,%%mm0\n"
500 "addl %3,%4\n"
501 "movq %%mm0,(%2)\n"
502 "decl %0\n"
503 "leal (%2, %3), %2\n"
504 "jnz 1b\n"
505 :
506 : "c" (h), "r" (s), "r" (d), "r" (lx2), "r" (s +lx)
507 );
508#endif
509}
510
511#endif // HAVE_MMX
512
513static inline void rec(unsigned char *s, unsigned char *d, int lx2, int h)
514{
515 int j;
516 for(j = 0; j < h; j++, s += lx2, d += lx2)
517 {
518 d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; d[3] = s[3];
519 d[4] = s[4]; d[5] = s[5]; d[6] = s[6]; d[7] = s[7];
520 d[8] = s[8]; d[9] = s[9]; d[10] = s[10]; d[11] = s[11];
521 d[12] = s[12]; d[13] = s[13]; d[14] = s[14]; d[15] = s[15];
522 }
523}
524
525
526
527static inline void recc(unsigned char *s, unsigned char *d, int lx2, int h)
528{
529 int j;
530 for(j = 0; j < h; j++, s += lx2, d += lx2)
531 {
532 d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; d[3] = s[3];
533 d[4] = s[4]; d[5] = s[5]; d[6] = s[6]; d[7] = s[7];
534 }
535}
536
537static inline void reca(unsigned char *s, unsigned char *d, int lx2, int h)
538{
539 int j;
540 for(j = 0; j < h; j++, s +=lx2, d +=lx2)
541 {
542 d[0] = (unsigned int)(d[0] + s[0] + 1) >> 1;
543 d[1] = (unsigned int)(d[1] + s[1] + 1) >> 1;
544 d[2] = (unsigned int)(d[2] + s[2] + 1) >> 1;
545 d[3] = (unsigned int)(d[3] + s[3] + 1) >> 1;
546 d[4] = (unsigned int)(d[4] + s[4] + 1) >> 1;
547 d[5] = (unsigned int)(d[5] + s[5] + 1) >> 1;
548 d[6] = (unsigned int)(d[6] + s[6] + 1) >> 1;
549 d[7] = (unsigned int)(d[7] + s[7] + 1) >> 1;
550 d[8] = (unsigned int)(d[8] + s[8] + 1) >> 1;
551 d[9] = (unsigned int)(d[9] + s[9] + 1) >> 1;
552 d[10] = (unsigned int)(d[10] + s[10] + 1) >> 1;
553 d[11] = (unsigned int)(d[11] + s[11] + 1) >> 1;
554 d[12] = (unsigned int)(d[12] + s[12] + 1) >> 1;
555 d[13] = (unsigned int)(d[13] + s[13] + 1) >> 1;
556 d[14] = (unsigned int)(d[14] + s[14] + 1) >> 1;
557 d[15] = (unsigned int)(d[15] + s[15] + 1) >> 1;
558 }
559}
560
561static inline void recac(unsigned char *s, unsigned char *d, int lx2, int h)
562{
563 int j;
564 for(j = 0; j < h; j++, s += lx2, d += lx2)
565 {
566 d[0] = (unsigned int)(d[0] + s[0] + 1)>>1;
567 d[1] = (unsigned int)(d[1] + s[1] + 1)>>1;
568 d[2] = (unsigned int)(d[2] + s[2] + 1)>>1;
569 d[3] = (unsigned int)(d[3] + s[3] + 1)>>1;
570 d[4] = (unsigned int)(d[4] + s[4] + 1)>>1;
571 d[5] = (unsigned int)(d[5] + s[5] + 1)>>1;
572 d[6] = (unsigned int)(d[6] + s[6] + 1)>>1;
573 d[7] = (unsigned int)(d[7] + s[7] + 1)>>1;
574 }
575}
576
577static inline void recv_(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
578{
579 unsigned char *dp,*sp,*sp2;
580 int j;
581 sp = s;
582 sp2 = s + lx;
583 dp = d;
584 for(j = 0; j < h; j++)
585 {
586 dp[0] = (unsigned int)(sp[0] + sp2[0] + 1) >> 1;
587 dp[1] = (unsigned int)(sp[1] + sp2[1] + 1) >> 1;
588 dp[2] = (unsigned int)(sp[2] + sp2[2] + 1) >> 1;
589 dp[3] = (unsigned int)(sp[3] + sp2[3] + 1) >> 1;
590 dp[4] = (unsigned int)(sp[4] + sp2[4] + 1) >> 1;
591 dp[5] = (unsigned int)(sp[5] + sp2[5] + 1) >> 1;
592 dp[6] = (unsigned int)(sp[6] + sp2[6] + 1) >> 1;
593 dp[7] = (unsigned int)(sp[7] + sp2[7] + 1) >> 1;
594 dp[8] = (unsigned int)(sp[8] + sp2[8] + 1) >> 1;
595 dp[9] = (unsigned int)(sp[9] + sp2[9] + 1) >> 1;
596 dp[10] = (unsigned int)(sp[10] + sp2[10] + 1) >> 1;
597 dp[11] = (unsigned int)(sp[11] + sp2[11] + 1) >> 1;
598 dp[12] = (unsigned int)(sp[12] + sp2[12] + 1) >> 1;
599 dp[13] = (unsigned int)(sp[13] + sp2[13] + 1) >> 1;
600 dp[14] = (unsigned int)(sp[14] + sp2[14] + 1) >> 1;
601 dp[15] = (unsigned int)(sp[15] + sp2[15] + 1) >> 1;
602 sp+= lx2;
603 sp2+= lx2;
604 dp+= lx2;
605 }
606}
607
608static inline void recvc(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
609{
610 unsigned char *dp,*sp,*sp2;
611 int j;
612
613 sp = s;
614 sp2 = s+lx;
615 dp = d;
616 for(j = 0; j < h; j++)
617 {
618 dp[0] = (unsigned int)(sp[0]+sp2[0]+1)>>1;
619 dp[1] = (unsigned int)(sp[1]+sp2[1]+1)>>1;
620 dp[2] = (unsigned int)(sp[2]+sp2[2]+1)>>1;
621 dp[3] = (unsigned int)(sp[3]+sp2[3]+1)>>1;
622 dp[4] = (unsigned int)(sp[4]+sp2[4]+1)>>1;
623 dp[5] = (unsigned int)(sp[5]+sp2[5]+1)>>1;
624 dp[6] = (unsigned int)(sp[6]+sp2[6]+1)>>1;
625 dp[7] = (unsigned int)(sp[7]+sp2[7]+1)>>1;
626 sp+= lx2;
627 sp2+= lx2;
628 dp+= lx2;
629 }
630}
631
632
633static inline void recva(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
634{
635 unsigned char *dp,*sp,*sp2;
636 int j;
637
638 sp = s;
639 sp2 = s+lx;
640 dp = d;
641 for (j=0; j<h; j++){
642 dp[0] = (dp[0] + ((unsigned int)(sp[0]+sp2[0]+1)>>1) + 1)>>1;
643 dp[1] = (dp[1] + ((unsigned int)(sp[1]+sp2[1]+1)>>1) + 1)>>1;
644 dp[2] = (dp[2] + ((unsigned int)(sp[2]+sp2[2]+1)>>1) + 1)>>1;
645 dp[3] = (dp[3] + ((unsigned int)(sp[3]+sp2[3]+1)>>1) + 1)>>1;
646 dp[4] = (dp[4] + ((unsigned int)(sp[4]+sp2[4]+1)>>1) + 1)>>1;
647 dp[5] = (dp[5] + ((unsigned int)(sp[5]+sp2[5]+1)>>1) + 1)>>1;
648 dp[6] = (dp[6] + ((unsigned int)(sp[6]+sp2[6]+1)>>1) + 1)>>1;
649 dp[7] = (dp[7] + ((unsigned int)(sp[7]+sp2[7]+1)>>1) + 1)>>1;
650 dp[8] = (dp[8] + ((unsigned int)(sp[8]+sp2[8]+1)>>1) + 1)>>1;
651 dp[9] = (dp[9] + ((unsigned int)(sp[9]+sp2[9]+1)>>1) + 1)>>1;
652 dp[10] = (dp[10] + ((unsigned int)(sp[10]+sp2[10]+1)>>1) + 1)>>1;
653 dp[11] = (dp[11] + ((unsigned int)(sp[11]+sp2[11]+1)>>1) + 1)>>1;
654 dp[12] = (dp[12] + ((unsigned int)(sp[12]+sp2[12]+1)>>1) + 1)>>1;
655 dp[13] = (dp[13] + ((unsigned int)(sp[13]+sp2[13]+1)>>1) + 1)>>1;
656 dp[14] = (dp[14] + ((unsigned int)(sp[14]+sp2[14]+1)>>1) + 1)>>1;
657 dp[15] = (dp[15] + ((unsigned int)(sp[15]+sp2[15]+1)>>1) + 1)>>1;
658 sp+= lx2;
659 sp2+= lx2;
660 dp+= lx2;
661 }
662}
663
664
665static inline void recvac(unsigned char *s, unsigned char *d, int lx,int lx2, int h){
666 unsigned char *dp,*sp,*sp2;
667 int j;
668
669 sp = s;
670 sp2 = s+lx;
671 dp = d;
672 for (j=0; j<h; j++){
673 dp[0] = (dp[0] + ((unsigned int)(sp[0]+sp2[0]+1)>>1) + 1)>>1;
674 dp[1] = (dp[1] + ((unsigned int)(sp[1]+sp2[1]+1)>>1) + 1)>>1;
675 dp[2] = (dp[2] + ((unsigned int)(sp[2]+sp2[2]+1)>>1) + 1)>>1;
676 dp[3] = (dp[3] + ((unsigned int)(sp[3]+sp2[3]+1)>>1) + 1)>>1;
677 dp[4] = (dp[4] + ((unsigned int)(sp[4]+sp2[4]+1)>>1) + 1)>>1;
678 dp[5] = (dp[5] + ((unsigned int)(sp[5]+sp2[5]+1)>>1) + 1)>>1;
679 dp[6] = (dp[6] + ((unsigned int)(sp[6]+sp2[6]+1)>>1) + 1)>>1;
680 dp[7] = (dp[7] + ((unsigned int)(sp[7]+sp2[7]+1)>>1) + 1)>>1;
681 sp+= lx2;
682 sp2+= lx2;
683 dp+= lx2;
684 }
685}
686
687
688static inline void rech(unsigned char *s, unsigned char *d, int lx2, int h){
689 unsigned char *dp,*sp;
690 unsigned int s1,s2;
691 int j;
692
693 sp = s;
694 dp = d;
695 for (j=0; j<h; j++){
696 s1=sp[0];
697 dp[0] = (unsigned int)(s1+(s2=sp[1])+1)>>1;
698 dp[1] = (unsigned int)(s2+(s1=sp[2])+1)>>1;
699 dp[2] = (unsigned int)(s1+(s2=sp[3])+1)>>1;
700 dp[3] = (unsigned int)(s2+(s1=sp[4])+1)>>1;
701 dp[4] = (unsigned int)(s1+(s2=sp[5])+1)>>1;
702 dp[5] = (unsigned int)(s2+(s1=sp[6])+1)>>1;
703 dp[6] = (unsigned int)(s1+(s2=sp[7])+1)>>1;
704 dp[7] = (unsigned int)(s2+(s1=sp[8])+1)>>1;
705 dp[8] = (unsigned int)(s1+(s2=sp[9])+1)>>1;
706 dp[9] = (unsigned int)(s2+(s1=sp[10])+1)>>1;
707 dp[10] = (unsigned int)(s1+(s2=sp[11])+1)>>1;
708 dp[11] = (unsigned int)(s2+(s1=sp[12])+1)>>1;
709 dp[12] = (unsigned int)(s1+(s2=sp[13])+1)>>1;
710 dp[13] = (unsigned int)(s2+(s1=sp[14])+1)>>1;
711 dp[14] = (unsigned int)(s1+(s2=sp[15])+1)>>1;
712 dp[15] = (unsigned int)(s2+sp[16]+1)>>1;
713 sp+= lx2;
714 dp+= lx2;
715 }
716}
717
718
719static inline void rechc(unsigned char *s,unsigned char *d, int lx2, int h){
720 unsigned char *dp,*sp;
721 unsigned int s1,s2;
722 int j;
723
724 sp = s;
725 dp = d;
726 for (j=0; j<h; j++){
727 s1=sp[0];
728 dp[0] = (unsigned int)(s1+(s2=sp[1])+1)>>1;
729 dp[1] = (unsigned int)(s2+(s1=sp[2])+1)>>1;
730 dp[2] = (unsigned int)(s1+(s2=sp[3])+1)>>1;
731 dp[3] = (unsigned int)(s2+(s1=sp[4])+1)>>1;
732 dp[4] = (unsigned int)(s1+(s2=sp[5])+1)>>1;
733 dp[5] = (unsigned int)(s2+(s1=sp[6])+1)>>1;
734 dp[6] = (unsigned int)(s1+(s2=sp[7])+1)>>1;
735 dp[7] = (unsigned int)(s2+sp[8]+1)>>1;
736 sp+= lx2;
737 dp+= lx2;
738 }
739}
740
741static inline void recha(unsigned char *s, unsigned char *d,int lx2, int h)
742{
743 unsigned char *dp,*sp;
744 unsigned int s1,s2;
745 int j;
746
747 sp = s;
748 dp = d;
749 for (j = 0; j < h; j++)
750 {
751 s1 = sp[0];
752 dp[0] = (dp[0] + ((unsigned int)(s1 + (s2 = sp[1]) + 1) >> 1) + 1) >> 1;
753 dp[1] = (dp[1] + ((unsigned int)(s2 + (s1 = sp[2]) + 1) >> 1) + 1) >> 1;
754 dp[2] = (dp[2] + ((unsigned int)(s1 + (s2 = sp[3]) + 1) >> 1) + 1) >> 1;
755 dp[3] = (dp[3] + ((unsigned int)(s2 + (s1 = sp[4]) + 1) >> 1) + 1) >> 1;
756 dp[4] = (dp[4] + ((unsigned int)(s1 + (s2 = sp[5]) + 1) >> 1) + 1) >> 1;
757 dp[5] = (dp[5] + ((unsigned int)(s2 + (s1 = sp[6]) + 1) >> 1) + 1) >> 1;
758 dp[6] = (dp[6] + ((unsigned int)(s1 + (s2 = sp[7]) + 1) >> 1) + 1) >> 1;
759 dp[7] = (dp[7] + ((unsigned int)(s2 + (s1 = sp[8]) + 1) >> 1) + 1) >> 1;
760 dp[8] = (dp[8] + ((unsigned int)(s1 + (s2 = sp[9]) + 1) >> 1) + 1) >> 1;
761 dp[9] = (dp[9] + ((unsigned int)(s2 + (s1 = sp[10]) + 1) >> 1) + 1) >> 1;
762 dp[10] = (dp[10] + ((unsigned int)(s1 + (s2 = sp[11]) + 1) >> 1) + 1) >> 1;
763 dp[11] = (dp[11] + ((unsigned int)(s2 + (s1 = sp[12]) + 1) >> 1) + 1) >> 1;
764 dp[12] = (dp[12] + ((unsigned int)(s1 + (s2 = sp[13]) + 1) >> 1) + 1) >> 1;
765 dp[13] = (dp[13] + ((unsigned int)(s2 + (s1 = sp[14]) + 1) >> 1) + 1) >> 1;
766 dp[14] = (dp[14] + ((unsigned int)(s1 + (s2 = sp[15]) + 1) >> 1) + 1) >> 1;
767 dp[15] = (dp[15] + ((unsigned int)(s2 + sp[16] + 1) >> 1) + 1) >> 1;
768 sp += lx2;
769 dp += lx2;
770 }
771}
772
773
774static inline void rechac(unsigned char *s,unsigned char *d, int lx2, int h)
775{
776 unsigned char *dp,*sp;
777 unsigned int s1,s2;
778 int j;
779
780 sp = s;
781 dp = d;
782 for(j = 0; j < h; j++)
783 {
784 s1 = sp[0];
785 dp[0] = (dp[0] + ((unsigned int)(s1 + (s2 = sp[1]) + 1) >> 1) + 1) >> 1;
786 dp[1] = (dp[1] + ((unsigned int)(s2 + (s1 = sp[2]) + 1) >> 1) + 1) >> 1;
787 dp[2] = (dp[2] + ((unsigned int)(s1 + (s2 = sp[3]) + 1) >> 1) + 1) >> 1;
788 dp[3] = (dp[3] + ((unsigned int)(s2 + (s1 = sp[4]) + 1) >> 1) + 1) >> 1;
789 dp[4] = (dp[4] + ((unsigned int)(s1 + (s2 = sp[5]) + 1) >> 1) + 1) >> 1;
790 dp[5] = (dp[5] + ((unsigned int)(s2 + (s1 = sp[6]) + 1) >> 1) + 1) >> 1;
791 dp[6] = (dp[6] + ((unsigned int)(s1 + (s2 = sp[7]) + 1) >> 1) + 1) >> 1;
792 dp[7] = (dp[7] + ((unsigned int)(s2 + sp[8] + 1) >> 1) + 1) >> 1;
793 sp += lx2;
794 dp += lx2;
795 }
796}
797
798
799static inline void rec4(unsigned char *s, unsigned char *d, int lx, int lx2, int h)
800{
801 unsigned char *dp,*sp,*sp2;
802 unsigned int s1,s2,s3,s4;
803 int j;
804
805 sp = s;
806 sp2 = s+lx;
807 dp = d;
808 for (j=0; j<h; j++){
809 s1=sp[0]; s3=sp2[0];
810 dp[0] = (unsigned int)(s1+(s2=sp[1])+s3+(s4=sp2[1])+2)>>2;
811 dp[1] = (unsigned int)(s2+(s1=sp[2])+s4+(s3=sp2[2])+2)>>2;
812 dp[2] = (unsigned int)(s1+(s2=sp[3])+s3+(s4=sp2[3])+2)>>2;
813 dp[3] = (unsigned int)(s2+(s1=sp[4])+s4+(s3=sp2[4])+2)>>2;
814 dp[4] = (unsigned int)(s1+(s2=sp[5])+s3+(s4=sp2[5])+2)>>2;
815 dp[5] = (unsigned int)(s2+(s1=sp[6])+s4+(s3=sp2[6])+2)>>2;
816 dp[6] = (unsigned int)(s1+(s2=sp[7])+s3+(s4=sp2[7])+2)>>2;
817 dp[7] = (unsigned int)(s2+(s1=sp[8])+s4+(s3=sp2[8])+2)>>2;
818 dp[8] = (unsigned int)(s1+(s2=sp[9])+s3+(s4=sp2[9])+2)>>2;
819 dp[9] = (unsigned int)(s2+(s1=sp[10])+s4+(s3=sp2[10])+2)>>2;
820 dp[10] = (unsigned int)(s1+(s2=sp[11])+s3+(s4=sp2[11])+2)>>2;
821 dp[11] = (unsigned int)(s2+(s1=sp[12])+s4+(s3=sp2[12])+2)>>2;
822 dp[12] = (unsigned int)(s1+(s2=sp[13])+s3+(s4=sp2[13])+2)>>2;
823 dp[13] = (unsigned int)(s2+(s1=sp[14])+s4+(s3=sp2[14])+2)>>2;
824 dp[14] = (unsigned int)(s1+(s2=sp[15])+s3+(s4=sp2[15])+2)>>2;
825 dp[15] = (unsigned int)(s2+sp[16]+s4+sp2[16]+2)>>2;
826 sp+= lx2;
827 sp2+= lx2;
828 dp+= lx2;
829 }
830}
831
832
833static inline void rec4c(unsigned char *s,unsigned char *d, int lx, int lx2, int h)
834{
835 unsigned char *dp,*sp,*sp2;
836 unsigned int s1,s2,s3,s4;
837 int j;
838
839 sp = s;
840 sp2 = s+lx;
841 dp = d;
842 for (j=0; j<h; j++){
843 s1=sp[0]; s3=sp2[0];
844 dp[0] = (unsigned int)(s1+(s2=sp[1])+s3+(s4=sp2[1])+2)>>2;
845 dp[1] = (unsigned int)(s2+(s1=sp[2])+s4+(s3=sp2[2])+2)>>2;
846 dp[2] = (unsigned int)(s1+(s2=sp[3])+s3+(s4=sp2[3])+2)>>2;
847 dp[3] = (unsigned int)(s2+(s1=sp[4])+s4+(s3=sp2[4])+2)>>2;
848 dp[4] = (unsigned int)(s1+(s2=sp[5])+s3+(s4=sp2[5])+2)>>2;
849 dp[5] = (unsigned int)(s2+(s1=sp[6])+s4+(s3=sp2[6])+2)>>2;
850 dp[6] = (unsigned int)(s1+(s2=sp[7])+s3+(s4=sp2[7])+2)>>2;
851 dp[7] = (unsigned int)(s2+sp[8]+s4+sp2[8]+2)>>2;
852 sp+= lx2;
853 sp2+= lx2;
854 dp+= lx2;
855 }
856}
857
858
859static inline void rec4a(unsigned char *s,unsigned char *d, int lx, int lx2, int h)
860{
861 unsigned char *dp=d, *sp=s, *sp2=s+lx;
862 unsigned int s1, s2, s3, s4;
863 int j;
864
865/*
866 sp = s;
867 sp2 = s+lx;
868 dp = d;
869*/
870 for (j=0; j<h; j++){
871 s1=sp[0]; s3=sp2[0];
872 dp[0] = (dp[0] + ((unsigned int)(s1+(s2=sp[1])+s3+(s4=sp2[1])+2)>>2) + 1)>>1;
873 dp[1] = (dp[1] + ((unsigned int)(s2+(s1=sp[2])+s4+(s3=sp2[2])+2)>>2) + 1)>>1;
874 dp[2] = (dp[2] + ((unsigned int)(s1+(s2=sp[3])+s3+(s4=sp2[3])+2)>>2) + 1)>>1;
875 dp[3] = (dp[3] + ((unsigned int)(s2+(s1=sp[4])+s4+(s3=sp2[4])+2)>>2) + 1)>>1;
876 dp[4] = (dp[4] + ((unsigned int)(s1+(s2=sp[5])+s3+(s4=sp2[5])+2)>>2) + 1)>>1;
877 dp[5] = (dp[5] + ((unsigned int)(s2+(s1=sp[6])+s4+(s3=sp2[6])+2)>>2) + 1)>>1;
878 dp[6] = (dp[6] + ((unsigned int)(s1+(s2=sp[7])+s3+(s4=sp2[7])+2)>>2) + 1)>>1;
879 dp[7] = (dp[7] + ((unsigned int)(s2+(s1=sp[8])+s4+(s3=sp2[8])+2)>>2) + 1)>>1;
880 dp[8] = (dp[8] + ((unsigned int)(s1+(s2=sp[9])+s3+(s4=sp2[9])+2)>>2) + 1)>>1;
881 dp[9] = (dp[9] + ((unsigned int)(s2+(s1=sp[10])+s4+(s3=sp2[10])+2)>>2) + 1)>>1;
882 dp[10] = (dp[10] + ((unsigned int)(s1+(s2=sp[11])+s3+(s4=sp2[11])+2)>>2) + 1)>>1;
883 dp[11] = (dp[11] + ((unsigned int)(s2+(s1=sp[12])+s4+(s3=sp2[12])+2)>>2) + 1)>>1;
884 dp[12] = (dp[12] + ((unsigned int)(s1+(s2=sp[13])+s3+(s4=sp2[13])+2)>>2) + 1)>>1;
885 dp[13] = (dp[13] + ((unsigned int)(s2+(s1=sp[14])+s4+(s3=sp2[14])+2)>>2) + 1)>>1;
886 dp[14] = (dp[14] + ((unsigned int)(s1+(s2=sp[15])+s3+(s4=sp2[15])+2)>>2) + 1)>>1;
887 dp[15] = (dp[15] + ((unsigned int)(s2+sp[16]+s4+sp2[16]+2)>>2) + 1)>>1;
888 sp+= lx2;
889 sp2+= lx2;
890 dp+= lx2;
891 }
892}
893
894
895static inline void rec4ac(unsigned char *s,unsigned char *d, int lx, int lx2, int h)
896{
897 unsigned char *dp=d, *sp=s, *sp2=s+lx;
898 unsigned int s1,s2,s3,s4;
899 int j;
900
901/*
902 sp = s;
903 sp2 = s+lx;
904 dp = d;
905*/
906 for (j=0; j<h; j++)
907 {
908 s1=sp[0]; s3=sp2[0];
909 dp[0] = (dp[0] + ((unsigned int)(s1+(s2=sp[1])+s3+(s4=sp2[1])+2)>>2) + 1)>>1;
910 dp[1] = (dp[1] + ((unsigned int)(s2+(s1=sp[2])+s4+(s3=sp2[2])+2)>>2) + 1)>>1;
911 dp[2] = (dp[2] + ((unsigned int)(s1+(s2=sp[3])+s3+(s4=sp2[3])+2)>>2) + 1)>>1;
912 dp[3] = (dp[3] + ((unsigned int)(s2+(s1=sp[4])+s4+(s3=sp2[4])+2)>>2) + 1)>>1;
913 dp[4] = (dp[4] + ((unsigned int)(s1+(s2=sp[5])+s3+(s4=sp2[5])+2)>>2) + 1)>>1;
914 dp[5] = (dp[5] + ((unsigned int)(s2+(s1=sp[6])+s4+(s3=sp2[6])+2)>>2) + 1)>>1;
915 dp[6] = (dp[6] + ((unsigned int)(s1+(s2=sp[7])+s3+(s4=sp2[7])+2)>>2) + 1)>>1;
916 dp[7] = (dp[7] + ((unsigned int)(s2+sp[8]+s4+sp2[8]+2)>>2) + 1)>>1;
917 sp+= lx2;
918 sp2+= lx2;
919 dp+= lx2;
920 }
921}
922
923static inline
924void recon_comp(mpeg3video_t *video,
925 unsigned char *src,
926 unsigned char *dst,
927 int lx,
928 int lx2,
929 int w,
930 int h,
931 int x,
932 int y,
933 int dx,
934 int dy,
935 int addflag)
936{
937 int switcher;
938 unsigned char *s, *d;
939
940/* half pel scaling */
941 switcher = (dx & 1) << 3 | (dy & 1) << 2 | w;
942 if(addflag) switcher |= 2;
943/* origins */
944 s = src + lx * (y + (dy >> 1)) + x + (dx >> 1);
945 d = dst + lx * y + x;
946
947// Accelerated functions
948#ifdef HAVE_3Dnow
949 if(video->have_mmx)
950 {
951 switch(switcher)
952 {
953 case 0x3: reca_mmx(s, d, lx2, h); break;
954 case 0x2:recac_mmx(s, d, lx2, h); break;
955 case 0x1:rec_mmx(s, d, lx2, h); break;
956 case 0x0:recc_mmx(s, d, lx2, h); break;
957 case 0x7: recva_mmx(s, d, lx, lx2, h); break;
958 case 0x6: recvac_mmx(s, d, lx, lx2, h); break;
959 case 0x5:recv_mmx(s, d, lx, lx2, h); break;
960 case 0x4:recvc_mmx(s, d, lx, lx2, h); break;
961 case 0x9:rech_mmx(s, d, lx2, h); break;
962 case 0x8: rechc_mmx(s, d, lx2, h); break;
963 }
964 }
965 else
966#endif
967 {
968 switch(switcher)
969 {
970 case 0x3: reca(s, d, lx2, h); break;
971 case 0x2:recac(s, d, lx2, h); break;
972 case 0x1:rec(s, d, lx2, h); break;
973 case 0x0:recc(s, d, lx2, h); break;
974 case 0x7: recva(s, d, lx, lx2, h); break;
975 case 0x6: recvac(s, d, lx, lx2, h); break;
976 case 0x5:recv_(s, d, lx, lx2, h); break;
977 case 0x4:recvc(s, d, lx, lx2, h); break;
978 case 0x9:rech(s, d, lx2, h); break;
979 case 0x8: rechc(s, d, lx2, h); break;
980 }
981 }
982
983// Unaccelerated functions
984 switch(switcher)
985 {
986 case 0xb: recha(s, d, lx2, h); break;
987 case 0xa:rechac(s, d, lx2, h); break;
988 case 0xf: rec4a(s, d, lx, lx2, h); break;
989 case 0xe:rec4ac(s, d, lx, lx2, h); break;
990 case 0xd:rec4(s, d, lx, lx2, h); break;
991 case 0xc:rec4c(s, d, lx, lx2, h); break;
992 }
993}
994
995/*
996 unsigned char *src[]; * prediction source buffer *
997 int sfield; * prediction source field number (0 or 1) *
998 unsigned char *dst[]; * prediction destination buffer *
999 int dfield; * prediction destination field number (0 or 1)*
1000 int lx,lx2; * horizontal offsets *
1001 int w,h; * prediction block/sub-block width, height *
1002 int x,y; * pixel co-ordinates of top-left sample in current MB *
1003 int dx,dy; * horizontal, vertical motion vector *
1004 int addflag; * add prediction error to prediction ? *
1005*/
1006static void recon(mpeg3video_t *video,
1007 unsigned char *src[],
1008 int sfield,
1009 unsigned char *dst[],
1010 int dfield,
1011 int lx,
1012 int lx2,
1013 int w,
1014 int h,
1015 int x,
1016 int y,
1017 int dx,
1018 int dy,
1019 int addflag)
1020{
1021
1022/* Y */
1023 recon_comp(video, (src[0] + (sfield ? (lx2 >> 1) : 0)),
1024 dst[0] + (dfield ? (lx2 >> 1) : 0),
1025 lx, lx2, w, h, x, y, dx, dy, addflag);
1026
1027 if(video->chroma_format != CHROMA444)
1028 {
1029 lx >>= 1;
1030 dx /= 2;
1031 lx2 >>= 1;
1032 w = 0;
1033 x >>= 1;
1034 }
1035
1036 if(video->chroma_format == CHROMA420)
1037 {
1038 h >>= 1;
1039 dy /= 2;
1040 y >>= 1;
1041 }
1042
1043/* Cb */
1044 recon_comp(video, (src[1] + (sfield ? (lx2 >> 1) : 0)),
1045 dst[1] + (dfield ? (lx2 >> 1) : 0),
1046 lx, lx2, w, h, x, y, dx, dy, addflag);
1047
1048/* Cr */
1049 recon_comp(video, (src[2] + (sfield ? (lx2 >> 1) : 0)),
1050 dst[2] + (dfield ? (lx2 >> 1) : 0),
1051 lx, lx2, w, h, x, y, dx, dy, addflag);
1052}
1053
1054#define WIDTH 1
1055
1056int mpeg3video_reconstruct(mpeg3video_t *video,
1057 int bx,
1058 int by,
1059 int mb_type,
1060 int motion_type,
1061 int PMV[2][2][2],
1062 int mv_field_sel[2][2],
1063 int dmvector[2],
1064 int stwtype)
1065{
1066 int currentfield;
1067 unsigned char **predframe;
1068 int DMV[2][2];
1069 int stwtop, stwbot;
1070
1071 stwtop = stwtype % 3; /* 0:temporal, 1 : (spat+temp) / 2, 2 : spatial */
1072 stwbot = stwtype / 3;
1073
1074 if((mb_type & MB_FORWARD) || (video->pict_type == P_TYPE))
1075 {
1076 if(video->pict_struct == FRAME_PICTURE)
1077 {
1078 if((motion_type == MC_FRAME) || !(mb_type & MB_FORWARD))
1079 {
1080/* frame-based prediction */
1081 {
1082 if(stwtop < 2)
1083 recon(video, video->oldrefframe, 0, video->newframe, 0,
1084 video->coded_picture_width, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1085 PMV[0][0][0], PMV[0][0][1], stwtop);
1086
1087 if(stwbot < 2)
1088 recon(video, video->oldrefframe, 1, video->newframe, 1,
1089 video->coded_picture_width, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1090 PMV[0][0][0], PMV[0][0][1], stwbot);
1091 }
1092 }
1093 else if(motion_type == MC_FIELD) /* field-based prediction */
1094 {
1095/* top field prediction */
1096 if(stwtop < 2)
1097 recon(video, video->oldrefframe, mv_field_sel[0][0], video->newframe, 0,
1098 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by >> 1,
1099 PMV[0][0][0], PMV[0][0][1] >> 1, stwtop);
1100
1101/* bottom field prediction */
1102 if(stwbot < 2)
1103 recon(video, video->oldrefframe, mv_field_sel[1][0], video->newframe, 1,
1104 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by >> 1,
1105 PMV[1][0][0], PMV[1][0][1] >> 1, stwbot);
1106 }
1107 else if(motion_type == MC_DMV)
1108 {
1109/* dual prime prediction */
1110/* calculate derived motion vectors */
1111 mpeg3video_calc_dmv(video,
1112 DMV,
1113 dmvector,
1114 PMV[0][0][0],
1115 PMV[0][0][1] >> 1);
1116
1117 if(stwtop < 2)
1118 {
1119/* predict top field from top field */
1120 recon(video, video->oldrefframe, 0, video->newframe, 0,
1121 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by>>1,
1122 PMV[0][0][0], PMV[0][0][1] >> 1, 0);
1123
1124/* predict and add to top field from bottom field */
1125 recon(video, video->oldrefframe, 1, video->newframe, 0,
1126 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by>>1,
1127 DMV[0][0], DMV[0][1], 1);
1128 }
1129
1130 if(stwbot < 2)
1131 {
1132/* predict bottom field from bottom field */
1133 recon(video, video->oldrefframe, 1, video->newframe, 1,
1134 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by>>1,
1135 PMV[0][0][0], PMV[0][0][1]>>1, 0);
1136
1137/* predict and add to bottom field from top field */
1138 recon(video, video->oldrefframe, 0, video->newframe, 1,
1139 video->coded_picture_width << 1, video->coded_picture_width<<1, WIDTH, 8, bx, by>>1,
1140 DMV[1][0], DMV[1][1], 1);
1141 }
1142 }
1143 else
1144/* invalid motion_type */
1145 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1146 ;
1147 }
1148 else
1149 {
1150/* TOP_FIELD or BOTTOM_FIELD */
1151/* field picture */
1152 currentfield = (video->pict_struct == BOTTOM_FIELD);
1153
1154/* determine which frame to use for prediction */
1155 if((video->pict_type == P_TYPE) && video->secondfield
1156 && (currentfield != mv_field_sel[0][0]))
1157 predframe = video->refframe; /* same frame */
1158 else
1159 predframe = video->oldrefframe; /* previous frame */
1160
1161 if((motion_type == MC_FIELD) || !(mb_type & MB_FORWARD))
1162 {
1163/* field-based prediction */
1164 if(stwtop < 2)
1165 recon(video, predframe,mv_field_sel[0][0],video->newframe,0,
1166 video->coded_picture_width << 1,video->coded_picture_width << 1,WIDTH,16,bx,by,
1167 PMV[0][0][0],PMV[0][0][1],stwtop);
1168 }
1169 else
1170 if(motion_type == MC_16X8)
1171 {
1172 if(stwtop < 2)
1173 {
1174 recon(video, predframe, mv_field_sel[0][0], video->newframe, 0,
1175 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1176 PMV[0][0][0], PMV[0][0][1], stwtop);
1177
1178 /* determine which frame to use for lower half prediction */
1179 if((video->pict_type==P_TYPE) && video->secondfield
1180 && (currentfield!=mv_field_sel[1][0]))
1181 predframe = video->refframe; /* same frame */
1182 else
1183 predframe = video->oldrefframe; /* previous frame */
1184
1185 recon(video, predframe, mv_field_sel[1][0], video->newframe, 0,
1186 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by+8,
1187 PMV[1][0][0], PMV[1][0][1], stwtop);
1188 }
1189 }
1190 else
1191 if(motion_type == MC_DMV) /* dual prime prediction */
1192 {
1193 if(video->secondfield)
1194 predframe = video->refframe; /* same frame */
1195 else
1196 predframe = video->oldrefframe; /* previous frame */
1197
1198/* calculate derived motion vectors */
1199 mpeg3video_calc_dmv(video,
1200 DMV,
1201 dmvector,
1202 PMV[0][0][0],
1203 PMV[0][0][1]);
1204
1205/* predict from field of same parity */
1206 recon(video, video->oldrefframe, currentfield, video->newframe, 0,
1207 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 16, bx, by,
1208 PMV[0][0][0], PMV[0][0][1], 0);
1209
1210/* predict from field of opposite parity */
1211 recon(video, predframe, !currentfield, video->newframe, 0,
1212 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 16, bx, by,
1213 DMV[0][0], DMV[0][1], 1);
1214 }
1215 else
1216/* invalid motion_type */
1217 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1218 ;
1219 }
1220 stwtop = stwbot = 1;
1221 }
1222
1223 if(mb_type & MB_BACKWARD)
1224 {
1225 if(video->pict_struct == FRAME_PICTURE)
1226 {
1227 if(motion_type == MC_FRAME)
1228 {
1229/* frame-based prediction */
1230 if(stwtop < 2)
1231 recon(video, video->refframe, 0, video->newframe, 0,
1232 video->coded_picture_width, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1233 PMV[0][1][0], PMV[0][1][1], stwtop);
1234
1235 if(stwbot < 2)
1236 recon(video, video->refframe, 1, video->newframe, 1,
1237 video->coded_picture_width, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1238 PMV[0][1][0], PMV[0][1][1], stwbot);
1239 }
1240 else
1241 {
1242/* field-based prediction */
1243/* top field prediction */
1244 if(stwtop < 2)
1245 {
1246 recon(video, video->refframe, mv_field_sel[0][1], video->newframe, 0,
1247 (video->coded_picture_width << 1), (video->coded_picture_width<<1), WIDTH, 8, bx, (by >> 1),
1248 PMV[0][1][0], (PMV[0][1][1] >> 1), stwtop);
1249 }
1250
1251/* bottom field prediction */
1252 if(stwbot < 2)
1253 {
1254 recon(video, video->refframe, mv_field_sel[1][1], video->newframe, 1, (video->coded_picture_width << 1),
1255 (video->coded_picture_width << 1), WIDTH, 8, bx, (by>>1),
1256 PMV[1][1][0], (PMV[1][1][1]>>1), stwbot);
1257 }
1258 }
1259 }
1260 else
1261 {
1262/* TOP_FIELD or BOTTOM_FIELD */
1263/* field picture */
1264 if(motion_type == MC_FIELD)
1265 {
1266/* field-based prediction */
1267 recon(video, video->refframe, mv_field_sel[0][1], video->newframe, 0,
1268 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 16, bx, by,
1269 PMV[0][1][0], PMV[0][1][1], stwtop);
1270 }
1271 else if(motion_type==MC_16X8)
1272 {
1273 recon(video, video->refframe, mv_field_sel[0][1], video->newframe, 0,
1274 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by,
1275 PMV[0][1][0], PMV[0][1][1], stwtop);
1276
1277 recon(video, video->refframe, mv_field_sel[1][1], video->newframe, 0,
1278 video->coded_picture_width << 1, video->coded_picture_width << 1, WIDTH, 8, bx, by+8,
1279 PMV[1][1][0], PMV[1][1][1], stwtop);
1280 }
1281 else
1282/* invalid motion_type */
1283 /* fprintf(stderr, "reconstruct: invalid motion_type\n"); */
1284 ;
1285 }
1286 } /* mb_type & MB_BACKWARD */
1287 return 0;
1288}
1289
1290
diff --git a/core/multimedia/opieplayer/libmpeg3/video/seek.c b/core/multimedia/opieplayer/libmpeg3/video/seek.c
new file mode 100644
index 0000000..04faba4
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/seek.c
@@ -0,0 +1,233 @@
1#include "../mpeg3private.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include <stdlib.h>
5#include <string.h>
6
7unsigned int mpeg3bits_next_startcode(mpeg3_bits_t* stream)
8{
9/* Perform forwards search */
10 mpeg3bits_byte_align(stream);
11
12/* Perform search */
13 while((mpeg3bits_showbits32_noptr(stream) >> 8) != MPEG3_PACKET_START_CODE_PREFIX &&
14 !mpeg3bits_eof(stream))
15 {
16 mpeg3bits_getbyte_noptr(stream);
17 }
18 return mpeg3bits_showbits32_noptr(stream);
19}
20
21/* Line up on the beginning of the next code. */
22int mpeg3video_next_code(mpeg3_bits_t* stream, unsigned int code)
23{
24 while(!mpeg3bits_eof(stream) &&
25 mpeg3bits_showbits32_noptr(stream) != code)
26 {
27 mpeg3bits_getbyte_noptr(stream);
28 }
29 return mpeg3bits_eof(stream);
30}
31
32/* Line up on the beginning of the previous code. */
33int mpeg3video_prev_code(mpeg3_bits_t* stream, unsigned int code)
34{
35 while(!mpeg3bits_bof(stream) &&
36 mpeg3bits_showbits_reverse(stream, 32) != code)
37 {
38 mpeg3bits_getbits_reverse(stream, 8);
39 }
40 return mpeg3bits_bof(stream);
41}
42
43long mpeg3video_goptimecode_to_frame(mpeg3video_t *video)
44{
45/* printf("mpeg3video_goptimecode_to_frame %d %d %d %d %f\n", */
46 /* video->gop_timecode.hour, video->gop_timecode.minute, video->gop_timecode.second, video->gop_timecode.frame, video->frame_rate); */
47 return (long)(video->gop_timecode.hour * 3600 * video->frame_rate +
48 video->gop_timecode.minute * 60 * video->frame_rate +
49 video->gop_timecode.second * video->frame_rate +
50 video->gop_timecode.frame) - 1 - video->first_frame;
51}
52
53int mpeg3video_match_refframes(mpeg3video_t *video)
54{
55 unsigned char *dst, *src;
56 int i, j, size;
57
58 for(i = 0; i < 3; i++)
59 {
60 if(video->newframe[i])
61 {
62 if(video->newframe[i] == video->refframe[i])
63 {
64 src = video->refframe[i];
65 dst = video->oldrefframe[i];
66 }
67 else
68 {
69 src = video->oldrefframe[i];
70 dst = video->refframe[i];
71 }
72
73 if(i == 0)
74 size = video->coded_picture_width * video->coded_picture_height + 32 * video->coded_picture_width;
75 else
76 size = video->chrom_width * video->chrom_height + 32 * video->chrom_width;
77
78 memcpy(dst, src, size);
79 }
80 }
81 return 0;
82}
83
84int mpeg3video_seek(mpeg3video_t *video)
85{
86 long this_gop_start;
87 int result = 0;
88 int back_step;
89 int attempts;
90 mpeg3_t *file = video->file;
91 mpeg3_bits_t *vstream = video->vstream;
92 double percentage;
93 long frame_number;
94 int match_refframes = 1;
95
96/* Seek to a percentage */
97 if(video->percentage_seek >= 0)
98 {
99 percentage = video->percentage_seek;
100 video->percentage_seek = -1;
101 mpeg3bits_seek_percentage(vstream, percentage);
102// Go to previous I-frame
103 mpeg3bits_start_reverse(vstream);
104 result = mpeg3video_prev_code(vstream, MPEG3_GOP_START_CODE);
105 if(!result) mpeg3bits_getbits_reverse(vstream, 32);
106 mpeg3bits_start_forward(vstream);
107
108 if(mpeg3bits_tell_percentage(vstream) < 0) mpeg3bits_seek_percentage(vstream, 0);
109
110// Read up to the correct percentage
111 result = 0;
112 while(!result && mpeg3bits_tell_percentage(vstream) < percentage)
113 {
114 result = mpeg3video_read_frame_backend(video, 0);
115 if(match_refframes)
116 mpeg3video_match_refframes(video);
117 match_refframes = 0;
118 }
119 }
120 else
121/* Seek to a frame */
122 if(video->frame_seek >= 0)
123 {
124 frame_number = video->frame_seek;
125 video->frame_seek = -1;
126 if(frame_number < 0) frame_number = 0;
127 if(frame_number > video->maxframe) frame_number = video->maxframe;
128
129/* Seek to start of file */
130 if(frame_number < 16)
131 {
132 video->repeat_count = video->current_repeat = 0;
133 mpeg3bits_seek_start(vstream);
134 video->framenum = 0;
135 result = mpeg3video_drop_frames(video, frame_number - video->framenum);
136 }
137 else
138 {
139/* Seek to an I frame. */
140 if((frame_number < video->framenum || frame_number - video->framenum > MPEG3_SEEK_THRESHOLD))
141 {
142/* Elementary stream */
143 if(file->is_video_stream)
144 {
145 mpeg3_t *file = video->file;
146 mpeg3_vtrack_t *track = video->track;
147 long byte = (long)((float)(mpeg3demuxer_total_bytes(vstream->demuxer) /
148 track->total_frames) *
149 frame_number);
150 long minimum = 65535;
151 int done = 0;
152
153//printf("seek elementary %d\n", frame_number);
154/* Get GOP just before frame */
155 do
156 {
157 result = mpeg3bits_seek_byte(vstream, byte);
158 mpeg3bits_start_reverse(vstream);
159 if(!result) result = mpeg3video_prev_code(vstream, MPEG3_GOP_START_CODE);
160 mpeg3bits_start_forward(vstream);
161 mpeg3bits_getbits(vstream, 8);
162 if(!result) result = mpeg3video_getgophdr(video);
163 this_gop_start = mpeg3video_goptimecode_to_frame(video);
164
165//printf("wanted %ld guessed %ld byte %ld result %d\n", frame_number, this_gop_start, byte, result);
166 if(labs(this_gop_start - frame_number) >= labs(minimum))
167 done = 1;
168 else
169 {
170 minimum = this_gop_start - frame_number;
171 byte += (long)((float)(frame_number - this_gop_start) *
172 (float)(mpeg3demuxer_total_bytes(vstream->demuxer) /
173 track->total_frames));
174 if(byte < 0) byte = 0;
175 }
176 }while(!result && !done);
177
178//printf("wanted %d guessed %d\n", frame_number, this_gop_start);
179 if(!result)
180 {
181 video->framenum = this_gop_start;
182 result = mpeg3video_drop_frames(video, frame_number - video->framenum);
183 }
184 }
185 else
186/* System stream */
187 {
188 mpeg3bits_seek_time(vstream, (double)frame_number / video->frame_rate);
189 percentage = mpeg3bits_tell_percentage(vstream);
190//printf("seek frame %ld percentage %f byte %ld\n", frame_number, percentage, mpeg3bits_tell(vstream));
191 mpeg3bits_start_reverse(vstream);
192 mpeg3video_prev_code(vstream, MPEG3_GOP_START_CODE);
193 mpeg3bits_getbits_reverse(vstream, 32);
194 mpeg3bits_start_forward(vstream);
195//printf("seek system 1 %f\n", (double)frame_number / video->frame_rate);
196
197 while(!result && mpeg3bits_tell_percentage(vstream) < percentage)
198 {
199 result = mpeg3video_read_frame_backend(video, 0);
200 if(match_refframes)
201 mpeg3video_match_refframes(video);
202
203//printf("seek system 2 %f %f\n", mpeg3bits_tell_percentage(vstream) / percentage);
204 match_refframes = 0;
205 }
206//printf("seek system 3 %f\n", (double)frame_number / video->frame_rate);
207 }
208
209 video->framenum = frame_number;
210 }
211 else
212// Drop frames
213 {
214 mpeg3video_drop_frames(video, frame_number - video->framenum);
215 }
216 }
217 }
218
219 return result;
220}
221
222int mpeg3video_drop_frames(mpeg3video_t *video, long frames)
223{
224 int result = 0;
225 long frame_number = video->framenum + frames;
226
227/* Read the selected number of frames and skip b-frames */
228 while(!result && frame_number > video->framenum)
229 {
230 result = mpeg3video_read_frame_backend(video, frame_number - video->framenum);
231 }
232 return result;
233}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/slice.c b/core/multimedia/opieplayer/libmpeg3/video/slice.c
new file mode 100644
index 0000000..90891b0
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/slice.c
@@ -0,0 +1,702 @@
1#include "../libmpeg3.h"
2#include "../mpeg3protos.h"
3#include "mpeg3video.h"
4#include "mpeg3videoprotos.h"
5#include "slice.h"
6
7#include <stdlib.h>
8
9static ULONGLONG MMX_128 = 0x80008000800080LL;
10
11int mpeg3_new_slice_buffer(mpeg3_slice_buffer_t *slice_buffer)
12{
13 pthread_mutexattr_t mutex_attr;
14 slice_buffer->data = (unsigned char*)malloc(1024);
15 slice_buffer->buffer_size = 0;
16 slice_buffer->buffer_allocation = 1024;
17 slice_buffer->current_position = 0;
18 slice_buffer->bits_size = 0;
19 slice_buffer->bits = 0;
20 slice_buffer->done = 0;
21 pthread_mutexattr_init(&mutex_attr);
22 pthread_mutex_init(&(slice_buffer->completion_lock), &mutex_attr);
23 return 0;
24}
25
26int mpeg3_delete_slice_buffer(mpeg3_slice_buffer_t *slice_buffer)
27{
28 free(slice_buffer->data);
29 pthread_mutex_destroy(&(slice_buffer->completion_lock));
30 return 0;
31}
32
33int mpeg3_expand_slice_buffer(mpeg3_slice_buffer_t *slice_buffer)
34{
35 int i;
36 unsigned char *new_buffer =
37 (unsigned char*)malloc(slice_buffer->buffer_allocation * 2);
38 for(i = 0; i < slice_buffer->buffer_size; i++)
39 new_buffer[i] = slice_buffer->data[i];
40 free(slice_buffer->data);
41 slice_buffer->data = new_buffer;
42 slice_buffer->buffer_allocation *= 2;
43 return 0;
44}
45
46/* limit coefficients to -2048..2047 */
47
48/* move/add 8x8-Block from block[comp] to refframe */
49
50static inline int mpeg3video_addblock(mpeg3_slice_t *slice,
51 mpeg3video_t *video,
52 int comp,
53 int bx,
54 int by,
55 int dct_type,
56 int addflag)
57{
58 int cc, i, iincr;
59 unsigned char *rfp;
60 short *bp;
61 int spar = slice->sparse[comp];
62/* color component index */
63 cc = (comp < 4) ? 0 : (comp & 1) + 1;
64
65 if(cc == 0)
66 {
67/* luminance */
68 if(video->pict_struct == FRAME_PICTURE)
69 {
70 if(dct_type)
71 {
72/* field DCT coding */
73 rfp = video->newframe[0] +
74 video->coded_picture_width * (by + ((comp & 2) >> 1)) + bx + ((comp & 1) << 3);
75 iincr = (video->coded_picture_width << 1);
76 }
77 else
78 {
79/* frame DCT coding */
80 rfp = video->newframe[0] +
81 video->coded_picture_width * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3);
82 iincr = video->coded_picture_width;
83 }
84 }
85 else
86 {
87/* field picture */
88 rfp = video->newframe[0] +
89 (video->coded_picture_width << 1) * (by + ((comp & 2) << 2)) + bx + ((comp & 1) << 3);
90 iincr = (video->coded_picture_width << 1);
91 }
92 }
93 else
94 {
95/* chrominance */
96
97/* scale coordinates */
98 if(video->chroma_format != CHROMA444) bx >>= 1;
99 if(video->chroma_format == CHROMA420) by >>= 1;
100 if(video->pict_struct == FRAME_PICTURE)
101 {
102 if(dct_type && (video->chroma_format != CHROMA420))
103 {
104/* field DCT coding */
105 rfp = video->newframe[cc]
106 + video->chrom_width * (by + ((comp & 2) >> 1)) + bx + (comp & 8);
107 iincr = (video->chrom_width << 1);
108 }
109 else
110 {
111/* frame DCT coding */
112 rfp = video->newframe[cc]
113 + video->chrom_width * (by + ((comp & 2) << 2)) + bx + (comp & 8);
114 iincr = video->chrom_width;
115 }
116 }
117 else
118 {
119/* field picture */
120 rfp = video->newframe[cc]
121 + (video->chrom_width << 1) * (by + ((comp & 2) << 2)) + bx + (comp & 8);
122 iincr = (video->chrom_width << 1);
123 }
124 }
125
126 bp = slice->block[comp];
127
128 if(addflag)
129 {
130#ifdef HAVE_MMX
131 if(video->have_mmx)
132 {
133 if(spar)
134 {
135 __asm__ __volatile__(
136 "movq (%2), %%mm6\n" /* 4 blockvals */
137 "pxor %%mm4, %%mm4\n"
138 "punpcklwd %%mm6, %%mm6\n"
139 "punpcklwd %%mm6, %%mm6\n"
140 ".align 8\n"
141 "1:"
142 "movq (%1), %%mm0\n" /* 8 rindex1 */
143 "movq %%mm0, %%mm2\n"
144 "punpcklbw %%mm4, %%mm0\n"
145 "punpckhbw %%mm4, %%mm2\n"
146 "paddw %%mm6, %%mm0\n"
147 "paddw %%mm6, %%mm2\n"
148
149 "packuswb %%mm2, %%mm0\n"
150 "movq %%mm0, (%1)\n"
151
152 "leal (%1, %3), %1\n"
153 "loop 1b\n"
154 : /* scr dest */
155 : "c" (8),"r" (rfp), "r" (bp), "r" (iincr)
156 );
157 }
158 else
159 {
160 __asm__ __volatile__(
161 "pxor %%mm4, %%mm4\n"
162
163 ".align 8\n"
164 "1:"
165 "movq (%2), %%mm0\n" /* 8 rfp 0 1 2 3 4 5 6 7*/
166 "movq (%1), %%mm6\n" /* 4 blockvals 0 1 2 3 */
167
168 "movq %%mm0, %%mm2\n"
169 "movq 8(%1), %%mm5\n" /* 4 blockvals 0 1 2 3 */
170 "punpcklbw %%mm4, %%mm0\n" /* 0 2 4 6 */
171 "punpckhbw %%mm4, %%mm2\n" /* 1 3 5 7 */
172
173 "paddw %%mm6, %%mm0\n"
174 "paddw %%mm5, %%mm2\n"
175 "packuswb %%mm2, %%mm0\n"
176
177 "addl $16, %1\n"
178 "movq %%mm0, (%2)\n"
179
180 "leal (%2,%3), %2\n"
181 "loop 1b\n"
182 : /* scr dest */
183 : "c" (8),"r" (bp), "r" (rfp), "r" (iincr)
184 );
185 }
186 }
187 else
188#endif
189 for(i = 0; i < 8; i++)
190 {
191 rfp[0] = CLIP(bp[0] + rfp[0]);
192 rfp[1] = CLIP(bp[1] + rfp[1]);
193 rfp[2] = CLIP(bp[2] + rfp[2]);
194 rfp[3] = CLIP(bp[3] + rfp[3]);
195 rfp[4] = CLIP(bp[4] + rfp[4]);
196 rfp[5] = CLIP(bp[5] + rfp[5]);
197 rfp[6] = CLIP(bp[6] + rfp[6]);
198 rfp[7] = CLIP(bp[7] + rfp[7]);
199 rfp += iincr;
200 bp += 8;
201 }
202 }
203 else
204 {
205#ifdef HAVE_MMX
206 if(video->have_mmx)
207 {
208 if(spar)
209 {
210 __asm__ __volatile__(
211 "movd (%2), %%mm0\n" /* " 0 0 0 v1" */
212 "punpcklwd %%mm0, %%mm0\n" /* " 0 0 v1 v1" */
213 "punpcklwd %%mm0, %%mm0\n"
214 "paddw MMX_128, %%mm0\n"
215 "packuswb %%mm0, %%mm0\n"
216 "leal (%0,%1,2), %%eax\n"
217
218 "movq %%mm0, (%0, %1)\n"
219 "movq %%mm0, (%%eax)\n"
220 "leal (%%eax,%1,2), %0\n"
221 "movq %%mm0, (%%eax, %1)\n"
222
223 "movq %%mm0, (%0)\n"
224 "leal (%0,%1,2), %%eax\n"
225 "movq %%mm0, (%0, %1)\n"
226
227 "movq %%mm0, (%%eax)\n"
228 "movq %%mm0, (%%eax, %1)\n"
229 :
230 : "D" (rfp), "c" (iincr), "b" (bp)
231 : "eax");
232 }
233 else
234 {
235 __asm__ __volatile__(
236 "movq MMX_128,%%mm4\n"
237 ".align 8\n"
238 "1:"
239 "movq (%1), %%mm0\n"
240 "movq 8(%1), %%mm1\n"
241 "paddw %%mm4, %%mm0\n"
242
243 "movq 16(%1), %%mm2\n"
244 "paddw %%mm4, %%mm1\n"
245
246 "movq 24(%1), %%mm3\n"
247 "paddw %%mm4, %%mm2\n"
248
249 "packuswb %%mm1, %%mm0\n"
250 "paddw %%mm4, %%mm3\n"
251
252 "addl $32, %1\n"
253 "packuswb %%mm3, %%mm2\n"
254
255 "movq %%mm0, (%2)\n"
256
257 "movq %%mm2, (%2,%3)\n"
258
259 "leal (%2,%3,2), %2\n"
260 "loop 1b\n"
261 :
262 : "c" (4), "r" (bp), "r" (rfp), "r" (iincr)
263 );
264 }
265 }
266 else
267#endif
268 for(i = 0; i < 8; i++)
269 {
270 rfp[0] = CLIP(bp[0] + 128);
271 rfp[1] = CLIP(bp[1] + 128);
272 rfp[2] = CLIP(bp[2] + 128);
273 rfp[3] = CLIP(bp[3] + 128);
274 rfp[4] = CLIP(bp[4] + 128);
275 rfp[5] = CLIP(bp[5] + 128);
276 rfp[6] = CLIP(bp[6] + 128);
277 rfp[7] = CLIP(bp[7] + 128);
278 rfp+= iincr;
279 bp += 8;
280 }
281 }
282 return 0;
283}
284
285int mpeg3_decode_slice(mpeg3_slice_t *slice)
286{
287 mpeg3video_t *video = slice->video;
288 int comp;
289 int mb_type, cbp, motion_type = 0, dct_type;
290 int macroblock_address, mba_inc, mba_max;
291 int slice_vert_pos_ext;
292 unsigned int code;
293 int bx, by;
294 int dc_dct_pred[3];
295 int mv_count, mv_format, mvscale;
296 int pmv[2][2][2], mv_field_sel[2][2];
297 int dmv, dmvector[2];
298 int qs;
299 int stwtype, stwclass;
300 int snr_cbp;
301 int i;
302 mpeg3_slice_buffer_t *slice_buffer = slice->slice_buffer;
303
304/* number of macroblocks per picture */
305 mba_max = video->mb_width * video->mb_height;
306
307/* field picture has half as many macroblocks as frame */
308 if(video->pict_struct != FRAME_PICTURE)
309 mba_max >>= 1;
310
311/* macroblock address */
312 macroblock_address = 0;
313/* first macroblock in slice is not skipped */
314 mba_inc = 0;
315 slice->fault = 0;
316
317 code = mpeg3slice_getbits(slice_buffer, 32);
318/* decode slice header (may change quant_scale) */
319 slice_vert_pos_ext = mpeg3video_getslicehdr(slice, video);
320
321/* reset all DC coefficient and motion vector predictors */
322 dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
323 pmv[0][0][0] = pmv[0][0][1] = pmv[1][0][0] = pmv[1][0][1] = 0;
324 pmv[0][1][0] = pmv[0][1][1] = pmv[1][1][0] = pmv[1][1][1] = 0;
325
326 for(i = 0;
327 slice_buffer->current_position < slice_buffer->buffer_size;
328 i++)
329 {
330 if(mba_inc == 0)
331 {
332/* Done */
333 if(!mpeg3slice_showbits(slice_buffer, 23)) return 0;
334/* decode macroblock address increment */
335 mba_inc = mpeg3video_get_macroblock_address(slice);
336
337 if(slice->fault) return 1;
338
339 if(i == 0)
340 {
341/* Get the macroblock_address */
342 macroblock_address = ((slice_vert_pos_ext << 7) + (code & 255) - 1) * video->mb_width + mba_inc - 1;
343/* first macroblock in slice: not skipped */
344 mba_inc = 1;
345 }
346 }
347
348 if(slice->fault) return 1;
349
350 if(macroblock_address >= mba_max)
351 {
352/* mba_inc points beyond picture dimensions */
353 /*fprintf(stderr, "mpeg3_decode_slice: too many macroblocks in picture\n"); */
354 return 1;
355 }
356
357/* not skipped */
358 if(mba_inc == 1)
359 {
360 mpeg3video_macroblock_modes(slice,
361 video,
362 &mb_type,
363 &stwtype,
364 &stwclass,
365 &motion_type,
366 &mv_count,
367 &mv_format,
368 &dmv,
369 &mvscale,
370 &dct_type);
371
372 if(slice->fault) return 1;
373
374 if(mb_type & MB_QUANT)
375 {
376 qs = mpeg3slice_getbits(slice_buffer, 5);
377
378 if(video->mpeg2)
379 slice->quant_scale = video->qscale_type ? mpeg3_non_linear_mquant_table[qs] : (qs << 1);
380 else
381 slice->quant_scale = qs;
382
383 if(video->scalable_mode == SC_DP)
384/* make sure quant_scale is valid */
385 slice->quant_scale = slice->quant_scale;
386 }
387
388/* motion vectors */
389
390
391/* decode forward motion vectors */
392 if((mb_type & MB_FORWARD) || ((mb_type & MB_INTRA) && video->conceal_mv))
393 {
394 if(video->mpeg2)
395 mpeg3video_motion_vectors(slice,
396 video,
397 pmv,
398 dmvector,
399 mv_field_sel,
400 0,
401 mv_count,
402 mv_format,
403 video->h_forw_r_size,
404 video->v_forw_r_size,
405 dmv,
406 mvscale);
407 else
408 mpeg3video_motion_vector(slice,
409 video,
410 pmv[0][0],
411 dmvector,
412 video->forw_r_size,
413 video->forw_r_size,
414 0,
415 0,
416 video->full_forw);
417 }
418 if(slice->fault) return 1;
419
420/* decode backward motion vectors */
421 if(mb_type & MB_BACKWARD)
422 {
423 if(video->mpeg2)
424 mpeg3video_motion_vectors(slice,
425 video,
426 pmv,
427 dmvector,
428 mv_field_sel,
429 1,
430 mv_count,
431 mv_format,
432 video->h_back_r_size,
433 video->v_back_r_size,
434 0,
435 mvscale);
436 else
437 mpeg3video_motion_vector(slice,
438 video,
439 pmv[0][1],
440 dmvector,
441 video->back_r_size,
442 video->back_r_size,
443 0,
444 0,
445 video->full_back);
446 }
447
448 if(slice->fault) return 1;
449
450/* remove marker_bit */
451 if((mb_type & MB_INTRA) && video->conceal_mv)
452 mpeg3slice_flushbit(slice_buffer);
453
454/* macroblock_pattern */
455 if(mb_type & MB_PATTERN)
456 {
457 cbp = mpeg3video_get_cbp(slice);
458 if(video->chroma_format == CHROMA422)
459 {
460/* coded_block_pattern_1 */
461 cbp = (cbp << 2) | mpeg3slice_getbits2(slice_buffer);
462 }
463 else
464 if(video->chroma_format == CHROMA444)
465 {
466/* coded_block_pattern_2 */
467 cbp = (cbp << 6) | mpeg3slice_getbits(slice_buffer, 6);
468 }
469 }
470 else
471 cbp = (mb_type & MB_INTRA) ? ((1 << video->blk_cnt) - 1) : 0;
472
473 if(slice->fault) return 1;
474/* decode blocks */
475 mpeg3video_clearblock(slice, 0, video->blk_cnt);
476 for(comp = 0; comp < video->blk_cnt; comp++)
477 {
478 if(cbp & (1 << (video->blk_cnt - comp - 1)))
479 {
480 if(mb_type & MB_INTRA)
481 {
482 if(video->mpeg2)
483 mpeg3video_getmpg2intrablock(slice, video, comp, dc_dct_pred);
484 else
485 mpeg3video_getintrablock(slice, video, comp, dc_dct_pred);
486 }
487 else
488 {
489 if(video->mpeg2)
490 mpeg3video_getmpg2interblock(slice, video, comp);
491 else
492 mpeg3video_getinterblock(slice, video, comp);
493 }
494 if(slice->fault) return 1;
495 }
496 }
497
498/* reset intra_dc predictors */
499 if(!(mb_type & MB_INTRA))
500 dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
501
502/* reset motion vector predictors */
503 if((mb_type & MB_INTRA) && !video->conceal_mv)
504 {
505/* intra mb without concealment motion vectors */
506 pmv[0][0][0] = pmv[0][0][1] = pmv[1][0][0] = pmv[1][0][1] = 0;
507 pmv[0][1][0] = pmv[0][1][1] = pmv[1][1][0] = pmv[1][1][1] = 0;
508 }
509
510 if((video->pict_type == P_TYPE) && !(mb_type & (MB_FORWARD | MB_INTRA)))
511 {
512/* non-intra mb without forward mv in a P picture */
513 pmv[0][0][0] = pmv[0][0][1] = pmv[1][0][0] = pmv[1][0][1] = 0;
514
515/* derive motion_type */
516 if(video->pict_struct == FRAME_PICTURE)
517 motion_type = MC_FRAME;
518 else
519 {
520 motion_type = MC_FIELD;
521/* predict from field of same parity */
522 mv_field_sel[0][0] = (video->pict_struct == BOTTOM_FIELD);
523 }
524 }
525
526 if(stwclass == 4)
527 {
528/* purely spatially predicted macroblock */
529 pmv[0][0][0] = pmv[0][0][1] = pmv[1][0][0] = pmv[1][0][1] = 0;
530 pmv[0][1][0] = pmv[0][1][1] = pmv[1][1][0] = pmv[1][1][1] = 0;
531 }
532 }
533 else
534 {
535/* mba_inc!=1: skipped macroblock */
536 mpeg3video_clearblock(slice, 0, video->blk_cnt);
537
538/* reset intra_dc predictors */
539 dc_dct_pred[0] = dc_dct_pred[1] = dc_dct_pred[2] = 0;
540
541/* reset motion vector predictors */
542 if(video->pict_type == P_TYPE)
543 pmv[0][0][0] = pmv[0][0][1] = pmv[1][0][0] = pmv[1][0][1] = 0;
544
545/* derive motion_type */
546 if(video->pict_struct == FRAME_PICTURE)
547 motion_type = MC_FRAME;
548 else
549 {
550 motion_type = MC_FIELD;
551/* predict from field of same parity */
552 mv_field_sel[0][0] = mv_field_sel[0][1] = (video->pict_struct == BOTTOM_FIELD);
553 }
554
555/* skipped I are spatial-only predicted, */
556/* skipped P and B are temporal-only predicted */
557 stwtype = (video->pict_type == I_TYPE) ? 8 : 0;
558
559/* clear MB_INTRA */
560 mb_type &= ~MB_INTRA;
561
562/* no block data */
563 cbp = 0;
564 }
565
566 snr_cbp = 0;
567
568/* pixel coordinates of top left corner of current macroblock */
569 bx = 16 * (macroblock_address % video->mb_width);
570 by = 16 * (macroblock_address / video->mb_width);
571
572/* motion compensation */
573 if(!(mb_type & MB_INTRA))
574 mpeg3video_reconstruct(video,
575 bx,
576 by,
577 mb_type,
578 motion_type,
579 pmv,
580 mv_field_sel,
581 dmvector,
582 stwtype);
583
584/* copy or add block data into picture */
585 for(comp = 0; comp < video->blk_cnt; comp++)
586 {
587 if((cbp | snr_cbp) & (1 << (video->blk_cnt - 1 - comp)))
588 {
589#ifdef HAVE_MMX
590 if(video->have_mmx)
591 IDCT_mmx(slice->block[comp]);
592 else
593#endif
594 mpeg3video_idct_conversion(slice->block[comp]);
595
596 mpeg3video_addblock(slice,
597 video,
598 comp,
599 bx,
600 by,
601 dct_type,
602 (mb_type & MB_INTRA) == 0);
603 }
604 }
605
606/* advance to next macroblock */
607 macroblock_address++;
608 mba_inc--;
609 }
610
611 return 0;
612}
613
614void mpeg3_slice_loop(mpeg3_slice_t *slice)
615{
616 mpeg3video_t *video = slice->video;
617 int result = 1;
618
619 while(!slice->done)
620 {
621 pthread_mutex_lock(&(slice->input_lock));
622
623 if(!slice->done)
624 {
625/* Get a buffer to decode */
626 result = 1;
627 pthread_mutex_lock(&(video->slice_lock));
628 if(slice->buffer_step > 0)
629 {
630 while(slice->current_buffer <= slice->last_buffer)
631 {
632 if(!video->slice_buffers[slice->current_buffer].done &&
633 slice->current_buffer <= slice->last_buffer)
634 {
635 result = 0;
636 break;
637 }
638 slice->current_buffer += slice->buffer_step;
639 }
640 }
641 else
642 {
643 while(slice->current_buffer >= slice->last_buffer)
644 {
645 if(!video->slice_buffers[slice->current_buffer].done &&
646 slice->current_buffer >= slice->last_buffer)
647 {
648 result = 0;
649 break;
650 }
651 slice->current_buffer += slice->buffer_step;
652 }
653 }
654
655/* Got one */
656 if(!result && slice->current_buffer >= 0 && slice->current_buffer < video->total_slice_buffers)
657 {
658 slice->slice_buffer = &(video->slice_buffers[slice->current_buffer]);
659 slice->slice_buffer->done = 1;
660 pthread_mutex_unlock(&(video->slice_lock));
661 pthread_mutex_unlock(&(slice->input_lock));
662 mpeg3_decode_slice(slice);
663 pthread_mutex_unlock(&(slice->slice_buffer->completion_lock));
664 }
665 else
666 pthread_mutex_unlock(&(video->slice_lock));
667 }
668
669 pthread_mutex_unlock(&(slice->output_lock));
670 }
671}
672
673int mpeg3_new_slice_decoder(mpeg3video_t *video, mpeg3_slice_t *slice)
674{
675 pthread_attr_t attr;
676 //struct sched_param param;
677 pthread_mutexattr_t mutex_attr;
678
679 slice->video = video;
680 slice->done = 0;
681 pthread_mutexattr_init(&mutex_attr);
682 pthread_mutex_init(&(slice->input_lock), &mutex_attr);
683 pthread_mutex_lock(&(slice->input_lock));
684 pthread_mutex_init(&(slice->output_lock), &mutex_attr);
685 pthread_mutex_lock(&(slice->output_lock));
686
687 pthread_attr_init(&attr);
688 pthread_create(&(slice->tid), &attr,
689 (void * (*)(void *))mpeg3_slice_loop, slice);
690
691 return 0;
692}
693
694int mpeg3_delete_slice_decoder(mpeg3_slice_t *slice)
695{
696 slice->done = 1;
697 pthread_mutex_unlock(&(slice->input_lock));
698 pthread_join(slice->tid, 0);
699 pthread_mutex_destroy(&(slice->input_lock));
700 pthread_mutex_destroy(&(slice->output_lock));
701 return 0;
702}
diff --git a/core/multimedia/opieplayer/libmpeg3/video/slice.h b/core/multimedia/opieplayer/libmpeg3/video/slice.h
new file mode 100644
index 0000000..e36ffef
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/slice.h
@@ -0,0 +1,194 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef SLICE_H
21#define SLICE_H
22
23#ifndef _WIN32
24#include <pthread.h>
25#endif
26
27/* Array of these feeds the slice decoders */
28typedef struct
29{
30 unsigned char *data; /* Buffer for holding the slice data */
31 int buffer_size; /* Size of buffer */
32 int buffer_allocation; /* Space allocated for buffer */
33 int current_position; /* Position in buffer */
34 unsigned MPEG3_INT32 bits;
35 int bits_size;
36 pthread_mutex_t completion_lock; /* Lock slice until completion */
37 int done; /* Signal for slice decoder to skip */
38} mpeg3_slice_buffer_t;
39
40/* Each slice decoder */
41typedef struct
42{
43 struct mpeg3video_rec *video;
44 mpeg3_slice_buffer_t *slice_buffer;
45
46 int thread_number; /* Number of this thread */
47 int current_buffer; /* Buffer this slice decoder is on */
48 int buffer_step; /* Number of buffers to skip */
49 int last_buffer; /* Last buffer this decoder should process */
50 int fault;
51 int done;
52 int quant_scale;
53 int pri_brk; /* slice/macroblock */
54 short block[12][64];
55 int sparse[12];
56 pthread_t tid; /* ID of thread */
57 pthread_mutex_t input_lock, output_lock;
58} mpeg3_slice_t;
59
60#define mpeg3slice_fillbits(buffer, nbits) \
61 while(((mpeg3_slice_buffer_t*)(buffer))->bits_size < (nbits)) \
62 { \
63 if(((mpeg3_slice_buffer_t*)(buffer))->current_position < ((mpeg3_slice_buffer_t*)(buffer))->buffer_size) \
64 { \
65 ((mpeg3_slice_buffer_t*)(buffer))->bits <<= 8; \
66 ((mpeg3_slice_buffer_t*)(buffer))->bits |= ((mpeg3_slice_buffer_t*)(buffer))->data[((mpeg3_slice_buffer_t*)(buffer))->current_position++]; \
67 } \
68 ((mpeg3_slice_buffer_t*)(buffer))->bits_size += 8; \
69 }
70
71#define mpeg3slice_flushbits(buffer, nbits) \
72 { \
73 mpeg3slice_fillbits((buffer), (nbits)); \
74 ((mpeg3_slice_buffer_t*)(buffer))->bits_size -= (nbits); \
75 }
76
77#define mpeg3slice_flushbit(buffer) \
78{ \
79 if(((mpeg3_slice_buffer_t*)(buffer))->bits_size) \
80 ((mpeg3_slice_buffer_t*)(buffer))->bits_size--; \
81 else \
82 if(((mpeg3_slice_buffer_t*)(buffer))->current_position < ((mpeg3_slice_buffer_t*)(buffer))->buffer_size) \
83 { \
84 ((mpeg3_slice_buffer_t*)(buffer))->bits = \
85 ((mpeg3_slice_buffer_t*)(buffer))->data[((mpeg3_slice_buffer_t*)(buffer))->current_position++]; \
86 ((mpeg3_slice_buffer_t*)(buffer))->bits_size = 7; \
87 } \
88}
89
90extern inline unsigned int mpeg3slice_getbit(mpeg3_slice_buffer_t *buffer)
91{
92 if(buffer->bits_size)
93 return (buffer->bits >> (--buffer->bits_size)) & 0x1;
94 else
95 if(buffer->current_position < buffer->buffer_size)
96 {
97 buffer->bits = buffer->data[buffer->current_position++];
98 buffer->bits_size = 7;
99 return (buffer->bits >> 7) & 0x1;
100 }
101 return 0; // WWA - stop warn
102}
103
104extern inline unsigned int mpeg3slice_getbits2(mpeg3_slice_buffer_t *buffer)
105{
106 if(buffer->bits_size >= 2)
107 return (buffer->bits >> (buffer->bits_size -= 2)) & 0x3;
108 else
109 if(buffer->current_position < buffer->buffer_size)
110 {
111 buffer->bits <<= 8;
112 buffer->bits |= buffer->data[buffer->current_position++];
113 buffer->bits_size += 6;
114 return (buffer->bits >> buffer->bits_size) & 0x3;
115 }
116 return 0; // WWA - stop warn
117}
118
119extern inline unsigned int mpeg3slice_getbyte(mpeg3_slice_buffer_t *buffer)
120{
121 if(buffer->bits_size >= 8)
122 return (buffer->bits >> (buffer->bits_size -= 8)) & 0xff;
123 else
124 if(buffer->current_position < buffer->buffer_size)
125 {
126 buffer->bits <<= 8;
127 buffer->bits |= buffer->data[buffer->current_position++];
128 return (buffer->bits >> buffer->bits_size) & 0xff;
129 }
130 return 0; // WWA - stop warn
131}
132
133
134extern inline unsigned int mpeg3slice_getbits(mpeg3_slice_buffer_t *slice_buffer, int bits)
135{
136 if(bits == 1) return mpeg3slice_getbit(slice_buffer);
137 mpeg3slice_fillbits(slice_buffer, bits);
138 return (slice_buffer->bits >> (slice_buffer->bits_size -= bits)) & (0xffffffff >> (32 - bits));
139}
140
141extern inline unsigned int mpeg3slice_showbits16(mpeg3_slice_buffer_t *buffer)
142{
143 if(buffer->bits_size >= 16)
144 return (buffer->bits >> (buffer->bits_size - 16)) & 0xffff;
145 else
146 if(buffer->current_position < buffer->buffer_size)
147 {
148 buffer->bits <<= 16;
149 buffer->bits_size += 16;
150 buffer->bits |= (unsigned int)buffer->data[buffer->current_position++] << 8;
151 buffer->bits |= buffer->data[buffer->current_position++];
152 return (buffer->bits >> (buffer->bits_size - 16)) & 0xffff;
153 }
154 return 0; // WWA - stop warn
155}
156
157extern inline unsigned int mpeg3slice_showbits9(mpeg3_slice_buffer_t *buffer)
158{
159 if(buffer->bits_size >= 9)
160 return (buffer->bits >> (buffer->bits_size - 9)) & 0x1ff;
161 else
162 if(buffer->current_position < buffer->buffer_size)
163 {
164 buffer->bits <<= 16;
165 buffer->bits_size += 16;
166 buffer->bits |= (unsigned int)buffer->data[buffer->current_position++] << 8;
167 buffer->bits |= buffer->data[buffer->current_position++];
168 return (buffer->bits >> (buffer->bits_size - 9)) & 0x1ff;
169 }
170 return 0; // WWA - stop warn
171}
172
173extern inline unsigned int mpeg3slice_showbits5(mpeg3_slice_buffer_t *buffer)
174{
175 if(buffer->bits_size >= 5)
176 return (buffer->bits >> (buffer->bits_size - 5)) & 0x1f;
177 else
178 if(buffer->current_position < buffer->buffer_size)
179 {
180 buffer->bits <<= 8;
181 buffer->bits_size += 8;
182 buffer->bits |= buffer->data[buffer->current_position++];
183 return (buffer->bits >> (buffer->bits_size - 5)) & 0x1f;
184 }
185 return 0; // WWA - stop warn
186}
187
188extern inline unsigned int mpeg3slice_showbits(mpeg3_slice_buffer_t *slice_buffer, int bits)
189{
190 mpeg3slice_fillbits(slice_buffer, bits);
191 return (slice_buffer->bits >> (slice_buffer->bits_size - bits)) & (0xffffffff >> (32 - bits));
192}
193
194#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/vlc.c b/core/multimedia/opieplayer/libmpeg3/video/vlc.c
new file mode 100644
index 0000000..4328d8a
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/vlc.c
@@ -0,0 +1,421 @@
1#include "mpeg3video.h"
2#include "vlc.h"
3
4/* variable length code tables */
5
6/* Table B-3, mb_type in P-pictures, codes 001..1xx */
7mpeg3_VLCtab_t mpeg3_PMBtab0[8] = {
8 {ERROR,0},
9 {MB_FORWARD,3},
10 {MB_PATTERN,2}, {MB_PATTERN,2},
11 {MB_FORWARD|MB_PATTERN,1}, {MB_FORWARD|MB_PATTERN,1},
12 {MB_FORWARD|MB_PATTERN,1}, {MB_FORWARD|MB_PATTERN,1}
13};
14
15/* Table B-3, mb_type in P-pictures, codes 000001..00011x */
16mpeg3_VLCtab_t mpeg3_PMBtab1[8] = {
17 {ERROR,0},
18 {MB_QUANT|MB_INTRA,6},
19 {MB_QUANT|MB_PATTERN,5}, {MB_QUANT|MB_PATTERN,5},
20 {MB_QUANT|MB_FORWARD|MB_PATTERN,5}, {MB_QUANT|MB_FORWARD|MB_PATTERN,5},
21 {MB_INTRA,5}, {MB_INTRA,5}
22};
23
24/* Table B-4, mb_type in B-pictures, codes 0010..11xx */
25mpeg3_VLCtab_t mpeg3_BMBtab0[16] = {
26 {ERROR,0}, {ERROR,0},
27 {MB_FORWARD,4},
28 {MB_FORWARD|MB_PATTERN,4},
29 {MB_BACKWARD,3}, {MB_BACKWARD,3},
30 {MB_BACKWARD|MB_PATTERN,3}, {MB_BACKWARD|MB_PATTERN,3},
31 {MB_FORWARD|MB_BACKWARD,2}, {MB_FORWARD|MB_BACKWARD,2},
32 {MB_FORWARD|MB_BACKWARD,2}, {MB_FORWARD|MB_BACKWARD,2},
33 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
34 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
35 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
36 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2}
37};
38
39/* Table B-4, mb_type in B-pictures, codes 000001..00011x */
40mpeg3_VLCtab_t mpeg3_BMBtab1[8] = {
41 {ERROR,0},
42 {MB_QUANT|MB_INTRA,6},
43 {MB_QUANT|MB_BACKWARD|MB_PATTERN,6},
44 {MB_QUANT|MB_FORWARD|MB_PATTERN,6},
45 {MB_QUANT|MB_FORWARD|MB_BACKWARD|MB_PATTERN,5},
46 {MB_QUANT|MB_FORWARD|MB_BACKWARD|MB_PATTERN,5},
47 {MB_INTRA,5}, {MB_INTRA,5}
48};
49
50/* Table B-5, mb_type in spat. scal. I-pictures, codes 0001..1xxx */
51mpeg3_VLCtab_t mpeg3_spIMBtab[16] = {
52 {ERROR,0},
53 {MB_CLASS4,4},
54 {MB_QUANT|MB_INTRA,4},
55 {MB_INTRA,4},
56 {MB_CLASS4|MB_QUANT|MB_PATTERN,2}, {MB_CLASS4|MB_QUANT|MB_PATTERN,2},
57 {MB_CLASS4|MB_QUANT|MB_PATTERN,2}, {MB_CLASS4|MB_QUANT|MB_PATTERN,2},
58 {MB_CLASS4|MB_PATTERN,1}, {MB_CLASS4|MB_PATTERN,1},
59 {MB_CLASS4|MB_PATTERN,1}, {MB_CLASS4|MB_PATTERN,1},
60 {MB_CLASS4|MB_PATTERN,1}, {MB_CLASS4|MB_PATTERN,1},
61 {MB_CLASS4|MB_PATTERN,1}, {MB_CLASS4|MB_PATTERN,1}
62};
63
64/* Table B-6, mb_type in spat. scal. P-pictures, codes 0010..11xx */
65mpeg3_VLCtab_t mpeg3_spPMBtab0[16] =
66{
67 {ERROR,0},{ERROR,0},
68 {MB_FORWARD,4},
69 {MB_WEIGHT|MB_FORWARD,4},
70 {MB_QUANT|MB_FORWARD|MB_PATTERN,3}, {MB_QUANT|MB_FORWARD|MB_PATTERN,3},
71 {MB_WEIGHT|MB_FORWARD|MB_PATTERN,3}, {MB_WEIGHT|MB_FORWARD|MB_PATTERN,3},
72 {MB_FORWARD|MB_PATTERN,2}, {MB_FORWARD|MB_PATTERN,2},
73 {MB_FORWARD|MB_PATTERN,2}, {MB_FORWARD|MB_PATTERN,2},
74 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,2},
75 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,2},
76 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,2},
77 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,2}
78};
79
80/* Table B-6, mb_type in spat. scal. P-pictures, codes 0000010..000111x */
81mpeg3_VLCtab_t mpeg3_spPMBtab1[16] = {
82 {ERROR,0},{ERROR,0},
83 {MB_CLASS4|MB_QUANT|MB_PATTERN,7},
84 {MB_CLASS4,7},
85 {MB_PATTERN,7},
86 {MB_CLASS4|MB_PATTERN,7},
87 {MB_QUANT|MB_INTRA,7},
88 {MB_INTRA,7},
89 {MB_QUANT|MB_PATTERN,6}, {MB_QUANT|MB_PATTERN,6},
90 {MB_WEIGHT|MB_QUANT|MB_PATTERN,6}, {MB_WEIGHT|MB_QUANT|MB_PATTERN,6},
91 {MB_WEIGHT,6}, {MB_WEIGHT,6},
92 {MB_WEIGHT|MB_PATTERN,6}, {MB_WEIGHT|MB_PATTERN,6}
93};
94
95/* Table B-7, mb_type in spat. scal. B-pictures, codes 0010..11xx */
96mpeg3_VLCtab_t mpeg3_spBMBtab0[14] = {
97 {MB_FORWARD,4},
98 {MB_FORWARD|MB_PATTERN,4},
99 {MB_BACKWARD,3}, {MB_BACKWARD,3},
100 {MB_BACKWARD|MB_PATTERN,3}, {MB_BACKWARD|MB_PATTERN,3},
101 {MB_FORWARD|MB_BACKWARD,2}, {MB_FORWARD|MB_BACKWARD,2},
102 {MB_FORWARD|MB_BACKWARD,2}, {MB_FORWARD|MB_BACKWARD,2},
103 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
104 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
105 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2},
106 {MB_FORWARD|MB_BACKWARD|MB_PATTERN,2}
107};
108
109/* Table B-7, mb_type in spat. scal. B-pictures, codes 0000100..000111x */
110mpeg3_VLCtab_t mpeg3_spBMBtab1[12] = {
111 {MB_QUANT|MB_FORWARD|MB_PATTERN,7},
112 {MB_QUANT|MB_BACKWARD|MB_PATTERN,7},
113 {MB_INTRA,7},
114 {MB_QUANT|MB_FORWARD|MB_BACKWARD|MB_PATTERN,7},
115 {MB_WEIGHT|MB_FORWARD,6}, {MB_WEIGHT|MB_FORWARD,6},
116 {MB_WEIGHT|MB_FORWARD|MB_PATTERN,6}, {MB_WEIGHT|MB_FORWARD|MB_PATTERN,6},
117 {MB_WEIGHT|MB_BACKWARD,6}, {MB_WEIGHT|MB_BACKWARD,6},
118 {MB_WEIGHT|MB_BACKWARD|MB_PATTERN,6}, {MB_WEIGHT|MB_BACKWARD|MB_PATTERN,6}
119};
120
121/* Table B-7, mb_type in spat. scal. B-pictures, codes 00000100x..000001111 */
122mpeg3_VLCtab_t mpeg3_spBMBtab2[8] = {
123 {MB_QUANT|MB_INTRA,8}, {MB_QUANT|MB_INTRA,8},
124 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,8},
125 {MB_WEIGHT|MB_QUANT|MB_FORWARD|MB_PATTERN,8},
126 {MB_WEIGHT|MB_QUANT|MB_BACKWARD|MB_PATTERN,9},
127 {MB_CLASS4|MB_QUANT|MB_PATTERN,9},
128 {MB_CLASS4,9},
129 {MB_CLASS4|MB_PATTERN,9}
130};
131
132/* Table B-8, mb_type in spat. scal. B-pictures, codes 001..1xx */
133mpeg3_VLCtab_t mpeg3_SNRMBtab[8] = {
134 {ERROR,0},
135 {0,3},
136 {MB_QUANT|MB_PATTERN,2}, {MB_QUANT|MB_PATTERN,2},
137 {MB_PATTERN,1}, {MB_PATTERN,1}, {MB_PATTERN,1}, {MB_PATTERN,1}
138};
139
140/* Table B-10, motion_code, codes 0001 ... 01xx */
141mpeg3_VLCtab_t mpeg3_MVtab0[8] =
142{ {ERROR,0}, {3,3}, {2,2}, {2,2}, {1,1}, {1,1}, {1,1}, {1,1}
143};
144
145/* Table B-10, motion_code, codes 0000011 ... 000011x */
146mpeg3_VLCtab_t mpeg3_MVtab1[8] =
147{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {7,6}, {6,6}, {5,6}, {4,5}, {4,5}
148};
149
150/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
151mpeg3_VLCtab_t mpeg3_MVtab2[12] =
152{ {16,9}, {15,9}, {14,9}, {13,9},
153 {12,9}, {11,9}, {10,8}, {10,8},
154 {9,8}, {9,8}, {8,8}, {8,8}
155};
156
157/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */
158mpeg3_VLCtab_t mpeg3_CBPtab0[32] =
159{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
160 {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
161 {62,5}, {2,5}, {61,5}, {1,5}, {56,5}, {52,5}, {44,5}, {28,5},
162 {40,5}, {20,5}, {48,5}, {12,5}, {32,4}, {32,4}, {16,4}, {16,4},
163 {8,4}, {8,4}, {4,4}, {4,4}, {60,3}, {60,3}, {60,3}, {60,3}
164};
165
166/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */
167mpeg3_VLCtab_t mpeg3_CBPtab1[64] =
168{ {ERROR,0}, {ERROR,0}, {ERROR,0}, {ERROR,0},
169 {58,8}, {54,8}, {46,8}, {30,8},
170 {57,8}, {53,8}, {45,8}, {29,8}, {38,8}, {26,8}, {37,8}, {25,8},
171 {43,8}, {23,8}, {51,8}, {15,8}, {42,8}, {22,8}, {50,8}, {14,8},
172 {41,8}, {21,8}, {49,8}, {13,8}, {35,8}, {19,8}, {11,8}, {7,8},
173 {34,7}, {34,7}, {18,7}, {18,7}, {10,7}, {10,7}, {6,7}, {6,7},
174 {33,7}, {33,7}, {17,7}, {17,7}, {9,7}, {9,7}, {5,7}, {5,7},
175 {63,6}, {63,6}, {63,6}, {63,6}, {3,6}, {3,6}, {3,6}, {3,6},
176 {36,6}, {36,6}, {36,6}, {36,6}, {24,6}, {24,6}, {24,6}, {24,6}
177};
178
179/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */
180mpeg3_VLCtab_t mpeg3_CBPtab2[8] =
181{ {ERROR,0}, {0,9}, {39,9}, {27,9}, {59,9}, {55,9}, {47,9}, {31,9}
182};
183
184/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
185mpeg3_VLCtab_t mpeg3_MBAtab1[16] =
186{ {ERROR,0}, {ERROR,0}, {7,5}, {6,5}, {5,4}, {5,4}, {4,4}, {4,4},
187 {3,3}, {3,3}, {3,3}, {3,3}, {2,3}, {2,3}, {2,3}, {2,3}
188};
189
190/* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
191mpeg3_VLCtab_t mpeg3_MBAtab2[104] =
192{
193 {33,11}, {32,11}, {31,11}, {30,11}, {29,11}, {28,11}, {27,11}, {26,11},
194 {25,11}, {24,11}, {23,11}, {22,11}, {21,10}, {21,10}, {20,10}, {20,10},
195 {19,10}, {19,10}, {18,10}, {18,10}, {17,10}, {17,10}, {16,10}, {16,10},
196 {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8}, {15,8},
197 {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8}, {14,8},
198 {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8}, {13,8},
199 {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8}, {12,8},
200 {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8}, {11,8},
201 {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8}, {10,8},
202 {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
203 {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7}, {9,7},
204 {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7},
205 {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}, {8,7}
206};
207
208/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
209mpeg3_VLCtab_t mpeg3_DClumtab0[32] =
210{ {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
211 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
212 {0, 3}, {0, 3}, {0, 3}, {0, 3}, {3, 3}, {3, 3}, {3, 3}, {3, 3},
213 {4, 3}, {4, 3}, {4, 3}, {4, 3}, {5, 4}, {5, 4}, {6, 5}, {ERROR, 0}
214};
215
216/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
217mpeg3_VLCtab_t mpeg3_DClumtab1[16] =
218{ {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6}, {7, 6},
219 {8, 7}, {8, 7}, {8, 7}, {8, 7}, {9, 8}, {9, 8}, {10,9}, {11,9}
220};
221
222/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
223mpeg3_VLCtab_t mpeg3_DCchromtab0[32] =
224{ {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2}, {0, 2},
225 {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 2},
226 {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2},
227 {3, 3}, {3, 3}, {3, 3}, {3, 3}, {4, 4}, {4, 4}, {5, 5}, {ERROR, 0}
228};
229
230/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
231mpeg3_VLCtab_t mpeg3_DCchromtab1[32] =
232{ {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
233 {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6}, {6, 6},
234 {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7}, {7, 7},
235 {8, 8}, {8, 8}, {8, 8}, {8, 8}, {9, 9}, {9, 9}, {10,10}, {11,10}
236};
237
238/* Table B-14, DCT coefficients table zero,
239 * codes 0100 ... 1xxx (used for first (DC) coefficient)
240 */
241mpeg3_DCTtab_t mpeg3_DCTtabfirst[12] =
242{
243 {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
244 {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1},
245 {0,1,1}, {0,1,1}, {0,1,1}, {0,1,1}
246};
247
248/* Table B-14, DCT coefficients table zero,
249 * codes 0100 ... 1xxx (used for all other coefficients)
250 */
251mpeg3_DCTtab_t mpeg3_DCTtabnext[12] =
252{
253 {0,2,4}, {2,1,4}, {1,1,3}, {1,1,3},
254 {64,0,2}, {64,0,2}, {64,0,2}, {64,0,2}, /* EOB */
255 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2}
256};
257
258/* Table B-14, DCT coefficients table zero,
259 * codes 000001xx ... 00111xxx
260 */
261mpeg3_DCTtab_t mpeg3_DCTtab0[60] =
262{
263 {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
264 {2,2,7}, {2,2,7}, {9,1,7}, {9,1,7},
265 {0,4,7}, {0,4,7}, {8,1,7}, {8,1,7},
266 {7,1,6}, {7,1,6}, {7,1,6}, {7,1,6},
267 {6,1,6}, {6,1,6}, {6,1,6}, {6,1,6},
268 {1,2,6}, {1,2,6}, {1,2,6}, {1,2,6},
269 {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
270 {13,1,8}, {0,6,8}, {12,1,8}, {11,1,8},
271 {3,2,8}, {1,3,8}, {0,5,8}, {10,1,8},
272 {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
273 {0,3,5}, {0,3,5}, {0,3,5}, {0,3,5},
274 {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
275 {4,1,5}, {4,1,5}, {4,1,5}, {4,1,5},
276 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
277 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5}
278};
279
280/* Table B-15, DCT coefficients table one,
281 * codes 000001xx ... 11111111
282*/
283mpeg3_DCTtab_t mpeg3_DCTtab0a[252] =
284{
285 {65,0,6}, {65,0,6}, {65,0,6}, {65,0,6}, /* Escape */
286 {7,1,7}, {7,1,7}, {8,1,7}, {8,1,7},
287 {6,1,7}, {6,1,7}, {2,2,7}, {2,2,7},
288 {0,7,6}, {0,7,6}, {0,7,6}, {0,7,6},
289 {0,6,6}, {0,6,6}, {0,6,6}, {0,6,6},
290 {4,1,6}, {4,1,6}, {4,1,6}, {4,1,6},
291 {5,1,6}, {5,1,6}, {5,1,6}, {5,1,6},
292 {1,5,8}, {11,1,8}, {0,11,8}, {0,10,8},
293 {13,1,8}, {12,1,8}, {3,2,8}, {1,4,8},
294 {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
295 {2,1,5}, {2,1,5}, {2,1,5}, {2,1,5},
296 {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
297 {1,2,5}, {1,2,5}, {1,2,5}, {1,2,5},
298 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
299 {3,1,5}, {3,1,5}, {3,1,5}, {3,1,5},
300 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
301 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
302 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
303 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
304 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
305 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
306 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
307 {1,1,3}, {1,1,3}, {1,1,3}, {1,1,3},
308 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4}, /* EOB */
309 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
310 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
311 {64,0,4}, {64,0,4}, {64,0,4}, {64,0,4},
312 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
313 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
314 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
315 {0,3,4}, {0,3,4}, {0,3,4}, {0,3,4},
316 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
317 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
318 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
319 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
320 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
321 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
322 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
323 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
324 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
325 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
326 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
327 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
328 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
329 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
330 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
331 {0,1,2}, {0,1,2}, {0,1,2}, {0,1,2},
332 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
333 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
334 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
335 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
336 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
337 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
338 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
339 {0,2,3}, {0,2,3}, {0,2,3}, {0,2,3},
340 {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
341 {0,4,5}, {0,4,5}, {0,4,5}, {0,4,5},
342 {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
343 {0,5,5}, {0,5,5}, {0,5,5}, {0,5,5},
344 {9,1,7}, {9,1,7}, {1,3,7}, {1,3,7},
345 {10,1,7}, {10,1,7}, {0,8,7}, {0,8,7},
346 {0,9,7}, {0,9,7}, {0,12,8}, {0,13,8},
347 {2,3,8}, {4,2,8}, {0,14,8}, {0,15,8}
348};
349
350/* Table B-14, DCT coefficients table zero,
351 * codes 0000001000 ... 0000001111
352 */
353mpeg3_DCTtab_t mpeg3_DCTtab1[8] =
354{
355 {16,1,10}, {5,2,10}, {0,7,10}, {2,3,10},
356 {1,4,10}, {15,1,10}, {14,1,10}, {4,2,10}
357};
358
359/* Table B-15, DCT coefficients table one,
360 * codes 000000100x ... 000000111x
361 */
362mpeg3_DCTtab_t mpeg3_DCTtab1a[8] =
363{
364 {5,2,9}, {5,2,9}, {14,1,9}, {14,1,9},
365 {2,4,10}, {16,1,10}, {15,1,9}, {15,1,9}
366};
367
368/* Table B-14/15, DCT coefficients table zero / one,
369 * codes 000000010000 ... 000000011111
370 */
371mpeg3_DCTtab_t mpeg3_DCTtab2[16] =
372{
373 {0,11,12}, {8,2,12}, {4,3,12}, {0,10,12},
374 {2,4,12}, {7,2,12}, {21,1,12}, {20,1,12},
375 {0,9,12}, {19,1,12}, {18,1,12}, {1,5,12},
376 {3,3,12}, {0,8,12}, {6,2,12}, {17,1,12}
377};
378
379/* Table B-14/15, DCT coefficients table zero / one,
380 * codes 0000000010000 ... 0000000011111
381 */
382mpeg3_DCTtab_t mpeg3_DCTtab3[16] =
383{
384 {10,2,13}, {9,2,13}, {5,3,13}, {3,4,13},
385 {2,5,13}, {1,7,13}, {1,6,13}, {0,15,13},
386 {0,14,13}, {0,13,13}, {0,12,13}, {26,1,13},
387 {25,1,13}, {24,1,13}, {23,1,13}, {22,1,13}
388};
389
390/* Table B-14/15, DCT coefficients table zero / one,
391 * codes 00000000010000 ... 00000000011111
392 */
393mpeg3_DCTtab_t mpeg3_DCTtab4[16] =
394{
395 {0,31,14}, {0,30,14}, {0,29,14}, {0,28,14},
396 {0,27,14}, {0,26,14}, {0,25,14}, {0,24,14},
397 {0,23,14}, {0,22,14}, {0,21,14}, {0,20,14},
398 {0,19,14}, {0,18,14}, {0,17,14}, {0,16,14}
399};
400
401/* Table B-14/15, DCT coefficients table zero / one,
402 * codes 000000000010000 ... 000000000011111
403 */
404mpeg3_DCTtab_t mpeg3_DCTtab5[16] =
405{
406 {0,40,15}, {0,39,15}, {0,38,15}, {0,37,15},
407 {0,36,15}, {0,35,15}, {0,34,15}, {0,33,15},
408 {0,32,15}, {1,14,15}, {1,13,15}, {1,12,15},
409 {1,11,15}, {1,10,15}, {1,9,15}, {1,8,15}
410};
411
412/* Table B-14/15, DCT coefficients table zero / one,
413 * codes 0000000000010000 ... 0000000000011111
414 */
415mpeg3_DCTtab_t mpeg3_DCTtab6[16] =
416{
417 {1,18,16}, {1,17,16}, {1,16,16}, {1,15,16},
418 {6,3,16}, {16,2,16}, {15,2,16}, {14,2,16},
419 {13,2,16}, {12,2,16}, {11,2,16}, {31,1,16},
420 {30,1,16}, {29,1,16}, {28,1,16}, {27,1,16}
421};
diff --git a/core/multimedia/opieplayer/libmpeg3/video/vlc.h b/core/multimedia/opieplayer/libmpeg3/video/vlc.h
new file mode 100644
index 0000000..727040b
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/vlc.h
@@ -0,0 +1,164 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef VLC_H
21#define VLC_H
22
23/* variable length code tables */
24
25typedef struct {
26 char val, len;
27} mpeg3_VLCtab_t;
28
29typedef struct {
30 char run, level, len;
31} mpeg3_DCTtab_t;
32
33/* Added 03/38/96 by Alex de Jong : avoid IRIX GNU warning */
34#ifdef ERROR
35#undef ERROR
36#define ERROR 99
37#endif
38
39/* Table B-3, mb_type in P-pictures, codes 001..1xx */
40extern mpeg3_VLCtab_t mpeg3_PMBtab0[8];
41
42/* Table B-3, mb_type in P-pictures, codes 000001..00011x */
43extern mpeg3_VLCtab_t mpeg3_PMBtab1[8];
44
45/* Table B-4, mb_type in B-pictures, codes 0010..11xx */
46extern mpeg3_VLCtab_t mpeg3_BMBtab0[16];
47
48/* Table B-4, mb_type in B-pictures, codes 000001..00011x */
49extern mpeg3_VLCtab_t mpeg3_BMBtab1[8];
50
51/* Table B-5, mb_type in spat. scal. I-pictures, codes 0001..1xxx */
52extern mpeg3_VLCtab_t mpeg3_spIMBtab[16];
53
54/* Table B-6, mb_type in spat. scal. P-pictures, codes 0010..11xx */
55extern mpeg3_VLCtab_t mpeg3_spPMBtab0[16];
56
57/* Table B-6, mb_type in spat. scal. P-pictures, codes 0000010..000111x */
58extern mpeg3_VLCtab_t mpeg3_spPMBtab1[16];
59
60/* Table B-7, mb_type in spat. scal. B-pictures, codes 0010..11xx */
61extern mpeg3_VLCtab_t mpeg3_spBMBtab0[14];
62
63/* Table B-7, mb_type in spat. scal. B-pictures, codes 0000100..000111x */
64extern mpeg3_VLCtab_t mpeg3_spBMBtab1[12];
65
66/* Table B-7, mb_type in spat. scal. B-pictures, codes 00000100x..000001111 */
67extern mpeg3_VLCtab_t mpeg3_spBMBtab2[8];
68
69/* Table B-8, mb_type in spat. scal. B-pictures, codes 001..1xx */
70extern mpeg3_VLCtab_t mpeg3_SNRMBtab[8];
71
72/* Table B-10, motion_code, codes 0001 ... 01xx */
73extern mpeg3_VLCtab_t mpeg3_MVtab0[8];
74
75/* Table B-10, motion_code, codes 0000011 ... 000011x */
76extern mpeg3_VLCtab_t mpeg3_MVtab1[8];
77
78/* Table B-10, motion_code, codes 0000001100 ... 000001011x */
79extern mpeg3_VLCtab_t mpeg3_MVtab2[12];
80
81/* Table B-9, coded_block_pattern, codes 01000 ... 111xx */
82extern mpeg3_VLCtab_t mpeg3_CBPtab0[32];
83
84/* Table B-9, coded_block_pattern, codes 00000100 ... 001111xx */
85extern mpeg3_VLCtab_t mpeg3_CBPtab1[64];
86
87/* Table B-9, coded_block_pattern, codes 000000001 ... 000000111 */
88extern mpeg3_VLCtab_t mpeg3_CBPtab2[8];
89
90/* Table B-1, macroblock_address_increment, codes 00010 ... 011xx */
91extern mpeg3_VLCtab_t mpeg3_MBAtab1[16];
92
93/* Table B-1, macroblock_address_increment, codes 00000011000 ... 0000111xxxx */
94extern mpeg3_VLCtab_t mpeg3_MBAtab2[104];
95
96/* Table B-12, dct_dc_size_luminance, codes 00xxx ... 11110 */
97extern mpeg3_VLCtab_t mpeg3_DClumtab0[32];
98
99/* Table B-12, dct_dc_size_luminance, codes 111110xxx ... 111111111 */
100extern mpeg3_VLCtab_t mpeg3_DClumtab1[16];
101
102/* Table B-13, dct_dc_size_chrominance, codes 00xxx ... 11110 */
103extern mpeg3_VLCtab_t mpeg3_DCchromtab0[32];
104
105/* Table B-13, dct_dc_size_chrominance, codes 111110xxxx ... 1111111111 */
106extern mpeg3_VLCtab_t mpeg3_DCchromtab1[32];
107
108/* Table B-14, DCT coefficients table zero,
109 * codes 0100 ... 1xxx (used for first (DC) coefficient)
110 */
111extern mpeg3_DCTtab_t mpeg3_DCTtabfirst[12];
112
113/* Table B-14, DCT coefficients table zero,
114 * codes 0100 ... 1xxx (used for all other coefficients)
115 */
116extern mpeg3_DCTtab_t mpeg3_DCTtabnext[12];
117
118/* Table B-14, DCT coefficients table zero,
119 * codes 000001xx ... 00111xxx
120 */
121extern mpeg3_DCTtab_t mpeg3_DCTtab0[60];
122
123/* Table B-15, DCT coefficients table one,
124 * codes 000001xx ... 11111111
125*/
126extern mpeg3_DCTtab_t mpeg3_DCTtab0a[252];
127
128/* Table B-14, DCT coefficients table zero,
129 * codes 0000001000 ... 0000001111
130 */
131extern mpeg3_DCTtab_t mpeg3_DCTtab1[8];
132
133/* Table B-15, DCT coefficients table one,
134 * codes 000000100x ... 000000111x
135 */
136extern mpeg3_DCTtab_t mpeg3_DCTtab1a[8];
137
138/* Table B-14/15, DCT coefficients table zero / one,
139 * codes 000000010000 ... 000000011111
140 */
141extern mpeg3_DCTtab_t mpeg3_DCTtab2[16];
142
143/* Table B-14/15, DCT coefficients table zero / one,
144 * codes 0000000010000 ... 0000000011111
145 */
146extern mpeg3_DCTtab_t mpeg3_DCTtab3[16];
147
148/* Table B-14/15, DCT coefficients table zero / one,
149 * codes 00000000010000 ... 00000000011111
150 */
151extern mpeg3_DCTtab_t mpeg3_DCTtab4[16];
152
153/* Table B-14/15, DCT coefficients table zero / one,
154 * codes 000000000010000 ... 000000000011111
155 */
156extern mpeg3_DCTtab_t mpeg3_DCTtab5[16];
157
158/* Table B-14/15, DCT coefficients table zero / one,
159 * codes 0000000000010000 ... 0000000000011111
160 */
161extern mpeg3_DCTtab_t mpeg3_DCTtab6[16];
162
163
164#endif
diff --git a/core/multimedia/opieplayer/libmpeg3/video/worksheet.c b/core/multimedia/opieplayer/libmpeg3/video/worksheet.c
new file mode 100644
index 0000000..c5a0553
--- a/dev/null
+++ b/core/multimedia/opieplayer/libmpeg3/video/worksheet.c
@@ -0,0 +1,30 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <time.h>
4
5
6static LONGLONG mpeg3_MMX_601_Y_COEF = 0x0000004000400040;
7
8inline void mpeg3_601_mmx(unsigned long y,
9 unsigned long *output)
10{
11asm("
12/* Output will be 0x00rrggbb */
13 movd (%0), %%mm0; /* Load y 0x00000000000000yy */
14 /*pmullw mpeg3_MMX_601_Y_COEF, %%mm0; // Scale y 0x00000000000000yy */
15 psllw $6, %%mm0; /* Shift y coeffs 0x0000yyy0yyy0yyy0 */
16 movd %%mm0, (%1); /* Store output */
17 "
18:
19: "r" (&y), "r" (output));
20}
21
22
23int main(int argc, char *argv[])
24{
25 unsigned char output[1024];
26
27 memset(output, 0, 1024);
28 mpeg3_601_mmx(1, (unsigned long*)output);
29 printf("%02x%02x\n", *(unsigned char*)&output[1], *(unsigned char*)&output[0]);
30}