diff options
author | Mohamed Tarek <mt@rockbox.org> | 2010-07-15 05:38:09 +0000 |
---|---|---|
committer | Mohamed Tarek <mt@rockbox.org> | 2010-07-15 05:38:09 +0000 |
commit | 387af97a26105fce79e6a8726752cf183d40939e (patch) | |
tree | 25c7898bbf08963b9c7688c8937061b4b3491dec | |
parent | 5d2969c94e97c81e3eb88211b921be80b66bd691 (diff) | |
download | rockbox-387af97a26105fce79e6a8726752cf183d40939e.tar.gz rockbox-387af97a26105fce79e6a8726752cf183d40939e.zip |
Initial cleanup for libwmapro.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27425 a1c6a512-1295-4272-9138-f99709370657
33 files changed, 126 insertions, 12233 deletions
diff --git a/apps/codecs/libwmapro/SOURCES b/apps/codecs/libwmapro/SOURCES index cfb1a97d4c..174bede984 100644 --- a/apps/codecs/libwmapro/SOURCES +++ b/apps/codecs/libwmapro/SOURCES | |||
@@ -3,4 +3,4 @@ wma.c | |||
3 | mdct_tables.c | 3 | mdct_tables.c |
4 | bitstream.c | 4 | bitstream.c |
5 | wmapro_mdct.c | 5 | wmapro_mdct.c |
6 | libavutil/mathematics.c | 6 | //libavutil/mathematics.c |
diff --git a/apps/codecs/libwmapro/avcodec.h b/apps/codecs/libwmapro/avcodec.h deleted file mode 100644 index 8812d409ee..0000000000 --- a/apps/codecs/libwmapro/avcodec.h +++ /dev/null | |||
@@ -1,3957 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2001 Fabrice Bellard | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef AVCODEC_AVCODEC_H | ||
22 | #define AVCODEC_AVCODEC_H | ||
23 | |||
24 | /** | ||
25 | * @file libavcodec/avcodec.h | ||
26 | * external API header | ||
27 | */ | ||
28 | |||
29 | #include <errno.h> | ||
30 | #include "libavutil/avutil.h" | ||
31 | |||
32 | #define LIBAVCODEC_VERSION_MAJOR 52 | ||
33 | #define LIBAVCODEC_VERSION_MINOR 66 | ||
34 | #define LIBAVCODEC_VERSION_MICRO 0 | ||
35 | |||
36 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | ||
37 | LIBAVCODEC_VERSION_MINOR, \ | ||
38 | LIBAVCODEC_VERSION_MICRO) | ||
39 | #define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ | ||
40 | LIBAVCODEC_VERSION_MINOR, \ | ||
41 | LIBAVCODEC_VERSION_MICRO) | ||
42 | #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT | ||
43 | |||
44 | #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) | ||
45 | |||
46 | #define AV_NOPTS_VALUE INT64_C(0x8000000000000000) | ||
47 | #define AV_TIME_BASE 1000000 | ||
48 | #define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} | ||
49 | |||
50 | /* some function declarations not used in rockbox use it */ | ||
51 | enum PixelFormat { | ||
52 | we_can_only_play_mpeg_video_anyway = -1 | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * Identifies the syntax and semantics of the bitstream. | ||
57 | * The principle is roughly: | ||
58 | * Two decoders with the same ID can decode the same streams. | ||
59 | * Two encoders with the same ID can encode compatible streams. | ||
60 | * There may be slight deviations from the principle due to implementation | ||
61 | * details. | ||
62 | * | ||
63 | * If you add a codec ID to this list, add it so that | ||
64 | * 1. no value of a existing codec ID changes (that would break ABI), | ||
65 | * 2. it is as close as possible to similar codecs. | ||
66 | */ | ||
67 | enum CodecID { | ||
68 | CODEC_ID_NONE, | ||
69 | |||
70 | /* video codecs */ | ||
71 | CODEC_ID_MPEG1VIDEO, | ||
72 | CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding | ||
73 | CODEC_ID_MPEG2VIDEO_XVMC, | ||
74 | CODEC_ID_H261, | ||
75 | CODEC_ID_H263, | ||
76 | CODEC_ID_RV10, | ||
77 | CODEC_ID_RV20, | ||
78 | CODEC_ID_MJPEG, | ||
79 | CODEC_ID_MJPEGB, | ||
80 | CODEC_ID_LJPEG, | ||
81 | CODEC_ID_SP5X, | ||
82 | CODEC_ID_JPEGLS, | ||
83 | CODEC_ID_MPEG4, | ||
84 | CODEC_ID_RAWVIDEO, | ||
85 | CODEC_ID_MSMPEG4V1, | ||
86 | CODEC_ID_MSMPEG4V2, | ||
87 | CODEC_ID_MSMPEG4V3, | ||
88 | CODEC_ID_WMV1, | ||
89 | CODEC_ID_WMV2, | ||
90 | CODEC_ID_H263P, | ||
91 | CODEC_ID_H263I, | ||
92 | CODEC_ID_FLV1, | ||
93 | CODEC_ID_SVQ1, | ||
94 | CODEC_ID_SVQ3, | ||
95 | CODEC_ID_DVVIDEO, | ||
96 | CODEC_ID_HUFFYUV, | ||
97 | CODEC_ID_CYUV, | ||
98 | CODEC_ID_H264, | ||
99 | CODEC_ID_INDEO3, | ||
100 | CODEC_ID_VP3, | ||
101 | CODEC_ID_THEORA, | ||
102 | CODEC_ID_ASV1, | ||
103 | CODEC_ID_ASV2, | ||
104 | CODEC_ID_FFV1, | ||
105 | CODEC_ID_4XM, | ||
106 | CODEC_ID_VCR1, | ||
107 | CODEC_ID_CLJR, | ||
108 | CODEC_ID_MDEC, | ||
109 | CODEC_ID_ROQ, | ||
110 | CODEC_ID_INTERPLAY_VIDEO, | ||
111 | CODEC_ID_XAN_WC3, | ||
112 | CODEC_ID_XAN_WC4, | ||
113 | CODEC_ID_RPZA, | ||
114 | CODEC_ID_CINEPAK, | ||
115 | CODEC_ID_WS_VQA, | ||
116 | CODEC_ID_MSRLE, | ||
117 | CODEC_ID_MSVIDEO1, | ||
118 | CODEC_ID_IDCIN, | ||
119 | CODEC_ID_8BPS, | ||
120 | CODEC_ID_SMC, | ||
121 | CODEC_ID_FLIC, | ||
122 | CODEC_ID_TRUEMOTION1, | ||
123 | CODEC_ID_VMDVIDEO, | ||
124 | CODEC_ID_MSZH, | ||
125 | CODEC_ID_ZLIB, | ||
126 | CODEC_ID_QTRLE, | ||
127 | CODEC_ID_SNOW, | ||
128 | CODEC_ID_TSCC, | ||
129 | CODEC_ID_ULTI, | ||
130 | CODEC_ID_QDRAW, | ||
131 | CODEC_ID_VIXL, | ||
132 | CODEC_ID_QPEG, | ||
133 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
134 | CODEC_ID_XVID, | ||
135 | #endif | ||
136 | CODEC_ID_PNG, | ||
137 | CODEC_ID_PPM, | ||
138 | CODEC_ID_PBM, | ||
139 | CODEC_ID_PGM, | ||
140 | CODEC_ID_PGMYUV, | ||
141 | CODEC_ID_PAM, | ||
142 | CODEC_ID_FFVHUFF, | ||
143 | CODEC_ID_RV30, | ||
144 | CODEC_ID_RV40, | ||
145 | CODEC_ID_VC1, | ||
146 | CODEC_ID_WMV3, | ||
147 | CODEC_ID_LOCO, | ||
148 | CODEC_ID_WNV1, | ||
149 | CODEC_ID_AASC, | ||
150 | CODEC_ID_INDEO2, | ||
151 | CODEC_ID_FRAPS, | ||
152 | CODEC_ID_TRUEMOTION2, | ||
153 | CODEC_ID_BMP, | ||
154 | CODEC_ID_CSCD, | ||
155 | CODEC_ID_MMVIDEO, | ||
156 | CODEC_ID_ZMBV, | ||
157 | CODEC_ID_AVS, | ||
158 | CODEC_ID_SMACKVIDEO, | ||
159 | CODEC_ID_NUV, | ||
160 | CODEC_ID_KMVC, | ||
161 | CODEC_ID_FLASHSV, | ||
162 | CODEC_ID_CAVS, | ||
163 | CODEC_ID_JPEG2000, | ||
164 | CODEC_ID_VMNC, | ||
165 | CODEC_ID_VP5, | ||
166 | CODEC_ID_VP6, | ||
167 | CODEC_ID_VP6F, | ||
168 | CODEC_ID_TARGA, | ||
169 | CODEC_ID_DSICINVIDEO, | ||
170 | CODEC_ID_TIERTEXSEQVIDEO, | ||
171 | CODEC_ID_TIFF, | ||
172 | CODEC_ID_GIF, | ||
173 | CODEC_ID_FFH264, | ||
174 | CODEC_ID_DXA, | ||
175 | CODEC_ID_DNXHD, | ||
176 | CODEC_ID_THP, | ||
177 | CODEC_ID_SGI, | ||
178 | CODEC_ID_C93, | ||
179 | CODEC_ID_BETHSOFTVID, | ||
180 | CODEC_ID_PTX, | ||
181 | CODEC_ID_TXD, | ||
182 | CODEC_ID_VP6A, | ||
183 | CODEC_ID_AMV, | ||
184 | CODEC_ID_VB, | ||
185 | CODEC_ID_PCX, | ||
186 | CODEC_ID_SUNRAST, | ||
187 | CODEC_ID_INDEO4, | ||
188 | CODEC_ID_INDEO5, | ||
189 | CODEC_ID_MIMIC, | ||
190 | CODEC_ID_RL2, | ||
191 | CODEC_ID_8SVX_EXP, | ||
192 | CODEC_ID_8SVX_FIB, | ||
193 | CODEC_ID_ESCAPE124, | ||
194 | CODEC_ID_DIRAC, | ||
195 | CODEC_ID_BFI, | ||
196 | CODEC_ID_CMV, | ||
197 | CODEC_ID_MOTIONPIXELS, | ||
198 | CODEC_ID_TGV, | ||
199 | CODEC_ID_TGQ, | ||
200 | CODEC_ID_TQI, | ||
201 | CODEC_ID_AURA, | ||
202 | CODEC_ID_AURA2, | ||
203 | CODEC_ID_V210X, | ||
204 | CODEC_ID_TMV, | ||
205 | CODEC_ID_V210, | ||
206 | CODEC_ID_DPX, | ||
207 | CODEC_ID_MAD, | ||
208 | CODEC_ID_FRWU, | ||
209 | CODEC_ID_FLASHSV2, | ||
210 | CODEC_ID_CDGRAPHICS, | ||
211 | CODEC_ID_R210, | ||
212 | CODEC_ID_ANM, | ||
213 | CODEC_ID_BINKVIDEO, | ||
214 | CODEC_ID_IFF_ILBM, | ||
215 | CODEC_ID_IFF_BYTERUN1, | ||
216 | CODEC_ID_KGV1, | ||
217 | CODEC_ID_YOP, | ||
218 | |||
219 | /* various PCM "codecs" */ | ||
220 | CODEC_ID_PCM_S16LE= 0x10000, | ||
221 | CODEC_ID_PCM_S16BE, | ||
222 | CODEC_ID_PCM_U16LE, | ||
223 | CODEC_ID_PCM_U16BE, | ||
224 | CODEC_ID_PCM_S8, | ||
225 | CODEC_ID_PCM_U8, | ||
226 | CODEC_ID_PCM_MULAW, | ||
227 | CODEC_ID_PCM_ALAW, | ||
228 | CODEC_ID_PCM_S32LE, | ||
229 | CODEC_ID_PCM_S32BE, | ||
230 | CODEC_ID_PCM_U32LE, | ||
231 | CODEC_ID_PCM_U32BE, | ||
232 | CODEC_ID_PCM_S24LE, | ||
233 | CODEC_ID_PCM_S24BE, | ||
234 | CODEC_ID_PCM_U24LE, | ||
235 | CODEC_ID_PCM_U24BE, | ||
236 | CODEC_ID_PCM_S24DAUD, | ||
237 | CODEC_ID_PCM_ZORK, | ||
238 | CODEC_ID_PCM_S16LE_PLANAR, | ||
239 | CODEC_ID_PCM_DVD, | ||
240 | CODEC_ID_PCM_F32BE, | ||
241 | CODEC_ID_PCM_F32LE, | ||
242 | CODEC_ID_PCM_F64BE, | ||
243 | CODEC_ID_PCM_F64LE, | ||
244 | CODEC_ID_PCM_BLURAY, | ||
245 | |||
246 | /* various ADPCM codecs */ | ||
247 | CODEC_ID_ADPCM_IMA_QT= 0x11000, | ||
248 | CODEC_ID_ADPCM_IMA_WAV, | ||
249 | CODEC_ID_ADPCM_IMA_DK3, | ||
250 | CODEC_ID_ADPCM_IMA_DK4, | ||
251 | CODEC_ID_ADPCM_IMA_WS, | ||
252 | CODEC_ID_ADPCM_IMA_SMJPEG, | ||
253 | CODEC_ID_ADPCM_MS, | ||
254 | CODEC_ID_ADPCM_4XM, | ||
255 | CODEC_ID_ADPCM_XA, | ||
256 | CODEC_ID_ADPCM_ADX, | ||
257 | CODEC_ID_ADPCM_EA, | ||
258 | CODEC_ID_ADPCM_G726, | ||
259 | CODEC_ID_ADPCM_CT, | ||
260 | CODEC_ID_ADPCM_SWF, | ||
261 | CODEC_ID_ADPCM_YAMAHA, | ||
262 | CODEC_ID_ADPCM_SBPRO_4, | ||
263 | CODEC_ID_ADPCM_SBPRO_3, | ||
264 | CODEC_ID_ADPCM_SBPRO_2, | ||
265 | CODEC_ID_ADPCM_THP, | ||
266 | CODEC_ID_ADPCM_IMA_AMV, | ||
267 | CODEC_ID_ADPCM_EA_R1, | ||
268 | CODEC_ID_ADPCM_EA_R3, | ||
269 | CODEC_ID_ADPCM_EA_R2, | ||
270 | CODEC_ID_ADPCM_IMA_EA_SEAD, | ||
271 | CODEC_ID_ADPCM_IMA_EA_EACS, | ||
272 | CODEC_ID_ADPCM_EA_XAS, | ||
273 | CODEC_ID_ADPCM_EA_MAXIS_XA, | ||
274 | CODEC_ID_ADPCM_IMA_ISS, | ||
275 | |||
276 | /* AMR */ | ||
277 | CODEC_ID_AMR_NB= 0x12000, | ||
278 | CODEC_ID_AMR_WB, | ||
279 | |||
280 | /* RealAudio codecs*/ | ||
281 | CODEC_ID_RA_144= 0x13000, | ||
282 | CODEC_ID_RA_288, | ||
283 | |||
284 | /* various DPCM codecs */ | ||
285 | CODEC_ID_ROQ_DPCM= 0x14000, | ||
286 | CODEC_ID_INTERPLAY_DPCM, | ||
287 | CODEC_ID_XAN_DPCM, | ||
288 | CODEC_ID_SOL_DPCM, | ||
289 | |||
290 | /* audio codecs */ | ||
291 | CODEC_ID_MP2= 0x15000, | ||
292 | CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 | ||
293 | CODEC_ID_AAC, | ||
294 | CODEC_ID_AC3, | ||
295 | CODEC_ID_DTS, | ||
296 | CODEC_ID_VORBIS, | ||
297 | CODEC_ID_DVAUDIO, | ||
298 | CODEC_ID_WMAV1, | ||
299 | CODEC_ID_WMAV2, | ||
300 | CODEC_ID_MACE3, | ||
301 | CODEC_ID_MACE6, | ||
302 | CODEC_ID_VMDAUDIO, | ||
303 | CODEC_ID_SONIC, | ||
304 | CODEC_ID_SONIC_LS, | ||
305 | CODEC_ID_FLAC, | ||
306 | CODEC_ID_MP3ADU, | ||
307 | CODEC_ID_MP3ON4, | ||
308 | CODEC_ID_SHORTEN, | ||
309 | CODEC_ID_ALAC, | ||
310 | CODEC_ID_WESTWOOD_SND1, | ||
311 | CODEC_ID_GSM, ///< as in Berlin toast format | ||
312 | CODEC_ID_QDM2, | ||
313 | CODEC_ID_COOK, | ||
314 | CODEC_ID_TRUESPEECH, | ||
315 | CODEC_ID_TTA, | ||
316 | CODEC_ID_SMACKAUDIO, | ||
317 | CODEC_ID_QCELP, | ||
318 | CODEC_ID_WAVPACK, | ||
319 | CODEC_ID_DSICINAUDIO, | ||
320 | CODEC_ID_IMC, | ||
321 | CODEC_ID_MUSEPACK7, | ||
322 | CODEC_ID_MLP, | ||
323 | CODEC_ID_GSM_MS, /* as found in WAV */ | ||
324 | CODEC_ID_ATRAC3, | ||
325 | CODEC_ID_VOXWARE, | ||
326 | CODEC_ID_APE, | ||
327 | CODEC_ID_NELLYMOSER, | ||
328 | CODEC_ID_MUSEPACK8, | ||
329 | CODEC_ID_SPEEX, | ||
330 | CODEC_ID_WMAVOICE, | ||
331 | CODEC_ID_WMAPRO, | ||
332 | CODEC_ID_WMALOSSLESS, | ||
333 | CODEC_ID_ATRAC3P, | ||
334 | CODEC_ID_EAC3, | ||
335 | CODEC_ID_SIPR, | ||
336 | CODEC_ID_MP1, | ||
337 | CODEC_ID_TWINVQ, | ||
338 | CODEC_ID_TRUEHD, | ||
339 | CODEC_ID_MP4ALS, | ||
340 | CODEC_ID_ATRAC1, | ||
341 | CODEC_ID_BINKAUDIO_RDFT, | ||
342 | CODEC_ID_BINKAUDIO_DCT, | ||
343 | |||
344 | /* subtitle codecs */ | ||
345 | CODEC_ID_DVD_SUBTITLE= 0x17000, | ||
346 | CODEC_ID_DVB_SUBTITLE, | ||
347 | CODEC_ID_TEXT, ///< raw UTF-8 text | ||
348 | CODEC_ID_XSUB, | ||
349 | CODEC_ID_SSA, | ||
350 | CODEC_ID_MOV_TEXT, | ||
351 | CODEC_ID_HDMV_PGS_SUBTITLE, | ||
352 | CODEC_ID_DVB_TELETEXT, | ||
353 | |||
354 | /* other specific kind of codecs (generally used for attachments) */ | ||
355 | CODEC_ID_TTF= 0x18000, | ||
356 | |||
357 | CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it | ||
358 | |||
359 | CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS | ||
360 | * stream (only used by libavformat) */ | ||
361 | }; | ||
362 | |||
363 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
364 | #define CodecType AVMediaType | ||
365 | |||
366 | #define CODEC_TYPE_UNKNOWN AVMEDIA_TYPE_UNKNOWN | ||
367 | #define CODEC_TYPE_VIDEO AVMEDIA_TYPE_VIDEO | ||
368 | #define CODEC_TYPE_AUDIO AVMEDIA_TYPE_AUDIO | ||
369 | #define CODEC_TYPE_DATA AVMEDIA_TYPE_DATA | ||
370 | #define CODEC_TYPE_SUBTITLE AVMEDIA_TYPE_SUBTITLE | ||
371 | #define CODEC_TYPE_ATTACHMENT AVMEDIA_TYPE_ATTACHMENT | ||
372 | #define CODEC_TYPE_NB AVMEDIA_TYPE_NB | ||
373 | #endif | ||
374 | |||
375 | /** | ||
376 | * all in native-endian format | ||
377 | */ | ||
378 | enum SampleFormat { | ||
379 | SAMPLE_FMT_NONE = -1, | ||
380 | SAMPLE_FMT_U8, ///< unsigned 8 bits | ||
381 | SAMPLE_FMT_S16, ///< signed 16 bits | ||
382 | SAMPLE_FMT_S32, ///< signed 32 bits | ||
383 | SAMPLE_FMT_FLT, ///< float | ||
384 | SAMPLE_FMT_DBL, ///< double | ||
385 | SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec | ||
386 | }; | ||
387 | |||
388 | /* Audio channel masks */ | ||
389 | #define CH_FRONT_LEFT 0x00000001 | ||
390 | #define CH_FRONT_RIGHT 0x00000002 | ||
391 | #define CH_FRONT_CENTER 0x00000004 | ||
392 | #define CH_LOW_FREQUENCY 0x00000008 | ||
393 | #define CH_BACK_LEFT 0x00000010 | ||
394 | #define CH_BACK_RIGHT 0x00000020 | ||
395 | #define CH_FRONT_LEFT_OF_CENTER 0x00000040 | ||
396 | #define CH_FRONT_RIGHT_OF_CENTER 0x00000080 | ||
397 | #define CH_BACK_CENTER 0x00000100 | ||
398 | #define CH_SIDE_LEFT 0x00000200 | ||
399 | #define CH_SIDE_RIGHT 0x00000400 | ||
400 | #define CH_TOP_CENTER 0x00000800 | ||
401 | #define CH_TOP_FRONT_LEFT 0x00001000 | ||
402 | #define CH_TOP_FRONT_CENTER 0x00002000 | ||
403 | #define CH_TOP_FRONT_RIGHT 0x00004000 | ||
404 | #define CH_TOP_BACK_LEFT 0x00008000 | ||
405 | #define CH_TOP_BACK_CENTER 0x00010000 | ||
406 | #define CH_TOP_BACK_RIGHT 0x00020000 | ||
407 | #define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. | ||
408 | #define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT. | ||
409 | |||
410 | /** Channel mask value used for AVCodecContext.request_channel_layout | ||
411 | to indicate that the user requests the channel order of the decoder output | ||
412 | to be the native codec channel order. */ | ||
413 | #define CH_LAYOUT_NATIVE 0x8000000000000000LL | ||
414 | |||
415 | /* Audio channel convenience macros */ | ||
416 | #define CH_LAYOUT_MONO (CH_FRONT_CENTER) | ||
417 | #define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT) | ||
418 | #define CH_LAYOUT_2_1 (CH_LAYOUT_STEREO|CH_BACK_CENTER) | ||
419 | #define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER) | ||
420 | #define CH_LAYOUT_4POINT0 (CH_LAYOUT_SURROUND|CH_BACK_CENTER) | ||
421 | #define CH_LAYOUT_2_2 (CH_LAYOUT_STEREO|CH_SIDE_LEFT|CH_SIDE_RIGHT) | ||
422 | #define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) | ||
423 | #define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) | ||
424 | #define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) | ||
425 | #define CH_LAYOUT_5POINT0_BACK (CH_LAYOUT_SURROUND|CH_BACK_LEFT|CH_BACK_RIGHT) | ||
426 | #define CH_LAYOUT_5POINT1_BACK (CH_LAYOUT_5POINT0_BACK|CH_LOW_FREQUENCY) | ||
427 | #define CH_LAYOUT_7POINT0 (CH_LAYOUT_5POINT0|CH_BACK_LEFT|CH_BACK_RIGHT) | ||
428 | #define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) | ||
429 | #define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_5POINT1_BACK|\ | ||
430 | CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) | ||
431 | #define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT) | ||
432 | |||
433 | /* in bytes */ | ||
434 | #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio | ||
435 | |||
436 | /** | ||
437 | * Required number of additionally allocated bytes at the end of the input bitstream for decoding. | ||
438 | * This is mainly needed because some optimized bitstream readers read | ||
439 | * 32 or 64 bit at once and could read over the end.<br> | ||
440 | * Note: If the first 23 bits of the additional bytes are not 0, then damaged | ||
441 | * MPEG bitstreams could cause overread and segfault. | ||
442 | */ | ||
443 | #define FF_INPUT_BUFFER_PADDING_SIZE 8 | ||
444 | |||
445 | /** | ||
446 | * minimum encoding buffer size | ||
447 | * Used to avoid some checks during header writing. | ||
448 | */ | ||
449 | #define FF_MIN_BUFFER_SIZE 16384 | ||
450 | |||
451 | |||
452 | /** | ||
453 | * motion estimation type. | ||
454 | */ | ||
455 | enum Motion_Est_ID { | ||
456 | ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed | ||
457 | ME_FULL, | ||
458 | ME_LOG, | ||
459 | ME_PHODS, | ||
460 | ME_EPZS, ///< enhanced predictive zonal search | ||
461 | ME_X1, ///< reserved for experiments | ||
462 | ME_HEX, ///< hexagon based search | ||
463 | ME_UMH, ///< uneven multi-hexagon search | ||
464 | ME_ITER, ///< iterative search | ||
465 | ME_TESA, ///< transformed exhaustive search algorithm | ||
466 | }; | ||
467 | |||
468 | enum AVDiscard{ | ||
469 | /* We leave some space between them for extensions (drop some | ||
470 | * keyframes for intra-only or drop just some bidir frames). */ | ||
471 | AVDISCARD_NONE =-16, ///< discard nothing | ||
472 | AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi | ||
473 | AVDISCARD_NONREF = 8, ///< discard all non reference | ||
474 | AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames | ||
475 | AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes | ||
476 | AVDISCARD_ALL = 48, ///< discard all | ||
477 | }; | ||
478 | |||
479 | enum AVColorPrimaries{ | ||
480 | AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B | ||
481 | AVCOL_PRI_UNSPECIFIED=2, | ||
482 | AVCOL_PRI_BT470M =4, | ||
483 | AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM | ||
484 | AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC | ||
485 | AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above | ||
486 | AVCOL_PRI_FILM =8, | ||
487 | AVCOL_PRI_NB , ///< Not part of ABI | ||
488 | }; | ||
489 | |||
490 | enum AVColorTransferCharacteristic{ | ||
491 | AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361 | ||
492 | AVCOL_TRC_UNSPECIFIED=2, | ||
493 | AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM | ||
494 | AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG | ||
495 | AVCOL_TRC_NB , ///< Not part of ABI | ||
496 | }; | ||
497 | |||
498 | enum AVColorSpace{ | ||
499 | AVCOL_SPC_RGB =0, | ||
500 | AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B | ||
501 | AVCOL_SPC_UNSPECIFIED=2, | ||
502 | AVCOL_SPC_FCC =4, | ||
503 | AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 | ||
504 | AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above | ||
505 | AVCOL_SPC_SMPTE240M =7, | ||
506 | AVCOL_SPC_NB , ///< Not part of ABI | ||
507 | }; | ||
508 | |||
509 | enum AVColorRange{ | ||
510 | AVCOL_RANGE_UNSPECIFIED=0, | ||
511 | AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges | ||
512 | AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges | ||
513 | AVCOL_RANGE_NB , ///< Not part of ABI | ||
514 | }; | ||
515 | |||
516 | /** | ||
517 | * X X 3 4 X X are luma samples, | ||
518 | * 1 2 1-6 are possible chroma positions | ||
519 | * X X 5 6 X 0 is undefined/unknown position | ||
520 | */ | ||
521 | enum AVChromaLocation{ | ||
522 | AVCHROMA_LOC_UNSPECIFIED=0, | ||
523 | AVCHROMA_LOC_LEFT =1, ///< mpeg2/4, h264 default | ||
524 | AVCHROMA_LOC_CENTER =2, ///< mpeg1, jpeg, h263 | ||
525 | AVCHROMA_LOC_TOPLEFT =3, ///< DV | ||
526 | AVCHROMA_LOC_TOP =4, | ||
527 | AVCHROMA_LOC_BOTTOMLEFT =5, | ||
528 | AVCHROMA_LOC_BOTTOM =6, | ||
529 | AVCHROMA_LOC_NB , ///< Not part of ABI | ||
530 | }; | ||
531 | |||
532 | typedef struct RcOverride{ | ||
533 | int start_frame; | ||
534 | int end_frame; | ||
535 | int qscale; // If this is 0 then quality_factor will be used instead. | ||
536 | float quality_factor; | ||
537 | } RcOverride; | ||
538 | |||
539 | #define FF_MAX_B_FRAMES 16 | ||
540 | |||
541 | /* encoding support | ||
542 | These flags can be passed in AVCodecContext.flags before initialization. | ||
543 | Note: Not everything is supported yet. | ||
544 | */ | ||
545 | |||
546 | #define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. | ||
547 | #define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. | ||
548 | #define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. | ||
549 | #define CODEC_FLAG_GMC 0x0020 ///< Use GMC. | ||
550 | #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. | ||
551 | #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. | ||
552 | /** | ||
553 | * The parent program guarantees that the input for B-frames containing | ||
554 | * streams is not written to for at least s->max_b_frames+1 frames, if | ||
555 | * this is not set the input will be copied. | ||
556 | */ | ||
557 | #define CODEC_FLAG_INPUT_PRESERVED 0x0100 | ||
558 | #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. | ||
559 | #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. | ||
560 | #define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). | ||
561 | #define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. | ||
562 | #define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. | ||
563 | #define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. | ||
564 | #define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random | ||
565 | location instead of only at frame boundaries. */ | ||
566 | #define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. | ||
567 | #define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. | ||
568 | #define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. | ||
569 | #define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. | ||
570 | #define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. | ||
571 | #define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). | ||
572 | /* Fx : Flag for h263+ extra options */ | ||
573 | #define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction | ||
574 | #define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector | ||
575 | #define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. | ||
576 | #define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. | ||
577 | #define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC | ||
578 | #define CODEC_FLAG_OBMC 0x00000001 ///< OBMC | ||
579 | #define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter | ||
580 | #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 | ||
581 | #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation | ||
582 | #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. | ||
583 | #define CODEC_FLAG_CLOSED_GOP 0x80000000 | ||
584 | #define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. | ||
585 | #define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. | ||
586 | #define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. | ||
587 | #define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. | ||
588 | #define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. | ||
589 | #define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames | ||
590 | #define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock | ||
591 | #define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform | ||
592 | #define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip | ||
593 | #define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters | ||
594 | #define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization | ||
595 | #define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. | ||
596 | #define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). | ||
597 | #define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. | ||
598 | #define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping | ||
599 | #define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. | ||
600 | #define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. | ||
601 | #define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible | ||
602 | #define CODEC_FLAG2_MBTREE 0x00040000 ///< Use macroblock tree ratecontrol (x264 only) | ||
603 | #define CODEC_FLAG2_PSY 0x00080000 ///< Use psycho visual optimizations. | ||
604 | #define CODEC_FLAG2_SSIM 0x00100000 ///< Compute SSIM during encoding, error[] values are undefined. | ||
605 | |||
606 | /* Unsupported options : | ||
607 | * Syntax Arithmetic coding (SAC) | ||
608 | * Reference Picture Selection | ||
609 | * Independent Segment Decoding */ | ||
610 | /* /Fx */ | ||
611 | /* codec capabilities */ | ||
612 | |||
613 | #define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. | ||
614 | /** | ||
615 | * Codec uses get_buffer() for allocating buffers and supports custom allocators. | ||
616 | * If not set, it might not use get_buffer() at all or use operations that | ||
617 | * assume the buffer was allocated by avcodec_default_get_buffer. | ||
618 | */ | ||
619 | #define CODEC_CAP_DR1 0x0002 | ||
620 | /* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ | ||
621 | #define CODEC_CAP_PARSE_ONLY 0x0004 | ||
622 | #define CODEC_CAP_TRUNCATED 0x0008 | ||
623 | /* Codec can export data for HW decoding (XvMC). */ | ||
624 | #define CODEC_CAP_HWACCEL 0x0010 | ||
625 | /** | ||
626 | * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. | ||
627 | * If this is not set, the codec is guaranteed to never be fed with NULL data. | ||
628 | */ | ||
629 | #define CODEC_CAP_DELAY 0x0020 | ||
630 | /** | ||
631 | * Codec can be fed a final frame with a smaller size. | ||
632 | * This can be used to prevent truncation of the last audio samples. | ||
633 | */ | ||
634 | #define CODEC_CAP_SMALL_LAST_FRAME 0x0040 | ||
635 | /** | ||
636 | * Codec can export data for HW decoding (VDPAU). | ||
637 | */ | ||
638 | #define CODEC_CAP_HWACCEL_VDPAU 0x0080 | ||
639 | /** | ||
640 | * Codec can output multiple frames per AVPacket | ||
641 | * Normally demuxers return one frame at a time, demuxers which do not do | ||
642 | * are connected to a parser to split what they return into proper frames. | ||
643 | * This flag is reserved to the very rare category of codecs which have a | ||
644 | * bitstream that cannot be split into frames without timeconsuming | ||
645 | * operations like full decoding. Demuxers carring such bitstreams thus | ||
646 | * may return multiple frames in a packet. This has many disadvantages like | ||
647 | * prohibiting stream copy in many cases thus it should only be considered | ||
648 | * as a last resort. | ||
649 | */ | ||
650 | #define CODEC_CAP_SUBFRAMES 0x0100 | ||
651 | |||
652 | //The following defines may change, don't expect compatibility if you use them. | ||
653 | #define MB_TYPE_INTRA4x4 0x0001 | ||
654 | #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific | ||
655 | #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific | ||
656 | #define MB_TYPE_16x16 0x0008 | ||
657 | #define MB_TYPE_16x8 0x0010 | ||
658 | #define MB_TYPE_8x16 0x0020 | ||
659 | #define MB_TYPE_8x8 0x0040 | ||
660 | #define MB_TYPE_INTERLACED 0x0080 | ||
661 | #define MB_TYPE_DIRECT2 0x0100 //FIXME | ||
662 | #define MB_TYPE_ACPRED 0x0200 | ||
663 | #define MB_TYPE_GMC 0x0400 | ||
664 | #define MB_TYPE_SKIP 0x0800 | ||
665 | #define MB_TYPE_P0L0 0x1000 | ||
666 | #define MB_TYPE_P1L0 0x2000 | ||
667 | #define MB_TYPE_P0L1 0x4000 | ||
668 | #define MB_TYPE_P1L1 0x8000 | ||
669 | #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) | ||
670 | #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) | ||
671 | #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) | ||
672 | #define MB_TYPE_QUANT 0x00010000 | ||
673 | #define MB_TYPE_CBP 0x00020000 | ||
674 | //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) | ||
675 | |||
676 | /** | ||
677 | * Pan Scan area. | ||
678 | * This specifies the area which should be displayed. | ||
679 | * Note there may be multiple such areas for one frame. | ||
680 | */ | ||
681 | typedef struct AVPanScan{ | ||
682 | /** | ||
683 | * id | ||
684 | * - encoding: Set by user. | ||
685 | * - decoding: Set by libavcodec. | ||
686 | */ | ||
687 | int id; | ||
688 | |||
689 | /** | ||
690 | * width and height in 1/16 pel | ||
691 | * - encoding: Set by user. | ||
692 | * - decoding: Set by libavcodec. | ||
693 | */ | ||
694 | int width; | ||
695 | int height; | ||
696 | |||
697 | /** | ||
698 | * position of the top left corner in 1/16 pel for up to 3 fields/frames | ||
699 | * - encoding: Set by user. | ||
700 | * - decoding: Set by libavcodec. | ||
701 | */ | ||
702 | int16_t position[3][2]; | ||
703 | }AVPanScan; | ||
704 | |||
705 | #define FF_COMMON_FRAME \ | ||
706 | /**\ | ||
707 | * pointer to the picture planes.\ | ||
708 | * This might be different from the first allocated byte\ | ||
709 | * - encoding: \ | ||
710 | * - decoding: \ | ||
711 | */\ | ||
712 | uint8_t *data[4];\ | ||
713 | int linesize[4];\ | ||
714 | /**\ | ||
715 | * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\ | ||
716 | * This isn't used by libavcodec unless the default get/release_buffer() is used.\ | ||
717 | * - encoding: \ | ||
718 | * - decoding: \ | ||
719 | */\ | ||
720 | uint8_t *base[4];\ | ||
721 | /**\ | ||
722 | * 1 -> keyframe, 0-> not\ | ||
723 | * - encoding: Set by libavcodec.\ | ||
724 | * - decoding: Set by libavcodec.\ | ||
725 | */\ | ||
726 | int key_frame;\ | ||
727 | \ | ||
728 | /**\ | ||
729 | * Picture type of the frame, see ?_TYPE below.\ | ||
730 | * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ | ||
731 | * - decoding: Set by libavcodec.\ | ||
732 | */\ | ||
733 | int pict_type;\ | ||
734 | \ | ||
735 | /**\ | ||
736 | * presentation timestamp in time_base units (time when frame should be shown to user)\ | ||
737 | * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\ | ||
738 | * - encoding: MUST be set by user.\ | ||
739 | * - decoding: Set by libavcodec.\ | ||
740 | */\ | ||
741 | int64_t pts;\ | ||
742 | \ | ||
743 | /**\ | ||
744 | * picture number in bitstream order\ | ||
745 | * - encoding: set by\ | ||
746 | * - decoding: Set by libavcodec.\ | ||
747 | */\ | ||
748 | int coded_picture_number;\ | ||
749 | /**\ | ||
750 | * picture number in display order\ | ||
751 | * - encoding: set by\ | ||
752 | * - decoding: Set by libavcodec.\ | ||
753 | */\ | ||
754 | int display_picture_number;\ | ||
755 | \ | ||
756 | /**\ | ||
757 | * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ | ||
758 | * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ | ||
759 | * - decoding: Set by libavcodec.\ | ||
760 | */\ | ||
761 | int quality; \ | ||
762 | \ | ||
763 | /**\ | ||
764 | * buffer age (1->was last buffer and dint change, 2->..., ...).\ | ||
765 | * Set to INT_MAX if the buffer has not been used yet.\ | ||
766 | * - encoding: unused\ | ||
767 | * - decoding: MUST be set by get_buffer().\ | ||
768 | */\ | ||
769 | int age;\ | ||
770 | \ | ||
771 | /**\ | ||
772 | * is this picture used as reference\ | ||
773 | * The values for this are the same as the MpegEncContext.picture_structure\ | ||
774 | * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\ | ||
775 | * Set to 4 for delayed, non-reference frames.\ | ||
776 | * - encoding: unused\ | ||
777 | * - decoding: Set by libavcodec. (before get_buffer() call)).\ | ||
778 | */\ | ||
779 | int reference;\ | ||
780 | \ | ||
781 | /**\ | ||
782 | * QP table\ | ||
783 | * - encoding: unused\ | ||
784 | * - decoding: Set by libavcodec.\ | ||
785 | */\ | ||
786 | int8_t *qscale_table;\ | ||
787 | /**\ | ||
788 | * QP store stride\ | ||
789 | * - encoding: unused\ | ||
790 | * - decoding: Set by libavcodec.\ | ||
791 | */\ | ||
792 | int qstride;\ | ||
793 | \ | ||
794 | /**\ | ||
795 | * mbskip_table[mb]>=1 if MB didn't change\ | ||
796 | * stride= mb_width = (width+15)>>4\ | ||
797 | * - encoding: unused\ | ||
798 | * - decoding: Set by libavcodec.\ | ||
799 | */\ | ||
800 | uint8_t *mbskip_table;\ | ||
801 | \ | ||
802 | /**\ | ||
803 | * motion vector table\ | ||
804 | * @code\ | ||
805 | * example:\ | ||
806 | * int mv_sample_log2= 4 - motion_subsample_log2;\ | ||
807 | * int mb_width= (width+15)>>4;\ | ||
808 | * int mv_stride= (mb_width << mv_sample_log2) + 1;\ | ||
809 | * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ | ||
810 | * @endcode\ | ||
811 | * - encoding: Set by user.\ | ||
812 | * - decoding: Set by libavcodec.\ | ||
813 | */\ | ||
814 | int16_t (*motion_val[2])[2];\ | ||
815 | \ | ||
816 | /**\ | ||
817 | * macroblock type table\ | ||
818 | * mb_type_base + mb_width + 2\ | ||
819 | * - encoding: Set by user.\ | ||
820 | * - decoding: Set by libavcodec.\ | ||
821 | */\ | ||
822 | uint32_t *mb_type;\ | ||
823 | \ | ||
824 | /**\ | ||
825 | * log2 of the size of the block which a single vector in motion_val represents: \ | ||
826 | * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ | ||
827 | * - encoding: unused\ | ||
828 | * - decoding: Set by libavcodec.\ | ||
829 | */\ | ||
830 | uint8_t motion_subsample_log2;\ | ||
831 | \ | ||
832 | /**\ | ||
833 | * for some private data of the user\ | ||
834 | * - encoding: unused\ | ||
835 | * - decoding: Set by user.\ | ||
836 | */\ | ||
837 | void *opaque;\ | ||
838 | \ | ||
839 | /**\ | ||
840 | * error\ | ||
841 | * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\ | ||
842 | * - decoding: unused\ | ||
843 | */\ | ||
844 | uint64_t error[4];\ | ||
845 | \ | ||
846 | /**\ | ||
847 | * type of the buffer (to keep track of who has to deallocate data[*])\ | ||
848 | * - encoding: Set by the one who allocates it.\ | ||
849 | * - decoding: Set by the one who allocates it.\ | ||
850 | * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\ | ||
851 | */\ | ||
852 | int type;\ | ||
853 | \ | ||
854 | /**\ | ||
855 | * When decoding, this signals how much the picture must be delayed.\ | ||
856 | * extra_delay = repeat_pict / (2*fps)\ | ||
857 | * - encoding: unused\ | ||
858 | * - decoding: Set by libavcodec.\ | ||
859 | */\ | ||
860 | int repeat_pict;\ | ||
861 | \ | ||
862 | /**\ | ||
863 | * \ | ||
864 | */\ | ||
865 | int qscale_type;\ | ||
866 | \ | ||
867 | /**\ | ||
868 | * The content of the picture is interlaced.\ | ||
869 | * - encoding: Set by user.\ | ||
870 | * - decoding: Set by libavcodec. (default 0)\ | ||
871 | */\ | ||
872 | int interlaced_frame;\ | ||
873 | \ | ||
874 | /**\ | ||
875 | * If the content is interlaced, is top field displayed first.\ | ||
876 | * - encoding: Set by user.\ | ||
877 | * - decoding: Set by libavcodec.\ | ||
878 | */\ | ||
879 | int top_field_first;\ | ||
880 | \ | ||
881 | /**\ | ||
882 | * Pan scan.\ | ||
883 | * - encoding: Set by user.\ | ||
884 | * - decoding: Set by libavcodec.\ | ||
885 | */\ | ||
886 | AVPanScan *pan_scan;\ | ||
887 | \ | ||
888 | /**\ | ||
889 | * Tell user application that palette has changed from previous frame.\ | ||
890 | * - encoding: ??? (no palette-enabled encoder yet)\ | ||
891 | * - decoding: Set by libavcodec. (default 0).\ | ||
892 | */\ | ||
893 | int palette_has_changed;\ | ||
894 | \ | ||
895 | /**\ | ||
896 | * codec suggestion on buffer type if != 0\ | ||
897 | * - encoding: unused\ | ||
898 | * - decoding: Set by libavcodec. (before get_buffer() call)).\ | ||
899 | */\ | ||
900 | int buffer_hints;\ | ||
901 | \ | ||
902 | /**\ | ||
903 | * DCT coefficients\ | ||
904 | * - encoding: unused\ | ||
905 | * - decoding: Set by libavcodec.\ | ||
906 | */\ | ||
907 | short *dct_coeff;\ | ||
908 | \ | ||
909 | /**\ | ||
910 | * motion reference frame index\ | ||
911 | * the order in which these are stored can depend on the codec.\ | ||
912 | * - encoding: Set by user.\ | ||
913 | * - decoding: Set by libavcodec.\ | ||
914 | */\ | ||
915 | int8_t *ref_index[2];\ | ||
916 | \ | ||
917 | /**\ | ||
918 | * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\ | ||
919 | * output in AVFrame.reordered_opaque\ | ||
920 | * - encoding: unused\ | ||
921 | * - decoding: Read by user.\ | ||
922 | */\ | ||
923 | int64_t reordered_opaque;\ | ||
924 | \ | ||
925 | /**\ | ||
926 | * hardware accelerator private data (FFmpeg allocated)\ | ||
927 | * - encoding: unused\ | ||
928 | * - decoding: Set by libavcodec\ | ||
929 | */\ | ||
930 | void *hwaccel_picture_private;\ | ||
931 | |||
932 | |||
933 | #define FF_QSCALE_TYPE_MPEG1 0 | ||
934 | #define FF_QSCALE_TYPE_MPEG2 1 | ||
935 | #define FF_QSCALE_TYPE_H264 2 | ||
936 | #define FF_QSCALE_TYPE_VP56 3 | ||
937 | |||
938 | #define FF_BUFFER_TYPE_INTERNAL 1 | ||
939 | #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) | ||
940 | #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. | ||
941 | #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. | ||
942 | |||
943 | |||
944 | #define FF_I_TYPE 1 ///< Intra | ||
945 | #define FF_P_TYPE 2 ///< Predicted | ||
946 | #define FF_B_TYPE 3 ///< Bi-dir predicted | ||
947 | #define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4 | ||
948 | #define FF_SI_TYPE 5 ///< Switching Intra | ||
949 | #define FF_SP_TYPE 6 ///< Switching Predicted | ||
950 | #define FF_BI_TYPE 7 | ||
951 | |||
952 | #define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). | ||
953 | #define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. | ||
954 | #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. | ||
955 | #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). | ||
956 | |||
957 | typedef struct AVPacket { | ||
958 | /** | ||
959 | * Presentation timestamp in AVStream->time_base units; the time at which | ||
960 | * the decompressed packet will be presented to the user. | ||
961 | * Can be AV_NOPTS_VALUE if it is not stored in the file. | ||
962 | * pts MUST be larger or equal to dts as presentation cannot happen before | ||
963 | * decompression, unless one wants to view hex dumps. Some formats misuse | ||
964 | * the terms dts and pts/cts to mean something different. Such timestamps | ||
965 | * must be converted to true pts/dts before they are stored in AVPacket. | ||
966 | */ | ||
967 | int64_t pts; | ||
968 | /** | ||
969 | * Decompression timestamp in AVStream->time_base units; the time at which | ||
970 | * the packet is decompressed. | ||
971 | * Can be AV_NOPTS_VALUE if it is not stored in the file. | ||
972 | */ | ||
973 | int64_t dts; | ||
974 | uint8_t *data; | ||
975 | int size; | ||
976 | int stream_index; | ||
977 | int flags; | ||
978 | /** | ||
979 | * Duration of this packet in AVStream->time_base units, 0 if unknown. | ||
980 | * Equals next_pts - this_pts in presentation order. | ||
981 | */ | ||
982 | int duration; | ||
983 | void (*destruct)(struct AVPacket *); | ||
984 | void *priv; | ||
985 | int64_t pos; ///< byte position in stream, -1 if unknown | ||
986 | |||
987 | /** | ||
988 | * Time difference in AVStream->time_base units from the pts of this | ||
989 | * packet to the point at which the output from the decoder has converged | ||
990 | * independent from the availability of previous frames. That is, the | ||
991 | * frames are virtually identical no matter if decoding started from | ||
992 | * the very first frame or from this keyframe. | ||
993 | * Is AV_NOPTS_VALUE if unknown. | ||
994 | * This field is not the display duration of the current packet. | ||
995 | * | ||
996 | * The purpose of this field is to allow seeking in streams that have no | ||
997 | * keyframes in the conventional sense. It corresponds to the | ||
998 | * recovery point SEI in H.264 and match_time_delta in NUT. It is also | ||
999 | * essential for some types of subtitle streams to ensure that all | ||
1000 | * subtitles are correctly displayed after seeking. | ||
1001 | */ | ||
1002 | int64_t convergence_duration; | ||
1003 | } AVPacket; | ||
1004 | #define AV_PKT_FLAG_KEY 0x0001 | ||
1005 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
1006 | #define PKT_FLAG_KEY AV_PKT_FLAG_KEY | ||
1007 | #endif | ||
1008 | |||
1009 | /** | ||
1010 | * Audio Video Frame. | ||
1011 | * New fields can be added to the end of FF_COMMON_FRAME with minor version | ||
1012 | * bumps. | ||
1013 | * Removal, reordering and changes to existing fields require a major | ||
1014 | * version bump. No fields should be added into AVFrame before or after | ||
1015 | * FF_COMMON_FRAME! | ||
1016 | * sizeof(AVFrame) must not be used outside libav*. | ||
1017 | */ | ||
1018 | typedef struct AVFrame { | ||
1019 | FF_COMMON_FRAME | ||
1020 | } AVFrame; | ||
1021 | |||
1022 | /** | ||
1023 | * main external API structure. | ||
1024 | * New fields can be added to the end with minor version bumps. | ||
1025 | * Removal, reordering and changes to existing fields require a major | ||
1026 | * version bump. | ||
1027 | * sizeof(AVCodecContext) must not be used outside libav*. | ||
1028 | */ | ||
1029 | typedef struct AVCodecContext { | ||
1030 | /** | ||
1031 | * information on struct for av_log | ||
1032 | * - set by avcodec_alloc_context | ||
1033 | */ | ||
1034 | const AVClass *av_class; | ||
1035 | /** | ||
1036 | * the average bitrate | ||
1037 | * - encoding: Set by user; unused for constant quantizer encoding. | ||
1038 | * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. | ||
1039 | */ | ||
1040 | int bit_rate; | ||
1041 | |||
1042 | /** | ||
1043 | * number of bits the bitstream is allowed to diverge from the reference. | ||
1044 | * the reference can be CBR (for CBR pass1) or VBR (for pass2) | ||
1045 | * - encoding: Set by user; unused for constant quantizer encoding. | ||
1046 | * - decoding: unused | ||
1047 | */ | ||
1048 | int bit_rate_tolerance; | ||
1049 | |||
1050 | /** | ||
1051 | * CODEC_FLAG_*. | ||
1052 | * - encoding: Set by user. | ||
1053 | * - decoding: Set by user. | ||
1054 | */ | ||
1055 | int flags; | ||
1056 | |||
1057 | /** | ||
1058 | * Some codecs need additional format info. It is stored here. | ||
1059 | * If any muxer uses this then ALL demuxers/parsers AND encoders for the | ||
1060 | * specific codec MUST set it correctly otherwise stream copy breaks. | ||
1061 | * In general use of this field by muxers is not recommanded. | ||
1062 | * - encoding: Set by libavcodec. | ||
1063 | * - decoding: Set by libavcodec. (FIXME: Is this OK?) | ||
1064 | */ | ||
1065 | int sub_id; | ||
1066 | |||
1067 | /** | ||
1068 | * Motion estimation algorithm used for video coding. | ||
1069 | * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), | ||
1070 | * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] | ||
1071 | * - encoding: MUST be set by user. | ||
1072 | * - decoding: unused | ||
1073 | */ | ||
1074 | int me_method; | ||
1075 | |||
1076 | /** | ||
1077 | * some codecs need / can use extradata like Huffman tables. | ||
1078 | * mjpeg: Huffman tables | ||
1079 | * rv10: additional flags | ||
1080 | * mpeg4: global headers (they can be in the bitstream or here) | ||
1081 | * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger | ||
1082 | * than extradata_size to avoid prolems if it is read with the bitstream reader. | ||
1083 | * The bytewise contents of extradata must not depend on the architecture or CPU endianness. | ||
1084 | * - encoding: Set/allocated/freed by libavcodec. | ||
1085 | * - decoding: Set/allocated/freed by user. | ||
1086 | */ | ||
1087 | uint8_t *extradata; | ||
1088 | int extradata_size; | ||
1089 | |||
1090 | /** | ||
1091 | * This is the fundamental unit of time (in seconds) in terms | ||
1092 | * of which frame timestamps are represented. For fixed-fps content, | ||
1093 | * timebase should be 1/framerate and timestamp increments should be | ||
1094 | * identically 1. | ||
1095 | * - encoding: MUST be set by user. | ||
1096 | * - decoding: Set by libavcodec. | ||
1097 | */ | ||
1098 | //AVRational time_base; | ||
1099 | |||
1100 | /* video only */ | ||
1101 | /** | ||
1102 | * picture width / height. | ||
1103 | * - encoding: MUST be set by user. | ||
1104 | * - decoding: Set by libavcodec. | ||
1105 | * Note: For compatibility it is possible to set this instead of | ||
1106 | * coded_width/height before decoding. | ||
1107 | */ | ||
1108 | int width, height; | ||
1109 | |||
1110 | #define FF_ASPECT_EXTENDED 15 | ||
1111 | |||
1112 | /** | ||
1113 | * the number of pictures in a group of pictures, or 0 for intra_only | ||
1114 | * - encoding: Set by user. | ||
1115 | * - decoding: unused | ||
1116 | */ | ||
1117 | int gop_size; | ||
1118 | |||
1119 | /** | ||
1120 | * Pixel format, see PIX_FMT_xxx. | ||
1121 | * - encoding: Set by user. | ||
1122 | * - decoding: Set by libavcodec. | ||
1123 | */ | ||
1124 | //enum PixelFormat pix_fmt; | ||
1125 | |||
1126 | /** | ||
1127 | * Frame rate emulation. If not zero, the lower layer (i.e. format handler) | ||
1128 | * has to read frames at native frame rate. | ||
1129 | * - encoding: Set by user. | ||
1130 | * - decoding: unused | ||
1131 | */ | ||
1132 | int rate_emu; | ||
1133 | |||
1134 | /** | ||
1135 | * If non NULL, 'draw_horiz_band' is called by the libavcodec | ||
1136 | * decoder to draw a horizontal band. It improves cache usage. Not | ||
1137 | * all codecs can do that. You must check the codec capabilities | ||
1138 | * beforehand. | ||
1139 | * The function is also used by hardware acceleration APIs. | ||
1140 | * It is called at least once during frame decoding to pass | ||
1141 | * the data needed for hardware render. | ||
1142 | * In that mode instead of pixel data, AVFrame points to | ||
1143 | * a structure specific to the acceleration API. The application | ||
1144 | * reads the structure and can change some fields to indicate progress | ||
1145 | * or mark state. | ||
1146 | * - encoding: unused | ||
1147 | * - decoding: Set by user. | ||
1148 | * @param height the height of the slice | ||
1149 | * @param y the y position of the slice | ||
1150 | * @param type 1->top field, 2->bottom field, 3->frame | ||
1151 | * @param offset offset into the AVFrame.data from which the slice should be read | ||
1152 | */ | ||
1153 | void (*draw_horiz_band)(struct AVCodecContext *s, | ||
1154 | const AVFrame *src, int offset[4], | ||
1155 | int y, int type, int height); | ||
1156 | |||
1157 | /* audio only */ | ||
1158 | int sample_rate; ///< samples per second | ||
1159 | int channels; ///< number of audio channels | ||
1160 | |||
1161 | /** | ||
1162 | * audio sample format | ||
1163 | * - encoding: Set by user. | ||
1164 | * - decoding: Set by libavcodec. | ||
1165 | */ | ||
1166 | enum SampleFormat sample_fmt; ///< sample format | ||
1167 | |||
1168 | /* The following data should not be initialized. */ | ||
1169 | /** | ||
1170 | * Samples per packet, initialized when calling 'init'. | ||
1171 | */ | ||
1172 | int frame_size; | ||
1173 | int frame_number; ///< audio or video frame number | ||
1174 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
1175 | int real_pict_num; ///< Returns the real picture number of previous encoded frame. | ||
1176 | #endif | ||
1177 | |||
1178 | /** | ||
1179 | * Number of frames the decoded output will be delayed relative to | ||
1180 | * the encoded input. | ||
1181 | * - encoding: Set by libavcodec. | ||
1182 | * - decoding: unused | ||
1183 | */ | ||
1184 | int delay; | ||
1185 | |||
1186 | /* - encoding parameters */ | ||
1187 | float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) | ||
1188 | float qblur; ///< amount of qscale smoothing over time (0.0-1.0) | ||
1189 | |||
1190 | /** | ||
1191 | * minimum quantizer | ||
1192 | * - encoding: Set by user. | ||
1193 | * - decoding: unused | ||
1194 | */ | ||
1195 | int qmin; | ||
1196 | |||
1197 | /** | ||
1198 | * maximum quantizer | ||
1199 | * - encoding: Set by user. | ||
1200 | * - decoding: unused | ||
1201 | */ | ||
1202 | int qmax; | ||
1203 | |||
1204 | /** | ||
1205 | * maximum quantizer difference between frames | ||
1206 | * - encoding: Set by user. | ||
1207 | * - decoding: unused | ||
1208 | */ | ||
1209 | int max_qdiff; | ||
1210 | |||
1211 | /** | ||
1212 | * maximum number of B-frames between non-B-frames | ||
1213 | * Note: The output will be delayed by max_b_frames+1 relative to the input. | ||
1214 | * - encoding: Set by user. | ||
1215 | * - decoding: unused | ||
1216 | */ | ||
1217 | int max_b_frames; | ||
1218 | |||
1219 | /** | ||
1220 | * qscale factor between IP and B-frames | ||
1221 | * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). | ||
1222 | * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). | ||
1223 | * - encoding: Set by user. | ||
1224 | * - decoding: unused | ||
1225 | */ | ||
1226 | float b_quant_factor; | ||
1227 | |||
1228 | /** obsolete FIXME remove */ | ||
1229 | int rc_strategy; | ||
1230 | #define FF_RC_STRATEGY_XVID 1 | ||
1231 | |||
1232 | int b_frame_strategy; | ||
1233 | |||
1234 | /** | ||
1235 | * hurry up amount | ||
1236 | * - encoding: unused | ||
1237 | * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header | ||
1238 | * @deprecated Deprecated in favor of skip_idct and skip_frame. | ||
1239 | */ | ||
1240 | int hurry_up; | ||
1241 | |||
1242 | struct AVCodec *codec; | ||
1243 | |||
1244 | void *priv_data; | ||
1245 | |||
1246 | int rtp_payload_size; /* The size of the RTP payload: the coder will */ | ||
1247 | /* do its best to deliver a chunk with size */ | ||
1248 | /* below rtp_payload_size, the chunk will start */ | ||
1249 | /* with a start code on some codecs like H.263. */ | ||
1250 | /* This doesn't take account of any particular */ | ||
1251 | /* headers inside the transmitted RTP payload. */ | ||
1252 | |||
1253 | |||
1254 | /* The RTP callback: This function is called */ | ||
1255 | /* every time the encoder has a packet to send. */ | ||
1256 | /* It depends on the encoder if the data starts */ | ||
1257 | /* with a Start Code (it should). H.263 does. */ | ||
1258 | /* mb_nb contains the number of macroblocks */ | ||
1259 | /* encoded in the RTP payload. */ | ||
1260 | void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); | ||
1261 | |||
1262 | /* statistics, used for 2-pass encoding */ | ||
1263 | int mv_bits; | ||
1264 | int header_bits; | ||
1265 | int i_tex_bits; | ||
1266 | int p_tex_bits; | ||
1267 | int i_count; | ||
1268 | int p_count; | ||
1269 | int skip_count; | ||
1270 | int misc_bits; | ||
1271 | |||
1272 | /** | ||
1273 | * number of bits used for the previously encoded frame | ||
1274 | * - encoding: Set by libavcodec. | ||
1275 | * - decoding: unused | ||
1276 | */ | ||
1277 | int frame_bits; | ||
1278 | |||
1279 | /** | ||
1280 | * Private data of the user, can be used to carry app specific stuff. | ||
1281 | * - encoding: Set by user. | ||
1282 | * - decoding: Set by user. | ||
1283 | */ | ||
1284 | void *opaque; | ||
1285 | |||
1286 | char codec_name[32]; | ||
1287 | enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ | ||
1288 | enum CodecID codec_id; /* see CODEC_ID_xxx */ | ||
1289 | |||
1290 | /** | ||
1291 | * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). | ||
1292 | * This is used to work around some encoder bugs. | ||
1293 | * A demuxer should set this to what is stored in the field used to identify the codec. | ||
1294 | * If there are multiple such fields in a container then the demuxer should choose the one | ||
1295 | * which maximizes the information about the used codec. | ||
1296 | * If the codec tag field in a container is larger then 32 bits then the demuxer should | ||
1297 | * remap the longer ID to 32 bits with a table or other structure. Alternatively a new | ||
1298 | * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated | ||
1299 | * first. | ||
1300 | * - encoding: Set by user, if not then the default based on codec_id will be used. | ||
1301 | * - decoding: Set by user, will be converted to uppercase by libavcodec during init. | ||
1302 | */ | ||
1303 | unsigned int codec_tag; | ||
1304 | |||
1305 | /** | ||
1306 | * Work around bugs in encoders which sometimes cannot be detected automatically. | ||
1307 | * - encoding: Set by user | ||
1308 | * - decoding: Set by user | ||
1309 | */ | ||
1310 | int workaround_bugs; | ||
1311 | #define FF_BUG_AUTODETECT 1 ///< autodetection | ||
1312 | #define FF_BUG_OLD_MSMPEG4 2 | ||
1313 | #define FF_BUG_XVID_ILACE 4 | ||
1314 | #define FF_BUG_UMP4 8 | ||
1315 | #define FF_BUG_NO_PADDING 16 | ||
1316 | #define FF_BUG_AMV 32 | ||
1317 | #define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. | ||
1318 | #define FF_BUG_QPEL_CHROMA 64 | ||
1319 | #define FF_BUG_STD_QPEL 128 | ||
1320 | #define FF_BUG_QPEL_CHROMA2 256 | ||
1321 | #define FF_BUG_DIRECT_BLOCKSIZE 512 | ||
1322 | #define FF_BUG_EDGE 1024 | ||
1323 | #define FF_BUG_HPEL_CHROMA 2048 | ||
1324 | #define FF_BUG_DC_CLIP 4096 | ||
1325 | #define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. | ||
1326 | #define FF_BUG_TRUNCATED 16384 | ||
1327 | //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. | ||
1328 | |||
1329 | /** | ||
1330 | * luma single coefficient elimination threshold | ||
1331 | * - encoding: Set by user. | ||
1332 | * - decoding: unused | ||
1333 | */ | ||
1334 | int luma_elim_threshold; | ||
1335 | |||
1336 | /** | ||
1337 | * chroma single coeff elimination threshold | ||
1338 | * - encoding: Set by user. | ||
1339 | * - decoding: unused | ||
1340 | */ | ||
1341 | int chroma_elim_threshold; | ||
1342 | |||
1343 | /** | ||
1344 | * strictly follow the standard (MPEG4, ...). | ||
1345 | * - encoding: Set by user. | ||
1346 | * - decoding: Set by user. | ||
1347 | * Setting this to STRICT or higher means the encoder and decoder will | ||
1348 | * generally do stupid things. While setting it to inofficial or lower | ||
1349 | * will mean the encoder might use things that are not supported by all | ||
1350 | * spec compliant decoders. Decoders make no difference between normal, | ||
1351 | * inofficial and experimental, that is they always try to decode things | ||
1352 | * when they can unless they are explicitly asked to behave stupid | ||
1353 | * (=strictly conform to the specs) | ||
1354 | */ | ||
1355 | int strict_std_compliance; | ||
1356 | #define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to a older more strict version of the spec or reference software. | ||
1357 | #define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. | ||
1358 | #define FF_COMPLIANCE_NORMAL 0 | ||
1359 | #define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions. | ||
1360 | #define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. | ||
1361 | |||
1362 | /** | ||
1363 | * qscale offset between IP and B-frames | ||
1364 | * - encoding: Set by user. | ||
1365 | * - decoding: unused | ||
1366 | */ | ||
1367 | float b_quant_offset; | ||
1368 | |||
1369 | /** | ||
1370 | * Error recognization; higher values will detect more errors but may | ||
1371 | * misdetect some more or less valid parts as errors. | ||
1372 | * - encoding: unused | ||
1373 | * - decoding: Set by user. | ||
1374 | */ | ||
1375 | int error_recognition; | ||
1376 | #define FF_ER_CAREFUL 1 | ||
1377 | #define FF_ER_COMPLIANT 2 | ||
1378 | #define FF_ER_AGGRESSIVE 3 | ||
1379 | #define FF_ER_VERY_AGGRESSIVE 4 | ||
1380 | |||
1381 | /** | ||
1382 | * Called at the beginning of each frame to get a buffer for it. | ||
1383 | * If pic.reference is set then the frame will be read later by libavcodec. | ||
1384 | * avcodec_align_dimensions2() should be used to find the required width and | ||
1385 | * height, as they normally need to be rounded up to the next multiple of 16. | ||
1386 | * if CODEC_CAP_DR1 is not set then get_buffer() must call | ||
1387 | * avcodec_default_get_buffer() instead of providing buffers allocated by | ||
1388 | * some other means. | ||
1389 | * - encoding: unused | ||
1390 | * - decoding: Set by libavcodec., user can override. | ||
1391 | */ | ||
1392 | int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); | ||
1393 | |||
1394 | /** | ||
1395 | * Called to release buffers which were allocated with get_buffer. | ||
1396 | * A released buffer can be reused in get_buffer(). | ||
1397 | * pic.data[*] must be set to NULL. | ||
1398 | * - encoding: unused | ||
1399 | * - decoding: Set by libavcodec., user can override. | ||
1400 | */ | ||
1401 | void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); | ||
1402 | |||
1403 | /** | ||
1404 | * Size of the frame reordering buffer in the decoder. | ||
1405 | * For MPEG-2 it is 1 IPB or 0 low delay IP. | ||
1406 | * - encoding: Set by libavcodec. | ||
1407 | * - decoding: Set by libavcodec. | ||
1408 | */ | ||
1409 | int has_b_frames; | ||
1410 | |||
1411 | /** | ||
1412 | * number of bytes per packet if constant and known or 0 | ||
1413 | * Used by some WAV based audio codecs. | ||
1414 | */ | ||
1415 | int block_align; | ||
1416 | |||
1417 | int parse_only; /* - decoding only: If true, only parsing is done | ||
1418 | (function avcodec_parse_frame()). The frame | ||
1419 | data is returned. Only MPEG codecs support this now. */ | ||
1420 | |||
1421 | /** | ||
1422 | * 0-> h263 quant 1-> mpeg quant | ||
1423 | * - encoding: Set by user. | ||
1424 | * - decoding: unused | ||
1425 | */ | ||
1426 | int mpeg_quant; | ||
1427 | |||
1428 | /** | ||
1429 | * pass1 encoding statistics output buffer | ||
1430 | * - encoding: Set by libavcodec. | ||
1431 | * - decoding: unused | ||
1432 | */ | ||
1433 | char *stats_out; | ||
1434 | |||
1435 | /** | ||
1436 | * pass2 encoding statistics input buffer | ||
1437 | * Concatenated stuff from stats_out of pass1 should be placed here. | ||
1438 | * - encoding: Allocated/set/freed by user. | ||
1439 | * - decoding: unused | ||
1440 | */ | ||
1441 | char *stats_in; | ||
1442 | |||
1443 | /** | ||
1444 | * ratecontrol qmin qmax limiting method | ||
1445 | * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. | ||
1446 | * - encoding: Set by user. | ||
1447 | * - decoding: unused | ||
1448 | */ | ||
1449 | float rc_qsquish; | ||
1450 | |||
1451 | float rc_qmod_amp; | ||
1452 | int rc_qmod_freq; | ||
1453 | |||
1454 | /** | ||
1455 | * ratecontrol override, see RcOverride | ||
1456 | * - encoding: Allocated/set/freed by user. | ||
1457 | * - decoding: unused | ||
1458 | */ | ||
1459 | RcOverride *rc_override; | ||
1460 | int rc_override_count; | ||
1461 | |||
1462 | /** | ||
1463 | * rate control equation | ||
1464 | * - encoding: Set by user | ||
1465 | * - decoding: unused | ||
1466 | */ | ||
1467 | const char *rc_eq; | ||
1468 | |||
1469 | /** | ||
1470 | * maximum bitrate | ||
1471 | * - encoding: Set by user. | ||
1472 | * - decoding: unused | ||
1473 | */ | ||
1474 | int rc_max_rate; | ||
1475 | |||
1476 | /** | ||
1477 | * minimum bitrate | ||
1478 | * - encoding: Set by user. | ||
1479 | * - decoding: unused | ||
1480 | */ | ||
1481 | int rc_min_rate; | ||
1482 | |||
1483 | /** | ||
1484 | * decoder bitstream buffer size | ||
1485 | * - encoding: Set by user. | ||
1486 | * - decoding: unused | ||
1487 | */ | ||
1488 | int rc_buffer_size; | ||
1489 | float rc_buffer_aggressivity; | ||
1490 | |||
1491 | /** | ||
1492 | * qscale factor between P and I-frames | ||
1493 | * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). | ||
1494 | * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). | ||
1495 | * - encoding: Set by user. | ||
1496 | * - decoding: unused | ||
1497 | */ | ||
1498 | float i_quant_factor; | ||
1499 | |||
1500 | /** | ||
1501 | * qscale offset between P and I-frames | ||
1502 | * - encoding: Set by user. | ||
1503 | * - decoding: unused | ||
1504 | */ | ||
1505 | float i_quant_offset; | ||
1506 | |||
1507 | /** | ||
1508 | * initial complexity for pass1 ratecontrol | ||
1509 | * - encoding: Set by user. | ||
1510 | * - decoding: unused | ||
1511 | */ | ||
1512 | float rc_initial_cplx; | ||
1513 | |||
1514 | /** | ||
1515 | * DCT algorithm, see FF_DCT_* below | ||
1516 | * - encoding: Set by user. | ||
1517 | * - decoding: unused | ||
1518 | */ | ||
1519 | int dct_algo; | ||
1520 | #define FF_DCT_AUTO 0 | ||
1521 | #define FF_DCT_FASTINT 1 | ||
1522 | #define FF_DCT_INT 2 | ||
1523 | #define FF_DCT_MMX 3 | ||
1524 | #define FF_DCT_MLIB 4 | ||
1525 | #define FF_DCT_ALTIVEC 5 | ||
1526 | #define FF_DCT_FAAN 6 | ||
1527 | |||
1528 | /** | ||
1529 | * luminance masking (0-> disabled) | ||
1530 | * - encoding: Set by user. | ||
1531 | * - decoding: unused | ||
1532 | */ | ||
1533 | float lumi_masking; | ||
1534 | |||
1535 | /** | ||
1536 | * temporary complexity masking (0-> disabled) | ||
1537 | * - encoding: Set by user. | ||
1538 | * - decoding: unused | ||
1539 | */ | ||
1540 | float temporal_cplx_masking; | ||
1541 | |||
1542 | /** | ||
1543 | * spatial complexity masking (0-> disabled) | ||
1544 | * - encoding: Set by user. | ||
1545 | * - decoding: unused | ||
1546 | */ | ||
1547 | float spatial_cplx_masking; | ||
1548 | |||
1549 | /** | ||
1550 | * p block masking (0-> disabled) | ||
1551 | * - encoding: Set by user. | ||
1552 | * - decoding: unused | ||
1553 | */ | ||
1554 | float p_masking; | ||
1555 | |||
1556 | /** | ||
1557 | * darkness masking (0-> disabled) | ||
1558 | * - encoding: Set by user. | ||
1559 | * - decoding: unused | ||
1560 | */ | ||
1561 | float dark_masking; | ||
1562 | |||
1563 | /** | ||
1564 | * IDCT algorithm, see FF_IDCT_* below. | ||
1565 | * - encoding: Set by user. | ||
1566 | * - decoding: Set by user. | ||
1567 | */ | ||
1568 | int idct_algo; | ||
1569 | #define FF_IDCT_AUTO 0 | ||
1570 | #define FF_IDCT_INT 1 | ||
1571 | #define FF_IDCT_SIMPLE 2 | ||
1572 | #define FF_IDCT_SIMPLEMMX 3 | ||
1573 | #define FF_IDCT_LIBMPEG2MMX 4 | ||
1574 | #define FF_IDCT_PS2 5 | ||
1575 | #define FF_IDCT_MLIB 6 | ||
1576 | #define FF_IDCT_ARM 7 | ||
1577 | #define FF_IDCT_ALTIVEC 8 | ||
1578 | #define FF_IDCT_SH4 9 | ||
1579 | #define FF_IDCT_SIMPLEARM 10 | ||
1580 | #define FF_IDCT_H264 11 | ||
1581 | #define FF_IDCT_VP3 12 | ||
1582 | #define FF_IDCT_IPP 13 | ||
1583 | #define FF_IDCT_XVIDMMX 14 | ||
1584 | #define FF_IDCT_CAVS 15 | ||
1585 | #define FF_IDCT_SIMPLEARMV5TE 16 | ||
1586 | #define FF_IDCT_SIMPLEARMV6 17 | ||
1587 | #define FF_IDCT_SIMPLEVIS 18 | ||
1588 | #define FF_IDCT_WMV2 19 | ||
1589 | #define FF_IDCT_FAAN 20 | ||
1590 | #define FF_IDCT_EA 21 | ||
1591 | #define FF_IDCT_SIMPLENEON 22 | ||
1592 | #define FF_IDCT_SIMPLEALPHA 23 | ||
1593 | #define FF_IDCT_BINK 24 | ||
1594 | |||
1595 | /** | ||
1596 | * slice count | ||
1597 | * - encoding: Set by libavcodec. | ||
1598 | * - decoding: Set by user (or 0). | ||
1599 | */ | ||
1600 | int slice_count; | ||
1601 | /** | ||
1602 | * slice offsets in the frame in bytes | ||
1603 | * - encoding: Set/allocated by libavcodec. | ||
1604 | * - decoding: Set/allocated by user (or NULL). | ||
1605 | */ | ||
1606 | int *slice_offset; | ||
1607 | |||
1608 | /** | ||
1609 | * error concealment flags | ||
1610 | * - encoding: unused | ||
1611 | * - decoding: Set by user. | ||
1612 | */ | ||
1613 | int error_concealment; | ||
1614 | #define FF_EC_GUESS_MVS 1 | ||
1615 | #define FF_EC_DEBLOCK 2 | ||
1616 | |||
1617 | /** | ||
1618 | * dsp_mask could be add used to disable unwanted CPU features | ||
1619 | * CPU features (i.e. MMX, SSE. ...) | ||
1620 | * | ||
1621 | * With the FORCE flag you may instead enable given CPU features. | ||
1622 | * (Dangerous: Usable in case of misdetection, improper usage however will | ||
1623 | * result into program crash.) | ||
1624 | */ | ||
1625 | unsigned dsp_mask; | ||
1626 | #define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ | ||
1627 | /* lower 16 bits - CPU features */ | ||
1628 | #define FF_MM_MMX 0x0001 ///< standard MMX | ||
1629 | #define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW | ||
1630 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
1631 | #define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext | ||
1632 | #endif | ||
1633 | #define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext | ||
1634 | #define FF_MM_SSE 0x0008 ///< SSE functions | ||
1635 | #define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions | ||
1636 | #define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt | ||
1637 | #define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions | ||
1638 | #define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions | ||
1639 | #define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions | ||
1640 | #define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions | ||
1641 | #define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT | ||
1642 | #define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec | ||
1643 | |||
1644 | /** | ||
1645 | * bits per sample/pixel from the demuxer (needed for huffyuv). | ||
1646 | * - encoding: Set by libavcodec. | ||
1647 | * - decoding: Set by user. | ||
1648 | */ | ||
1649 | int bits_per_coded_sample; | ||
1650 | |||
1651 | /** | ||
1652 | * prediction method (needed for huffyuv) | ||
1653 | * - encoding: Set by user. | ||
1654 | * - decoding: unused | ||
1655 | */ | ||
1656 | int prediction_method; | ||
1657 | #define FF_PRED_LEFT 0 | ||
1658 | #define FF_PRED_PLANE 1 | ||
1659 | #define FF_PRED_MEDIAN 2 | ||
1660 | |||
1661 | /** | ||
1662 | * sample aspect ratio (0 if unknown) | ||
1663 | * That is the width of a pixel divided by the height of the pixel. | ||
1664 | * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. | ||
1665 | * - encoding: Set by user. | ||
1666 | * - decoding: Set by libavcodec. | ||
1667 | */ | ||
1668 | //AVRational sample_aspect_ratio; | ||
1669 | |||
1670 | /** | ||
1671 | * the picture in the bitstream | ||
1672 | * - encoding: Set by libavcodec. | ||
1673 | * - decoding: Set by libavcodec. | ||
1674 | */ | ||
1675 | AVFrame *coded_frame; | ||
1676 | |||
1677 | /** | ||
1678 | * debug | ||
1679 | * - encoding: Set by user. | ||
1680 | * - decoding: Set by user. | ||
1681 | */ | ||
1682 | int debug; | ||
1683 | #define FF_DEBUG_PICT_INFO 1 | ||
1684 | #define FF_DEBUG_RC 2 | ||
1685 | #define FF_DEBUG_BITSTREAM 4 | ||
1686 | #define FF_DEBUG_MB_TYPE 8 | ||
1687 | #define FF_DEBUG_QP 16 | ||
1688 | #define FF_DEBUG_MV 32 | ||
1689 | #define FF_DEBUG_DCT_COEFF 0x00000040 | ||
1690 | #define FF_DEBUG_SKIP 0x00000080 | ||
1691 | #define FF_DEBUG_STARTCODE 0x00000100 | ||
1692 | #define FF_DEBUG_PTS 0x00000200 | ||
1693 | #define FF_DEBUG_ER 0x00000400 | ||
1694 | #define FF_DEBUG_MMCO 0x00000800 | ||
1695 | #define FF_DEBUG_BUGS 0x00001000 | ||
1696 | #define FF_DEBUG_VIS_QP 0x00002000 | ||
1697 | #define FF_DEBUG_VIS_MB_TYPE 0x00004000 | ||
1698 | #define FF_DEBUG_BUFFERS 0x00008000 | ||
1699 | |||
1700 | /** | ||
1701 | * debug | ||
1702 | * - encoding: Set by user. | ||
1703 | * - decoding: Set by user. | ||
1704 | */ | ||
1705 | int debug_mv; | ||
1706 | #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames | ||
1707 | #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames | ||
1708 | #define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames | ||
1709 | |||
1710 | /** | ||
1711 | * error | ||
1712 | * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. | ||
1713 | * - decoding: unused | ||
1714 | */ | ||
1715 | uint64_t error[4]; | ||
1716 | |||
1717 | /** | ||
1718 | * minimum MB quantizer | ||
1719 | * - encoding: unused | ||
1720 | * - decoding: unused | ||
1721 | */ | ||
1722 | int mb_qmin; | ||
1723 | |||
1724 | /** | ||
1725 | * maximum MB quantizer | ||
1726 | * - encoding: unused | ||
1727 | * - decoding: unused | ||
1728 | */ | ||
1729 | int mb_qmax; | ||
1730 | |||
1731 | /** | ||
1732 | * motion estimation comparison function | ||
1733 | * - encoding: Set by user. | ||
1734 | * - decoding: unused | ||
1735 | */ | ||
1736 | int me_cmp; | ||
1737 | /** | ||
1738 | * subpixel motion estimation comparison function | ||
1739 | * - encoding: Set by user. | ||
1740 | * - decoding: unused | ||
1741 | */ | ||
1742 | int me_sub_cmp; | ||
1743 | /** | ||
1744 | * macroblock comparison function (not supported yet) | ||
1745 | * - encoding: Set by user. | ||
1746 | * - decoding: unused | ||
1747 | */ | ||
1748 | int mb_cmp; | ||
1749 | /** | ||
1750 | * interlaced DCT comparison function | ||
1751 | * - encoding: Set by user. | ||
1752 | * - decoding: unused | ||
1753 | */ | ||
1754 | int ildct_cmp; | ||
1755 | #define FF_CMP_SAD 0 | ||
1756 | #define FF_CMP_SSE 1 | ||
1757 | #define FF_CMP_SATD 2 | ||
1758 | #define FF_CMP_DCT 3 | ||
1759 | #define FF_CMP_PSNR 4 | ||
1760 | #define FF_CMP_BIT 5 | ||
1761 | #define FF_CMP_RD 6 | ||
1762 | #define FF_CMP_ZERO 7 | ||
1763 | #define FF_CMP_VSAD 8 | ||
1764 | #define FF_CMP_VSSE 9 | ||
1765 | #define FF_CMP_NSSE 10 | ||
1766 | #define FF_CMP_W53 11 | ||
1767 | #define FF_CMP_W97 12 | ||
1768 | #define FF_CMP_DCTMAX 13 | ||
1769 | #define FF_CMP_DCT264 14 | ||
1770 | #define FF_CMP_CHROMA 256 | ||
1771 | |||
1772 | /** | ||
1773 | * ME diamond size & shape | ||
1774 | * - encoding: Set by user. | ||
1775 | * - decoding: unused | ||
1776 | */ | ||
1777 | int dia_size; | ||
1778 | |||
1779 | /** | ||
1780 | * amount of previous MV predictors (2a+1 x 2a+1 square) | ||
1781 | * - encoding: Set by user. | ||
1782 | * - decoding: unused | ||
1783 | */ | ||
1784 | int last_predictor_count; | ||
1785 | |||
1786 | /** | ||
1787 | * prepass for motion estimation | ||
1788 | * - encoding: Set by user. | ||
1789 | * - decoding: unused | ||
1790 | */ | ||
1791 | int pre_me; | ||
1792 | |||
1793 | /** | ||
1794 | * motion estimation prepass comparison function | ||
1795 | * - encoding: Set by user. | ||
1796 | * - decoding: unused | ||
1797 | */ | ||
1798 | int me_pre_cmp; | ||
1799 | |||
1800 | /** | ||
1801 | * ME prepass diamond size & shape | ||
1802 | * - encoding: Set by user. | ||
1803 | * - decoding: unused | ||
1804 | */ | ||
1805 | int pre_dia_size; | ||
1806 | |||
1807 | /** | ||
1808 | * subpel ME quality | ||
1809 | * - encoding: Set by user. | ||
1810 | * - decoding: unused | ||
1811 | */ | ||
1812 | int me_subpel_quality; | ||
1813 | |||
1814 | /** | ||
1815 | * callback to negotiate the pixelFormat | ||
1816 | * @param fmt is the list of formats which are supported by the codec, | ||
1817 | * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. | ||
1818 | * The first is always the native one. | ||
1819 | * @return the chosen format | ||
1820 | * - encoding: unused | ||
1821 | * - decoding: Set by user, if not set the native format will be chosen. | ||
1822 | */ | ||
1823 | enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt); | ||
1824 | |||
1825 | /** | ||
1826 | * DTG active format information (additional aspect ratio | ||
1827 | * information only used in DVB MPEG-2 transport streams) | ||
1828 | * 0 if not set. | ||
1829 | * | ||
1830 | * - encoding: unused | ||
1831 | * - decoding: Set by decoder. | ||
1832 | */ | ||
1833 | int dtg_active_format; | ||
1834 | #define FF_DTG_AFD_SAME 8 | ||
1835 | #define FF_DTG_AFD_4_3 9 | ||
1836 | #define FF_DTG_AFD_16_9 10 | ||
1837 | #define FF_DTG_AFD_14_9 11 | ||
1838 | #define FF_DTG_AFD_4_3_SP_14_9 13 | ||
1839 | #define FF_DTG_AFD_16_9_SP_14_9 14 | ||
1840 | #define FF_DTG_AFD_SP_4_3 15 | ||
1841 | |||
1842 | /** | ||
1843 | * maximum motion estimation search range in subpel units | ||
1844 | * If 0 then no limit. | ||
1845 | * | ||
1846 | * - encoding: Set by user. | ||
1847 | * - decoding: unused | ||
1848 | */ | ||
1849 | int me_range; | ||
1850 | |||
1851 | /** | ||
1852 | * intra quantizer bias | ||
1853 | * - encoding: Set by user. | ||
1854 | * - decoding: unused | ||
1855 | */ | ||
1856 | int intra_quant_bias; | ||
1857 | #define FF_DEFAULT_QUANT_BIAS 999999 | ||
1858 | |||
1859 | /** | ||
1860 | * inter quantizer bias | ||
1861 | * - encoding: Set by user. | ||
1862 | * - decoding: unused | ||
1863 | */ | ||
1864 | int inter_quant_bias; | ||
1865 | |||
1866 | /** | ||
1867 | * color table ID | ||
1868 | * - encoding: unused | ||
1869 | * - decoding: Which clrtable should be used for 8bit RGB images. | ||
1870 | * Tables have to be stored somewhere. FIXME | ||
1871 | */ | ||
1872 | int color_table_id; | ||
1873 | |||
1874 | /** | ||
1875 | * internal_buffer count | ||
1876 | * Don't touch, used by libavcodec default_get_buffer(). | ||
1877 | */ | ||
1878 | int internal_buffer_count; | ||
1879 | |||
1880 | /** | ||
1881 | * internal_buffers | ||
1882 | * Don't touch, used by libavcodec default_get_buffer(). | ||
1883 | */ | ||
1884 | void *internal_buffer; | ||
1885 | |||
1886 | #define FF_LAMBDA_SHIFT 7 | ||
1887 | #define FF_LAMBDA_SCALE (1<<FF_LAMBDA_SHIFT) | ||
1888 | #define FF_QP2LAMBDA 118 ///< factor to convert from H.263 QP to lambda | ||
1889 | #define FF_LAMBDA_MAX (256*128-1) | ||
1890 | |||
1891 | #define FF_QUALITY_SCALE FF_LAMBDA_SCALE //FIXME maybe remove | ||
1892 | /** | ||
1893 | * Global quality for codecs which cannot change it per frame. | ||
1894 | * This should be proportional to MPEG-1/2/4 qscale. | ||
1895 | * - encoding: Set by user. | ||
1896 | * - decoding: unused | ||
1897 | */ | ||
1898 | int global_quality; | ||
1899 | |||
1900 | #define FF_CODER_TYPE_VLC 0 | ||
1901 | #define FF_CODER_TYPE_AC 1 | ||
1902 | #define FF_CODER_TYPE_RAW 2 | ||
1903 | #define FF_CODER_TYPE_RLE 3 | ||
1904 | #define FF_CODER_TYPE_DEFLATE 4 | ||
1905 | /** | ||
1906 | * coder type | ||
1907 | * - encoding: Set by user. | ||
1908 | * - decoding: unused | ||
1909 | */ | ||
1910 | int coder_type; | ||
1911 | |||
1912 | /** | ||
1913 | * context model | ||
1914 | * - encoding: Set by user. | ||
1915 | * - decoding: unused | ||
1916 | */ | ||
1917 | int context_model; | ||
1918 | #if 0 | ||
1919 | /** | ||
1920 | * | ||
1921 | * - encoding: unused | ||
1922 | * - decoding: Set by user. | ||
1923 | */ | ||
1924 | uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size); | ||
1925 | #endif | ||
1926 | |||
1927 | /** | ||
1928 | * slice flags | ||
1929 | * - encoding: unused | ||
1930 | * - decoding: Set by user. | ||
1931 | */ | ||
1932 | int slice_flags; | ||
1933 | #define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display | ||
1934 | #define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics) | ||
1935 | #define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) | ||
1936 | |||
1937 | /** | ||
1938 | * XVideo Motion Acceleration | ||
1939 | * - encoding: forbidden | ||
1940 | * - decoding: set by decoder | ||
1941 | */ | ||
1942 | int xvmc_acceleration; | ||
1943 | |||
1944 | /** | ||
1945 | * macroblock decision mode | ||
1946 | * - encoding: Set by user. | ||
1947 | * - decoding: unused | ||
1948 | */ | ||
1949 | int mb_decision; | ||
1950 | #define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp | ||
1951 | #define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits | ||
1952 | #define FF_MB_DECISION_RD 2 ///< rate distortion | ||
1953 | |||
1954 | /** | ||
1955 | * custom intra quantization matrix | ||
1956 | * - encoding: Set by user, can be NULL. | ||
1957 | * - decoding: Set by libavcodec. | ||
1958 | */ | ||
1959 | uint16_t *intra_matrix; | ||
1960 | |||
1961 | /** | ||
1962 | * custom inter quantization matrix | ||
1963 | * - encoding: Set by user, can be NULL. | ||
1964 | * - decoding: Set by libavcodec. | ||
1965 | */ | ||
1966 | uint16_t *inter_matrix; | ||
1967 | |||
1968 | /** | ||
1969 | * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). | ||
1970 | * This is used to work around some encoder bugs. | ||
1971 | * - encoding: unused | ||
1972 | * - decoding: Set by user, will be converted to uppercase by libavcodec during init. | ||
1973 | */ | ||
1974 | unsigned int stream_codec_tag; | ||
1975 | |||
1976 | /** | ||
1977 | * scene change detection threshold | ||
1978 | * 0 is default, larger means fewer detected scene changes. | ||
1979 | * - encoding: Set by user. | ||
1980 | * - decoding: unused | ||
1981 | */ | ||
1982 | int scenechange_threshold; | ||
1983 | |||
1984 | /** | ||
1985 | * minimum Lagrange multipler | ||
1986 | * - encoding: Set by user. | ||
1987 | * - decoding: unused | ||
1988 | */ | ||
1989 | int lmin; | ||
1990 | |||
1991 | /** | ||
1992 | * maximum Lagrange multipler | ||
1993 | * - encoding: Set by user. | ||
1994 | * - decoding: unused | ||
1995 | */ | ||
1996 | int lmax; | ||
1997 | |||
1998 | /** | ||
1999 | * palette control structure | ||
2000 | * - encoding: ??? (no palette-enabled encoder yet) | ||
2001 | * - decoding: Set by user. | ||
2002 | */ | ||
2003 | struct AVPaletteControl *palctrl; | ||
2004 | |||
2005 | /** | ||
2006 | * noise reduction strength | ||
2007 | * - encoding: Set by user. | ||
2008 | * - decoding: unused | ||
2009 | */ | ||
2010 | int noise_reduction; | ||
2011 | |||
2012 | /** | ||
2013 | * Called at the beginning of a frame to get cr buffer for it. | ||
2014 | * Buffer type (size, hints) must be the same. libavcodec won't check it. | ||
2015 | * libavcodec will pass previous buffer in pic, function should return | ||
2016 | * same buffer or new buffer with old frame "painted" into it. | ||
2017 | * If pic.data[0] == NULL must behave like get_buffer(). | ||
2018 | * if CODEC_CAP_DR1 is not set then reget_buffer() must call | ||
2019 | * avcodec_default_reget_buffer() instead of providing buffers allocated by | ||
2020 | * some other means. | ||
2021 | * - encoding: unused | ||
2022 | * - decoding: Set by libavcodec., user can override | ||
2023 | */ | ||
2024 | int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); | ||
2025 | |||
2026 | /** | ||
2027 | * Number of bits which should be loaded into the rc buffer before decoding starts. | ||
2028 | * - encoding: Set by user. | ||
2029 | * - decoding: unused | ||
2030 | */ | ||
2031 | int rc_initial_buffer_occupancy; | ||
2032 | |||
2033 | /** | ||
2034 | * | ||
2035 | * - encoding: Set by user. | ||
2036 | * - decoding: unused | ||
2037 | */ | ||
2038 | int inter_threshold; | ||
2039 | |||
2040 | /** | ||
2041 | * CODEC_FLAG2_* | ||
2042 | * - encoding: Set by user. | ||
2043 | * - decoding: Set by user. | ||
2044 | */ | ||
2045 | int flags2; | ||
2046 | |||
2047 | /** | ||
2048 | * Simulates errors in the bitstream to test error concealment. | ||
2049 | * - encoding: Set by user. | ||
2050 | * - decoding: unused | ||
2051 | */ | ||
2052 | int error_rate; | ||
2053 | |||
2054 | /** | ||
2055 | * MP3 antialias algorithm, see FF_AA_* below. | ||
2056 | * - encoding: unused | ||
2057 | * - decoding: Set by user. | ||
2058 | */ | ||
2059 | int antialias_algo; | ||
2060 | #define FF_AA_AUTO 0 | ||
2061 | #define FF_AA_FASTINT 1 //not implemented yet | ||
2062 | #define FF_AA_INT 2 | ||
2063 | #define FF_AA_FLOAT 3 | ||
2064 | /** | ||
2065 | * quantizer noise shaping | ||
2066 | * - encoding: Set by user. | ||
2067 | * - decoding: unused | ||
2068 | */ | ||
2069 | int quantizer_noise_shaping; | ||
2070 | |||
2071 | /** | ||
2072 | * thread count | ||
2073 | * is used to decide how many independent tasks should be passed to execute() | ||
2074 | * - encoding: Set by user. | ||
2075 | * - decoding: Set by user. | ||
2076 | */ | ||
2077 | int thread_count; | ||
2078 | |||
2079 | /** | ||
2080 | * The codec may call this to execute several independent things. | ||
2081 | * It will return only after finishing all tasks. | ||
2082 | * The user may replace this with some multithreaded implementation, | ||
2083 | * the default implementation will execute the parts serially. | ||
2084 | * @param count the number of things to execute | ||
2085 | * - encoding: Set by libavcodec, user can override. | ||
2086 | * - decoding: Set by libavcodec, user can override. | ||
2087 | */ | ||
2088 | int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); | ||
2089 | |||
2090 | /** | ||
2091 | * thread opaque | ||
2092 | * Can be used by execute() to store some per AVCodecContext stuff. | ||
2093 | * - encoding: set by execute() | ||
2094 | * - decoding: set by execute() | ||
2095 | */ | ||
2096 | void *thread_opaque; | ||
2097 | |||
2098 | /** | ||
2099 | * Motion estimation threshold below which no motion estimation is | ||
2100 | * performed, but instead the user specified motion vectors are used. | ||
2101 | * | ||
2102 | * - encoding: Set by user. | ||
2103 | * - decoding: unused | ||
2104 | */ | ||
2105 | int me_threshold; | ||
2106 | |||
2107 | /** | ||
2108 | * Macroblock threshold below which the user specified macroblock types will be used. | ||
2109 | * - encoding: Set by user. | ||
2110 | * - decoding: unused | ||
2111 | */ | ||
2112 | int mb_threshold; | ||
2113 | |||
2114 | /** | ||
2115 | * precision of the intra DC coefficient - 8 | ||
2116 | * - encoding: Set by user. | ||
2117 | * - decoding: unused | ||
2118 | */ | ||
2119 | int intra_dc_precision; | ||
2120 | |||
2121 | /** | ||
2122 | * noise vs. sse weight for the nsse comparsion function | ||
2123 | * - encoding: Set by user. | ||
2124 | * - decoding: unused | ||
2125 | */ | ||
2126 | int nsse_weight; | ||
2127 | |||
2128 | /** | ||
2129 | * Number of macroblock rows at the top which are skipped. | ||
2130 | * - encoding: unused | ||
2131 | * - decoding: Set by user. | ||
2132 | */ | ||
2133 | int skip_top; | ||
2134 | |||
2135 | /** | ||
2136 | * Number of macroblock rows at the bottom which are skipped. | ||
2137 | * - encoding: unused | ||
2138 | * - decoding: Set by user. | ||
2139 | */ | ||
2140 | int skip_bottom; | ||
2141 | |||
2142 | /** | ||
2143 | * profile | ||
2144 | * - encoding: Set by user. | ||
2145 | * - decoding: Set by libavcodec. | ||
2146 | */ | ||
2147 | int profile; | ||
2148 | #define FF_PROFILE_UNKNOWN -99 | ||
2149 | |||
2150 | #define FF_PROFILE_AAC_MAIN 0 | ||
2151 | #define FF_PROFILE_AAC_LOW 1 | ||
2152 | #define FF_PROFILE_AAC_SSR 2 | ||
2153 | #define FF_PROFILE_AAC_LTP 3 | ||
2154 | |||
2155 | #define FF_PROFILE_H264_BASELINE 66 | ||
2156 | #define FF_PROFILE_H264_MAIN 77 | ||
2157 | #define FF_PROFILE_H264_EXTENDED 88 | ||
2158 | #define FF_PROFILE_H264_HIGH 100 | ||
2159 | #define FF_PROFILE_H264_HIGH_10 110 | ||
2160 | #define FF_PROFILE_H264_HIGH_422 122 | ||
2161 | #define FF_PROFILE_H264_HIGH_444 244 | ||
2162 | #define FF_PROFILE_H264_CAVLC_444 44 | ||
2163 | |||
2164 | /** | ||
2165 | * level | ||
2166 | * - encoding: Set by user. | ||
2167 | * - decoding: Set by libavcodec. | ||
2168 | */ | ||
2169 | int level; | ||
2170 | #define FF_LEVEL_UNKNOWN -99 | ||
2171 | |||
2172 | /** | ||
2173 | * low resolution decoding, 1-> 1/2 size, 2->1/4 size | ||
2174 | * - encoding: unused | ||
2175 | * - decoding: Set by user. | ||
2176 | */ | ||
2177 | int lowres; | ||
2178 | |||
2179 | /** | ||
2180 | * Bitstream width / height, may be different from width/height if lowres | ||
2181 | * or other things are used. | ||
2182 | * - encoding: unused | ||
2183 | * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. | ||
2184 | */ | ||
2185 | int coded_width, coded_height; | ||
2186 | |||
2187 | /** | ||
2188 | * frame skip threshold | ||
2189 | * - encoding: Set by user. | ||
2190 | * - decoding: unused | ||
2191 | */ | ||
2192 | int frame_skip_threshold; | ||
2193 | |||
2194 | /** | ||
2195 | * frame skip factor | ||
2196 | * - encoding: Set by user. | ||
2197 | * - decoding: unused | ||
2198 | */ | ||
2199 | int frame_skip_factor; | ||
2200 | |||
2201 | /** | ||
2202 | * frame skip exponent | ||
2203 | * - encoding: Set by user. | ||
2204 | * - decoding: unused | ||
2205 | */ | ||
2206 | int frame_skip_exp; | ||
2207 | |||
2208 | /** | ||
2209 | * frame skip comparison function | ||
2210 | * - encoding: Set by user. | ||
2211 | * - decoding: unused | ||
2212 | */ | ||
2213 | int frame_skip_cmp; | ||
2214 | |||
2215 | /** | ||
2216 | * Border processing masking, raises the quantizer for mbs on the borders | ||
2217 | * of the picture. | ||
2218 | * - encoding: Set by user. | ||
2219 | * - decoding: unused | ||
2220 | */ | ||
2221 | float border_masking; | ||
2222 | |||
2223 | /** | ||
2224 | * minimum MB lagrange multipler | ||
2225 | * - encoding: Set by user. | ||
2226 | * - decoding: unused | ||
2227 | */ | ||
2228 | int mb_lmin; | ||
2229 | |||
2230 | /** | ||
2231 | * maximum MB lagrange multipler | ||
2232 | * - encoding: Set by user. | ||
2233 | * - decoding: unused | ||
2234 | */ | ||
2235 | int mb_lmax; | ||
2236 | |||
2237 | /** | ||
2238 | * | ||
2239 | * - encoding: Set by user. | ||
2240 | * - decoding: unused | ||
2241 | */ | ||
2242 | int me_penalty_compensation; | ||
2243 | |||
2244 | /** | ||
2245 | * | ||
2246 | * - encoding: unused | ||
2247 | * - decoding: Set by user. | ||
2248 | */ | ||
2249 | enum AVDiscard skip_loop_filter; | ||
2250 | |||
2251 | /** | ||
2252 | * | ||
2253 | * - encoding: unused | ||
2254 | * - decoding: Set by user. | ||
2255 | */ | ||
2256 | enum AVDiscard skip_idct; | ||
2257 | |||
2258 | /** | ||
2259 | * | ||
2260 | * - encoding: unused | ||
2261 | * - decoding: Set by user. | ||
2262 | */ | ||
2263 | enum AVDiscard skip_frame; | ||
2264 | |||
2265 | /** | ||
2266 | * | ||
2267 | * - encoding: Set by user. | ||
2268 | * - decoding: unused | ||
2269 | */ | ||
2270 | int bidir_refine; | ||
2271 | |||
2272 | /** | ||
2273 | * | ||
2274 | * - encoding: Set by user. | ||
2275 | * - decoding: unused | ||
2276 | */ | ||
2277 | int brd_scale; | ||
2278 | |||
2279 | /** | ||
2280 | * constant rate factor - quality-based VBR - values ~correspond to qps | ||
2281 | * - encoding: Set by user. | ||
2282 | * - decoding: unused | ||
2283 | */ | ||
2284 | float crf; | ||
2285 | |||
2286 | /** | ||
2287 | * constant quantization parameter rate control method | ||
2288 | * - encoding: Set by user. | ||
2289 | * - decoding: unused | ||
2290 | */ | ||
2291 | int cqp; | ||
2292 | |||
2293 | /** | ||
2294 | * minimum GOP size | ||
2295 | * - encoding: Set by user. | ||
2296 | * - decoding: unused | ||
2297 | */ | ||
2298 | int keyint_min; | ||
2299 | |||
2300 | /** | ||
2301 | * number of reference frames | ||
2302 | * - encoding: Set by user. | ||
2303 | * - decoding: Set by lavc. | ||
2304 | */ | ||
2305 | int refs; | ||
2306 | |||
2307 | /** | ||
2308 | * chroma qp offset from luma | ||
2309 | * - encoding: Set by user. | ||
2310 | * - decoding: unused | ||
2311 | */ | ||
2312 | int chromaoffset; | ||
2313 | |||
2314 | /** | ||
2315 | * Influences how often B-frames are used. | ||
2316 | * - encoding: Set by user. | ||
2317 | * - decoding: unused | ||
2318 | */ | ||
2319 | int bframebias; | ||
2320 | |||
2321 | /** | ||
2322 | * trellis RD quantization | ||
2323 | * - encoding: Set by user. | ||
2324 | * - decoding: unused | ||
2325 | */ | ||
2326 | int trellis; | ||
2327 | |||
2328 | /** | ||
2329 | * Reduce fluctuations in qp (before curve compression). | ||
2330 | * - encoding: Set by user. | ||
2331 | * - decoding: unused | ||
2332 | */ | ||
2333 | float complexityblur; | ||
2334 | |||
2335 | /** | ||
2336 | * in-loop deblocking filter alphac0 parameter | ||
2337 | * alpha is in the range -6...6 | ||
2338 | * - encoding: Set by user. | ||
2339 | * - decoding: unused | ||
2340 | */ | ||
2341 | int deblockalpha; | ||
2342 | |||
2343 | /** | ||
2344 | * in-loop deblocking filter beta parameter | ||
2345 | * beta is in the range -6...6 | ||
2346 | * - encoding: Set by user. | ||
2347 | * - decoding: unused | ||
2348 | */ | ||
2349 | int deblockbeta; | ||
2350 | |||
2351 | /** | ||
2352 | * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 | ||
2353 | * - encoding: Set by user. | ||
2354 | * - decoding: unused | ||
2355 | */ | ||
2356 | int partitions; | ||
2357 | #define X264_PART_I4X4 0x001 /* Analyze i4x4 */ | ||
2358 | #define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ | ||
2359 | #define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ | ||
2360 | #define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ | ||
2361 | #define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ | ||
2362 | |||
2363 | /** | ||
2364 | * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto) | ||
2365 | * - encoding: Set by user. | ||
2366 | * - decoding: unused | ||
2367 | */ | ||
2368 | int directpred; | ||
2369 | |||
2370 | /** | ||
2371 | * Audio cutoff bandwidth (0 means "automatic") | ||
2372 | * - encoding: Set by user. | ||
2373 | * - decoding: unused | ||
2374 | */ | ||
2375 | int cutoff; | ||
2376 | |||
2377 | /** | ||
2378 | * Multiplied by qscale for each frame and added to scene_change_score. | ||
2379 | * - encoding: Set by user. | ||
2380 | * - decoding: unused | ||
2381 | */ | ||
2382 | int scenechange_factor; | ||
2383 | |||
2384 | /** | ||
2385 | * | ||
2386 | * Note: Value depends upon the compare function used for fullpel ME. | ||
2387 | * - encoding: Set by user. | ||
2388 | * - decoding: unused | ||
2389 | */ | ||
2390 | int mv0_threshold; | ||
2391 | |||
2392 | /** | ||
2393 | * Adjusts sensitivity of b_frame_strategy 1. | ||
2394 | * - encoding: Set by user. | ||
2395 | * - decoding: unused | ||
2396 | */ | ||
2397 | int b_sensitivity; | ||
2398 | |||
2399 | /** | ||
2400 | * - encoding: Set by user. | ||
2401 | * - decoding: unused | ||
2402 | */ | ||
2403 | int compression_level; | ||
2404 | #define FF_COMPRESSION_DEFAULT -1 | ||
2405 | |||
2406 | /** | ||
2407 | * Sets whether to use LPC mode - used by FLAC encoder. | ||
2408 | * - encoding: Set by user. | ||
2409 | * - decoding: unused | ||
2410 | */ | ||
2411 | int use_lpc; | ||
2412 | |||
2413 | /** | ||
2414 | * LPC coefficient precision - used by FLAC encoder | ||
2415 | * - encoding: Set by user. | ||
2416 | * - decoding: unused | ||
2417 | */ | ||
2418 | int lpc_coeff_precision; | ||
2419 | |||
2420 | /** | ||
2421 | * - encoding: Set by user. | ||
2422 | * - decoding: unused | ||
2423 | */ | ||
2424 | int min_prediction_order; | ||
2425 | |||
2426 | /** | ||
2427 | * - encoding: Set by user. | ||
2428 | * - decoding: unused | ||
2429 | */ | ||
2430 | int max_prediction_order; | ||
2431 | |||
2432 | /** | ||
2433 | * search method for selecting prediction order | ||
2434 | * - encoding: Set by user. | ||
2435 | * - decoding: unused | ||
2436 | */ | ||
2437 | int prediction_order_method; | ||
2438 | |||
2439 | /** | ||
2440 | * - encoding: Set by user. | ||
2441 | * - decoding: unused | ||
2442 | */ | ||
2443 | int min_partition_order; | ||
2444 | |||
2445 | /** | ||
2446 | * - encoding: Set by user. | ||
2447 | * - decoding: unused | ||
2448 | */ | ||
2449 | int max_partition_order; | ||
2450 | |||
2451 | /** | ||
2452 | * GOP timecode frame start number, in non drop frame format | ||
2453 | * - encoding: Set by user. | ||
2454 | * - decoding: unused | ||
2455 | */ | ||
2456 | int64_t timecode_frame_start; | ||
2457 | |||
2458 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
2459 | /** | ||
2460 | * Decoder should decode to this many channels if it can (0 for default) | ||
2461 | * - encoding: unused | ||
2462 | * - decoding: Set by user. | ||
2463 | * @deprecated Deprecated in favor of request_channel_layout. | ||
2464 | */ | ||
2465 | int request_channels; | ||
2466 | #endif | ||
2467 | |||
2468 | /** | ||
2469 | * Percentage of dynamic range compression to be applied by the decoder. | ||
2470 | * The default value is 1.0, corresponding to full compression. | ||
2471 | * - encoding: unused | ||
2472 | * - decoding: Set by user. | ||
2473 | */ | ||
2474 | float drc_scale; | ||
2475 | |||
2476 | /** | ||
2477 | * opaque 64bit number (generally a PTS) that will be reordered and | ||
2478 | * output in AVFrame.reordered_opaque | ||
2479 | * - encoding: unused | ||
2480 | * - decoding: Set by user. | ||
2481 | */ | ||
2482 | int64_t reordered_opaque; | ||
2483 | |||
2484 | /** | ||
2485 | * Bits per sample/pixel of internal libavcodec pixel/sample format. | ||
2486 | * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. | ||
2487 | * - encoding: set by user. | ||
2488 | * - decoding: set by libavcodec. | ||
2489 | */ | ||
2490 | int bits_per_raw_sample; | ||
2491 | |||
2492 | /** | ||
2493 | * Audio channel layout. | ||
2494 | * - encoding: set by user. | ||
2495 | * - decoding: set by libavcodec. | ||
2496 | */ | ||
2497 | int64_t channel_layout; | ||
2498 | |||
2499 | /** | ||
2500 | * Request decoder to use this channel layout if it can (0 for default) | ||
2501 | * - encoding: unused | ||
2502 | * - decoding: Set by user. | ||
2503 | */ | ||
2504 | int64_t request_channel_layout; | ||
2505 | |||
2506 | /** | ||
2507 | * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow. | ||
2508 | * - encoding: Set by user. | ||
2509 | * - decoding: unused. | ||
2510 | */ | ||
2511 | float rc_max_available_vbv_use; | ||
2512 | |||
2513 | /** | ||
2514 | * Ratecontrol attempt to use, at least, <value> times the amount needed to prevent a vbv overflow. | ||
2515 | * - encoding: Set by user. | ||
2516 | * - decoding: unused. | ||
2517 | */ | ||
2518 | float rc_min_vbv_overflow_use; | ||
2519 | |||
2520 | /** | ||
2521 | * Hardware accelerator in use | ||
2522 | * - encoding: unused. | ||
2523 | * - decoding: Set by libavcodec | ||
2524 | */ | ||
2525 | struct AVHWAccel *hwaccel; | ||
2526 | |||
2527 | /** | ||
2528 | * For some codecs, the time base is closer to the field rate than the frame rate. | ||
2529 | * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration | ||
2530 | * if no telecine is used ... | ||
2531 | * | ||
2532 | * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. | ||
2533 | */ | ||
2534 | int ticks_per_frame; | ||
2535 | |||
2536 | /** | ||
2537 | * Hardware accelerator context. | ||
2538 | * For some hardware accelerators, a global context needs to be | ||
2539 | * provided by the user. In that case, this holds display-dependent | ||
2540 | * data FFmpeg cannot instantiate itself. Please refer to the | ||
2541 | * FFmpeg HW accelerator documentation to know how to fill this | ||
2542 | * is. e.g. for VA API, this is a struct vaapi_context. | ||
2543 | * - encoding: unused | ||
2544 | * - decoding: Set by user | ||
2545 | */ | ||
2546 | void *hwaccel_context; | ||
2547 | |||
2548 | /** | ||
2549 | * Chromaticity coordinates of the source primaries. | ||
2550 | * - encoding: Set by user | ||
2551 | * - decoding: Set by libavcodec | ||
2552 | */ | ||
2553 | enum AVColorPrimaries color_primaries; | ||
2554 | |||
2555 | /** | ||
2556 | * Color Transfer Characteristic. | ||
2557 | * - encoding: Set by user | ||
2558 | * - decoding: Set by libavcodec | ||
2559 | */ | ||
2560 | enum AVColorTransferCharacteristic color_trc; | ||
2561 | |||
2562 | /** | ||
2563 | * YUV colorspace type. | ||
2564 | * - encoding: Set by user | ||
2565 | * - decoding: Set by libavcodec | ||
2566 | */ | ||
2567 | enum AVColorSpace colorspace; | ||
2568 | |||
2569 | /** | ||
2570 | * MPEG vs JPEG YUV range. | ||
2571 | * - encoding: Set by user | ||
2572 | * - decoding: Set by libavcodec | ||
2573 | */ | ||
2574 | enum AVColorRange color_range; | ||
2575 | |||
2576 | /** | ||
2577 | * This defines the location of chroma samples. | ||
2578 | * - encoding: Set by user | ||
2579 | * - decoding: Set by libavcodec | ||
2580 | */ | ||
2581 | enum AVChromaLocation chroma_sample_location; | ||
2582 | |||
2583 | /** | ||
2584 | * The codec may call this to execute several independent things. | ||
2585 | * It will return only after finishing all tasks. | ||
2586 | * The user may replace this with some multithreaded implementation, | ||
2587 | * the default implementation will execute the parts serially. | ||
2588 | * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. | ||
2589 | * @param c context passed also to func | ||
2590 | * @param count the number of things to execute | ||
2591 | * @param arg2 argument passed unchanged to func | ||
2592 | * @param ret return values of executed functions, must have space for "count" values. May be NULL. | ||
2593 | * @param func function that will be called count times, with jobnr from 0 to count-1. | ||
2594 | * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no | ||
2595 | * two instances of func executing at the same time will have the same threadnr. | ||
2596 | * @return always 0 currently, but code should handle a future improvement where when any call to func | ||
2597 | * returns < 0 no further calls to func may be done and < 0 is returned. | ||
2598 | * - encoding: Set by libavcodec, user can override. | ||
2599 | * - decoding: Set by libavcodec, user can override. | ||
2600 | */ | ||
2601 | int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); | ||
2602 | |||
2603 | /** | ||
2604 | * explicit P-frame weighted prediction analysis method | ||
2605 | * 0: off | ||
2606 | * 1: fast blind weighting (one reference duplicate with -1 offset) | ||
2607 | * 2: smart weighting (full fade detection analysis) | ||
2608 | * - encoding: Set by user. | ||
2609 | * - decoding: unused | ||
2610 | */ | ||
2611 | int weighted_p_pred; | ||
2612 | |||
2613 | /** | ||
2614 | * AQ mode | ||
2615 | * 0: Disabled | ||
2616 | * 1: Variance AQ (complexity mask) | ||
2617 | * 2: Auto-variance AQ (experimental) | ||
2618 | * - encoding: Set by user | ||
2619 | * - decoding: unused | ||
2620 | */ | ||
2621 | int aq_mode; | ||
2622 | |||
2623 | /** | ||
2624 | * AQ strength | ||
2625 | * Reduces blocking and blurring in flat and textured areas. | ||
2626 | * - encoding: Set by user | ||
2627 | * - decoding: unused | ||
2628 | */ | ||
2629 | float aq_strength; | ||
2630 | |||
2631 | /** | ||
2632 | * PSY RD | ||
2633 | * Strength of psychovisual optimization | ||
2634 | * - encoding: Set by user | ||
2635 | * - decoding: unused | ||
2636 | */ | ||
2637 | float psy_rd; | ||
2638 | |||
2639 | /** | ||
2640 | * PSY trellis | ||
2641 | * Strength of psychovisual optimization | ||
2642 | * - encoding: Set by user | ||
2643 | * - decoding: unused | ||
2644 | */ | ||
2645 | float psy_trellis; | ||
2646 | |||
2647 | /** | ||
2648 | * RC lookahead | ||
2649 | * Number of frames for frametype and ratecontrol lookahead | ||
2650 | * - encoding: Set by user | ||
2651 | * - decoding: unused | ||
2652 | */ | ||
2653 | int rc_lookahead; | ||
2654 | } AVCodecContext; | ||
2655 | |||
2656 | /** | ||
2657 | * AVCodec. | ||
2658 | */ | ||
2659 | typedef struct AVCodec { | ||
2660 | /** | ||
2661 | * Name of the codec implementation. | ||
2662 | * The name is globally unique among encoders and among decoders (but an | ||
2663 | * encoder and a decoder can share the same name). | ||
2664 | * This is the primary way to find a codec from the user perspective. | ||
2665 | */ | ||
2666 | const char *name; | ||
2667 | enum AVMediaType type; | ||
2668 | enum CodecID id; | ||
2669 | int priv_data_size; | ||
2670 | int (*init)(AVCodecContext *); | ||
2671 | int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); | ||
2672 | int (*close)(AVCodecContext *); | ||
2673 | int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); | ||
2674 | /** | ||
2675 | * Codec capabilities. | ||
2676 | * see CODEC_CAP_* | ||
2677 | */ | ||
2678 | int capabilities; | ||
2679 | struct AVCodec *next; | ||
2680 | /** | ||
2681 | * Flush buffers. | ||
2682 | * Will be called when seeking | ||
2683 | */ | ||
2684 | void (*flush)(AVCodecContext *); | ||
2685 | //const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} | ||
2686 | const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 | ||
2687 | /** | ||
2688 | * Descriptive name for the codec, meant to be more human readable than name. | ||
2689 | * You should use the NULL_IF_CONFIG_SMALL() macro to define it. | ||
2690 | */ | ||
2691 | const char *long_name; | ||
2692 | const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 | ||
2693 | const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 | ||
2694 | const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 | ||
2695 | } AVCodec; | ||
2696 | |||
2697 | /** | ||
2698 | * AVHWAccel. | ||
2699 | */ | ||
2700 | typedef struct AVHWAccel { | ||
2701 | /** | ||
2702 | * Name of the hardware accelerated codec. | ||
2703 | * The name is globally unique among encoders and among decoders (but an | ||
2704 | * encoder and a decoder can share the same name). | ||
2705 | */ | ||
2706 | const char *name; | ||
2707 | |||
2708 | /** | ||
2709 | * Type of codec implemented by the hardware accelerator. | ||
2710 | * | ||
2711 | * See AVMEDIA_TYPE_xxx | ||
2712 | */ | ||
2713 | enum AVMediaType type; | ||
2714 | |||
2715 | /** | ||
2716 | * Codec implemented by the hardware accelerator. | ||
2717 | * | ||
2718 | * See CODEC_ID_xxx | ||
2719 | */ | ||
2720 | enum CodecID id; | ||
2721 | |||
2722 | /** | ||
2723 | * Supported pixel format. | ||
2724 | * | ||
2725 | * Only hardware accelerated formats are supported here. | ||
2726 | */ | ||
2727 | //enum PixelFormat pix_fmt; | ||
2728 | |||
2729 | /** | ||
2730 | * Hardware accelerated codec capabilities. | ||
2731 | * see FF_HWACCEL_CODEC_CAP_* | ||
2732 | */ | ||
2733 | int capabilities; | ||
2734 | |||
2735 | struct AVHWAccel *next; | ||
2736 | |||
2737 | /** | ||
2738 | * Called at the beginning of each frame or field picture. | ||
2739 | * | ||
2740 | * Meaningful frame information (codec specific) is guaranteed to | ||
2741 | * be parsed at this point. This function is mandatory. | ||
2742 | * | ||
2743 | * Note that buf can be NULL along with buf_size set to 0. | ||
2744 | * Otherwise, this means the whole frame is available at this point. | ||
2745 | * | ||
2746 | * @param avctx the codec context | ||
2747 | * @param buf the frame data buffer base | ||
2748 | * @param buf_size the size of the frame in bytes | ||
2749 | * @return zero if successful, a negative value otherwise | ||
2750 | */ | ||
2751 | int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); | ||
2752 | |||
2753 | /** | ||
2754 | * Callback for each slice. | ||
2755 | * | ||
2756 | * Meaningful slice information (codec specific) is guaranteed to | ||
2757 | * be parsed at this point. This function is mandatory. | ||
2758 | * | ||
2759 | * @param avctx the codec context | ||
2760 | * @param buf the slice data buffer base | ||
2761 | * @param buf_size the size of the slice in bytes | ||
2762 | * @return zero if successful, a negative value otherwise | ||
2763 | */ | ||
2764 | int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); | ||
2765 | |||
2766 | /** | ||
2767 | * Called at the end of each frame or field picture. | ||
2768 | * | ||
2769 | * The whole picture is parsed at this point and can now be sent | ||
2770 | * to the hardware accelerator. This function is mandatory. | ||
2771 | * | ||
2772 | * @param avctx the codec context | ||
2773 | * @return zero if successful, a negative value otherwise | ||
2774 | */ | ||
2775 | int (*end_frame)(AVCodecContext *avctx); | ||
2776 | |||
2777 | /** | ||
2778 | * Size of HW accelerator private data. | ||
2779 | * | ||
2780 | * Private data is allocated with av_mallocz() before | ||
2781 | * AVCodecContext.get_buffer() and deallocated after | ||
2782 | * AVCodecContext.release_buffer(). | ||
2783 | */ | ||
2784 | int priv_data_size; | ||
2785 | } AVHWAccel; | ||
2786 | |||
2787 | /** | ||
2788 | * four components are given, that's all. | ||
2789 | * the last component is alpha | ||
2790 | */ | ||
2791 | typedef struct AVPicture { | ||
2792 | uint8_t *data[4]; | ||
2793 | int linesize[4]; ///< number of bytes per line | ||
2794 | } AVPicture; | ||
2795 | |||
2796 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
2797 | /** | ||
2798 | * AVPaletteControl | ||
2799 | * This structure defines a method for communicating palette changes | ||
2800 | * between and demuxer and a decoder. | ||
2801 | * | ||
2802 | * @deprecated Use AVPacket to send palette changes instead. | ||
2803 | * This is totally broken. | ||
2804 | */ | ||
2805 | #define AVPALETTE_SIZE 1024 | ||
2806 | #define AVPALETTE_COUNT 256 | ||
2807 | typedef struct AVPaletteControl { | ||
2808 | |||
2809 | /* Demuxer sets this to 1 to indicate the palette has changed; | ||
2810 | * decoder resets to 0. */ | ||
2811 | int palette_changed; | ||
2812 | |||
2813 | /* 4-byte ARGB palette entries, stored in native byte order; note that | ||
2814 | * the individual palette components should be on a 8-bit scale; if | ||
2815 | * the palette data comes from an IBM VGA native format, the component | ||
2816 | * data is probably 6 bits in size and needs to be scaled. */ | ||
2817 | unsigned int palette[AVPALETTE_COUNT]; | ||
2818 | |||
2819 | } AVPaletteControl attribute_deprecated; | ||
2820 | #endif | ||
2821 | |||
2822 | enum AVSubtitleType { | ||
2823 | SUBTITLE_NONE, | ||
2824 | |||
2825 | SUBTITLE_BITMAP, ///< A bitmap, pict will be set | ||
2826 | |||
2827 | /** | ||
2828 | * Plain text, the text field must be set by the decoder and is | ||
2829 | * authoritative. ass and pict fields may contain approximations. | ||
2830 | */ | ||
2831 | SUBTITLE_TEXT, | ||
2832 | |||
2833 | /** | ||
2834 | * Formatted text, the ass field must be set by the decoder and is | ||
2835 | * authoritative. pict and text fields may contain approximations. | ||
2836 | */ | ||
2837 | SUBTITLE_ASS, | ||
2838 | }; | ||
2839 | |||
2840 | typedef struct AVSubtitleRect { | ||
2841 | int x; ///< top left corner of pict, undefined when pict is not set | ||
2842 | int y; ///< top left corner of pict, undefined when pict is not set | ||
2843 | int w; ///< width of pict, undefined when pict is not set | ||
2844 | int h; ///< height of pict, undefined when pict is not set | ||
2845 | int nb_colors; ///< number of colors in pict, undefined when pict is not set | ||
2846 | |||
2847 | /** | ||
2848 | * data+linesize for the bitmap of this subtitle. | ||
2849 | * can be set for text/ass as well once they where rendered | ||
2850 | */ | ||
2851 | AVPicture pict; | ||
2852 | enum AVSubtitleType type; | ||
2853 | |||
2854 | char *text; ///< 0 terminated plain UTF-8 text | ||
2855 | |||
2856 | /** | ||
2857 | * 0 terminated ASS/SSA compatible event line. | ||
2858 | * The pressentation of this is unaffected by the other values in this | ||
2859 | * struct. | ||
2860 | */ | ||
2861 | char *ass; | ||
2862 | } AVSubtitleRect; | ||
2863 | |||
2864 | typedef struct AVSubtitle { | ||
2865 | uint16_t format; /* 0 = graphics */ | ||
2866 | uint32_t start_display_time; /* relative to packet pts, in ms */ | ||
2867 | uint32_t end_display_time; /* relative to packet pts, in ms */ | ||
2868 | unsigned num_rects; | ||
2869 | AVSubtitleRect **rects; | ||
2870 | int64_t pts; ///< Same as packet pts, in AV_TIME_BASE | ||
2871 | } AVSubtitle; | ||
2872 | |||
2873 | /* packet functions */ | ||
2874 | |||
2875 | /** | ||
2876 | * @deprecated use NULL instead | ||
2877 | */ | ||
2878 | attribute_deprecated void av_destruct_packet_nofree(AVPacket *pkt); | ||
2879 | |||
2880 | /** | ||
2881 | * Default packet destructor. | ||
2882 | */ | ||
2883 | void av_destruct_packet(AVPacket *pkt); | ||
2884 | |||
2885 | /** | ||
2886 | * Initialize optional fields of a packet with default values. | ||
2887 | * | ||
2888 | * @param pkt packet | ||
2889 | */ | ||
2890 | void av_init_packet(AVPacket *pkt); | ||
2891 | |||
2892 | /** | ||
2893 | * Allocate the payload of a packet and initialize its fields with | ||
2894 | * default values. | ||
2895 | * | ||
2896 | * @param pkt packet | ||
2897 | * @param size wanted payload size | ||
2898 | * @return 0 if OK, AVERROR_xxx otherwise | ||
2899 | */ | ||
2900 | int av_new_packet(AVPacket *pkt, int size); | ||
2901 | |||
2902 | /** | ||
2903 | * Reduce packet size, correctly zeroing padding | ||
2904 | * | ||
2905 | * @param pkt packet | ||
2906 | * @param size new size | ||
2907 | */ | ||
2908 | void av_shrink_packet(AVPacket *pkt, int size); | ||
2909 | |||
2910 | /** | ||
2911 | * @warning This is a hack - the packet memory allocation stuff is broken. The | ||
2912 | * packet is allocated if it was not really allocated. | ||
2913 | */ | ||
2914 | int av_dup_packet(AVPacket *pkt); | ||
2915 | |||
2916 | /** | ||
2917 | * Free a packet. | ||
2918 | * | ||
2919 | * @param pkt packet to free | ||
2920 | */ | ||
2921 | void av_free_packet(AVPacket *pkt); | ||
2922 | |||
2923 | /* resample.c */ | ||
2924 | |||
2925 | struct ReSampleContext; | ||
2926 | struct AVResampleContext; | ||
2927 | |||
2928 | typedef struct ReSampleContext ReSampleContext; | ||
2929 | |||
2930 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
2931 | /** | ||
2932 | * @deprecated Use av_audio_resample_init() instead. | ||
2933 | */ | ||
2934 | attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels, | ||
2935 | int output_rate, int input_rate); | ||
2936 | #endif | ||
2937 | /** | ||
2938 | * Initializes audio resampling context | ||
2939 | * | ||
2940 | * @param output_channels number of output channels | ||
2941 | * @param input_channels number of input channels | ||
2942 | * @param output_rate output sample rate | ||
2943 | * @param input_rate input sample rate | ||
2944 | * @param sample_fmt_out requested output sample format | ||
2945 | * @param sample_fmt_in input sample format | ||
2946 | * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq | ||
2947 | * @param log2_phase_count log2 of the number of entries in the polyphase filterbank | ||
2948 | * @param linear If 1 then the used FIR filter will be linearly interpolated | ||
2949 | between the 2 closest, if 0 the closest will be used | ||
2950 | * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate | ||
2951 | * @return allocated ReSampleContext, NULL if error occured | ||
2952 | */ | ||
2953 | ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, | ||
2954 | int output_rate, int input_rate, | ||
2955 | enum SampleFormat sample_fmt_out, | ||
2956 | enum SampleFormat sample_fmt_in, | ||
2957 | int filter_length, int log2_phase_count, | ||
2958 | int linear, double cutoff); | ||
2959 | |||
2960 | int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); | ||
2961 | void audio_resample_close(ReSampleContext *s); | ||
2962 | |||
2963 | |||
2964 | /** | ||
2965 | * Initializes an audio resampler. | ||
2966 | * Note, if either rate is not an integer then simply scale both rates up so they are. | ||
2967 | * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq | ||
2968 | * @param log2_phase_count log2 of the number of entries in the polyphase filterbank | ||
2969 | * @param linear If 1 then the used FIR filter will be linearly interpolated | ||
2970 | between the 2 closest, if 0 the closest will be used | ||
2971 | * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate | ||
2972 | */ | ||
2973 | struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); | ||
2974 | |||
2975 | /** | ||
2976 | * resamples. | ||
2977 | * @param src an array of unconsumed samples | ||
2978 | * @param consumed the number of samples of src which have been consumed are returned here | ||
2979 | * @param src_size the number of unconsumed samples available | ||
2980 | * @param dst_size the amount of space in samples available in dst | ||
2981 | * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. | ||
2982 | * @return the number of samples written in dst or -1 if an error occurred | ||
2983 | */ | ||
2984 | int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); | ||
2985 | |||
2986 | |||
2987 | /** | ||
2988 | * Compensates samplerate/timestamp drift. The compensation is done by changing | ||
2989 | * the resampler parameters, so no audible clicks or similar distortions occur | ||
2990 | * @param compensation_distance distance in output samples over which the compensation should be performed | ||
2991 | * @param sample_delta number of output samples which should be output less | ||
2992 | * | ||
2993 | * example: av_resample_compensate(c, 10, 500) | ||
2994 | * here instead of 510 samples only 500 samples would be output | ||
2995 | * | ||
2996 | * note, due to rounding the actual compensation might be slightly different, | ||
2997 | * especially if the compensation_distance is large and the in_rate used during init is small | ||
2998 | */ | ||
2999 | void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); | ||
3000 | void av_resample_close(struct AVResampleContext *c); | ||
3001 | |||
3002 | /** | ||
3003 | * Allocate memory for a picture. Call avpicture_free to free it. | ||
3004 | * | ||
3005 | * @param picture the picture to be filled in | ||
3006 | * @param pix_fmt the format of the picture | ||
3007 | * @param width the width of the picture | ||
3008 | * @param height the height of the picture | ||
3009 | * @return zero if successful, a negative value if not | ||
3010 | */ | ||
3011 | int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height); | ||
3012 | |||
3013 | /** | ||
3014 | * Free a picture previously allocated by avpicture_alloc(). | ||
3015 | * | ||
3016 | * @param picture the AVPicture to be freed | ||
3017 | */ | ||
3018 | void avpicture_free(AVPicture *picture); | ||
3019 | |||
3020 | /** | ||
3021 | * Fill in the AVPicture fields. | ||
3022 | * The fields of the given AVPicture are filled in by using the 'ptr' address | ||
3023 | * which points to the image data buffer. Depending on the specified picture | ||
3024 | * format, one or multiple image data pointers and line sizes will be set. | ||
3025 | * If a planar format is specified, several pointers will be set pointing to | ||
3026 | * the different picture planes and the line sizes of the different planes | ||
3027 | * will be stored in the lines_sizes array. | ||
3028 | * Call with ptr == NULL to get the required size for the ptr buffer. | ||
3029 | * | ||
3030 | * @param picture AVPicture whose fields are to be filled in | ||
3031 | * @param ptr Buffer which will contain or contains the actual image data | ||
3032 | * @param pix_fmt The format in which the picture data is stored. | ||
3033 | * @param width the width of the image in pixels | ||
3034 | * @param height the height of the image in pixels | ||
3035 | * @return size of the image data in bytes | ||
3036 | */ | ||
3037 | int avpicture_fill(AVPicture *picture, uint8_t *ptr, | ||
3038 | enum PixelFormat pix_fmt, int width, int height); | ||
3039 | int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height, | ||
3040 | unsigned char *dest, int dest_size); | ||
3041 | |||
3042 | /** | ||
3043 | * Calculate the size in bytes that a picture of the given width and height | ||
3044 | * would occupy if stored in the given picture format. | ||
3045 | * Note that this returns the size of a compact representation as generated | ||
3046 | * by avpicture_layout, which can be smaller than the size required for e.g. | ||
3047 | * avpicture_fill. | ||
3048 | * | ||
3049 | * @param pix_fmt the given picture format | ||
3050 | * @param width the width of the image | ||
3051 | * @param height the height of the image | ||
3052 | * @return Image data size in bytes or -1 on error (e.g. too large dimensions). | ||
3053 | */ | ||
3054 | int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height); | ||
3055 | void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift); | ||
3056 | const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt); | ||
3057 | void avcodec_set_dimensions(AVCodecContext *s, int width, int height); | ||
3058 | |||
3059 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3060 | /** | ||
3061 | * Returns the pixel format corresponding to the name name. | ||
3062 | * | ||
3063 | * If there is no pixel format with name name, then looks for a | ||
3064 | * pixel format with the name corresponding to the native endian | ||
3065 | * format of name. | ||
3066 | * For example in a little-endian system, first looks for "gray16", | ||
3067 | * then for "gray16le". | ||
3068 | * | ||
3069 | * Finally if no pixel format has been found, returns PIX_FMT_NONE. | ||
3070 | * | ||
3071 | * @deprecated Deprecated in favor of av_get_pix_fmt(). | ||
3072 | */ | ||
3073 | attribute_deprecated enum PixelFormat avcodec_get_pix_fmt(const char* name); | ||
3074 | #endif | ||
3075 | |||
3076 | /** | ||
3077 | * Returns a value representing the fourCC code associated to the | ||
3078 | * pixel format pix_fmt, or 0 if no associated fourCC code can be | ||
3079 | * found. | ||
3080 | */ | ||
3081 | unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat pix_fmt); | ||
3082 | |||
3083 | #define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ | ||
3084 | #define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ | ||
3085 | #define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ | ||
3086 | #define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ | ||
3087 | #define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ | ||
3088 | #define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ | ||
3089 | |||
3090 | /** | ||
3091 | * Computes what kind of losses will occur when converting from one specific | ||
3092 | * pixel format to another. | ||
3093 | * When converting from one pixel format to another, information loss may occur. | ||
3094 | * For example, when converting from RGB24 to GRAY, the color information will | ||
3095 | * be lost. Similarly, other losses occur when converting from some formats to | ||
3096 | * other formats. These losses can involve loss of chroma, but also loss of | ||
3097 | * resolution, loss of color depth, loss due to the color space conversion, loss | ||
3098 | * of the alpha bits or loss due to color quantization. | ||
3099 | * avcodec_get_fix_fmt_loss() informs you about the various types of losses | ||
3100 | * which will occur when converting from one pixel format to another. | ||
3101 | * | ||
3102 | * @param[in] dst_pix_fmt destination pixel format | ||
3103 | * @param[in] src_pix_fmt source pixel format | ||
3104 | * @param[in] has_alpha Whether the source pixel format alpha channel is used. | ||
3105 | * @return Combination of flags informing you what kind of losses will occur. | ||
3106 | */ | ||
3107 | int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt, | ||
3108 | int has_alpha); | ||
3109 | |||
3110 | /** | ||
3111 | * Finds the best pixel format to convert to given a certain source pixel | ||
3112 | * format. When converting from one pixel format to another, information loss | ||
3113 | * may occur. For example, when converting from RGB24 to GRAY, the color | ||
3114 | * information will be lost. Similarly, other losses occur when converting from | ||
3115 | * some formats to other formats. avcodec_find_best_pix_fmt() searches which of | ||
3116 | * the given pixel formats should be used to suffer the least amount of loss. | ||
3117 | * The pixel formats from which it chooses one, are determined by the | ||
3118 | * pix_fmt_mask parameter. | ||
3119 | * | ||
3120 | * @code | ||
3121 | * src_pix_fmt = PIX_FMT_YUV420P; | ||
3122 | * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); | ||
3123 | * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); | ||
3124 | * @endcode | ||
3125 | * | ||
3126 | * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from | ||
3127 | * @param[in] src_pix_fmt source pixel format | ||
3128 | * @param[in] has_alpha Whether the source pixel format alpha channel is used. | ||
3129 | * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. | ||
3130 | * @return The best pixel format to convert to or -1 if none was found. | ||
3131 | */ | ||
3132 | enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt, | ||
3133 | int has_alpha, int *loss_ptr); | ||
3134 | |||
3135 | |||
3136 | /** | ||
3137 | * Print in buf the string corresponding to the pixel format with | ||
3138 | * number pix_fmt, or an header if pix_fmt is negative. | ||
3139 | * | ||
3140 | * @param[in] buf the buffer where to write the string | ||
3141 | * @param[in] buf_size the size of buf | ||
3142 | * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or | ||
3143 | * a negative value to print the corresponding header. | ||
3144 | * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. | ||
3145 | */ | ||
3146 | void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt); | ||
3147 | |||
3148 | #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ | ||
3149 | #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ | ||
3150 | |||
3151 | /** | ||
3152 | * Tell if an image really has transparent alpha values. | ||
3153 | * @return ored mask of FF_ALPHA_xxx constants | ||
3154 | */ | ||
3155 | int img_get_alpha_info(const AVPicture *src, | ||
3156 | enum PixelFormat pix_fmt, int width, int height); | ||
3157 | |||
3158 | /* deinterlace a picture */ | ||
3159 | /* deinterlace - if not supported return -1 */ | ||
3160 | int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, | ||
3161 | enum PixelFormat pix_fmt, int width, int height); | ||
3162 | |||
3163 | /* external high level API */ | ||
3164 | |||
3165 | /** | ||
3166 | * If c is NULL, returns the first registered codec, | ||
3167 | * if c is non-NULL, returns the next registered codec after c, | ||
3168 | * or NULL if c is the last one. | ||
3169 | */ | ||
3170 | AVCodec *av_codec_next(AVCodec *c); | ||
3171 | |||
3172 | /** | ||
3173 | * Returns the LIBAVCODEC_VERSION_INT constant. | ||
3174 | */ | ||
3175 | unsigned avcodec_version(void); | ||
3176 | |||
3177 | /** | ||
3178 | * Returns the libavcodec build-time configuration. | ||
3179 | */ | ||
3180 | const char *avcodec_configuration(void); | ||
3181 | |||
3182 | /** | ||
3183 | * Returns the libavcodec license. | ||
3184 | */ | ||
3185 | const char *avcodec_license(void); | ||
3186 | |||
3187 | /** | ||
3188 | * Initializes libavcodec. | ||
3189 | * | ||
3190 | * @warning This function must be called before any other libavcodec | ||
3191 | * function. | ||
3192 | */ | ||
3193 | void avcodec_init(void); | ||
3194 | |||
3195 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3196 | /** | ||
3197 | * @deprecated Deprecated in favor of avcodec_register(). | ||
3198 | */ | ||
3199 | attribute_deprecated void register_avcodec(AVCodec *codec); | ||
3200 | #endif | ||
3201 | |||
3202 | /** | ||
3203 | * Register the codec codec and initialize libavcodec. | ||
3204 | * | ||
3205 | * @see avcodec_init() | ||
3206 | */ | ||
3207 | void avcodec_register(AVCodec *codec); | ||
3208 | |||
3209 | /** | ||
3210 | * Finds a registered encoder with a matching codec ID. | ||
3211 | * | ||
3212 | * @param id CodecID of the requested encoder | ||
3213 | * @return An encoder if one was found, NULL otherwise. | ||
3214 | */ | ||
3215 | AVCodec *avcodec_find_encoder(enum CodecID id); | ||
3216 | |||
3217 | /** | ||
3218 | * Finds a registered encoder with the specified name. | ||
3219 | * | ||
3220 | * @param name name of the requested encoder | ||
3221 | * @return An encoder if one was found, NULL otherwise. | ||
3222 | */ | ||
3223 | AVCodec *avcodec_find_encoder_by_name(const char *name); | ||
3224 | |||
3225 | /** | ||
3226 | * Finds a registered decoder with a matching codec ID. | ||
3227 | * | ||
3228 | * @param id CodecID of the requested decoder | ||
3229 | * @return A decoder if one was found, NULL otherwise. | ||
3230 | */ | ||
3231 | AVCodec *avcodec_find_decoder(enum CodecID id); | ||
3232 | |||
3233 | /** | ||
3234 | * Finds a registered decoder with the specified name. | ||
3235 | * | ||
3236 | * @param name name of the requested decoder | ||
3237 | * @return A decoder if one was found, NULL otherwise. | ||
3238 | */ | ||
3239 | AVCodec *avcodec_find_decoder_by_name(const char *name); | ||
3240 | void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); | ||
3241 | |||
3242 | /** | ||
3243 | * Sets the fields of the given AVCodecContext to default values. | ||
3244 | * | ||
3245 | * @param s The AVCodecContext of which the fields should be set to default values. | ||
3246 | */ | ||
3247 | void avcodec_get_context_defaults(AVCodecContext *s); | ||
3248 | |||
3249 | /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! | ||
3250 | * we WILL change its arguments and name a few times! */ | ||
3251 | void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); | ||
3252 | |||
3253 | /** | ||
3254 | * Allocates an AVCodecContext and sets its fields to default values. The | ||
3255 | * resulting struct can be deallocated by simply calling av_free(). | ||
3256 | * | ||
3257 | * @return An AVCodecContext filled with default values or NULL on failure. | ||
3258 | * @see avcodec_get_context_defaults | ||
3259 | */ | ||
3260 | AVCodecContext *avcodec_alloc_context(void); | ||
3261 | |||
3262 | /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! | ||
3263 | * we WILL change its arguments and name a few times! */ | ||
3264 | AVCodecContext *avcodec_alloc_context2(enum AVMediaType); | ||
3265 | |||
3266 | /** | ||
3267 | * Copy the settings of the source AVCodecContext into the destination | ||
3268 | * AVCodecContext. The resulting destination codec context will be | ||
3269 | * unopened, i.e. you are required to call avcodec_open() before you | ||
3270 | * can use this AVCodecContext to decode/encode video/audio data. | ||
3271 | * | ||
3272 | * @param dest target codec context, should be initialized with | ||
3273 | * avcodec_alloc_context(), but otherwise uninitialized | ||
3274 | * @param src source codec context | ||
3275 | * @return AVERROR() on error (e.g. memory allocation error), 0 on success | ||
3276 | */ | ||
3277 | int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); | ||
3278 | |||
3279 | /** | ||
3280 | * Sets the fields of the given AVFrame to default values. | ||
3281 | * | ||
3282 | * @param pic The AVFrame of which the fields should be set to default values. | ||
3283 | */ | ||
3284 | void avcodec_get_frame_defaults(AVFrame *pic); | ||
3285 | |||
3286 | /** | ||
3287 | * Allocates an AVFrame and sets its fields to default values. The resulting | ||
3288 | * struct can be deallocated by simply calling av_free(). | ||
3289 | * | ||
3290 | * @return An AVFrame filled with default values or NULL on failure. | ||
3291 | * @see avcodec_get_frame_defaults | ||
3292 | */ | ||
3293 | AVFrame *avcodec_alloc_frame(void); | ||
3294 | |||
3295 | int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); | ||
3296 | void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); | ||
3297 | int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); | ||
3298 | |||
3299 | /** | ||
3300 | * Returns the amount of padding in pixels which the get_buffer callback must | ||
3301 | * provide around the edge of the image for codecs which do not have the | ||
3302 | * CODEC_FLAG_EMU_EDGE flag. | ||
3303 | * | ||
3304 | * @return Required padding in pixels. | ||
3305 | */ | ||
3306 | unsigned avcodec_get_edge_width(void); | ||
3307 | /** | ||
3308 | * Modifies width and height values so that they will result in a memory | ||
3309 | * buffer that is acceptable for the codec if you do not use any horizontal | ||
3310 | * padding. | ||
3311 | */ | ||
3312 | void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); | ||
3313 | /** | ||
3314 | * Modifies width and height values so that they will result in a memory | ||
3315 | * buffer that is acceptable for the codec if you also ensure that all | ||
3316 | * line sizes are a multiple of the respective linesize_align[i]. | ||
3317 | */ | ||
3318 | void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, | ||
3319 | int linesize_align[4]); | ||
3320 | |||
3321 | /** | ||
3322 | * Checks if the given dimension of a picture is valid, meaning that all | ||
3323 | * bytes of the picture can be addressed with a signed int. | ||
3324 | * | ||
3325 | * @param[in] w Width of the picture. | ||
3326 | * @param[in] h Height of the picture. | ||
3327 | * @return Zero if valid, a negative value if invalid. | ||
3328 | */ | ||
3329 | int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); | ||
3330 | enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); | ||
3331 | |||
3332 | int avcodec_thread_init(AVCodecContext *s, int thread_count); | ||
3333 | void avcodec_thread_free(AVCodecContext *s); | ||
3334 | int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); | ||
3335 | int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); | ||
3336 | //FIXME func typedef | ||
3337 | |||
3338 | /** | ||
3339 | * Initializes the AVCodecContext to use the given AVCodec. Prior to using this | ||
3340 | * function the context has to be allocated. | ||
3341 | * | ||
3342 | * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), | ||
3343 | * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for | ||
3344 | * retrieving a codec. | ||
3345 | * | ||
3346 | * @warning This function is not thread safe! | ||
3347 | * | ||
3348 | * @code | ||
3349 | * avcodec_register_all(); | ||
3350 | * codec = avcodec_find_decoder(CODEC_ID_H264); | ||
3351 | * if (!codec) | ||
3352 | * exit(1); | ||
3353 | * | ||
3354 | * context = avcodec_alloc_context(); | ||
3355 | * | ||
3356 | * if (avcodec_open(context, codec) < 0) | ||
3357 | * exit(1); | ||
3358 | * @endcode | ||
3359 | * | ||
3360 | * @param avctx The context which will be set up to use the given codec. | ||
3361 | * @param codec The codec to use within the context. | ||
3362 | * @return zero on success, a negative value on error | ||
3363 | * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder | ||
3364 | */ | ||
3365 | int avcodec_open(AVCodecContext *avctx, AVCodec *codec); | ||
3366 | |||
3367 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3368 | /** | ||
3369 | * Decodes an audio frame from buf into samples. | ||
3370 | * Wrapper function which calls avcodec_decode_audio3. | ||
3371 | * | ||
3372 | * @deprecated Use avcodec_decode_audio3 instead. | ||
3373 | * @param avctx the codec context | ||
3374 | * @param[out] samples the output buffer | ||
3375 | * @param[in,out] frame_size_ptr the output buffer size in bytes | ||
3376 | * @param[in] buf the input buffer | ||
3377 | * @param[in] buf_size the input buffer size in bytes | ||
3378 | * @return On error a negative value is returned, otherwise the number of bytes | ||
3379 | * used or zero if no frame could be decompressed. | ||
3380 | */ | ||
3381 | attribute_deprecated int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, | ||
3382 | int *frame_size_ptr, | ||
3383 | const uint8_t *buf, int buf_size); | ||
3384 | #endif | ||
3385 | |||
3386 | /** | ||
3387 | * Decodes the audio frame of size avpkt->size from avpkt->data into samples. | ||
3388 | * Some decoders may support multiple frames in a single AVPacket, such | ||
3389 | * decoders would then just decode the first frame. In this case, | ||
3390 | * avcodec_decode_audio3 has to be called again with an AVPacket that contains | ||
3391 | * the remaining data in order to decode the second frame etc. | ||
3392 | * If no frame | ||
3393 | * could be outputted, frame_size_ptr is zero. Otherwise, it is the | ||
3394 | * decompressed frame size in bytes. | ||
3395 | * | ||
3396 | * @warning You must set frame_size_ptr to the allocated size of the | ||
3397 | * output buffer before calling avcodec_decode_audio3(). | ||
3398 | * | ||
3399 | * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than | ||
3400 | * the actual read bytes because some optimized bitstream readers read 32 or 64 | ||
3401 | * bits at once and could read over the end. | ||
3402 | * | ||
3403 | * @warning The end of the input buffer avpkt->data should be set to 0 to ensure that | ||
3404 | * no overreading happens for damaged MPEG streams. | ||
3405 | * | ||
3406 | * @note You might have to align the input buffer avpkt->data and output buffer | ||
3407 | * samples. The alignment requirements depend on the CPU: On some CPUs it isn't | ||
3408 | * necessary at all, on others it won't work at all if not aligned and on others | ||
3409 | * it will work but it will have an impact on performance. | ||
3410 | * | ||
3411 | * In practice, avpkt->data should have 4 byte alignment at minimum and | ||
3412 | * samples should be 16 byte aligned unless the CPU doesn't need it | ||
3413 | * (AltiVec and SSE do). | ||
3414 | * | ||
3415 | * @param avctx the codec context | ||
3416 | * @param[out] samples the output buffer, sample type in avctx->sample_fmt | ||
3417 | * @param[in,out] frame_size_ptr the output buffer size in bytes | ||
3418 | * @param[in] avpkt The input AVPacket containing the input buffer. | ||
3419 | * You can create such packet with av_init_packet() and by then setting | ||
3420 | * data and size, some decoders might in addition need other fields. | ||
3421 | * All decoders are designed to use the least fields possible though. | ||
3422 | * @return On error a negative value is returned, otherwise the number of bytes | ||
3423 | * used or zero if no frame data was decompressed (used) from the input AVPacket. | ||
3424 | */ | ||
3425 | int avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, | ||
3426 | int *frame_size_ptr, | ||
3427 | AVPacket *avpkt); | ||
3428 | |||
3429 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3430 | /** | ||
3431 | * Decodes a video frame from buf into picture. | ||
3432 | * Wrapper function which calls avcodec_decode_video2. | ||
3433 | * | ||
3434 | * @deprecated Use avcodec_decode_video2 instead. | ||
3435 | * @param avctx the codec context | ||
3436 | * @param[out] picture The AVFrame in which the decoded video frame will be stored. | ||
3437 | * @param[in] buf the input buffer | ||
3438 | * @param[in] buf_size the size of the input buffer in bytes | ||
3439 | * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. | ||
3440 | * @return On error a negative value is returned, otherwise the number of bytes | ||
3441 | * used or zero if no frame could be decompressed. | ||
3442 | */ | ||
3443 | attribute_deprecated int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, | ||
3444 | int *got_picture_ptr, | ||
3445 | const uint8_t *buf, int buf_size); | ||
3446 | #endif | ||
3447 | |||
3448 | /** | ||
3449 | * Decodes the video frame of size avpkt->size from avpkt->data into picture. | ||
3450 | * Some decoders may support multiple frames in a single AVPacket, such | ||
3451 | * decoders would then just decode the first frame. | ||
3452 | * | ||
3453 | * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than | ||
3454 | * the actual read bytes because some optimized bitstream readers read 32 or 64 | ||
3455 | * bits at once and could read over the end. | ||
3456 | * | ||
3457 | * @warning The end of the input buffer buf should be set to 0 to ensure that | ||
3458 | * no overreading happens for damaged MPEG streams. | ||
3459 | * | ||
3460 | * @note You might have to align the input buffer avpkt->data. | ||
3461 | * The alignment requirements depend on the CPU: on some CPUs it isn't | ||
3462 | * necessary at all, on others it won't work at all if not aligned and on others | ||
3463 | * it will work but it will have an impact on performance. | ||
3464 | * | ||
3465 | * In practice, avpkt->data should have 4 byte alignment at minimum. | ||
3466 | * | ||
3467 | * @note Some codecs have a delay between input and output, these need to be | ||
3468 | * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. | ||
3469 | * | ||
3470 | * @param avctx the codec context | ||
3471 | * @param[out] picture The AVFrame in which the decoded video frame will be stored. | ||
3472 | * @param[in] avpkt The input AVpacket containing the input buffer. | ||
3473 | * You can create such packet with av_init_packet() and by then setting | ||
3474 | * data and size, some decoders might in addition need other fields like | ||
3475 | * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least | ||
3476 | * fields possible. | ||
3477 | * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. | ||
3478 | * @return On error a negative value is returned, otherwise the number of bytes | ||
3479 | * used or zero if no frame could be decompressed. | ||
3480 | */ | ||
3481 | int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, | ||
3482 | int *got_picture_ptr, | ||
3483 | AVPacket *avpkt); | ||
3484 | |||
3485 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3486 | /* Decode a subtitle message. Return -1 if error, otherwise return the | ||
3487 | * number of bytes used. If no subtitle could be decompressed, | ||
3488 | * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ | ||
3489 | attribute_deprecated int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, | ||
3490 | int *got_sub_ptr, | ||
3491 | const uint8_t *buf, int buf_size); | ||
3492 | #endif | ||
3493 | |||
3494 | /** | ||
3495 | * Decodes a subtitle message. | ||
3496 | * Returns a negative value on error, otherwise returns the number of bytes used. | ||
3497 | * If no subtitle could be decompressed, got_sub_ptr is zero. | ||
3498 | * Otherwise, the subtitle is stored in *sub. | ||
3499 | * | ||
3500 | * @param avctx the codec context | ||
3501 | * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored. | ||
3502 | * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. | ||
3503 | * @param[in] avpkt The input AVPacket containing the input buffer. | ||
3504 | */ | ||
3505 | int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, | ||
3506 | int *got_sub_ptr, | ||
3507 | AVPacket *avpkt); | ||
3508 | int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, | ||
3509 | int *data_size_ptr, | ||
3510 | uint8_t *buf, int buf_size); | ||
3511 | |||
3512 | /** | ||
3513 | * Encodes an audio frame from samples into buf. | ||
3514 | * | ||
3515 | * @note The output buffer should be at least FF_MIN_BUFFER_SIZE bytes large. | ||
3516 | * However, for PCM audio the user will know how much space is needed | ||
3517 | * because it depends on the value passed in buf_size as described | ||
3518 | * below. In that case a lower value can be used. | ||
3519 | * | ||
3520 | * @param avctx the codec context | ||
3521 | * @param[out] buf the output buffer | ||
3522 | * @param[in] buf_size the output buffer size | ||
3523 | * @param[in] samples the input buffer containing the samples | ||
3524 | * The number of samples read from this buffer is frame_size*channels, | ||
3525 | * both of which are defined in avctx. | ||
3526 | * For PCM audio the number of samples read from samples is equal to | ||
3527 | * buf_size * input_sample_size / output_sample_size. | ||
3528 | * @return On error a negative value is returned, on success zero or the number | ||
3529 | * of bytes used to encode the data read from the input buffer. | ||
3530 | */ | ||
3531 | int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, | ||
3532 | const short *samples); | ||
3533 | |||
3534 | /** | ||
3535 | * Encodes a video frame from pict into buf. | ||
3536 | * The input picture should be | ||
3537 | * stored using a specific format, namely avctx.pix_fmt. | ||
3538 | * | ||
3539 | * @param avctx the codec context | ||
3540 | * @param[out] buf the output buffer for the bitstream of encoded frame | ||
3541 | * @param[in] buf_size the size of the output buffer in bytes | ||
3542 | * @param[in] pict the input picture to encode | ||
3543 | * @return On error a negative value is returned, on success zero or the number | ||
3544 | * of bytes used from the output buffer. | ||
3545 | */ | ||
3546 | int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, | ||
3547 | const AVFrame *pict); | ||
3548 | int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, | ||
3549 | const AVSubtitle *sub); | ||
3550 | |||
3551 | int avcodec_close(AVCodecContext *avctx); | ||
3552 | |||
3553 | /** | ||
3554 | * Register all the codecs, parsers and bitstream filters which were enabled at | ||
3555 | * configuration time. If you do not call this function you can select exactly | ||
3556 | * which formats you want to support, by using the individual registration | ||
3557 | * functions. | ||
3558 | * | ||
3559 | * @see avcodec_register | ||
3560 | * @see av_register_codec_parser | ||
3561 | * @see av_register_bitstream_filter | ||
3562 | */ | ||
3563 | void avcodec_register_all(void); | ||
3564 | |||
3565 | /** | ||
3566 | * Flush buffers, should be called when seeking or when switching to a different stream. | ||
3567 | */ | ||
3568 | void avcodec_flush_buffers(AVCodecContext *avctx); | ||
3569 | |||
3570 | void avcodec_default_free_buffers(AVCodecContext *s); | ||
3571 | |||
3572 | /* misc useful functions */ | ||
3573 | |||
3574 | /** | ||
3575 | * Returns a single letter to describe the given picture type pict_type. | ||
3576 | * | ||
3577 | * @param[in] pict_type the picture type | ||
3578 | * @return A single character representing the picture type. | ||
3579 | */ | ||
3580 | char av_get_pict_type_char(int pict_type); | ||
3581 | |||
3582 | /** | ||
3583 | * Returns codec bits per sample. | ||
3584 | * | ||
3585 | * @param[in] codec_id the codec | ||
3586 | * @return Number of bits per sample or zero if unknown for the given codec. | ||
3587 | */ | ||
3588 | int av_get_bits_per_sample(enum CodecID codec_id); | ||
3589 | |||
3590 | /** | ||
3591 | * Returns sample format bits per sample. | ||
3592 | * | ||
3593 | * @param[in] sample_fmt the sample format | ||
3594 | * @return Number of bits per sample or zero if unknown for the given sample format. | ||
3595 | */ | ||
3596 | int av_get_bits_per_sample_format(enum SampleFormat sample_fmt); | ||
3597 | |||
3598 | /* frame parsing */ | ||
3599 | typedef struct AVCodecParserContext { | ||
3600 | void *priv_data; | ||
3601 | struct AVCodecParser *parser; | ||
3602 | int64_t frame_offset; /* offset of the current frame */ | ||
3603 | int64_t cur_offset; /* current offset | ||
3604 | (incremented by each av_parser_parse()) */ | ||
3605 | int64_t next_frame_offset; /* offset of the next frame */ | ||
3606 | /* video info */ | ||
3607 | int pict_type; /* XXX: Put it back in AVCodecContext. */ | ||
3608 | /** | ||
3609 | * This field is used for proper frame duration computation in lavf. | ||
3610 | * It signals, how much longer the frame duration of the current frame | ||
3611 | * is compared to normal frame duration. | ||
3612 | * | ||
3613 | * frame_duration = (1 + repeat_pict) * time_base | ||
3614 | * | ||
3615 | * It is used by codecs like H.264 to display telecined material. | ||
3616 | */ | ||
3617 | int repeat_pict; /* XXX: Put it back in AVCodecContext. */ | ||
3618 | int64_t pts; /* pts of the current frame */ | ||
3619 | int64_t dts; /* dts of the current frame */ | ||
3620 | |||
3621 | /* private data */ | ||
3622 | int64_t last_pts; | ||
3623 | int64_t last_dts; | ||
3624 | int fetch_timestamp; | ||
3625 | |||
3626 | #define AV_PARSER_PTS_NB 4 | ||
3627 | int cur_frame_start_index; | ||
3628 | int64_t cur_frame_offset[AV_PARSER_PTS_NB]; | ||
3629 | int64_t cur_frame_pts[AV_PARSER_PTS_NB]; | ||
3630 | int64_t cur_frame_dts[AV_PARSER_PTS_NB]; | ||
3631 | |||
3632 | int flags; | ||
3633 | #define PARSER_FLAG_COMPLETE_FRAMES 0x0001 | ||
3634 | |||
3635 | int64_t offset; ///< byte offset from starting packet start | ||
3636 | int64_t cur_frame_end[AV_PARSER_PTS_NB]; | ||
3637 | |||
3638 | /*! | ||
3639 | * Set by parser to 1 for key frames and 0 for non-key frames. | ||
3640 | * It is initialized to -1, so if the parser doesn't set this flag, | ||
3641 | * old-style fallback using FF_I_TYPE picture type as key frames | ||
3642 | * will be used. | ||
3643 | */ | ||
3644 | int key_frame; | ||
3645 | |||
3646 | /** | ||
3647 | * Time difference in stream time base units from the pts of this | ||
3648 | * packet to the point at which the output from the decoder has converged | ||
3649 | * independent from the availability of previous frames. That is, the | ||
3650 | * frames are virtually identical no matter if decoding started from | ||
3651 | * the very first frame or from this keyframe. | ||
3652 | * Is AV_NOPTS_VALUE if unknown. | ||
3653 | * This field is not the display duration of the current frame. | ||
3654 | * | ||
3655 | * The purpose of this field is to allow seeking in streams that have no | ||
3656 | * keyframes in the conventional sense. It corresponds to the | ||
3657 | * recovery point SEI in H.264 and match_time_delta in NUT. It is also | ||
3658 | * essential for some types of subtitle streams to ensure that all | ||
3659 | * subtitles are correctly displayed after seeking. | ||
3660 | */ | ||
3661 | int64_t convergence_duration; | ||
3662 | |||
3663 | // Timestamp generation support: | ||
3664 | /** | ||
3665 | * Synchronization point for start of timestamp generation. | ||
3666 | * | ||
3667 | * Set to >0 for sync point, 0 for no sync point and <0 for undefined | ||
3668 | * (default). | ||
3669 | * | ||
3670 | * For example, this corresponds to presence of H.264 buffering period | ||
3671 | * SEI message. | ||
3672 | */ | ||
3673 | int dts_sync_point; | ||
3674 | |||
3675 | /** | ||
3676 | * Offset of the current timestamp against last timestamp sync point in | ||
3677 | * units of AVCodecContext.time_base. | ||
3678 | * | ||
3679 | * Set to INT_MIN when dts_sync_point unused. Otherwise, it must | ||
3680 | * contain a valid timestamp offset. | ||
3681 | * | ||
3682 | * Note that the timestamp of sync point has usually a nonzero | ||
3683 | * dts_ref_dts_delta, which refers to the previous sync point. Offset of | ||
3684 | * the next frame after timestamp sync point will be usually 1. | ||
3685 | * | ||
3686 | * For example, this corresponds to H.264 cpb_removal_delay. | ||
3687 | */ | ||
3688 | int dts_ref_dts_delta; | ||
3689 | |||
3690 | /** | ||
3691 | * Presentation delay of current frame in units of AVCodecContext.time_base. | ||
3692 | * | ||
3693 | * Set to INT_MIN when dts_sync_point unused. Otherwise, it must | ||
3694 | * contain valid non-negative timestamp delta (presentation time of a frame | ||
3695 | * must not lie in the past). | ||
3696 | * | ||
3697 | * This delay represents the difference between decoding and presentation | ||
3698 | * time of the frame. | ||
3699 | * | ||
3700 | * For example, this corresponds to H.264 dpb_output_delay. | ||
3701 | */ | ||
3702 | int pts_dts_delta; | ||
3703 | |||
3704 | /** | ||
3705 | * Position of the packet in file. | ||
3706 | * | ||
3707 | * Analogous to cur_frame_pts/dts | ||
3708 | */ | ||
3709 | int64_t cur_frame_pos[AV_PARSER_PTS_NB]; | ||
3710 | |||
3711 | /** | ||
3712 | * Byte position of currently parsed frame in stream. | ||
3713 | */ | ||
3714 | int64_t pos; | ||
3715 | |||
3716 | /** | ||
3717 | * Previous frame byte position. | ||
3718 | */ | ||
3719 | int64_t last_pos; | ||
3720 | } AVCodecParserContext; | ||
3721 | |||
3722 | typedef struct AVCodecParser { | ||
3723 | int codec_ids[5]; /* several codec IDs are permitted */ | ||
3724 | int priv_data_size; | ||
3725 | int (*parser_init)(AVCodecParserContext *s); | ||
3726 | int (*parser_parse)(AVCodecParserContext *s, | ||
3727 | AVCodecContext *avctx, | ||
3728 | const uint8_t **poutbuf, int *poutbuf_size, | ||
3729 | const uint8_t *buf, int buf_size); | ||
3730 | void (*parser_close)(AVCodecParserContext *s); | ||
3731 | int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); | ||
3732 | struct AVCodecParser *next; | ||
3733 | } AVCodecParser; | ||
3734 | |||
3735 | AVCodecParser *av_parser_next(AVCodecParser *c); | ||
3736 | |||
3737 | void av_register_codec_parser(AVCodecParser *parser); | ||
3738 | AVCodecParserContext *av_parser_init(int codec_id); | ||
3739 | |||
3740 | #if LIBAVCODEC_VERSION_MAJOR < 53 | ||
3741 | attribute_deprecated | ||
3742 | int av_parser_parse(AVCodecParserContext *s, | ||
3743 | AVCodecContext *avctx, | ||
3744 | uint8_t **poutbuf, int *poutbuf_size, | ||
3745 | const uint8_t *buf, int buf_size, | ||
3746 | int64_t pts, int64_t dts); | ||
3747 | #endif | ||
3748 | |||
3749 | /** | ||
3750 | * Parse a packet. | ||
3751 | * | ||
3752 | * @param s parser context. | ||
3753 | * @param avctx codec context. | ||
3754 | * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. | ||
3755 | * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. | ||
3756 | * @param buf input buffer. | ||
3757 | * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). | ||
3758 | * @param pts input presentation timestamp. | ||
3759 | * @param dts input decoding timestamp. | ||
3760 | * @param pos input byte position in stream. | ||
3761 | * @return the number of bytes of the input bitstream used. | ||
3762 | * | ||
3763 | * Example: | ||
3764 | * @code | ||
3765 | * while(in_len){ | ||
3766 | * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, | ||
3767 | * in_data, in_len, | ||
3768 | * pts, dts, pos); | ||
3769 | * in_data += len; | ||
3770 | * in_len -= len; | ||
3771 | * | ||
3772 | * if(size) | ||
3773 | * decode_frame(data, size); | ||
3774 | * } | ||
3775 | * @endcode | ||
3776 | */ | ||
3777 | int av_parser_parse2(AVCodecParserContext *s, | ||
3778 | AVCodecContext *avctx, | ||
3779 | uint8_t **poutbuf, int *poutbuf_size, | ||
3780 | const uint8_t *buf, int buf_size, | ||
3781 | int64_t pts, int64_t dts, | ||
3782 | int64_t pos); | ||
3783 | |||
3784 | int av_parser_change(AVCodecParserContext *s, | ||
3785 | AVCodecContext *avctx, | ||
3786 | uint8_t **poutbuf, int *poutbuf_size, | ||
3787 | const uint8_t *buf, int buf_size, int keyframe); | ||
3788 | void av_parser_close(AVCodecParserContext *s); | ||
3789 | |||
3790 | |||
3791 | typedef struct AVBitStreamFilterContext { | ||
3792 | void *priv_data; | ||
3793 | struct AVBitStreamFilter *filter; | ||
3794 | AVCodecParserContext *parser; | ||
3795 | struct AVBitStreamFilterContext *next; | ||
3796 | } AVBitStreamFilterContext; | ||
3797 | |||
3798 | |||
3799 | typedef struct AVBitStreamFilter { | ||
3800 | const char *name; | ||
3801 | int priv_data_size; | ||
3802 | int (*filter)(AVBitStreamFilterContext *bsfc, | ||
3803 | AVCodecContext *avctx, const char *args, | ||
3804 | uint8_t **poutbuf, int *poutbuf_size, | ||
3805 | const uint8_t *buf, int buf_size, int keyframe); | ||
3806 | void (*close)(AVBitStreamFilterContext *bsfc); | ||
3807 | struct AVBitStreamFilter *next; | ||
3808 | } AVBitStreamFilter; | ||
3809 | |||
3810 | void av_register_bitstream_filter(AVBitStreamFilter *bsf); | ||
3811 | AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); | ||
3812 | int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, | ||
3813 | AVCodecContext *avctx, const char *args, | ||
3814 | uint8_t **poutbuf, int *poutbuf_size, | ||
3815 | const uint8_t *buf, int buf_size, int keyframe); | ||
3816 | void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); | ||
3817 | |||
3818 | AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); | ||
3819 | |||
3820 | /* memory */ | ||
3821 | |||
3822 | /** | ||
3823 | * Reallocates the given block if it is not large enough, otherwise it | ||
3824 | * does nothing. | ||
3825 | * | ||
3826 | * @see av_realloc | ||
3827 | */ | ||
3828 | void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); | ||
3829 | |||
3830 | /** | ||
3831 | * Allocates a buffer, reusing the given one if large enough. | ||
3832 | * | ||
3833 | * Contrary to av_fast_realloc the current buffer contents might not be | ||
3834 | * preserved and on error the old buffer is freed, thus no special | ||
3835 | * handling to avoid memleaks is necessary. | ||
3836 | * | ||
3837 | * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer | ||
3838 | * @param size size of the buffer *ptr points to | ||
3839 | * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and | ||
3840 | * *size 0 if an error occurred. | ||
3841 | */ | ||
3842 | void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size); | ||
3843 | |||
3844 | /** | ||
3845 | * Copy image 'src' to 'dst'. | ||
3846 | */ | ||
3847 | void av_picture_copy(AVPicture *dst, const AVPicture *src, | ||
3848 | enum PixelFormat pix_fmt, int width, int height); | ||
3849 | |||
3850 | /** | ||
3851 | * Crop image top and left side. | ||
3852 | */ | ||
3853 | int av_picture_crop(AVPicture *dst, const AVPicture *src, | ||
3854 | enum PixelFormat pix_fmt, int top_band, int left_band); | ||
3855 | |||
3856 | /** | ||
3857 | * Pad image. | ||
3858 | */ | ||
3859 | int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt, | ||
3860 | int padtop, int padbottom, int padleft, int padright, int *color); | ||
3861 | |||
3862 | /** | ||
3863 | * Encodes extradata length to a buffer. Used by xiph codecs. | ||
3864 | * | ||
3865 | * @param s buffer to write to; must be at least (v/255+1) bytes long | ||
3866 | * @param v size of extradata in bytes | ||
3867 | * @return number of bytes written to the buffer. | ||
3868 | */ | ||
3869 | unsigned int av_xiphlacing(unsigned char *s, unsigned int v); | ||
3870 | |||
3871 | /** | ||
3872 | * Parses str and put in width_ptr and height_ptr the detected values. | ||
3873 | * | ||
3874 | * @return 0 in case of a successful parsing, a negative value otherwise | ||
3875 | * @param[in] str the string to parse: it has to be a string in the format | ||
3876 | * <width>x<height> or a valid video frame size abbreviation. | ||
3877 | * @param[in,out] width_ptr pointer to the variable which will contain the detected | ||
3878 | * frame width value | ||
3879 | * @param[in,out] height_ptr pointer to the variable which will contain the detected | ||
3880 | * frame height value | ||
3881 | */ | ||
3882 | int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); | ||
3883 | |||
3884 | /** | ||
3885 | * Parses str and put in frame_rate the detected values. | ||
3886 | * | ||
3887 | * @return 0 in case of a successful parsing, a negative value otherwise | ||
3888 | * @param[in] str the string to parse: it has to be a string in the format | ||
3889 | * <frame_rate_num>/<frame_rate_den>, a float number or a valid video rate abbreviation | ||
3890 | * @param[in,out] frame_rate pointer to the AVRational which will contain the detected | ||
3891 | * frame rate | ||
3892 | */ | ||
3893 | //int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); | ||
3894 | |||
3895 | /** | ||
3896 | * Logs a generic warning message about a missing feature. This function is | ||
3897 | * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) | ||
3898 | * only, and would normally not be used by applications. | ||
3899 | * @param[in] avc a pointer to an arbitrary struct of which the first field is | ||
3900 | * a pointer to an AVClass struct | ||
3901 | * @param[in] feature string containing the name of the missing feature | ||
3902 | * @param[in] want_sample indicates if samples are wanted which exhibit this feature. | ||
3903 | * If want_sample is non-zero, additional verbage will be added to the log | ||
3904 | * message which tells the user how to report samples to the development | ||
3905 | * mailing list. | ||
3906 | */ | ||
3907 | void av_log_missing_feature(void *avc, const char *feature, int want_sample); | ||
3908 | |||
3909 | /** | ||
3910 | * Logs a generic warning message asking for a sample. This function is | ||
3911 | * intended to be used internally by FFmpeg (libavcodec, libavformat, etc.) | ||
3912 | * only, and would normally not be used by applications. | ||
3913 | * @param[in] avc a pointer to an arbitrary struct of which the first field is | ||
3914 | * a pointer to an AVClass struct | ||
3915 | * @param[in] msg string containing an optional message, or NULL if no message | ||
3916 | */ | ||
3917 | void av_log_ask_for_sample(void *avc, const char *msg); | ||
3918 | |||
3919 | /** | ||
3920 | * Registers the hardware accelerator hwaccel. | ||
3921 | */ | ||
3922 | void av_register_hwaccel(AVHWAccel *hwaccel); | ||
3923 | |||
3924 | /** | ||
3925 | * If hwaccel is NULL, returns the first registered hardware accelerator, | ||
3926 | * if hwaccel is non-NULL, returns the next registered hardware accelerator | ||
3927 | * after hwaccel, or NULL if hwaccel is the last one. | ||
3928 | */ | ||
3929 | AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); | ||
3930 | |||
3931 | |||
3932 | /** | ||
3933 | * Lock operation used by lockmgr | ||
3934 | */ | ||
3935 | enum AVLockOp { | ||
3936 | AV_LOCK_CREATE, ///< Create a mutex | ||
3937 | AV_LOCK_OBTAIN, ///< Lock the mutex | ||
3938 | AV_LOCK_RELEASE, ///< Unlock the mutex | ||
3939 | AV_LOCK_DESTROY, ///< Free mutex resources | ||
3940 | }; | ||
3941 | |||
3942 | /** | ||
3943 | * Register a user provided lock manager supporting the operations | ||
3944 | * specified by AVLockOp. mutex points to a (void *) where the | ||
3945 | * lockmgr should store/get a pointer to a user allocated mutex. It's | ||
3946 | * NULL upon AV_LOCK_CREATE and != NULL for all other ops. | ||
3947 | * | ||
3948 | * @param cb User defined callback. Note: FFmpeg may invoke calls to this | ||
3949 | * callback during the call to av_lockmgr_register(). | ||
3950 | * Thus, the application must be prepared to handle that. | ||
3951 | * If cb is set to NULL the lockmgr will be unregistered. | ||
3952 | * Also note that during unregistration the previously registered | ||
3953 | * lockmgr callback may also be invoked. | ||
3954 | */ | ||
3955 | int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); | ||
3956 | |||
3957 | #endif /* AVCODEC_AVCODEC_H */ | ||
diff --git a/apps/codecs/libwmapro/avfft.h b/apps/codecs/libwmapro/avfft.h deleted file mode 100644 index 623f0a33b5..0000000000 --- a/apps/codecs/libwmapro/avfft.h +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of FFmpeg. | ||
3 | * | ||
4 | * FFmpeg is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * FFmpeg is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with FFmpeg; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | #ifndef AVCODEC_AVFFT_H | ||
20 | #define AVCODEC_AVFFT_H | ||
21 | |||
22 | typedef float FFTSample; | ||
23 | |||
24 | typedef struct FFTComplex { | ||
25 | FFTSample re, im; | ||
26 | } FFTComplex; | ||
27 | |||
28 | typedef struct FFTContext FFTContext; | ||
29 | |||
30 | /** | ||
31 | * Set up a complex FFT. | ||
32 | * @param nbits log2 of the length of the input array | ||
33 | * @param inverse if 0 perform the forward transform, if 1 perform the inverse | ||
34 | */ | ||
35 | FFTContext *av_fft_init(int nbits, int inverse); | ||
36 | |||
37 | /** | ||
38 | * Do the permutation needed BEFORE calling ff_fft_calc(). | ||
39 | */ | ||
40 | void av_fft_permute(FFTContext *s, FFTComplex *z); | ||
41 | |||
42 | /** | ||
43 | * Do a complex FFT with the parameters defined in av_fft_init(). The | ||
44 | * input data must be permuted before. No 1.0/sqrt(n) normalization is done. | ||
45 | */ | ||
46 | void av_fft_calc(FFTContext *s, FFTComplex *z); | ||
47 | |||
48 | void av_fft_end(FFTContext *s); | ||
49 | |||
50 | FFTContext *av_mdct_init(int nbits, int inverse, double scale); | ||
51 | void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
52 | void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
53 | void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
54 | void av_mdct_end(FFTContext *s); | ||
55 | |||
56 | /* Real Discrete Fourier Transform */ | ||
57 | |||
58 | enum RDFTransformType { | ||
59 | DFT_R2C, | ||
60 | IDFT_C2R, | ||
61 | IDFT_R2C, | ||
62 | DFT_C2R, | ||
63 | }; | ||
64 | |||
65 | typedef struct RDFTContext RDFTContext; | ||
66 | |||
67 | /** | ||
68 | * Set up a real FFT. | ||
69 | * @param nbits log2 of the length of the input array | ||
70 | * @param trans the type of transform | ||
71 | */ | ||
72 | RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); | ||
73 | void av_rdft_calc(RDFTContext *s, FFTSample *data); | ||
74 | void av_rdft_end(RDFTContext *s); | ||
75 | |||
76 | /* Discrete Cosine Transform */ | ||
77 | |||
78 | typedef struct DCTContext DCTContext; | ||
79 | |||
80 | enum DCTTransformType { | ||
81 | DCT_II = 0, | ||
82 | DCT_III, | ||
83 | DCT_I, | ||
84 | DST_I, | ||
85 | }; | ||
86 | |||
87 | /** | ||
88 | * Sets up DCT. | ||
89 | * @param nbits size of the input array: | ||
90 | * (1 << nbits) for DCT-II, DCT-III and DST-I | ||
91 | * (1 << nbits) + 1 for DCT-I | ||
92 | * | ||
93 | * @note the first element of the input of DST-I is ignored | ||
94 | */ | ||
95 | DCTContext *av_dct_init(int nbits, enum DCTTransformType type); | ||
96 | void av_dct_calc(DCTContext *s, FFTSample *data); | ||
97 | void av_dct_end (DCTContext *s); | ||
98 | |||
99 | #endif /* AVCODEC_AVFFT_H */ | ||
diff --git a/apps/codecs/libwmapro/bitstream.c b/apps/codecs/libwmapro/bitstream.c index 4ae9727ac0..142ffa7651 100644 --- a/apps/codecs/libwmapro/bitstream.c +++ b/apps/codecs/libwmapro/bitstream.c | |||
@@ -28,12 +28,37 @@ | |||
28 | * bitstream api. | 28 | * bitstream api. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include "avcodec.h" | ||
32 | #include "get_bits.h" | 31 | #include "get_bits.h" |
33 | #include "put_bits.h" | 32 | #include "put_bits.h" |
33 | #include <string.h> | ||
34 | 34 | ||
35 | #define av_log(...) | 35 | #define av_log(...) |
36 | 36 | ||
37 | /* Taken from libavutil/common.h */ | ||
38 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
39 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
40 | |||
41 | /* av_reverse - taken from libavutil/mathematics.c*/ | ||
42 | const uint8_t av_reverse[256]={ | ||
43 | 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, | ||
44 | 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, | ||
45 | 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, | ||
46 | 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, | ||
47 | 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, | ||
48 | 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, | ||
49 | 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, | ||
50 | 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, | ||
51 | 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, | ||
52 | 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, | ||
53 | 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, | ||
54 | 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, | ||
55 | 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, | ||
56 | 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, | ||
57 | 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, | ||
58 | 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, | ||
59 | }; | ||
60 | |||
61 | |||
37 | const uint8_t ff_log2_run[32]={ | 62 | const uint8_t ff_log2_run[32]={ |
38 | 0, 0, 0, 0, 1, 1, 1, 1, | 63 | 0, 0, 0, 0, 1, 1, 1, 1, |
39 | 2, 2, 2, 2, 3, 3, 3, 3, | 64 | 2, 2, 2, 2, 3, 3, 3, 3, |
@@ -120,7 +145,7 @@ static int alloc_table(VLC *vlc, int size, int use_static) | |||
120 | return index; | 145 | return index; |
121 | } | 146 | } |
122 | 147 | ||
123 | static av_always_inline uint32_t bitswap_32(uint32_t x) { | 148 | static inline uint32_t bitswap_32(uint32_t x) { |
124 | return av_reverse[x&0xFF]<<24 | 149 | return av_reverse[x&0xFF]<<24 |
125 | | av_reverse[(x>>8)&0xFF]<<16 | 150 | | av_reverse[(x>>8)&0xFF]<<16 |
126 | | av_reverse[(x>>16)&0xFF]<<8 | 151 | | av_reverse[(x>>16)&0xFF]<<8 |
diff --git a/apps/codecs/libwmapro/dsputil.c b/apps/codecs/libwmapro/dsputil.c deleted file mode 100644 index b09311925a..0000000000 --- a/apps/codecs/libwmapro/dsputil.c +++ /dev/null | |||
@@ -1,4572 +0,0 @@ | |||
1 | /* | ||
2 | * DSP utils | ||
3 | * Copyright (c) 2000, 2001 Fabrice Bellard | ||
4 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at> | ||
7 | * | ||
8 | * This file is part of FFmpeg. | ||
9 | * | ||
10 | * FFmpeg is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU Lesser General Public | ||
12 | * License as published by the Free Software Foundation; either | ||
13 | * version 2.1 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * FFmpeg is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * Lesser General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Lesser General Public | ||
21 | * License along with FFmpeg; if not, write to the Free Software | ||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
23 | */ | ||
24 | |||
25 | /** | ||
26 | * @file libavcodec/dsputil.c | ||
27 | * DSP utils | ||
28 | */ | ||
29 | |||
30 | #include "avcodec.h" | ||
31 | #include "dsputil.h" | ||
32 | //#include "simple_idct.h" | ||
33 | //#include "faandct.h" | ||
34 | //#include "faanidct.h" | ||
35 | #include "mathops.h" | ||
36 | //#include "mpegvideo.h" | ||
37 | //#include "config.h" | ||
38 | //#include "lpc.h" | ||
39 | //#include "ac3dec.h" | ||
40 | //#include "vorbis.h" | ||
41 | //#include "png.h" | ||
42 | |||
43 | #if 0 | ||
44 | uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; | ||
45 | uint32_t ff_squareTbl[512] = {0, }; | ||
46 | |||
47 | // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size | ||
48 | #define pb_7f (~0UL/255 * 0x7f) | ||
49 | #define pb_80 (~0UL/255 * 0x80) | ||
50 | |||
51 | const uint8_t ff_zigzag_direct[64] = { | ||
52 | 0, 1, 8, 16, 9, 2, 3, 10, | ||
53 | 17, 24, 32, 25, 18, 11, 4, 5, | ||
54 | 12, 19, 26, 33, 40, 48, 41, 34, | ||
55 | 27, 20, 13, 6, 7, 14, 21, 28, | ||
56 | 35, 42, 49, 56, 57, 50, 43, 36, | ||
57 | 29, 22, 15, 23, 30, 37, 44, 51, | ||
58 | 58, 59, 52, 45, 38, 31, 39, 46, | ||
59 | 53, 60, 61, 54, 47, 55, 62, 63 | ||
60 | }; | ||
61 | |||
62 | /* Specific zigzag scan for 248 idct. NOTE that unlike the | ||
63 | specification, we interleave the fields */ | ||
64 | const uint8_t ff_zigzag248_direct[64] = { | ||
65 | 0, 8, 1, 9, 16, 24, 2, 10, | ||
66 | 17, 25, 32, 40, 48, 56, 33, 41, | ||
67 | 18, 26, 3, 11, 4, 12, 19, 27, | ||
68 | 34, 42, 49, 57, 50, 58, 35, 43, | ||
69 | 20, 28, 5, 13, 6, 14, 21, 29, | ||
70 | 36, 44, 51, 59, 52, 60, 37, 45, | ||
71 | 22, 30, 7, 15, 23, 31, 38, 46, | ||
72 | 53, 61, 54, 62, 39, 47, 55, 63, | ||
73 | }; | ||
74 | |||
75 | /* not permutated inverse zigzag_direct + 1 for MMX quantizer */ | ||
76 | DECLARE_ALIGNED(16, uint16_t, inv_zigzag_direct16)[64]; | ||
77 | |||
78 | const uint8_t ff_alternate_horizontal_scan[64] = { | ||
79 | 0, 1, 2, 3, 8, 9, 16, 17, | ||
80 | 10, 11, 4, 5, 6, 7, 15, 14, | ||
81 | 13, 12, 19, 18, 24, 25, 32, 33, | ||
82 | 26, 27, 20, 21, 22, 23, 28, 29, | ||
83 | 30, 31, 34, 35, 40, 41, 48, 49, | ||
84 | 42, 43, 36, 37, 38, 39, 44, 45, | ||
85 | 46, 47, 50, 51, 56, 57, 58, 59, | ||
86 | 52, 53, 54, 55, 60, 61, 62, 63, | ||
87 | }; | ||
88 | |||
89 | const uint8_t ff_alternate_vertical_scan[64] = { | ||
90 | 0, 8, 16, 24, 1, 9, 2, 10, | ||
91 | 17, 25, 32, 40, 48, 56, 57, 49, | ||
92 | 41, 33, 26, 18, 3, 11, 4, 12, | ||
93 | 19, 27, 34, 42, 50, 58, 35, 43, | ||
94 | 51, 59, 20, 28, 5, 13, 6, 14, | ||
95 | 21, 29, 36, 44, 52, 60, 37, 45, | ||
96 | 53, 61, 22, 30, 7, 15, 23, 31, | ||
97 | 38, 46, 54, 62, 39, 47, 55, 63, | ||
98 | }; | ||
99 | |||
100 | /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256 | ||
101 | * for a>16909558, is an overestimate by less than 1 part in 1<<24 */ | ||
102 | const uint32_t ff_inverse[257]={ | ||
103 | 0, 4294967295U,2147483648U,1431655766, 1073741824, 858993460, 715827883, 613566757, | ||
104 | 536870912, 477218589, 429496730, 390451573, 357913942, 330382100, 306783379, 286331154, | ||
105 | 268435456, 252645136, 238609295, 226050911, 214748365, 204522253, 195225787, 186737709, | ||
106 | 178956971, 171798692, 165191050, 159072863, 153391690, 148102321, 143165577, 138547333, | ||
107 | 134217728, 130150525, 126322568, 122713352, 119304648, 116080198, 113025456, 110127367, | ||
108 | 107374183, 104755300, 102261127, 99882961, 97612894, 95443718, 93368855, 91382283, | ||
109 | 89478486, 87652394, 85899346, 84215046, 82595525, 81037119, 79536432, 78090315, | ||
110 | 76695845, 75350304, 74051161, 72796056, 71582789, 70409300, 69273667, 68174085, | ||
111 | 67108864, 66076420, 65075263, 64103990, 63161284, 62245903, 61356676, 60492498, | ||
112 | 59652324, 58835169, 58040099, 57266231, 56512728, 55778797, 55063684, 54366675, | ||
113 | 53687092, 53024288, 52377650, 51746594, 51130564, 50529028, 49941481, 49367441, | ||
114 | 48806447, 48258060, 47721859, 47197443, 46684428, 46182445, 45691142, 45210183, | ||
115 | 44739243, 44278014, 43826197, 43383509, 42949673, 42524429, 42107523, 41698712, | ||
116 | 41297763, 40904451, 40518560, 40139882, 39768216, 39403370, 39045158, 38693400, | ||
117 | 38347923, 38008561, 37675152, 37347542, 37025581, 36709123, 36398028, 36092163, | ||
118 | 35791395, 35495598, 35204650, 34918434, 34636834, 34359739, 34087043, 33818641, | ||
119 | 33554432, 33294321, 33038210, 32786010, 32537632, 32292988, 32051995, 31814573, | ||
120 | 31580642, 31350127, 31122952, 30899046, 30678338, 30460761, 30246249, 30034737, | ||
121 | 29826162, 29620465, 29417585, 29217465, 29020050, 28825284, 28633116, 28443493, | ||
122 | 28256364, 28071682, 27889399, 27709467, 27531842, 27356480, 27183338, 27012373, | ||
123 | 26843546, 26676816, 26512144, 26349493, 26188825, 26030105, 25873297, 25718368, | ||
124 | 25565282, 25414008, 25264514, 25116768, 24970741, 24826401, 24683721, 24542671, | ||
125 | 24403224, 24265352, 24129030, 23994231, 23860930, 23729102, 23598722, 23469767, | ||
126 | 23342214, 23216040, 23091223, 22967740, 22845571, 22724695, 22605092, 22486740, | ||
127 | 22369622, 22253717, 22139007, 22025474, 21913099, 21801865, 21691755, 21582751, | ||
128 | 21474837, 21367997, 21262215, 21157475, 21053762, 20951060, 20849356, 20748635, | ||
129 | 20648882, 20550083, 20452226, 20355296, 20259280, 20164166, 20069941, 19976593, | ||
130 | 19884108, 19792477, 19701685, 19611723, 19522579, 19434242, 19346700, 19259944, | ||
131 | 19173962, 19088744, 19004281, 18920561, 18837576, 18755316, 18673771, 18592933, | ||
132 | 18512791, 18433337, 18354562, 18276457, 18199014, 18122225, 18046082, 17970575, | ||
133 | 17895698, 17821442, 17747799, 17674763, 17602325, 17530479, 17459217, 17388532, | ||
134 | 17318417, 17248865, 17179870, 17111424, 17043522, 16976156, 16909321, 16843010, | ||
135 | 16777216 | ||
136 | }; | ||
137 | |||
138 | /* Input permutation for the simple_idct_mmx */ | ||
139 | static const uint8_t simple_mmx_permutation[64]={ | ||
140 | 0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D, | ||
141 | 0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D, | ||
142 | 0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D, | ||
143 | 0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F, | ||
144 | 0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F, | ||
145 | 0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D, | ||
146 | 0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F, | ||
147 | 0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F, | ||
148 | }; | ||
149 | |||
150 | static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7}; | ||
151 | |||
152 | void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){ | ||
153 | int i; | ||
154 | int end; | ||
155 | |||
156 | st->scantable= src_scantable; | ||
157 | |||
158 | for(i=0; i<64; i++){ | ||
159 | int j; | ||
160 | j = src_scantable[i]; | ||
161 | st->permutated[i] = permutation[j]; | ||
162 | #if ARCH_PPC | ||
163 | st->inverse[j] = i; | ||
164 | #endif | ||
165 | } | ||
166 | |||
167 | end=-1; | ||
168 | for(i=0; i<64; i++){ | ||
169 | int j; | ||
170 | j = st->permutated[i]; | ||
171 | if(j>end) end=j; | ||
172 | st->raster_end[i]= end; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | static int pix_sum_c(uint8_t * pix, int line_size) | ||
177 | { | ||
178 | int s, i, j; | ||
179 | |||
180 | s = 0; | ||
181 | for (i = 0; i < 16; i++) { | ||
182 | for (j = 0; j < 16; j += 8) { | ||
183 | s += pix[0]; | ||
184 | s += pix[1]; | ||
185 | s += pix[2]; | ||
186 | s += pix[3]; | ||
187 | s += pix[4]; | ||
188 | s += pix[5]; | ||
189 | s += pix[6]; | ||
190 | s += pix[7]; | ||
191 | pix += 8; | ||
192 | } | ||
193 | pix += line_size - 16; | ||
194 | } | ||
195 | return s; | ||
196 | } | ||
197 | |||
198 | static int pix_norm1_c(uint8_t * pix, int line_size) | ||
199 | { | ||
200 | int s, i, j; | ||
201 | uint32_t *sq = ff_squareTbl + 256; | ||
202 | |||
203 | s = 0; | ||
204 | for (i = 0; i < 16; i++) { | ||
205 | for (j = 0; j < 16; j += 8) { | ||
206 | #if 0 | ||
207 | s += sq[pix[0]]; | ||
208 | s += sq[pix[1]]; | ||
209 | s += sq[pix[2]]; | ||
210 | s += sq[pix[3]]; | ||
211 | s += sq[pix[4]]; | ||
212 | s += sq[pix[5]]; | ||
213 | s += sq[pix[6]]; | ||
214 | s += sq[pix[7]]; | ||
215 | #else | ||
216 | #if LONG_MAX > 2147483647 | ||
217 | register uint64_t x=*(uint64_t*)pix; | ||
218 | s += sq[x&0xff]; | ||
219 | s += sq[(x>>8)&0xff]; | ||
220 | s += sq[(x>>16)&0xff]; | ||
221 | s += sq[(x>>24)&0xff]; | ||
222 | s += sq[(x>>32)&0xff]; | ||
223 | s += sq[(x>>40)&0xff]; | ||
224 | s += sq[(x>>48)&0xff]; | ||
225 | s += sq[(x>>56)&0xff]; | ||
226 | #else | ||
227 | register uint32_t x=*(uint32_t*)pix; | ||
228 | s += sq[x&0xff]; | ||
229 | s += sq[(x>>8)&0xff]; | ||
230 | s += sq[(x>>16)&0xff]; | ||
231 | s += sq[(x>>24)&0xff]; | ||
232 | x=*(uint32_t*)(pix+4); | ||
233 | s += sq[x&0xff]; | ||
234 | s += sq[(x>>8)&0xff]; | ||
235 | s += sq[(x>>16)&0xff]; | ||
236 | s += sq[(x>>24)&0xff]; | ||
237 | #endif | ||
238 | #endif | ||
239 | pix += 8; | ||
240 | } | ||
241 | pix += line_size - 16; | ||
242 | } | ||
243 | return s; | ||
244 | } | ||
245 | |||
246 | static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){ | ||
247 | int i; | ||
248 | |||
249 | for(i=0; i+8<=w; i+=8){ | ||
250 | dst[i+0]= bswap_32(src[i+0]); | ||
251 | dst[i+1]= bswap_32(src[i+1]); | ||
252 | dst[i+2]= bswap_32(src[i+2]); | ||
253 | dst[i+3]= bswap_32(src[i+3]); | ||
254 | dst[i+4]= bswap_32(src[i+4]); | ||
255 | dst[i+5]= bswap_32(src[i+5]); | ||
256 | dst[i+6]= bswap_32(src[i+6]); | ||
257 | dst[i+7]= bswap_32(src[i+7]); | ||
258 | } | ||
259 | for(;i<w; i++){ | ||
260 | dst[i+0]= bswap_32(src[i+0]); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) | ||
265 | { | ||
266 | int s, i; | ||
267 | uint32_t *sq = ff_squareTbl + 256; | ||
268 | |||
269 | s = 0; | ||
270 | for (i = 0; i < h; i++) { | ||
271 | s += sq[pix1[0] - pix2[0]]; | ||
272 | s += sq[pix1[1] - pix2[1]]; | ||
273 | s += sq[pix1[2] - pix2[2]]; | ||
274 | s += sq[pix1[3] - pix2[3]]; | ||
275 | pix1 += line_size; | ||
276 | pix2 += line_size; | ||
277 | } | ||
278 | return s; | ||
279 | } | ||
280 | |||
281 | static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) | ||
282 | { | ||
283 | int s, i; | ||
284 | uint32_t *sq = ff_squareTbl + 256; | ||
285 | |||
286 | s = 0; | ||
287 | for (i = 0; i < h; i++) { | ||
288 | s += sq[pix1[0] - pix2[0]]; | ||
289 | s += sq[pix1[1] - pix2[1]]; | ||
290 | s += sq[pix1[2] - pix2[2]]; | ||
291 | s += sq[pix1[3] - pix2[3]]; | ||
292 | s += sq[pix1[4] - pix2[4]]; | ||
293 | s += sq[pix1[5] - pix2[5]]; | ||
294 | s += sq[pix1[6] - pix2[6]]; | ||
295 | s += sq[pix1[7] - pix2[7]]; | ||
296 | pix1 += line_size; | ||
297 | pix2 += line_size; | ||
298 | } | ||
299 | return s; | ||
300 | } | ||
301 | |||
302 | static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
303 | { | ||
304 | int s, i; | ||
305 | uint32_t *sq = ff_squareTbl + 256; | ||
306 | |||
307 | s = 0; | ||
308 | for (i = 0; i < h; i++) { | ||
309 | s += sq[pix1[ 0] - pix2[ 0]]; | ||
310 | s += sq[pix1[ 1] - pix2[ 1]]; | ||
311 | s += sq[pix1[ 2] - pix2[ 2]]; | ||
312 | s += sq[pix1[ 3] - pix2[ 3]]; | ||
313 | s += sq[pix1[ 4] - pix2[ 4]]; | ||
314 | s += sq[pix1[ 5] - pix2[ 5]]; | ||
315 | s += sq[pix1[ 6] - pix2[ 6]]; | ||
316 | s += sq[pix1[ 7] - pix2[ 7]]; | ||
317 | s += sq[pix1[ 8] - pix2[ 8]]; | ||
318 | s += sq[pix1[ 9] - pix2[ 9]]; | ||
319 | s += sq[pix1[10] - pix2[10]]; | ||
320 | s += sq[pix1[11] - pix2[11]]; | ||
321 | s += sq[pix1[12] - pix2[12]]; | ||
322 | s += sq[pix1[13] - pix2[13]]; | ||
323 | s += sq[pix1[14] - pix2[14]]; | ||
324 | s += sq[pix1[15] - pix2[15]]; | ||
325 | |||
326 | pix1 += line_size; | ||
327 | pix2 += line_size; | ||
328 | } | ||
329 | return s; | ||
330 | } | ||
331 | |||
332 | /* draw the edges of width 'w' of an image of size width, height */ | ||
333 | //FIXME check that this is ok for mpeg4 interlaced | ||
334 | static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w) | ||
335 | { | ||
336 | uint8_t *ptr, *last_line; | ||
337 | int i; | ||
338 | |||
339 | last_line = buf + (height - 1) * wrap; | ||
340 | for(i=0;i<w;i++) { | ||
341 | /* top and bottom */ | ||
342 | memcpy(buf - (i + 1) * wrap, buf, width); | ||
343 | memcpy(last_line + (i + 1) * wrap, last_line, width); | ||
344 | } | ||
345 | /* left and right */ | ||
346 | ptr = buf; | ||
347 | for(i=0;i<height;i++) { | ||
348 | memset(ptr - w, ptr[0], w); | ||
349 | memset(ptr + width, ptr[width-1], w); | ||
350 | ptr += wrap; | ||
351 | } | ||
352 | /* corners */ | ||
353 | for(i=0;i<w;i++) { | ||
354 | memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */ | ||
355 | memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */ | ||
356 | memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ | ||
357 | memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ | ||
358 | } | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples. | ||
363 | * @param buf destination buffer | ||
364 | * @param src source buffer | ||
365 | * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers | ||
366 | * @param block_w width of block | ||
367 | * @param block_h height of block | ||
368 | * @param src_x x coordinate of the top left sample of the block in the source buffer | ||
369 | * @param src_y y coordinate of the top left sample of the block in the source buffer | ||
370 | * @param w width of the source buffer | ||
371 | * @param h height of the source buffer | ||
372 | */ | ||
373 | void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h, | ||
374 | int src_x, int src_y, int w, int h){ | ||
375 | int x, y; | ||
376 | int start_y, start_x, end_y, end_x; | ||
377 | |||
378 | if(src_y>= h){ | ||
379 | src+= (h-1-src_y)*linesize; | ||
380 | src_y=h-1; | ||
381 | }else if(src_y<=-block_h){ | ||
382 | src+= (1-block_h-src_y)*linesize; | ||
383 | src_y=1-block_h; | ||
384 | } | ||
385 | if(src_x>= w){ | ||
386 | src+= (w-1-src_x); | ||
387 | src_x=w-1; | ||
388 | }else if(src_x<=-block_w){ | ||
389 | src+= (1-block_w-src_x); | ||
390 | src_x=1-block_w; | ||
391 | } | ||
392 | |||
393 | start_y= FFMAX(0, -src_y); | ||
394 | start_x= FFMAX(0, -src_x); | ||
395 | end_y= FFMIN(block_h, h-src_y); | ||
396 | end_x= FFMIN(block_w, w-src_x); | ||
397 | |||
398 | // copy existing part | ||
399 | for(y=start_y; y<end_y; y++){ | ||
400 | for(x=start_x; x<end_x; x++){ | ||
401 | buf[x + y*linesize]= src[x + y*linesize]; | ||
402 | } | ||
403 | } | ||
404 | |||
405 | //top | ||
406 | for(y=0; y<start_y; y++){ | ||
407 | for(x=start_x; x<end_x; x++){ | ||
408 | buf[x + y*linesize]= buf[x + start_y*linesize]; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | //bottom | ||
413 | for(y=end_y; y<block_h; y++){ | ||
414 | for(x=start_x; x<end_x; x++){ | ||
415 | buf[x + y*linesize]= buf[x + (end_y-1)*linesize]; | ||
416 | } | ||
417 | } | ||
418 | |||
419 | for(y=0; y<block_h; y++){ | ||
420 | //left | ||
421 | for(x=0; x<start_x; x++){ | ||
422 | buf[x + y*linesize]= buf[start_x + y*linesize]; | ||
423 | } | ||
424 | |||
425 | //right | ||
426 | for(x=end_x; x<block_w; x++){ | ||
427 | buf[x + y*linesize]= buf[end_x - 1 + y*linesize]; | ||
428 | } | ||
429 | } | ||
430 | } | ||
431 | |||
432 | static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) | ||
433 | { | ||
434 | int i; | ||
435 | |||
436 | /* read the pixels */ | ||
437 | for(i=0;i<8;i++) { | ||
438 | block[0] = pixels[0]; | ||
439 | block[1] = pixels[1]; | ||
440 | block[2] = pixels[2]; | ||
441 | block[3] = pixels[3]; | ||
442 | block[4] = pixels[4]; | ||
443 | block[5] = pixels[5]; | ||
444 | block[6] = pixels[6]; | ||
445 | block[7] = pixels[7]; | ||
446 | pixels += line_size; | ||
447 | block += 8; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | static void diff_pixels_c(DCTELEM *restrict block, const uint8_t *s1, | ||
452 | const uint8_t *s2, int stride){ | ||
453 | int i; | ||
454 | |||
455 | /* read the pixels */ | ||
456 | for(i=0;i<8;i++) { | ||
457 | block[0] = s1[0] - s2[0]; | ||
458 | block[1] = s1[1] - s2[1]; | ||
459 | block[2] = s1[2] - s2[2]; | ||
460 | block[3] = s1[3] - s2[3]; | ||
461 | block[4] = s1[4] - s2[4]; | ||
462 | block[5] = s1[5] - s2[5]; | ||
463 | block[6] = s1[6] - s2[6]; | ||
464 | block[7] = s1[7] - s2[7]; | ||
465 | s1 += stride; | ||
466 | s2 += stride; | ||
467 | block += 8; | ||
468 | } | ||
469 | } | ||
470 | |||
471 | |||
472 | static void put_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
473 | int line_size) | ||
474 | { | ||
475 | int i; | ||
476 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
477 | |||
478 | /* read the pixels */ | ||
479 | for(i=0;i<8;i++) { | ||
480 | pixels[0] = cm[block[0]]; | ||
481 | pixels[1] = cm[block[1]]; | ||
482 | pixels[2] = cm[block[2]]; | ||
483 | pixels[3] = cm[block[3]]; | ||
484 | pixels[4] = cm[block[4]]; | ||
485 | pixels[5] = cm[block[5]]; | ||
486 | pixels[6] = cm[block[6]]; | ||
487 | pixels[7] = cm[block[7]]; | ||
488 | |||
489 | pixels += line_size; | ||
490 | block += 8; | ||
491 | } | ||
492 | } | ||
493 | |||
494 | static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
495 | int line_size) | ||
496 | { | ||
497 | int i; | ||
498 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
499 | |||
500 | /* read the pixels */ | ||
501 | for(i=0;i<4;i++) { | ||
502 | pixels[0] = cm[block[0]]; | ||
503 | pixels[1] = cm[block[1]]; | ||
504 | pixels[2] = cm[block[2]]; | ||
505 | pixels[3] = cm[block[3]]; | ||
506 | |||
507 | pixels += line_size; | ||
508 | block += 8; | ||
509 | } | ||
510 | } | ||
511 | |||
512 | static void put_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
513 | int line_size) | ||
514 | { | ||
515 | int i; | ||
516 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
517 | |||
518 | /* read the pixels */ | ||
519 | for(i=0;i<2;i++) { | ||
520 | pixels[0] = cm[block[0]]; | ||
521 | pixels[1] = cm[block[1]]; | ||
522 | |||
523 | pixels += line_size; | ||
524 | block += 8; | ||
525 | } | ||
526 | } | ||
527 | |||
528 | static void put_signed_pixels_clamped_c(const DCTELEM *block, | ||
529 | uint8_t *restrict pixels, | ||
530 | int line_size) | ||
531 | { | ||
532 | int i, j; | ||
533 | |||
534 | for (i = 0; i < 8; i++) { | ||
535 | for (j = 0; j < 8; j++) { | ||
536 | if (*block < -128) | ||
537 | *pixels = 0; | ||
538 | else if (*block > 127) | ||
539 | *pixels = 255; | ||
540 | else | ||
541 | *pixels = (uint8_t)(*block + 128); | ||
542 | block++; | ||
543 | pixels++; | ||
544 | } | ||
545 | pixels += (line_size - 8); | ||
546 | } | ||
547 | } | ||
548 | |||
549 | static void put_pixels_nonclamped_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
550 | int line_size) | ||
551 | { | ||
552 | int i; | ||
553 | |||
554 | /* read the pixels */ | ||
555 | for(i=0;i<8;i++) { | ||
556 | pixels[0] = block[0]; | ||
557 | pixels[1] = block[1]; | ||
558 | pixels[2] = block[2]; | ||
559 | pixels[3] = block[3]; | ||
560 | pixels[4] = block[4]; | ||
561 | pixels[5] = block[5]; | ||
562 | pixels[6] = block[6]; | ||
563 | pixels[7] = block[7]; | ||
564 | |||
565 | pixels += line_size; | ||
566 | block += 8; | ||
567 | } | ||
568 | } | ||
569 | |||
570 | static void add_pixels_clamped_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
571 | int line_size) | ||
572 | { | ||
573 | int i; | ||
574 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
575 | |||
576 | /* read the pixels */ | ||
577 | for(i=0;i<8;i++) { | ||
578 | pixels[0] = cm[pixels[0] + block[0]]; | ||
579 | pixels[1] = cm[pixels[1] + block[1]]; | ||
580 | pixels[2] = cm[pixels[2] + block[2]]; | ||
581 | pixels[3] = cm[pixels[3] + block[3]]; | ||
582 | pixels[4] = cm[pixels[4] + block[4]]; | ||
583 | pixels[5] = cm[pixels[5] + block[5]]; | ||
584 | pixels[6] = cm[pixels[6] + block[6]]; | ||
585 | pixels[7] = cm[pixels[7] + block[7]]; | ||
586 | pixels += line_size; | ||
587 | block += 8; | ||
588 | } | ||
589 | } | ||
590 | |||
591 | static void add_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
592 | int line_size) | ||
593 | { | ||
594 | int i; | ||
595 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
596 | |||
597 | /* read the pixels */ | ||
598 | for(i=0;i<4;i++) { | ||
599 | pixels[0] = cm[pixels[0] + block[0]]; | ||
600 | pixels[1] = cm[pixels[1] + block[1]]; | ||
601 | pixels[2] = cm[pixels[2] + block[2]]; | ||
602 | pixels[3] = cm[pixels[3] + block[3]]; | ||
603 | pixels += line_size; | ||
604 | block += 8; | ||
605 | } | ||
606 | } | ||
607 | |||
608 | static void add_pixels_clamped2_c(const DCTELEM *block, uint8_t *restrict pixels, | ||
609 | int line_size) | ||
610 | { | ||
611 | int i; | ||
612 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
613 | |||
614 | /* read the pixels */ | ||
615 | for(i=0;i<2;i++) { | ||
616 | pixels[0] = cm[pixels[0] + block[0]]; | ||
617 | pixels[1] = cm[pixels[1] + block[1]]; | ||
618 | pixels += line_size; | ||
619 | block += 8; | ||
620 | } | ||
621 | } | ||
622 | |||
623 | static void add_pixels8_c(uint8_t *restrict pixels, DCTELEM *block, int line_size) | ||
624 | { | ||
625 | int i; | ||
626 | for(i=0;i<8;i++) { | ||
627 | pixels[0] += block[0]; | ||
628 | pixels[1] += block[1]; | ||
629 | pixels[2] += block[2]; | ||
630 | pixels[3] += block[3]; | ||
631 | pixels[4] += block[4]; | ||
632 | pixels[5] += block[5]; | ||
633 | pixels[6] += block[6]; | ||
634 | pixels[7] += block[7]; | ||
635 | pixels += line_size; | ||
636 | block += 8; | ||
637 | } | ||
638 | } | ||
639 | |||
640 | static void add_pixels4_c(uint8_t *restrict pixels, DCTELEM *block, int line_size) | ||
641 | { | ||
642 | int i; | ||
643 | for(i=0;i<4;i++) { | ||
644 | pixels[0] += block[0]; | ||
645 | pixels[1] += block[1]; | ||
646 | pixels[2] += block[2]; | ||
647 | pixels[3] += block[3]; | ||
648 | pixels += line_size; | ||
649 | block += 4; | ||
650 | } | ||
651 | } | ||
652 | |||
653 | static int sum_abs_dctelem_c(DCTELEM *block) | ||
654 | { | ||
655 | int sum=0, i; | ||
656 | for(i=0; i<64; i++) | ||
657 | sum+= FFABS(block[i]); | ||
658 | return sum; | ||
659 | } | ||
660 | |||
661 | static void fill_block16_c(uint8_t *block, uint8_t value, int line_size, int h) | ||
662 | { | ||
663 | int i; | ||
664 | |||
665 | for (i = 0; i < h; i++) { | ||
666 | memset(block, value, 16); | ||
667 | block += line_size; | ||
668 | } | ||
669 | } | ||
670 | |||
671 | static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h) | ||
672 | { | ||
673 | int i; | ||
674 | |||
675 | for (i = 0; i < h; i++) { | ||
676 | memset(block, value, 8); | ||
677 | block += line_size; | ||
678 | } | ||
679 | } | ||
680 | |||
681 | static void scale_block_c(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize) | ||
682 | { | ||
683 | int i, j; | ||
684 | uint16_t *dst1 = (uint16_t *) dst; | ||
685 | uint16_t *dst2 = (uint16_t *)(dst + linesize); | ||
686 | |||
687 | for (j = 0; j < 8; j++) { | ||
688 | for (i = 0; i < 8; i++) { | ||
689 | dst1[i] = dst2[i] = src[i] * 0x0101; | ||
690 | } | ||
691 | src += 8; | ||
692 | dst1 += linesize; | ||
693 | dst2 += linesize; | ||
694 | } | ||
695 | } | ||
696 | |||
697 | #if 0 | ||
698 | |||
699 | #define PIXOP2(OPNAME, OP) \ | ||
700 | static void OPNAME ## _pixels(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
701 | {\ | ||
702 | int i;\ | ||
703 | for(i=0; i<h; i++){\ | ||
704 | OP(*((uint64_t*)block), AV_RN64(pixels));\ | ||
705 | pixels+=line_size;\ | ||
706 | block +=line_size;\ | ||
707 | }\ | ||
708 | }\ | ||
709 | \ | ||
710 | static void OPNAME ## _no_rnd_pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
711 | {\ | ||
712 | int i;\ | ||
713 | for(i=0; i<h; i++){\ | ||
714 | const uint64_t a= AV_RN64(pixels );\ | ||
715 | const uint64_t b= AV_RN64(pixels+1);\ | ||
716 | OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | ||
717 | pixels+=line_size;\ | ||
718 | block +=line_size;\ | ||
719 | }\ | ||
720 | }\ | ||
721 | \ | ||
722 | static void OPNAME ## _pixels_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
723 | {\ | ||
724 | int i;\ | ||
725 | for(i=0; i<h; i++){\ | ||
726 | const uint64_t a= AV_RN64(pixels );\ | ||
727 | const uint64_t b= AV_RN64(pixels+1);\ | ||
728 | OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | ||
729 | pixels+=line_size;\ | ||
730 | block +=line_size;\ | ||
731 | }\ | ||
732 | }\ | ||
733 | \ | ||
734 | static void OPNAME ## _no_rnd_pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
735 | {\ | ||
736 | int i;\ | ||
737 | for(i=0; i<h; i++){\ | ||
738 | const uint64_t a= AV_RN64(pixels );\ | ||
739 | const uint64_t b= AV_RN64(pixels+line_size);\ | ||
740 | OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | ||
741 | pixels+=line_size;\ | ||
742 | block +=line_size;\ | ||
743 | }\ | ||
744 | }\ | ||
745 | \ | ||
746 | static void OPNAME ## _pixels_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
747 | {\ | ||
748 | int i;\ | ||
749 | for(i=0; i<h; i++){\ | ||
750 | const uint64_t a= AV_RN64(pixels );\ | ||
751 | const uint64_t b= AV_RN64(pixels+line_size);\ | ||
752 | OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\ | ||
753 | pixels+=line_size;\ | ||
754 | block +=line_size;\ | ||
755 | }\ | ||
756 | }\ | ||
757 | \ | ||
758 | static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
759 | {\ | ||
760 | int i;\ | ||
761 | const uint64_t a= AV_RN64(pixels );\ | ||
762 | const uint64_t b= AV_RN64(pixels+1);\ | ||
763 | uint64_t l0= (a&0x0303030303030303ULL)\ | ||
764 | + (b&0x0303030303030303ULL)\ | ||
765 | + 0x0202020202020202ULL;\ | ||
766 | uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
767 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
768 | uint64_t l1,h1;\ | ||
769 | \ | ||
770 | pixels+=line_size;\ | ||
771 | for(i=0; i<h; i+=2){\ | ||
772 | uint64_t a= AV_RN64(pixels );\ | ||
773 | uint64_t b= AV_RN64(pixels+1);\ | ||
774 | l1= (a&0x0303030303030303ULL)\ | ||
775 | + (b&0x0303030303030303ULL);\ | ||
776 | h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
777 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
778 | OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | ||
779 | pixels+=line_size;\ | ||
780 | block +=line_size;\ | ||
781 | a= AV_RN64(pixels );\ | ||
782 | b= AV_RN64(pixels+1);\ | ||
783 | l0= (a&0x0303030303030303ULL)\ | ||
784 | + (b&0x0303030303030303ULL)\ | ||
785 | + 0x0202020202020202ULL;\ | ||
786 | h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
787 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
788 | OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | ||
789 | pixels+=line_size;\ | ||
790 | block +=line_size;\ | ||
791 | }\ | ||
792 | }\ | ||
793 | \ | ||
794 | static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
795 | {\ | ||
796 | int i;\ | ||
797 | const uint64_t a= AV_RN64(pixels );\ | ||
798 | const uint64_t b= AV_RN64(pixels+1);\ | ||
799 | uint64_t l0= (a&0x0303030303030303ULL)\ | ||
800 | + (b&0x0303030303030303ULL)\ | ||
801 | + 0x0101010101010101ULL;\ | ||
802 | uint64_t h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
803 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
804 | uint64_t l1,h1;\ | ||
805 | \ | ||
806 | pixels+=line_size;\ | ||
807 | for(i=0; i<h; i+=2){\ | ||
808 | uint64_t a= AV_RN64(pixels );\ | ||
809 | uint64_t b= AV_RN64(pixels+1);\ | ||
810 | l1= (a&0x0303030303030303ULL)\ | ||
811 | + (b&0x0303030303030303ULL);\ | ||
812 | h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
813 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
814 | OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | ||
815 | pixels+=line_size;\ | ||
816 | block +=line_size;\ | ||
817 | a= AV_RN64(pixels );\ | ||
818 | b= AV_RN64(pixels+1);\ | ||
819 | l0= (a&0x0303030303030303ULL)\ | ||
820 | + (b&0x0303030303030303ULL)\ | ||
821 | + 0x0101010101010101ULL;\ | ||
822 | h0= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\ | ||
823 | + ((b&0xFCFCFCFCFCFCFCFCULL)>>2);\ | ||
824 | OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\ | ||
825 | pixels+=line_size;\ | ||
826 | block +=line_size;\ | ||
827 | }\ | ||
828 | }\ | ||
829 | \ | ||
830 | CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels_c , 8)\ | ||
831 | CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels_x2_c , 8)\ | ||
832 | CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels_y2_c , 8)\ | ||
833 | CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels_xy2_c, 8)\ | ||
834 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels_x2_c , 8)\ | ||
835 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels_y2_c , 8)\ | ||
836 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels_xy2_c, 8) | ||
837 | |||
838 | #define op_avg(a, b) a = ( ((a)|(b)) - ((((a)^(b))&0xFEFEFEFEFEFEFEFEULL)>>1) ) | ||
839 | #else // 64 bit variant | ||
840 | |||
841 | #define PIXOP2(OPNAME, OP) \ | ||
842 | static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
843 | int i;\ | ||
844 | for(i=0; i<h; i++){\ | ||
845 | OP(*((uint16_t*)(block )), AV_RN16(pixels ));\ | ||
846 | pixels+=line_size;\ | ||
847 | block +=line_size;\ | ||
848 | }\ | ||
849 | }\ | ||
850 | static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
851 | int i;\ | ||
852 | for(i=0; i<h; i++){\ | ||
853 | OP(*((uint32_t*)(block )), AV_RN32(pixels ));\ | ||
854 | pixels+=line_size;\ | ||
855 | block +=line_size;\ | ||
856 | }\ | ||
857 | }\ | ||
858 | static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
859 | int i;\ | ||
860 | for(i=0; i<h; i++){\ | ||
861 | OP(*((uint32_t*)(block )), AV_RN32(pixels ));\ | ||
862 | OP(*((uint32_t*)(block+4)), AV_RN32(pixels+4));\ | ||
863 | pixels+=line_size;\ | ||
864 | block +=line_size;\ | ||
865 | }\ | ||
866 | }\ | ||
867 | static inline void OPNAME ## _no_rnd_pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
868 | OPNAME ## _pixels8_c(block, pixels, line_size, h);\ | ||
869 | }\ | ||
870 | \ | ||
871 | static inline void OPNAME ## _no_rnd_pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
872 | int src_stride1, int src_stride2, int h){\ | ||
873 | int i;\ | ||
874 | for(i=0; i<h; i++){\ | ||
875 | uint32_t a,b;\ | ||
876 | a= AV_RN32(&src1[i*src_stride1 ]);\ | ||
877 | b= AV_RN32(&src2[i*src_stride2 ]);\ | ||
878 | OP(*((uint32_t*)&dst[i*dst_stride ]), no_rnd_avg32(a, b));\ | ||
879 | a= AV_RN32(&src1[i*src_stride1+4]);\ | ||
880 | b= AV_RN32(&src2[i*src_stride2+4]);\ | ||
881 | OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\ | ||
882 | }\ | ||
883 | }\ | ||
884 | \ | ||
885 | static inline void OPNAME ## _pixels8_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
886 | int src_stride1, int src_stride2, int h){\ | ||
887 | int i;\ | ||
888 | for(i=0; i<h; i++){\ | ||
889 | uint32_t a,b;\ | ||
890 | a= AV_RN32(&src1[i*src_stride1 ]);\ | ||
891 | b= AV_RN32(&src2[i*src_stride2 ]);\ | ||
892 | OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\ | ||
893 | a= AV_RN32(&src1[i*src_stride1+4]);\ | ||
894 | b= AV_RN32(&src2[i*src_stride2+4]);\ | ||
895 | OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\ | ||
896 | }\ | ||
897 | }\ | ||
898 | \ | ||
899 | static inline void OPNAME ## _pixels4_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
900 | int src_stride1, int src_stride2, int h){\ | ||
901 | int i;\ | ||
902 | for(i=0; i<h; i++){\ | ||
903 | uint32_t a,b;\ | ||
904 | a= AV_RN32(&src1[i*src_stride1 ]);\ | ||
905 | b= AV_RN32(&src2[i*src_stride2 ]);\ | ||
906 | OP(*((uint32_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\ | ||
907 | }\ | ||
908 | }\ | ||
909 | \ | ||
910 | static inline void OPNAME ## _pixels2_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
911 | int src_stride1, int src_stride2, int h){\ | ||
912 | int i;\ | ||
913 | for(i=0; i<h; i++){\ | ||
914 | uint32_t a,b;\ | ||
915 | a= AV_RN16(&src1[i*src_stride1 ]);\ | ||
916 | b= AV_RN16(&src2[i*src_stride2 ]);\ | ||
917 | OP(*((uint16_t*)&dst[i*dst_stride ]), rnd_avg32(a, b));\ | ||
918 | }\ | ||
919 | }\ | ||
920 | \ | ||
921 | static inline void OPNAME ## _pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
922 | int src_stride1, int src_stride2, int h){\ | ||
923 | OPNAME ## _pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\ | ||
924 | OPNAME ## _pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\ | ||
925 | }\ | ||
926 | \ | ||
927 | static inline void OPNAME ## _no_rnd_pixels16_l2(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \ | ||
928 | int src_stride1, int src_stride2, int h){\ | ||
929 | OPNAME ## _no_rnd_pixels8_l2(dst , src1 , src2 , dst_stride, src_stride1, src_stride2, h);\ | ||
930 | OPNAME ## _no_rnd_pixels8_l2(dst+8, src1+8, src2+8, dst_stride, src_stride1, src_stride2, h);\ | ||
931 | }\ | ||
932 | \ | ||
933 | static inline void OPNAME ## _no_rnd_pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
934 | OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | ||
935 | }\ | ||
936 | \ | ||
937 | static inline void OPNAME ## _pixels8_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
938 | OPNAME ## _pixels8_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | ||
939 | }\ | ||
940 | \ | ||
941 | static inline void OPNAME ## _no_rnd_pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
942 | OPNAME ## _no_rnd_pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | ||
943 | }\ | ||
944 | \ | ||
945 | static inline void OPNAME ## _pixels8_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
946 | OPNAME ## _pixels8_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | ||
947 | }\ | ||
948 | \ | ||
949 | static inline void OPNAME ## _pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | ||
950 | int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | ||
951 | int i;\ | ||
952 | for(i=0; i<h; i++){\ | ||
953 | uint32_t a, b, c, d, l0, l1, h0, h1;\ | ||
954 | a= AV_RN32(&src1[i*src_stride1]);\ | ||
955 | b= AV_RN32(&src2[i*src_stride2]);\ | ||
956 | c= AV_RN32(&src3[i*src_stride3]);\ | ||
957 | d= AV_RN32(&src4[i*src_stride4]);\ | ||
958 | l0= (a&0x03030303UL)\ | ||
959 | + (b&0x03030303UL)\ | ||
960 | + 0x02020202UL;\ | ||
961 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
962 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
963 | l1= (c&0x03030303UL)\ | ||
964 | + (d&0x03030303UL);\ | ||
965 | h1= ((c&0xFCFCFCFCUL)>>2)\ | ||
966 | + ((d&0xFCFCFCFCUL)>>2);\ | ||
967 | OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
968 | a= AV_RN32(&src1[i*src_stride1+4]);\ | ||
969 | b= AV_RN32(&src2[i*src_stride2+4]);\ | ||
970 | c= AV_RN32(&src3[i*src_stride3+4]);\ | ||
971 | d= AV_RN32(&src4[i*src_stride4+4]);\ | ||
972 | l0= (a&0x03030303UL)\ | ||
973 | + (b&0x03030303UL)\ | ||
974 | + 0x02020202UL;\ | ||
975 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
976 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
977 | l1= (c&0x03030303UL)\ | ||
978 | + (d&0x03030303UL);\ | ||
979 | h1= ((c&0xFCFCFCFCUL)>>2)\ | ||
980 | + ((d&0xFCFCFCFCUL)>>2);\ | ||
981 | OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
982 | }\ | ||
983 | }\ | ||
984 | \ | ||
985 | static inline void OPNAME ## _pixels4_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
986 | OPNAME ## _pixels4_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | ||
987 | }\ | ||
988 | \ | ||
989 | static inline void OPNAME ## _pixels4_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
990 | OPNAME ## _pixels4_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | ||
991 | }\ | ||
992 | \ | ||
993 | static inline void OPNAME ## _pixels2_x2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
994 | OPNAME ## _pixels2_l2(block, pixels, pixels+1, line_size, line_size, line_size, h);\ | ||
995 | }\ | ||
996 | \ | ||
997 | static inline void OPNAME ## _pixels2_y2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
998 | OPNAME ## _pixels2_l2(block, pixels, pixels+line_size, line_size, line_size, line_size, h);\ | ||
999 | }\ | ||
1000 | \ | ||
1001 | static inline void OPNAME ## _no_rnd_pixels8_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | ||
1002 | int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | ||
1003 | int i;\ | ||
1004 | for(i=0; i<h; i++){\ | ||
1005 | uint32_t a, b, c, d, l0, l1, h0, h1;\ | ||
1006 | a= AV_RN32(&src1[i*src_stride1]);\ | ||
1007 | b= AV_RN32(&src2[i*src_stride2]);\ | ||
1008 | c= AV_RN32(&src3[i*src_stride3]);\ | ||
1009 | d= AV_RN32(&src4[i*src_stride4]);\ | ||
1010 | l0= (a&0x03030303UL)\ | ||
1011 | + (b&0x03030303UL)\ | ||
1012 | + 0x01010101UL;\ | ||
1013 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1014 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1015 | l1= (c&0x03030303UL)\ | ||
1016 | + (d&0x03030303UL);\ | ||
1017 | h1= ((c&0xFCFCFCFCUL)>>2)\ | ||
1018 | + ((d&0xFCFCFCFCUL)>>2);\ | ||
1019 | OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1020 | a= AV_RN32(&src1[i*src_stride1+4]);\ | ||
1021 | b= AV_RN32(&src2[i*src_stride2+4]);\ | ||
1022 | c= AV_RN32(&src3[i*src_stride3+4]);\ | ||
1023 | d= AV_RN32(&src4[i*src_stride4+4]);\ | ||
1024 | l0= (a&0x03030303UL)\ | ||
1025 | + (b&0x03030303UL)\ | ||
1026 | + 0x01010101UL;\ | ||
1027 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1028 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1029 | l1= (c&0x03030303UL)\ | ||
1030 | + (d&0x03030303UL);\ | ||
1031 | h1= ((c&0xFCFCFCFCUL)>>2)\ | ||
1032 | + ((d&0xFCFCFCFCUL)>>2);\ | ||
1033 | OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1034 | }\ | ||
1035 | }\ | ||
1036 | static inline void OPNAME ## _pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | ||
1037 | int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | ||
1038 | OPNAME ## _pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | ||
1039 | OPNAME ## _pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | ||
1040 | }\ | ||
1041 | static inline void OPNAME ## _no_rnd_pixels16_l4(uint8_t *dst, const uint8_t *src1, uint8_t *src2, uint8_t *src3, uint8_t *src4,\ | ||
1042 | int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\ | ||
1043 | OPNAME ## _no_rnd_pixels8_l4(dst , src1 , src2 , src3 , src4 , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | ||
1044 | OPNAME ## _no_rnd_pixels8_l4(dst+8, src1+8, src2+8, src3+8, src4+8, dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\ | ||
1045 | }\ | ||
1046 | \ | ||
1047 | static inline void OPNAME ## _pixels2_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
1048 | {\ | ||
1049 | int i, a0, b0, a1, b1;\ | ||
1050 | a0= pixels[0];\ | ||
1051 | b0= pixels[1] + 2;\ | ||
1052 | a0 += b0;\ | ||
1053 | b0 += pixels[2];\ | ||
1054 | \ | ||
1055 | pixels+=line_size;\ | ||
1056 | for(i=0; i<h; i+=2){\ | ||
1057 | a1= pixels[0];\ | ||
1058 | b1= pixels[1];\ | ||
1059 | a1 += b1;\ | ||
1060 | b1 += pixels[2];\ | ||
1061 | \ | ||
1062 | block[0]= (a1+a0)>>2; /* FIXME non put */\ | ||
1063 | block[1]= (b1+b0)>>2;\ | ||
1064 | \ | ||
1065 | pixels+=line_size;\ | ||
1066 | block +=line_size;\ | ||
1067 | \ | ||
1068 | a0= pixels[0];\ | ||
1069 | b0= pixels[1] + 2;\ | ||
1070 | a0 += b0;\ | ||
1071 | b0 += pixels[2];\ | ||
1072 | \ | ||
1073 | block[0]= (a1+a0)>>2;\ | ||
1074 | block[1]= (b1+b0)>>2;\ | ||
1075 | pixels+=line_size;\ | ||
1076 | block +=line_size;\ | ||
1077 | }\ | ||
1078 | }\ | ||
1079 | \ | ||
1080 | static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
1081 | {\ | ||
1082 | int i;\ | ||
1083 | const uint32_t a= AV_RN32(pixels );\ | ||
1084 | const uint32_t b= AV_RN32(pixels+1);\ | ||
1085 | uint32_t l0= (a&0x03030303UL)\ | ||
1086 | + (b&0x03030303UL)\ | ||
1087 | + 0x02020202UL;\ | ||
1088 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1089 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1090 | uint32_t l1,h1;\ | ||
1091 | \ | ||
1092 | pixels+=line_size;\ | ||
1093 | for(i=0; i<h; i+=2){\ | ||
1094 | uint32_t a= AV_RN32(pixels );\ | ||
1095 | uint32_t b= AV_RN32(pixels+1);\ | ||
1096 | l1= (a&0x03030303UL)\ | ||
1097 | + (b&0x03030303UL);\ | ||
1098 | h1= ((a&0xFCFCFCFCUL)>>2)\ | ||
1099 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1100 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1101 | pixels+=line_size;\ | ||
1102 | block +=line_size;\ | ||
1103 | a= AV_RN32(pixels );\ | ||
1104 | b= AV_RN32(pixels+1);\ | ||
1105 | l0= (a&0x03030303UL)\ | ||
1106 | + (b&0x03030303UL)\ | ||
1107 | + 0x02020202UL;\ | ||
1108 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1109 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1110 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1111 | pixels+=line_size;\ | ||
1112 | block +=line_size;\ | ||
1113 | }\ | ||
1114 | }\ | ||
1115 | \ | ||
1116 | static inline void OPNAME ## _pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
1117 | {\ | ||
1118 | int j;\ | ||
1119 | for(j=0; j<2; j++){\ | ||
1120 | int i;\ | ||
1121 | const uint32_t a= AV_RN32(pixels );\ | ||
1122 | const uint32_t b= AV_RN32(pixels+1);\ | ||
1123 | uint32_t l0= (a&0x03030303UL)\ | ||
1124 | + (b&0x03030303UL)\ | ||
1125 | + 0x02020202UL;\ | ||
1126 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1127 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1128 | uint32_t l1,h1;\ | ||
1129 | \ | ||
1130 | pixels+=line_size;\ | ||
1131 | for(i=0; i<h; i+=2){\ | ||
1132 | uint32_t a= AV_RN32(pixels );\ | ||
1133 | uint32_t b= AV_RN32(pixels+1);\ | ||
1134 | l1= (a&0x03030303UL)\ | ||
1135 | + (b&0x03030303UL);\ | ||
1136 | h1= ((a&0xFCFCFCFCUL)>>2)\ | ||
1137 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1138 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1139 | pixels+=line_size;\ | ||
1140 | block +=line_size;\ | ||
1141 | a= AV_RN32(pixels );\ | ||
1142 | b= AV_RN32(pixels+1);\ | ||
1143 | l0= (a&0x03030303UL)\ | ||
1144 | + (b&0x03030303UL)\ | ||
1145 | + 0x02020202UL;\ | ||
1146 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1147 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1148 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1149 | pixels+=line_size;\ | ||
1150 | block +=line_size;\ | ||
1151 | }\ | ||
1152 | pixels+=4-line_size*(h+1);\ | ||
1153 | block +=4-line_size*h;\ | ||
1154 | }\ | ||
1155 | }\ | ||
1156 | \ | ||
1157 | static inline void OPNAME ## _no_rnd_pixels8_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\ | ||
1158 | {\ | ||
1159 | int j;\ | ||
1160 | for(j=0; j<2; j++){\ | ||
1161 | int i;\ | ||
1162 | const uint32_t a= AV_RN32(pixels );\ | ||
1163 | const uint32_t b= AV_RN32(pixels+1);\ | ||
1164 | uint32_t l0= (a&0x03030303UL)\ | ||
1165 | + (b&0x03030303UL)\ | ||
1166 | + 0x01010101UL;\ | ||
1167 | uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1168 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1169 | uint32_t l1,h1;\ | ||
1170 | \ | ||
1171 | pixels+=line_size;\ | ||
1172 | for(i=0; i<h; i+=2){\ | ||
1173 | uint32_t a= AV_RN32(pixels );\ | ||
1174 | uint32_t b= AV_RN32(pixels+1);\ | ||
1175 | l1= (a&0x03030303UL)\ | ||
1176 | + (b&0x03030303UL);\ | ||
1177 | h1= ((a&0xFCFCFCFCUL)>>2)\ | ||
1178 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1179 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1180 | pixels+=line_size;\ | ||
1181 | block +=line_size;\ | ||
1182 | a= AV_RN32(pixels );\ | ||
1183 | b= AV_RN32(pixels+1);\ | ||
1184 | l0= (a&0x03030303UL)\ | ||
1185 | + (b&0x03030303UL)\ | ||
1186 | + 0x01010101UL;\ | ||
1187 | h0= ((a&0xFCFCFCFCUL)>>2)\ | ||
1188 | + ((b&0xFCFCFCFCUL)>>2);\ | ||
1189 | OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\ | ||
1190 | pixels+=line_size;\ | ||
1191 | block +=line_size;\ | ||
1192 | }\ | ||
1193 | pixels+=4-line_size*(h+1);\ | ||
1194 | block +=4-line_size*h;\ | ||
1195 | }\ | ||
1196 | }\ | ||
1197 | \ | ||
1198 | CALL_2X_PIXELS(OPNAME ## _pixels16_c , OPNAME ## _pixels8_c , 8)\ | ||
1199 | CALL_2X_PIXELS(OPNAME ## _pixels16_x2_c , OPNAME ## _pixels8_x2_c , 8)\ | ||
1200 | CALL_2X_PIXELS(OPNAME ## _pixels16_y2_c , OPNAME ## _pixels8_y2_c , 8)\ | ||
1201 | CALL_2X_PIXELS(OPNAME ## _pixels16_xy2_c, OPNAME ## _pixels8_xy2_c, 8)\ | ||
1202 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_c , OPNAME ## _pixels8_c , 8)\ | ||
1203 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_x2_c , OPNAME ## _no_rnd_pixels8_x2_c , 8)\ | ||
1204 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_y2_c , OPNAME ## _no_rnd_pixels8_y2_c , 8)\ | ||
1205 | CALL_2X_PIXELS(OPNAME ## _no_rnd_pixels16_xy2_c, OPNAME ## _no_rnd_pixels8_xy2_c, 8)\ | ||
1206 | |||
1207 | #define op_avg(a, b) a = rnd_avg32(a, b) | ||
1208 | #endif | ||
1209 | #define op_put(a, b) a = b | ||
1210 | |||
1211 | PIXOP2(avg, op_avg) | ||
1212 | PIXOP2(put, op_put) | ||
1213 | #undef op_avg | ||
1214 | #undef op_put | ||
1215 | |||
1216 | #define avg2(a,b) ((a+b+1)>>1) | ||
1217 | #define avg4(a,b,c,d) ((a+b+c+d+2)>>2) | ||
1218 | |||
1219 | static void put_no_rnd_pixels16_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){ | ||
1220 | put_no_rnd_pixels16_l2(dst, a, b, stride, stride, stride, h); | ||
1221 | } | ||
1222 | |||
1223 | static void put_no_rnd_pixels8_l2_c(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h){ | ||
1224 | put_no_rnd_pixels8_l2(dst, a, b, stride, stride, stride, h); | ||
1225 | } | ||
1226 | |||
1227 | static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder) | ||
1228 | { | ||
1229 | const int A=(16-x16)*(16-y16); | ||
1230 | const int B=( x16)*(16-y16); | ||
1231 | const int C=(16-x16)*( y16); | ||
1232 | const int D=( x16)*( y16); | ||
1233 | int i; | ||
1234 | |||
1235 | for(i=0; i<h; i++) | ||
1236 | { | ||
1237 | dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8; | ||
1238 | dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8; | ||
1239 | dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8; | ||
1240 | dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8; | ||
1241 | dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8; | ||
1242 | dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8; | ||
1243 | dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8; | ||
1244 | dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8; | ||
1245 | dst+= stride; | ||
1246 | src+= stride; | ||
1247 | } | ||
1248 | } | ||
1249 | |||
1250 | void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, | ||
1251 | int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height) | ||
1252 | { | ||
1253 | int y, vx, vy; | ||
1254 | const int s= 1<<shift; | ||
1255 | |||
1256 | width--; | ||
1257 | height--; | ||
1258 | |||
1259 | for(y=0; y<h; y++){ | ||
1260 | int x; | ||
1261 | |||
1262 | vx= ox; | ||
1263 | vy= oy; | ||
1264 | for(x=0; x<8; x++){ //XXX FIXME optimize | ||
1265 | int src_x, src_y, frac_x, frac_y, index; | ||
1266 | |||
1267 | src_x= vx>>16; | ||
1268 | src_y= vy>>16; | ||
1269 | frac_x= src_x&(s-1); | ||
1270 | frac_y= src_y&(s-1); | ||
1271 | src_x>>=shift; | ||
1272 | src_y>>=shift; | ||
1273 | |||
1274 | if((unsigned)src_x < width){ | ||
1275 | if((unsigned)src_y < height){ | ||
1276 | index= src_x + src_y*stride; | ||
1277 | dst[y*stride + x]= ( ( src[index ]*(s-frac_x) | ||
1278 | + src[index +1]* frac_x )*(s-frac_y) | ||
1279 | + ( src[index+stride ]*(s-frac_x) | ||
1280 | + src[index+stride+1]* frac_x )* frac_y | ||
1281 | + r)>>(shift*2); | ||
1282 | }else{ | ||
1283 | index= src_x + av_clip(src_y, 0, height)*stride; | ||
1284 | dst[y*stride + x]= ( ( src[index ]*(s-frac_x) | ||
1285 | + src[index +1]* frac_x )*s | ||
1286 | + r)>>(shift*2); | ||
1287 | } | ||
1288 | }else{ | ||
1289 | if((unsigned)src_y < height){ | ||
1290 | index= av_clip(src_x, 0, width) + src_y*stride; | ||
1291 | dst[y*stride + x]= ( ( src[index ]*(s-frac_y) | ||
1292 | + src[index+stride ]* frac_y )*s | ||
1293 | + r)>>(shift*2); | ||
1294 | }else{ | ||
1295 | index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride; | ||
1296 | dst[y*stride + x]= src[index ]; | ||
1297 | } | ||
1298 | } | ||
1299 | |||
1300 | vx+= dxx; | ||
1301 | vy+= dyx; | ||
1302 | } | ||
1303 | ox += dxy; | ||
1304 | oy += dyy; | ||
1305 | } | ||
1306 | } | ||
1307 | |||
1308 | static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1309 | switch(width){ | ||
1310 | case 2: put_pixels2_c (dst, src, stride, height); break; | ||
1311 | case 4: put_pixels4_c (dst, src, stride, height); break; | ||
1312 | case 8: put_pixels8_c (dst, src, stride, height); break; | ||
1313 | case 16:put_pixels16_c(dst, src, stride, height); break; | ||
1314 | } | ||
1315 | } | ||
1316 | |||
1317 | static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1318 | int i,j; | ||
1319 | for (i=0; i < height; i++) { | ||
1320 | for (j=0; j < width; j++) { | ||
1321 | dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11; | ||
1322 | } | ||
1323 | src += stride; | ||
1324 | dst += stride; | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1329 | int i,j; | ||
1330 | for (i=0; i < height; i++) { | ||
1331 | for (j=0; j < width; j++) { | ||
1332 | dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11; | ||
1333 | } | ||
1334 | src += stride; | ||
1335 | dst += stride; | ||
1336 | } | ||
1337 | } | ||
1338 | |||
1339 | static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1340 | int i,j; | ||
1341 | for (i=0; i < height; i++) { | ||
1342 | for (j=0; j < width; j++) { | ||
1343 | dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11; | ||
1344 | } | ||
1345 | src += stride; | ||
1346 | dst += stride; | ||
1347 | } | ||
1348 | } | ||
1349 | |||
1350 | static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1351 | int i,j; | ||
1352 | for (i=0; i < height; i++) { | ||
1353 | for (j=0; j < width; j++) { | ||
1354 | dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15; | ||
1355 | } | ||
1356 | src += stride; | ||
1357 | dst += stride; | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1362 | int i,j; | ||
1363 | for (i=0; i < height; i++) { | ||
1364 | for (j=0; j < width; j++) { | ||
1365 | dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15; | ||
1366 | } | ||
1367 | src += stride; | ||
1368 | dst += stride; | ||
1369 | } | ||
1370 | } | ||
1371 | |||
1372 | static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1373 | int i,j; | ||
1374 | for (i=0; i < height; i++) { | ||
1375 | for (j=0; j < width; j++) { | ||
1376 | dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11; | ||
1377 | } | ||
1378 | src += stride; | ||
1379 | dst += stride; | ||
1380 | } | ||
1381 | } | ||
1382 | |||
1383 | static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1384 | int i,j; | ||
1385 | for (i=0; i < height; i++) { | ||
1386 | for (j=0; j < width; j++) { | ||
1387 | dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15; | ||
1388 | } | ||
1389 | src += stride; | ||
1390 | dst += stride; | ||
1391 | } | ||
1392 | } | ||
1393 | |||
1394 | static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1395 | int i,j; | ||
1396 | for (i=0; i < height; i++) { | ||
1397 | for (j=0; j < width; j++) { | ||
1398 | dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15; | ||
1399 | } | ||
1400 | src += stride; | ||
1401 | dst += stride; | ||
1402 | } | ||
1403 | } | ||
1404 | |||
1405 | static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1406 | switch(width){ | ||
1407 | case 2: avg_pixels2_c (dst, src, stride, height); break; | ||
1408 | case 4: avg_pixels4_c (dst, src, stride, height); break; | ||
1409 | case 8: avg_pixels8_c (dst, src, stride, height); break; | ||
1410 | case 16:avg_pixels16_c(dst, src, stride, height); break; | ||
1411 | } | ||
1412 | } | ||
1413 | |||
1414 | static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1415 | int i,j; | ||
1416 | for (i=0; i < height; i++) { | ||
1417 | for (j=0; j < width; j++) { | ||
1418 | dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1; | ||
1419 | } | ||
1420 | src += stride; | ||
1421 | dst += stride; | ||
1422 | } | ||
1423 | } | ||
1424 | |||
1425 | static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1426 | int i,j; | ||
1427 | for (i=0; i < height; i++) { | ||
1428 | for (j=0; j < width; j++) { | ||
1429 | dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1; | ||
1430 | } | ||
1431 | src += stride; | ||
1432 | dst += stride; | ||
1433 | } | ||
1434 | } | ||
1435 | |||
1436 | static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1437 | int i,j; | ||
1438 | for (i=0; i < height; i++) { | ||
1439 | for (j=0; j < width; j++) { | ||
1440 | dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1; | ||
1441 | } | ||
1442 | src += stride; | ||
1443 | dst += stride; | ||
1444 | } | ||
1445 | } | ||
1446 | |||
1447 | static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1448 | int i,j; | ||
1449 | for (i=0; i < height; i++) { | ||
1450 | for (j=0; j < width; j++) { | ||
1451 | dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1; | ||
1452 | } | ||
1453 | src += stride; | ||
1454 | dst += stride; | ||
1455 | } | ||
1456 | } | ||
1457 | |||
1458 | static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1459 | int i,j; | ||
1460 | for (i=0; i < height; i++) { | ||
1461 | for (j=0; j < width; j++) { | ||
1462 | dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1; | ||
1463 | } | ||
1464 | src += stride; | ||
1465 | dst += stride; | ||
1466 | } | ||
1467 | } | ||
1468 | |||
1469 | static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1470 | int i,j; | ||
1471 | for (i=0; i < height; i++) { | ||
1472 | for (j=0; j < width; j++) { | ||
1473 | dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1; | ||
1474 | } | ||
1475 | src += stride; | ||
1476 | dst += stride; | ||
1477 | } | ||
1478 | } | ||
1479 | |||
1480 | static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1481 | int i,j; | ||
1482 | for (i=0; i < height; i++) { | ||
1483 | for (j=0; j < width; j++) { | ||
1484 | dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1; | ||
1485 | } | ||
1486 | src += stride; | ||
1487 | dst += stride; | ||
1488 | } | ||
1489 | } | ||
1490 | |||
1491 | static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){ | ||
1492 | int i,j; | ||
1493 | for (i=0; i < height; i++) { | ||
1494 | for (j=0; j < width; j++) { | ||
1495 | dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1; | ||
1496 | } | ||
1497 | src += stride; | ||
1498 | dst += stride; | ||
1499 | } | ||
1500 | } | ||
1501 | #if 0 | ||
1502 | #define TPEL_WIDTH(width)\ | ||
1503 | static void put_tpel_pixels ## width ## _mc00_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1504 | void put_tpel_pixels_mc00_c(dst, src, stride, width, height);}\ | ||
1505 | static void put_tpel_pixels ## width ## _mc10_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1506 | void put_tpel_pixels_mc10_c(dst, src, stride, width, height);}\ | ||
1507 | static void put_tpel_pixels ## width ## _mc20_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1508 | void put_tpel_pixels_mc20_c(dst, src, stride, width, height);}\ | ||
1509 | static void put_tpel_pixels ## width ## _mc01_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1510 | void put_tpel_pixels_mc01_c(dst, src, stride, width, height);}\ | ||
1511 | static void put_tpel_pixels ## width ## _mc11_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1512 | void put_tpel_pixels_mc11_c(dst, src, stride, width, height);}\ | ||
1513 | static void put_tpel_pixels ## width ## _mc21_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1514 | void put_tpel_pixels_mc21_c(dst, src, stride, width, height);}\ | ||
1515 | static void put_tpel_pixels ## width ## _mc02_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1516 | void put_tpel_pixels_mc02_c(dst, src, stride, width, height);}\ | ||
1517 | static void put_tpel_pixels ## width ## _mc12_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1518 | void put_tpel_pixels_mc12_c(dst, src, stride, width, height);}\ | ||
1519 | static void put_tpel_pixels ## width ## _mc22_c(uint8_t *dst, const uint8_t *src, int stride, int height){\ | ||
1520 | void put_tpel_pixels_mc22_c(dst, src, stride, width, height);} | ||
1521 | #endif | ||
1522 | |||
1523 | #define H264_CHROMA_MC(OPNAME, OP)\ | ||
1524 | static void OPNAME ## h264_chroma_mc2_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ | ||
1525 | const int A=(8-x)*(8-y);\ | ||
1526 | const int B=( x)*(8-y);\ | ||
1527 | const int C=(8-x)*( y);\ | ||
1528 | const int D=( x)*( y);\ | ||
1529 | int i;\ | ||
1530 | \ | ||
1531 | assert(x<8 && y<8 && x>=0 && y>=0);\ | ||
1532 | \ | ||
1533 | if(D){\ | ||
1534 | for(i=0; i<h; i++){\ | ||
1535 | OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ | ||
1536 | OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ | ||
1537 | dst+= stride;\ | ||
1538 | src+= stride;\ | ||
1539 | }\ | ||
1540 | }else{\ | ||
1541 | const int E= B+C;\ | ||
1542 | const int step= C ? stride : 1;\ | ||
1543 | for(i=0; i<h; i++){\ | ||
1544 | OP(dst[0], (A*src[0] + E*src[step+0]));\ | ||
1545 | OP(dst[1], (A*src[1] + E*src[step+1]));\ | ||
1546 | dst+= stride;\ | ||
1547 | src+= stride;\ | ||
1548 | }\ | ||
1549 | }\ | ||
1550 | }\ | ||
1551 | \ | ||
1552 | static void OPNAME ## h264_chroma_mc4_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ | ||
1553 | const int A=(8-x)*(8-y);\ | ||
1554 | const int B=( x)*(8-y);\ | ||
1555 | const int C=(8-x)*( y);\ | ||
1556 | const int D=( x)*( y);\ | ||
1557 | int i;\ | ||
1558 | \ | ||
1559 | assert(x<8 && y<8 && x>=0 && y>=0);\ | ||
1560 | \ | ||
1561 | if(D){\ | ||
1562 | for(i=0; i<h; i++){\ | ||
1563 | OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ | ||
1564 | OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ | ||
1565 | OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\ | ||
1566 | OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\ | ||
1567 | dst+= stride;\ | ||
1568 | src+= stride;\ | ||
1569 | }\ | ||
1570 | }else{\ | ||
1571 | const int E= B+C;\ | ||
1572 | const int step= C ? stride : 1;\ | ||
1573 | for(i=0; i<h; i++){\ | ||
1574 | OP(dst[0], (A*src[0] + E*src[step+0]));\ | ||
1575 | OP(dst[1], (A*src[1] + E*src[step+1]));\ | ||
1576 | OP(dst[2], (A*src[2] + E*src[step+2]));\ | ||
1577 | OP(dst[3], (A*src[3] + E*src[step+3]));\ | ||
1578 | dst+= stride;\ | ||
1579 | src+= stride;\ | ||
1580 | }\ | ||
1581 | }\ | ||
1582 | }\ | ||
1583 | \ | ||
1584 | static void OPNAME ## h264_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){\ | ||
1585 | const int A=(8-x)*(8-y);\ | ||
1586 | const int B=( x)*(8-y);\ | ||
1587 | const int C=(8-x)*( y);\ | ||
1588 | const int D=( x)*( y);\ | ||
1589 | int i;\ | ||
1590 | \ | ||
1591 | assert(x<8 && y<8 && x>=0 && y>=0);\ | ||
1592 | \ | ||
1593 | if(D){\ | ||
1594 | for(i=0; i<h; i++){\ | ||
1595 | OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\ | ||
1596 | OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\ | ||
1597 | OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\ | ||
1598 | OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\ | ||
1599 | OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\ | ||
1600 | OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\ | ||
1601 | OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\ | ||
1602 | OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\ | ||
1603 | dst+= stride;\ | ||
1604 | src+= stride;\ | ||
1605 | }\ | ||
1606 | }else{\ | ||
1607 | const int E= B+C;\ | ||
1608 | const int step= C ? stride : 1;\ | ||
1609 | for(i=0; i<h; i++){\ | ||
1610 | OP(dst[0], (A*src[0] + E*src[step+0]));\ | ||
1611 | OP(dst[1], (A*src[1] + E*src[step+1]));\ | ||
1612 | OP(dst[2], (A*src[2] + E*src[step+2]));\ | ||
1613 | OP(dst[3], (A*src[3] + E*src[step+3]));\ | ||
1614 | OP(dst[4], (A*src[4] + E*src[step+4]));\ | ||
1615 | OP(dst[5], (A*src[5] + E*src[step+5]));\ | ||
1616 | OP(dst[6], (A*src[6] + E*src[step+6]));\ | ||
1617 | OP(dst[7], (A*src[7] + E*src[step+7]));\ | ||
1618 | dst+= stride;\ | ||
1619 | src+= stride;\ | ||
1620 | }\ | ||
1621 | }\ | ||
1622 | } | ||
1623 | |||
1624 | #define op_avg(a, b) a = (((a)+(((b) + 32)>>6)+1)>>1) | ||
1625 | #define op_put(a, b) a = (((b) + 32)>>6) | ||
1626 | |||
1627 | H264_CHROMA_MC(put_ , op_put) | ||
1628 | H264_CHROMA_MC(avg_ , op_avg) | ||
1629 | #undef op_avg | ||
1630 | #undef op_put | ||
1631 | |||
1632 | static void put_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){ | ||
1633 | const int A=(8-x)*(8-y); | ||
1634 | const int B=( x)*(8-y); | ||
1635 | const int C=(8-x)*( y); | ||
1636 | const int D=( x)*( y); | ||
1637 | int i; | ||
1638 | |||
1639 | assert(x<8 && y<8 && x>=0 && y>=0); | ||
1640 | |||
1641 | for(i=0; i<h; i++) | ||
1642 | { | ||
1643 | dst[0] = (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6; | ||
1644 | dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6; | ||
1645 | dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6; | ||
1646 | dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6; | ||
1647 | dst[4] = (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6; | ||
1648 | dst[5] = (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6; | ||
1649 | dst[6] = (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6; | ||
1650 | dst[7] = (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6; | ||
1651 | dst+= stride; | ||
1652 | src+= stride; | ||
1653 | } | ||
1654 | } | ||
1655 | |||
1656 | static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){ | ||
1657 | const int A=(8-x)*(8-y); | ||
1658 | const int B=( x)*(8-y); | ||
1659 | const int C=(8-x)*( y); | ||
1660 | const int D=( x)*( y); | ||
1661 | int i; | ||
1662 | |||
1663 | assert(x<8 && y<8 && x>=0 && y>=0); | ||
1664 | |||
1665 | for(i=0; i<h; i++) | ||
1666 | { | ||
1667 | dst[0] = avg2(dst[0], ((A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + 32 - 4) >> 6)); | ||
1668 | dst[1] = avg2(dst[1], ((A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6)); | ||
1669 | dst[2] = avg2(dst[2], ((A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6)); | ||
1670 | dst[3] = avg2(dst[3], ((A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6)); | ||
1671 | dst[4] = avg2(dst[4], ((A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + 32 - 4) >> 6)); | ||
1672 | dst[5] = avg2(dst[5], ((A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + 32 - 4) >> 6)); | ||
1673 | dst[6] = avg2(dst[6], ((A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + 32 - 4) >> 6)); | ||
1674 | dst[7] = avg2(dst[7], ((A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + 32 - 4) >> 6)); | ||
1675 | dst+= stride; | ||
1676 | src+= stride; | ||
1677 | } | ||
1678 | } | ||
1679 | |||
1680 | #define QPEL_MC(r, OPNAME, RND, OP) \ | ||
1681 | static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | ||
1682 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
1683 | int i;\ | ||
1684 | for(i=0; i<h; i++)\ | ||
1685 | {\ | ||
1686 | OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\ | ||
1687 | OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\ | ||
1688 | OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\ | ||
1689 | OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\ | ||
1690 | OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\ | ||
1691 | OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\ | ||
1692 | OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\ | ||
1693 | OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\ | ||
1694 | dst+=dstStride;\ | ||
1695 | src+=srcStride;\ | ||
1696 | }\ | ||
1697 | }\ | ||
1698 | \ | ||
1699 | static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
1700 | const int w=8;\ | ||
1701 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
1702 | int i;\ | ||
1703 | for(i=0; i<w; i++)\ | ||
1704 | {\ | ||
1705 | const int src0= src[0*srcStride];\ | ||
1706 | const int src1= src[1*srcStride];\ | ||
1707 | const int src2= src[2*srcStride];\ | ||
1708 | const int src3= src[3*srcStride];\ | ||
1709 | const int src4= src[4*srcStride];\ | ||
1710 | const int src5= src[5*srcStride];\ | ||
1711 | const int src6= src[6*srcStride];\ | ||
1712 | const int src7= src[7*srcStride];\ | ||
1713 | const int src8= src[8*srcStride];\ | ||
1714 | OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\ | ||
1715 | OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\ | ||
1716 | OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\ | ||
1717 | OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\ | ||
1718 | OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\ | ||
1719 | OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\ | ||
1720 | OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\ | ||
1721 | OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\ | ||
1722 | dst++;\ | ||
1723 | src++;\ | ||
1724 | }\ | ||
1725 | }\ | ||
1726 | \ | ||
1727 | static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\ | ||
1728 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
1729 | int i;\ | ||
1730 | \ | ||
1731 | for(i=0; i<h; i++)\ | ||
1732 | {\ | ||
1733 | OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\ | ||
1734 | OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\ | ||
1735 | OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\ | ||
1736 | OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\ | ||
1737 | OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\ | ||
1738 | OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\ | ||
1739 | OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\ | ||
1740 | OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\ | ||
1741 | OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\ | ||
1742 | OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\ | ||
1743 | OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\ | ||
1744 | OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\ | ||
1745 | OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\ | ||
1746 | OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\ | ||
1747 | OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\ | ||
1748 | OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\ | ||
1749 | dst+=dstStride;\ | ||
1750 | src+=srcStride;\ | ||
1751 | }\ | ||
1752 | }\ | ||
1753 | \ | ||
1754 | static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
1755 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
1756 | int i;\ | ||
1757 | const int w=16;\ | ||
1758 | for(i=0; i<w; i++)\ | ||
1759 | {\ | ||
1760 | const int src0= src[0*srcStride];\ | ||
1761 | const int src1= src[1*srcStride];\ | ||
1762 | const int src2= src[2*srcStride];\ | ||
1763 | const int src3= src[3*srcStride];\ | ||
1764 | const int src4= src[4*srcStride];\ | ||
1765 | const int src5= src[5*srcStride];\ | ||
1766 | const int src6= src[6*srcStride];\ | ||
1767 | const int src7= src[7*srcStride];\ | ||
1768 | const int src8= src[8*srcStride];\ | ||
1769 | const int src9= src[9*srcStride];\ | ||
1770 | const int src10= src[10*srcStride];\ | ||
1771 | const int src11= src[11*srcStride];\ | ||
1772 | const int src12= src[12*srcStride];\ | ||
1773 | const int src13= src[13*srcStride];\ | ||
1774 | const int src14= src[14*srcStride];\ | ||
1775 | const int src15= src[15*srcStride];\ | ||
1776 | const int src16= src[16*srcStride];\ | ||
1777 | OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\ | ||
1778 | OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\ | ||
1779 | OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\ | ||
1780 | OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\ | ||
1781 | OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\ | ||
1782 | OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\ | ||
1783 | OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\ | ||
1784 | OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\ | ||
1785 | OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\ | ||
1786 | OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\ | ||
1787 | OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\ | ||
1788 | OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\ | ||
1789 | OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\ | ||
1790 | OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\ | ||
1791 | OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\ | ||
1792 | OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\ | ||
1793 | dst++;\ | ||
1794 | src++;\ | ||
1795 | }\ | ||
1796 | }\ | ||
1797 | \ | ||
1798 | static void OPNAME ## qpel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){\ | ||
1799 | OPNAME ## pixels8_c(dst, src, stride, 8);\ | ||
1800 | }\ | ||
1801 | \ | ||
1802 | static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1803 | uint8_t half[64];\ | ||
1804 | put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ | ||
1805 | OPNAME ## pixels8_l2(dst, src, half, stride, stride, 8, 8);\ | ||
1806 | }\ | ||
1807 | \ | ||
1808 | static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1809 | OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\ | ||
1810 | }\ | ||
1811 | \ | ||
1812 | static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1813 | uint8_t half[64];\ | ||
1814 | put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\ | ||
1815 | OPNAME ## pixels8_l2(dst, src+1, half, stride, stride, 8, 8);\ | ||
1816 | }\ | ||
1817 | \ | ||
1818 | static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1819 | uint8_t full[16*9];\ | ||
1820 | uint8_t half[64];\ | ||
1821 | copy_block9(full, src, 16, stride, 9);\ | ||
1822 | put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ | ||
1823 | OPNAME ## pixels8_l2(dst, full, half, stride, 16, 8, 8);\ | ||
1824 | }\ | ||
1825 | \ | ||
1826 | static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1827 | uint8_t full[16*9];\ | ||
1828 | copy_block9(full, src, 16, stride, 9);\ | ||
1829 | OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\ | ||
1830 | }\ | ||
1831 | \ | ||
1832 | static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1833 | uint8_t full[16*9];\ | ||
1834 | uint8_t half[64];\ | ||
1835 | copy_block9(full, src, 16, stride, 9);\ | ||
1836 | put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\ | ||
1837 | OPNAME ## pixels8_l2(dst, full+16, half, stride, 16, 8, 8);\ | ||
1838 | }\ | ||
1839 | void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1840 | uint8_t full[16*9];\ | ||
1841 | uint8_t halfH[72];\ | ||
1842 | uint8_t halfV[64];\ | ||
1843 | uint8_t halfHV[64];\ | ||
1844 | copy_block9(full, src, 16, stride, 9);\ | ||
1845 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1846 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ | ||
1847 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1848 | OPNAME ## pixels8_l4(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | ||
1849 | }\ | ||
1850 | static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1851 | uint8_t full[16*9];\ | ||
1852 | uint8_t halfH[72];\ | ||
1853 | uint8_t halfHV[64];\ | ||
1854 | copy_block9(full, src, 16, stride, 9);\ | ||
1855 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1856 | put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ | ||
1857 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1858 | OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ | ||
1859 | }\ | ||
1860 | void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1861 | uint8_t full[16*9];\ | ||
1862 | uint8_t halfH[72];\ | ||
1863 | uint8_t halfV[64];\ | ||
1864 | uint8_t halfHV[64];\ | ||
1865 | copy_block9(full, src, 16, stride, 9);\ | ||
1866 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1867 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ | ||
1868 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1869 | OPNAME ## pixels8_l4(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | ||
1870 | }\ | ||
1871 | static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1872 | uint8_t full[16*9];\ | ||
1873 | uint8_t halfH[72];\ | ||
1874 | uint8_t halfHV[64];\ | ||
1875 | copy_block9(full, src, 16, stride, 9);\ | ||
1876 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1877 | put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ | ||
1878 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1879 | OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ | ||
1880 | }\ | ||
1881 | void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1882 | uint8_t full[16*9];\ | ||
1883 | uint8_t halfH[72];\ | ||
1884 | uint8_t halfV[64];\ | ||
1885 | uint8_t halfHV[64];\ | ||
1886 | copy_block9(full, src, 16, stride, 9);\ | ||
1887 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1888 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ | ||
1889 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1890 | OPNAME ## pixels8_l4(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | ||
1891 | }\ | ||
1892 | static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1893 | uint8_t full[16*9];\ | ||
1894 | uint8_t halfH[72];\ | ||
1895 | uint8_t halfHV[64];\ | ||
1896 | copy_block9(full, src, 16, stride, 9);\ | ||
1897 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1898 | put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ | ||
1899 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1900 | OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ | ||
1901 | }\ | ||
1902 | void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1903 | uint8_t full[16*9];\ | ||
1904 | uint8_t halfH[72];\ | ||
1905 | uint8_t halfV[64];\ | ||
1906 | uint8_t halfHV[64];\ | ||
1907 | copy_block9(full, src, 16, stride, 9);\ | ||
1908 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full , 8, 16, 9);\ | ||
1909 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ | ||
1910 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1911 | OPNAME ## pixels8_l4(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\ | ||
1912 | }\ | ||
1913 | static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1914 | uint8_t full[16*9];\ | ||
1915 | uint8_t halfH[72];\ | ||
1916 | uint8_t halfHV[64];\ | ||
1917 | copy_block9(full, src, 16, stride, 9);\ | ||
1918 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1919 | put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ | ||
1920 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1921 | OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ | ||
1922 | }\ | ||
1923 | static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1924 | uint8_t halfH[72];\ | ||
1925 | uint8_t halfHV[64];\ | ||
1926 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | ||
1927 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1928 | OPNAME ## pixels8_l2(dst, halfH, halfHV, stride, 8, 8, 8);\ | ||
1929 | }\ | ||
1930 | static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1931 | uint8_t halfH[72];\ | ||
1932 | uint8_t halfHV[64];\ | ||
1933 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | ||
1934 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1935 | OPNAME ## pixels8_l2(dst, halfH+8, halfHV, stride, 8, 8, 8);\ | ||
1936 | }\ | ||
1937 | void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1938 | uint8_t full[16*9];\ | ||
1939 | uint8_t halfH[72];\ | ||
1940 | uint8_t halfV[64];\ | ||
1941 | uint8_t halfHV[64];\ | ||
1942 | copy_block9(full, src, 16, stride, 9);\ | ||
1943 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1944 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\ | ||
1945 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1946 | OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ | ||
1947 | }\ | ||
1948 | static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1949 | uint8_t full[16*9];\ | ||
1950 | uint8_t halfH[72];\ | ||
1951 | copy_block9(full, src, 16, stride, 9);\ | ||
1952 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1953 | put ## RND ## pixels8_l2(halfH, halfH, full, 8, 8, 16, 9);\ | ||
1954 | OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ | ||
1955 | }\ | ||
1956 | void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1957 | uint8_t full[16*9];\ | ||
1958 | uint8_t halfH[72];\ | ||
1959 | uint8_t halfV[64];\ | ||
1960 | uint8_t halfHV[64];\ | ||
1961 | copy_block9(full, src, 16, stride, 9);\ | ||
1962 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1963 | put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\ | ||
1964 | put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\ | ||
1965 | OPNAME ## pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8);\ | ||
1966 | }\ | ||
1967 | static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1968 | uint8_t full[16*9];\ | ||
1969 | uint8_t halfH[72];\ | ||
1970 | copy_block9(full, src, 16, stride, 9);\ | ||
1971 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\ | ||
1972 | put ## RND ## pixels8_l2(halfH, halfH, full+1, 8, 8, 16, 9);\ | ||
1973 | OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ | ||
1974 | }\ | ||
1975 | static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1976 | uint8_t halfH[72];\ | ||
1977 | put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\ | ||
1978 | OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\ | ||
1979 | }\ | ||
1980 | static void OPNAME ## qpel16_mc00_c (uint8_t *dst, uint8_t *src, int stride){\ | ||
1981 | OPNAME ## pixels16_c(dst, src, stride, 16);\ | ||
1982 | }\ | ||
1983 | \ | ||
1984 | static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1985 | uint8_t half[256];\ | ||
1986 | put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ | ||
1987 | OPNAME ## pixels16_l2(dst, src, half, stride, stride, 16, 16);\ | ||
1988 | }\ | ||
1989 | \ | ||
1990 | static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1991 | OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\ | ||
1992 | }\ | ||
1993 | \ | ||
1994 | static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
1995 | uint8_t half[256];\ | ||
1996 | put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\ | ||
1997 | OPNAME ## pixels16_l2(dst, src+1, half, stride, stride, 16, 16);\ | ||
1998 | }\ | ||
1999 | \ | ||
2000 | static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2001 | uint8_t full[24*17];\ | ||
2002 | uint8_t half[256];\ | ||
2003 | copy_block17(full, src, 24, stride, 17);\ | ||
2004 | put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ | ||
2005 | OPNAME ## pixels16_l2(dst, full, half, stride, 24, 16, 16);\ | ||
2006 | }\ | ||
2007 | \ | ||
2008 | static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2009 | uint8_t full[24*17];\ | ||
2010 | copy_block17(full, src, 24, stride, 17);\ | ||
2011 | OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\ | ||
2012 | }\ | ||
2013 | \ | ||
2014 | static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2015 | uint8_t full[24*17];\ | ||
2016 | uint8_t half[256];\ | ||
2017 | copy_block17(full, src, 24, stride, 17);\ | ||
2018 | put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\ | ||
2019 | OPNAME ## pixels16_l2(dst, full+24, half, stride, 24, 16, 16);\ | ||
2020 | }\ | ||
2021 | void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2022 | uint8_t full[24*17];\ | ||
2023 | uint8_t halfH[272];\ | ||
2024 | uint8_t halfV[256];\ | ||
2025 | uint8_t halfHV[256];\ | ||
2026 | copy_block17(full, src, 24, stride, 17);\ | ||
2027 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2028 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ | ||
2029 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2030 | OPNAME ## pixels16_l4(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | ||
2031 | }\ | ||
2032 | static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2033 | uint8_t full[24*17];\ | ||
2034 | uint8_t halfH[272];\ | ||
2035 | uint8_t halfHV[256];\ | ||
2036 | copy_block17(full, src, 24, stride, 17);\ | ||
2037 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2038 | put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ | ||
2039 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2040 | OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ | ||
2041 | }\ | ||
2042 | void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2043 | uint8_t full[24*17];\ | ||
2044 | uint8_t halfH[272];\ | ||
2045 | uint8_t halfV[256];\ | ||
2046 | uint8_t halfHV[256];\ | ||
2047 | copy_block17(full, src, 24, stride, 17);\ | ||
2048 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2049 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ | ||
2050 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2051 | OPNAME ## pixels16_l4(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | ||
2052 | }\ | ||
2053 | static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2054 | uint8_t full[24*17];\ | ||
2055 | uint8_t halfH[272];\ | ||
2056 | uint8_t halfHV[256];\ | ||
2057 | copy_block17(full, src, 24, stride, 17);\ | ||
2058 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2059 | put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ | ||
2060 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2061 | OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ | ||
2062 | }\ | ||
2063 | void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2064 | uint8_t full[24*17];\ | ||
2065 | uint8_t halfH[272];\ | ||
2066 | uint8_t halfV[256];\ | ||
2067 | uint8_t halfHV[256];\ | ||
2068 | copy_block17(full, src, 24, stride, 17);\ | ||
2069 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2070 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ | ||
2071 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2072 | OPNAME ## pixels16_l4(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | ||
2073 | }\ | ||
2074 | static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2075 | uint8_t full[24*17];\ | ||
2076 | uint8_t halfH[272];\ | ||
2077 | uint8_t halfHV[256];\ | ||
2078 | copy_block17(full, src, 24, stride, 17);\ | ||
2079 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2080 | put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ | ||
2081 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2082 | OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ | ||
2083 | }\ | ||
2084 | void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2085 | uint8_t full[24*17];\ | ||
2086 | uint8_t halfH[272];\ | ||
2087 | uint8_t halfV[256];\ | ||
2088 | uint8_t halfHV[256];\ | ||
2089 | copy_block17(full, src, 24, stride, 17);\ | ||
2090 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full , 16, 24, 17);\ | ||
2091 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ | ||
2092 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2093 | OPNAME ## pixels16_l4(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\ | ||
2094 | }\ | ||
2095 | static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2096 | uint8_t full[24*17];\ | ||
2097 | uint8_t halfH[272];\ | ||
2098 | uint8_t halfHV[256];\ | ||
2099 | copy_block17(full, src, 24, stride, 17);\ | ||
2100 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2101 | put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ | ||
2102 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2103 | OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ | ||
2104 | }\ | ||
2105 | static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2106 | uint8_t halfH[272];\ | ||
2107 | uint8_t halfHV[256];\ | ||
2108 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | ||
2109 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2110 | OPNAME ## pixels16_l2(dst, halfH, halfHV, stride, 16, 16, 16);\ | ||
2111 | }\ | ||
2112 | static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2113 | uint8_t halfH[272];\ | ||
2114 | uint8_t halfHV[256];\ | ||
2115 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | ||
2116 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2117 | OPNAME ## pixels16_l2(dst, halfH+16, halfHV, stride, 16, 16, 16);\ | ||
2118 | }\ | ||
2119 | void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2120 | uint8_t full[24*17];\ | ||
2121 | uint8_t halfH[272];\ | ||
2122 | uint8_t halfV[256];\ | ||
2123 | uint8_t halfHV[256];\ | ||
2124 | copy_block17(full, src, 24, stride, 17);\ | ||
2125 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2126 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\ | ||
2127 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2128 | OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ | ||
2129 | }\ | ||
2130 | static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2131 | uint8_t full[24*17];\ | ||
2132 | uint8_t halfH[272];\ | ||
2133 | copy_block17(full, src, 24, stride, 17);\ | ||
2134 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2135 | put ## RND ## pixels16_l2(halfH, halfH, full, 16, 16, 24, 17);\ | ||
2136 | OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ | ||
2137 | }\ | ||
2138 | void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2139 | uint8_t full[24*17];\ | ||
2140 | uint8_t halfH[272];\ | ||
2141 | uint8_t halfV[256];\ | ||
2142 | uint8_t halfHV[256];\ | ||
2143 | copy_block17(full, src, 24, stride, 17);\ | ||
2144 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2145 | put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\ | ||
2146 | put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\ | ||
2147 | OPNAME ## pixels16_l2(dst, halfV, halfHV, stride, 16, 16, 16);\ | ||
2148 | }\ | ||
2149 | static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2150 | uint8_t full[24*17];\ | ||
2151 | uint8_t halfH[272];\ | ||
2152 | copy_block17(full, src, 24, stride, 17);\ | ||
2153 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\ | ||
2154 | put ## RND ## pixels16_l2(halfH, halfH, full+1, 16, 16, 24, 17);\ | ||
2155 | OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ | ||
2156 | }\ | ||
2157 | static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2158 | uint8_t halfH[272];\ | ||
2159 | put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\ | ||
2160 | OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\ | ||
2161 | } | ||
2162 | |||
2163 | #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1) | ||
2164 | #define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1) | ||
2165 | #define op_put(a, b) a = cm[((b) + 16)>>5] | ||
2166 | #define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5] | ||
2167 | |||
2168 | QPEL_MC(0, put_ , _ , op_put) | ||
2169 | QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd) | ||
2170 | QPEL_MC(0, avg_ , _ , op_avg) | ||
2171 | //QPEL_MC(1, avg_no_rnd , _ , op_avg) | ||
2172 | #undef op_avg | ||
2173 | #undef op_avg_no_rnd | ||
2174 | #undef op_put | ||
2175 | #undef op_put_no_rnd | ||
2176 | |||
2177 | #if 1 | ||
2178 | #define H264_LOWPASS(OPNAME, OP, OP2) \ | ||
2179 | static av_unused void OPNAME ## h264_qpel2_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2180 | const int h=2;\ | ||
2181 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2182 | int i;\ | ||
2183 | for(i=0; i<h; i++)\ | ||
2184 | {\ | ||
2185 | OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\ | ||
2186 | OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\ | ||
2187 | dst+=dstStride;\ | ||
2188 | src+=srcStride;\ | ||
2189 | }\ | ||
2190 | }\ | ||
2191 | \ | ||
2192 | static av_unused void OPNAME ## h264_qpel2_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2193 | const int w=2;\ | ||
2194 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2195 | int i;\ | ||
2196 | for(i=0; i<w; i++)\ | ||
2197 | {\ | ||
2198 | const int srcB= src[-2*srcStride];\ | ||
2199 | const int srcA= src[-1*srcStride];\ | ||
2200 | const int src0= src[0 *srcStride];\ | ||
2201 | const int src1= src[1 *srcStride];\ | ||
2202 | const int src2= src[2 *srcStride];\ | ||
2203 | const int src3= src[3 *srcStride];\ | ||
2204 | const int src4= src[4 *srcStride];\ | ||
2205 | OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\ | ||
2206 | OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\ | ||
2207 | dst++;\ | ||
2208 | src++;\ | ||
2209 | }\ | ||
2210 | }\ | ||
2211 | \ | ||
2212 | static av_unused void OPNAME ## h264_qpel2_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | ||
2213 | const int h=2;\ | ||
2214 | const int w=2;\ | ||
2215 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2216 | int i;\ | ||
2217 | src -= 2*srcStride;\ | ||
2218 | for(i=0; i<h+5; i++)\ | ||
2219 | {\ | ||
2220 | tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\ | ||
2221 | tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\ | ||
2222 | tmp+=tmpStride;\ | ||
2223 | src+=srcStride;\ | ||
2224 | }\ | ||
2225 | tmp -= tmpStride*(h+5-2);\ | ||
2226 | for(i=0; i<w; i++)\ | ||
2227 | {\ | ||
2228 | const int tmpB= tmp[-2*tmpStride];\ | ||
2229 | const int tmpA= tmp[-1*tmpStride];\ | ||
2230 | const int tmp0= tmp[0 *tmpStride];\ | ||
2231 | const int tmp1= tmp[1 *tmpStride];\ | ||
2232 | const int tmp2= tmp[2 *tmpStride];\ | ||
2233 | const int tmp3= tmp[3 *tmpStride];\ | ||
2234 | const int tmp4= tmp[4 *tmpStride];\ | ||
2235 | OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\ | ||
2236 | OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\ | ||
2237 | dst++;\ | ||
2238 | tmp++;\ | ||
2239 | }\ | ||
2240 | }\ | ||
2241 | static void OPNAME ## h264_qpel4_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2242 | const int h=4;\ | ||
2243 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2244 | int i;\ | ||
2245 | for(i=0; i<h; i++)\ | ||
2246 | {\ | ||
2247 | OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]));\ | ||
2248 | OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]));\ | ||
2249 | OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]));\ | ||
2250 | OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]));\ | ||
2251 | dst+=dstStride;\ | ||
2252 | src+=srcStride;\ | ||
2253 | }\ | ||
2254 | }\ | ||
2255 | \ | ||
2256 | static void OPNAME ## h264_qpel4_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2257 | const int w=4;\ | ||
2258 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2259 | int i;\ | ||
2260 | for(i=0; i<w; i++)\ | ||
2261 | {\ | ||
2262 | const int srcB= src[-2*srcStride];\ | ||
2263 | const int srcA= src[-1*srcStride];\ | ||
2264 | const int src0= src[0 *srcStride];\ | ||
2265 | const int src1= src[1 *srcStride];\ | ||
2266 | const int src2= src[2 *srcStride];\ | ||
2267 | const int src3= src[3 *srcStride];\ | ||
2268 | const int src4= src[4 *srcStride];\ | ||
2269 | const int src5= src[5 *srcStride];\ | ||
2270 | const int src6= src[6 *srcStride];\ | ||
2271 | OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\ | ||
2272 | OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\ | ||
2273 | OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\ | ||
2274 | OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\ | ||
2275 | dst++;\ | ||
2276 | src++;\ | ||
2277 | }\ | ||
2278 | }\ | ||
2279 | \ | ||
2280 | static void OPNAME ## h264_qpel4_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | ||
2281 | const int h=4;\ | ||
2282 | const int w=4;\ | ||
2283 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2284 | int i;\ | ||
2285 | src -= 2*srcStride;\ | ||
2286 | for(i=0; i<h+5; i++)\ | ||
2287 | {\ | ||
2288 | tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3]);\ | ||
2289 | tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4]);\ | ||
2290 | tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5]);\ | ||
2291 | tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6]);\ | ||
2292 | tmp+=tmpStride;\ | ||
2293 | src+=srcStride;\ | ||
2294 | }\ | ||
2295 | tmp -= tmpStride*(h+5-2);\ | ||
2296 | for(i=0; i<w; i++)\ | ||
2297 | {\ | ||
2298 | const int tmpB= tmp[-2*tmpStride];\ | ||
2299 | const int tmpA= tmp[-1*tmpStride];\ | ||
2300 | const int tmp0= tmp[0 *tmpStride];\ | ||
2301 | const int tmp1= tmp[1 *tmpStride];\ | ||
2302 | const int tmp2= tmp[2 *tmpStride];\ | ||
2303 | const int tmp3= tmp[3 *tmpStride];\ | ||
2304 | const int tmp4= tmp[4 *tmpStride];\ | ||
2305 | const int tmp5= tmp[5 *tmpStride];\ | ||
2306 | const int tmp6= tmp[6 *tmpStride];\ | ||
2307 | OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\ | ||
2308 | OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\ | ||
2309 | OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\ | ||
2310 | OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\ | ||
2311 | dst++;\ | ||
2312 | tmp++;\ | ||
2313 | }\ | ||
2314 | }\ | ||
2315 | \ | ||
2316 | static void OPNAME ## h264_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2317 | const int h=8;\ | ||
2318 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2319 | int i;\ | ||
2320 | for(i=0; i<h; i++)\ | ||
2321 | {\ | ||
2322 | OP(dst[0], (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]));\ | ||
2323 | OP(dst[1], (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]));\ | ||
2324 | OP(dst[2], (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]));\ | ||
2325 | OP(dst[3], (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]));\ | ||
2326 | OP(dst[4], (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]));\ | ||
2327 | OP(dst[5], (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]));\ | ||
2328 | OP(dst[6], (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]));\ | ||
2329 | OP(dst[7], (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]));\ | ||
2330 | dst+=dstStride;\ | ||
2331 | src+=srcStride;\ | ||
2332 | }\ | ||
2333 | }\ | ||
2334 | \ | ||
2335 | static void OPNAME ## h264_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2336 | const int w=8;\ | ||
2337 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2338 | int i;\ | ||
2339 | for(i=0; i<w; i++)\ | ||
2340 | {\ | ||
2341 | const int srcB= src[-2*srcStride];\ | ||
2342 | const int srcA= src[-1*srcStride];\ | ||
2343 | const int src0= src[0 *srcStride];\ | ||
2344 | const int src1= src[1 *srcStride];\ | ||
2345 | const int src2= src[2 *srcStride];\ | ||
2346 | const int src3= src[3 *srcStride];\ | ||
2347 | const int src4= src[4 *srcStride];\ | ||
2348 | const int src5= src[5 *srcStride];\ | ||
2349 | const int src6= src[6 *srcStride];\ | ||
2350 | const int src7= src[7 *srcStride];\ | ||
2351 | const int src8= src[8 *srcStride];\ | ||
2352 | const int src9= src[9 *srcStride];\ | ||
2353 | const int src10=src[10*srcStride];\ | ||
2354 | OP(dst[0*dstStride], (src0+src1)*20 - (srcA+src2)*5 + (srcB+src3));\ | ||
2355 | OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*5 + (srcA+src4));\ | ||
2356 | OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*5 + (src0+src5));\ | ||
2357 | OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*5 + (src1+src6));\ | ||
2358 | OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*5 + (src2+src7));\ | ||
2359 | OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*5 + (src3+src8));\ | ||
2360 | OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*5 + (src4+src9));\ | ||
2361 | OP(dst[7*dstStride], (src7+src8)*20 - (src6+src9)*5 + (src5+src10));\ | ||
2362 | dst++;\ | ||
2363 | src++;\ | ||
2364 | }\ | ||
2365 | }\ | ||
2366 | \ | ||
2367 | static void OPNAME ## h264_qpel8_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | ||
2368 | const int h=8;\ | ||
2369 | const int w=8;\ | ||
2370 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\ | ||
2371 | int i;\ | ||
2372 | src -= 2*srcStride;\ | ||
2373 | for(i=0; i<h+5; i++)\ | ||
2374 | {\ | ||
2375 | tmp[0]= (src[0]+src[1])*20 - (src[-1]+src[2])*5 + (src[-2]+src[3 ]);\ | ||
2376 | tmp[1]= (src[1]+src[2])*20 - (src[0 ]+src[3])*5 + (src[-1]+src[4 ]);\ | ||
2377 | tmp[2]= (src[2]+src[3])*20 - (src[1 ]+src[4])*5 + (src[0 ]+src[5 ]);\ | ||
2378 | tmp[3]= (src[3]+src[4])*20 - (src[2 ]+src[5])*5 + (src[1 ]+src[6 ]);\ | ||
2379 | tmp[4]= (src[4]+src[5])*20 - (src[3 ]+src[6])*5 + (src[2 ]+src[7 ]);\ | ||
2380 | tmp[5]= (src[5]+src[6])*20 - (src[4 ]+src[7])*5 + (src[3 ]+src[8 ]);\ | ||
2381 | tmp[6]= (src[6]+src[7])*20 - (src[5 ]+src[8])*5 + (src[4 ]+src[9 ]);\ | ||
2382 | tmp[7]= (src[7]+src[8])*20 - (src[6 ]+src[9])*5 + (src[5 ]+src[10]);\ | ||
2383 | tmp+=tmpStride;\ | ||
2384 | src+=srcStride;\ | ||
2385 | }\ | ||
2386 | tmp -= tmpStride*(h+5-2);\ | ||
2387 | for(i=0; i<w; i++)\ | ||
2388 | {\ | ||
2389 | const int tmpB= tmp[-2*tmpStride];\ | ||
2390 | const int tmpA= tmp[-1*tmpStride];\ | ||
2391 | const int tmp0= tmp[0 *tmpStride];\ | ||
2392 | const int tmp1= tmp[1 *tmpStride];\ | ||
2393 | const int tmp2= tmp[2 *tmpStride];\ | ||
2394 | const int tmp3= tmp[3 *tmpStride];\ | ||
2395 | const int tmp4= tmp[4 *tmpStride];\ | ||
2396 | const int tmp5= tmp[5 *tmpStride];\ | ||
2397 | const int tmp6= tmp[6 *tmpStride];\ | ||
2398 | const int tmp7= tmp[7 *tmpStride];\ | ||
2399 | const int tmp8= tmp[8 *tmpStride];\ | ||
2400 | const int tmp9= tmp[9 *tmpStride];\ | ||
2401 | const int tmp10=tmp[10*tmpStride];\ | ||
2402 | OP2(dst[0*dstStride], (tmp0+tmp1)*20 - (tmpA+tmp2)*5 + (tmpB+tmp3));\ | ||
2403 | OP2(dst[1*dstStride], (tmp1+tmp2)*20 - (tmp0+tmp3)*5 + (tmpA+tmp4));\ | ||
2404 | OP2(dst[2*dstStride], (tmp2+tmp3)*20 - (tmp1+tmp4)*5 + (tmp0+tmp5));\ | ||
2405 | OP2(dst[3*dstStride], (tmp3+tmp4)*20 - (tmp2+tmp5)*5 + (tmp1+tmp6));\ | ||
2406 | OP2(dst[4*dstStride], (tmp4+tmp5)*20 - (tmp3+tmp6)*5 + (tmp2+tmp7));\ | ||
2407 | OP2(dst[5*dstStride], (tmp5+tmp6)*20 - (tmp4+tmp7)*5 + (tmp3+tmp8));\ | ||
2408 | OP2(dst[6*dstStride], (tmp6+tmp7)*20 - (tmp5+tmp8)*5 + (tmp4+tmp9));\ | ||
2409 | OP2(dst[7*dstStride], (tmp7+tmp8)*20 - (tmp6+tmp9)*5 + (tmp5+tmp10));\ | ||
2410 | dst++;\ | ||
2411 | tmp++;\ | ||
2412 | }\ | ||
2413 | }\ | ||
2414 | \ | ||
2415 | static void OPNAME ## h264_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2416 | OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\ | ||
2417 | OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\ | ||
2418 | src += 8*srcStride;\ | ||
2419 | dst += 8*dstStride;\ | ||
2420 | OPNAME ## h264_qpel8_v_lowpass(dst , src , dstStride, srcStride);\ | ||
2421 | OPNAME ## h264_qpel8_v_lowpass(dst+8, src+8, dstStride, srcStride);\ | ||
2422 | }\ | ||
2423 | \ | ||
2424 | static void OPNAME ## h264_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\ | ||
2425 | OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\ | ||
2426 | OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\ | ||
2427 | src += 8*srcStride;\ | ||
2428 | dst += 8*dstStride;\ | ||
2429 | OPNAME ## h264_qpel8_h_lowpass(dst , src , dstStride, srcStride);\ | ||
2430 | OPNAME ## h264_qpel8_h_lowpass(dst+8, src+8, dstStride, srcStride);\ | ||
2431 | }\ | ||
2432 | \ | ||
2433 | static void OPNAME ## h264_qpel16_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\ | ||
2434 | OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\ | ||
2435 | OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\ | ||
2436 | src += 8*srcStride;\ | ||
2437 | dst += 8*dstStride;\ | ||
2438 | OPNAME ## h264_qpel8_hv_lowpass(dst , tmp , src , dstStride, tmpStride, srcStride);\ | ||
2439 | OPNAME ## h264_qpel8_hv_lowpass(dst+8, tmp+8, src+8, dstStride, tmpStride, srcStride);\ | ||
2440 | }\ | ||
2441 | |||
2442 | #define H264_MC(OPNAME, SIZE) \ | ||
2443 | static void OPNAME ## h264_qpel ## SIZE ## _mc00_c (uint8_t *dst, uint8_t *src, int stride){\ | ||
2444 | OPNAME ## pixels ## SIZE ## _c(dst, src, stride, SIZE);\ | ||
2445 | }\ | ||
2446 | \ | ||
2447 | static void OPNAME ## h264_qpel ## SIZE ## _mc10_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2448 | uint8_t half[SIZE*SIZE];\ | ||
2449 | put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\ | ||
2450 | OPNAME ## pixels ## SIZE ## _l2(dst, src, half, stride, stride, SIZE, SIZE);\ | ||
2451 | }\ | ||
2452 | \ | ||
2453 | static void OPNAME ## h264_qpel ## SIZE ## _mc20_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2454 | OPNAME ## h264_qpel ## SIZE ## _h_lowpass(dst, src, stride, stride);\ | ||
2455 | }\ | ||
2456 | \ | ||
2457 | static void OPNAME ## h264_qpel ## SIZE ## _mc30_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2458 | uint8_t half[SIZE*SIZE];\ | ||
2459 | put_h264_qpel ## SIZE ## _h_lowpass(half, src, SIZE, stride);\ | ||
2460 | OPNAME ## pixels ## SIZE ## _l2(dst, src+1, half, stride, stride, SIZE, SIZE);\ | ||
2461 | }\ | ||
2462 | \ | ||
2463 | static void OPNAME ## h264_qpel ## SIZE ## _mc01_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2464 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2465 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2466 | uint8_t half[SIZE*SIZE];\ | ||
2467 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2468 | put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\ | ||
2469 | OPNAME ## pixels ## SIZE ## _l2(dst, full_mid, half, stride, SIZE, SIZE, SIZE);\ | ||
2470 | }\ | ||
2471 | \ | ||
2472 | static void OPNAME ## h264_qpel ## SIZE ## _mc02_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2473 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2474 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2475 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2476 | OPNAME ## h264_qpel ## SIZE ## _v_lowpass(dst, full_mid, stride, SIZE);\ | ||
2477 | }\ | ||
2478 | \ | ||
2479 | static void OPNAME ## h264_qpel ## SIZE ## _mc03_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2480 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2481 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2482 | uint8_t half[SIZE*SIZE];\ | ||
2483 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2484 | put_h264_qpel ## SIZE ## _v_lowpass(half, full_mid, SIZE, SIZE);\ | ||
2485 | OPNAME ## pixels ## SIZE ## _l2(dst, full_mid+SIZE, half, stride, SIZE, SIZE, SIZE);\ | ||
2486 | }\ | ||
2487 | \ | ||
2488 | static void OPNAME ## h264_qpel ## SIZE ## _mc11_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2489 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2490 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2491 | uint8_t halfH[SIZE*SIZE];\ | ||
2492 | uint8_t halfV[SIZE*SIZE];\ | ||
2493 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ | ||
2494 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2495 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2496 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ | ||
2497 | }\ | ||
2498 | \ | ||
2499 | static void OPNAME ## h264_qpel ## SIZE ## _mc31_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2500 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2501 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2502 | uint8_t halfH[SIZE*SIZE];\ | ||
2503 | uint8_t halfV[SIZE*SIZE];\ | ||
2504 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ | ||
2505 | copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ | ||
2506 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2507 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ | ||
2508 | }\ | ||
2509 | \ | ||
2510 | static void OPNAME ## h264_qpel ## SIZE ## _mc13_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2511 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2512 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2513 | uint8_t halfH[SIZE*SIZE];\ | ||
2514 | uint8_t halfV[SIZE*SIZE];\ | ||
2515 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ | ||
2516 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2517 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2518 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ | ||
2519 | }\ | ||
2520 | \ | ||
2521 | static void OPNAME ## h264_qpel ## SIZE ## _mc33_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2522 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2523 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2524 | uint8_t halfH[SIZE*SIZE];\ | ||
2525 | uint8_t halfV[SIZE*SIZE];\ | ||
2526 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ | ||
2527 | copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ | ||
2528 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2529 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfV, stride, SIZE, SIZE, SIZE);\ | ||
2530 | }\ | ||
2531 | \ | ||
2532 | static void OPNAME ## h264_qpel ## SIZE ## _mc22_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2533 | int16_t tmp[SIZE*(SIZE+5)];\ | ||
2534 | OPNAME ## h264_qpel ## SIZE ## _hv_lowpass(dst, tmp, src, stride, SIZE, stride);\ | ||
2535 | }\ | ||
2536 | \ | ||
2537 | static void OPNAME ## h264_qpel ## SIZE ## _mc21_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2538 | int16_t tmp[SIZE*(SIZE+5)];\ | ||
2539 | uint8_t halfH[SIZE*SIZE];\ | ||
2540 | uint8_t halfHV[SIZE*SIZE];\ | ||
2541 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src, SIZE, stride);\ | ||
2542 | put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ | ||
2543 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\ | ||
2544 | }\ | ||
2545 | \ | ||
2546 | static void OPNAME ## h264_qpel ## SIZE ## _mc23_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2547 | int16_t tmp[SIZE*(SIZE+5)];\ | ||
2548 | uint8_t halfH[SIZE*SIZE];\ | ||
2549 | uint8_t halfHV[SIZE*SIZE];\ | ||
2550 | put_h264_qpel ## SIZE ## _h_lowpass(halfH, src + stride, SIZE, stride);\ | ||
2551 | put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ | ||
2552 | OPNAME ## pixels ## SIZE ## _l2(dst, halfH, halfHV, stride, SIZE, SIZE, SIZE);\ | ||
2553 | }\ | ||
2554 | \ | ||
2555 | static void OPNAME ## h264_qpel ## SIZE ## _mc12_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2556 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2557 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2558 | int16_t tmp[SIZE*(SIZE+5)];\ | ||
2559 | uint8_t halfV[SIZE*SIZE];\ | ||
2560 | uint8_t halfHV[SIZE*SIZE];\ | ||
2561 | copy_block ## SIZE (full, src - stride*2, SIZE, stride, SIZE + 5);\ | ||
2562 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2563 | put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ | ||
2564 | OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\ | ||
2565 | }\ | ||
2566 | \ | ||
2567 | static void OPNAME ## h264_qpel ## SIZE ## _mc32_c(uint8_t *dst, uint8_t *src, int stride){\ | ||
2568 | uint8_t full[SIZE*(SIZE+5)];\ | ||
2569 | uint8_t * const full_mid= full + SIZE*2;\ | ||
2570 | int16_t tmp[SIZE*(SIZE+5)];\ | ||
2571 | uint8_t halfV[SIZE*SIZE];\ | ||
2572 | uint8_t halfHV[SIZE*SIZE];\ | ||
2573 | copy_block ## SIZE (full, src - stride*2 + 1, SIZE, stride, SIZE + 5);\ | ||
2574 | put_h264_qpel ## SIZE ## _v_lowpass(halfV, full_mid, SIZE, SIZE);\ | ||
2575 | put_h264_qpel ## SIZE ## _hv_lowpass(halfHV, tmp, src, SIZE, SIZE, stride);\ | ||
2576 | OPNAME ## pixels ## SIZE ## _l2(dst, halfV, halfHV, stride, SIZE, SIZE, SIZE);\ | ||
2577 | }\ | ||
2578 | |||
2579 | #define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1) | ||
2580 | //#define op_avg2(a, b) a = (((a)*w1+cm[((b) + 16)>>5]*w2 + o + 64)>>7) | ||
2581 | #define op_put(a, b) a = cm[((b) + 16)>>5] | ||
2582 | #define op2_avg(a, b) a = (((a)+cm[((b) + 512)>>10]+1)>>1) | ||
2583 | #define op2_put(a, b) a = cm[((b) + 512)>>10] | ||
2584 | |||
2585 | H264_LOWPASS(put_ , op_put, op2_put) | ||
2586 | H264_LOWPASS(avg_ , op_avg, op2_avg) | ||
2587 | H264_MC(put_, 2) | ||
2588 | H264_MC(put_, 4) | ||
2589 | H264_MC(put_, 8) | ||
2590 | H264_MC(put_, 16) | ||
2591 | H264_MC(avg_, 4) | ||
2592 | H264_MC(avg_, 8) | ||
2593 | H264_MC(avg_, 16) | ||
2594 | |||
2595 | #undef op_avg | ||
2596 | #undef op_put | ||
2597 | #undef op2_avg | ||
2598 | #undef op2_put | ||
2599 | #endif | ||
2600 | |||
2601 | static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){ | ||
2602 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
2603 | int i; | ||
2604 | |||
2605 | for(i=0; i<h; i++){ | ||
2606 | dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4]; | ||
2607 | dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4]; | ||
2608 | dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4]; | ||
2609 | dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4]; | ||
2610 | dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4]; | ||
2611 | dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4]; | ||
2612 | dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4]; | ||
2613 | dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4]; | ||
2614 | dst+=dstStride; | ||
2615 | src+=srcStride; | ||
2616 | } | ||
2617 | } | ||
2618 | |||
2619 | #if CONFIG_CAVS_DECODER | ||
2620 | /* AVS specific */ | ||
2621 | void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) { | ||
2622 | put_pixels8_c(dst, src, stride, 8); | ||
2623 | } | ||
2624 | void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride) { | ||
2625 | avg_pixels8_c(dst, src, stride, 8); | ||
2626 | } | ||
2627 | void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) { | ||
2628 | put_pixels16_c(dst, src, stride, 16); | ||
2629 | } | ||
2630 | void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride) { | ||
2631 | avg_pixels16_c(dst, src, stride, 16); | ||
2632 | } | ||
2633 | #endif /* CONFIG_CAVS_DECODER */ | ||
2634 | |||
2635 | #if CONFIG_VC1_DECODER | ||
2636 | /* VC-1 specific */ | ||
2637 | void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { | ||
2638 | put_pixels8_c(dst, src, stride, 8); | ||
2639 | } | ||
2640 | void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd) { | ||
2641 | avg_pixels8_c(dst, src, stride, 8); | ||
2642 | } | ||
2643 | #endif /* CONFIG_VC1_DECODER */ | ||
2644 | |||
2645 | #if CONFIG_RV40_DECODER | ||
2646 | static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2647 | put_pixels16_xy2_c(dst, src, stride, 16); | ||
2648 | } | ||
2649 | static void avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2650 | avg_pixels16_xy2_c(dst, src, stride, 16); | ||
2651 | } | ||
2652 | static void put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2653 | put_pixels8_xy2_c(dst, src, stride, 8); | ||
2654 | } | ||
2655 | static void avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2656 | avg_pixels8_xy2_c(dst, src, stride, 8); | ||
2657 | } | ||
2658 | #endif /* CONFIG_RV40_DECODER */ | ||
2659 | |||
2660 | static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){ | ||
2661 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
2662 | int i; | ||
2663 | |||
2664 | for(i=0; i<w; i++){ | ||
2665 | const int src_1= src[ -srcStride]; | ||
2666 | const int src0 = src[0 ]; | ||
2667 | const int src1 = src[ srcStride]; | ||
2668 | const int src2 = src[2*srcStride]; | ||
2669 | const int src3 = src[3*srcStride]; | ||
2670 | const int src4 = src[4*srcStride]; | ||
2671 | const int src5 = src[5*srcStride]; | ||
2672 | const int src6 = src[6*srcStride]; | ||
2673 | const int src7 = src[7*srcStride]; | ||
2674 | const int src8 = src[8*srcStride]; | ||
2675 | const int src9 = src[9*srcStride]; | ||
2676 | dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4]; | ||
2677 | dst[1*dstStride]= cm[(9*(src1 + src2) - (src0 + src3) + 8)>>4]; | ||
2678 | dst[2*dstStride]= cm[(9*(src2 + src3) - (src1 + src4) + 8)>>4]; | ||
2679 | dst[3*dstStride]= cm[(9*(src3 + src4) - (src2 + src5) + 8)>>4]; | ||
2680 | dst[4*dstStride]= cm[(9*(src4 + src5) - (src3 + src6) + 8)>>4]; | ||
2681 | dst[5*dstStride]= cm[(9*(src5 + src6) - (src4 + src7) + 8)>>4]; | ||
2682 | dst[6*dstStride]= cm[(9*(src6 + src7) - (src5 + src8) + 8)>>4]; | ||
2683 | dst[7*dstStride]= cm[(9*(src7 + src8) - (src6 + src9) + 8)>>4]; | ||
2684 | src++; | ||
2685 | dst++; | ||
2686 | } | ||
2687 | } | ||
2688 | |||
2689 | static void put_mspel8_mc00_c (uint8_t *dst, uint8_t *src, int stride){ | ||
2690 | put_pixels8_c(dst, src, stride, 8); | ||
2691 | } | ||
2692 | |||
2693 | static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2694 | uint8_t half[64]; | ||
2695 | wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); | ||
2696 | put_pixels8_l2(dst, src, half, stride, stride, 8, 8); | ||
2697 | } | ||
2698 | |||
2699 | static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2700 | wmv2_mspel8_h_lowpass(dst, src, stride, stride, 8); | ||
2701 | } | ||
2702 | |||
2703 | static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2704 | uint8_t half[64]; | ||
2705 | wmv2_mspel8_h_lowpass(half, src, 8, stride, 8); | ||
2706 | put_pixels8_l2(dst, src+1, half, stride, stride, 8, 8); | ||
2707 | } | ||
2708 | |||
2709 | static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2710 | wmv2_mspel8_v_lowpass(dst, src, stride, stride, 8); | ||
2711 | } | ||
2712 | |||
2713 | static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2714 | uint8_t halfH[88]; | ||
2715 | uint8_t halfV[64]; | ||
2716 | uint8_t halfHV[64]; | ||
2717 | wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); | ||
2718 | wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8); | ||
2719 | wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); | ||
2720 | put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); | ||
2721 | } | ||
2722 | static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2723 | uint8_t halfH[88]; | ||
2724 | uint8_t halfV[64]; | ||
2725 | uint8_t halfHV[64]; | ||
2726 | wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); | ||
2727 | wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8); | ||
2728 | wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8); | ||
2729 | put_pixels8_l2(dst, halfV, halfHV, stride, 8, 8, 8); | ||
2730 | } | ||
2731 | static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, int stride){ | ||
2732 | uint8_t halfH[88]; | ||
2733 | wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11); | ||
2734 | wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8); | ||
2735 | } | ||
2736 | |||
2737 | static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){ | ||
2738 | if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { | ||
2739 | int x; | ||
2740 | const int strength= ff_h263_loop_filter_strength[qscale]; | ||
2741 | |||
2742 | for(x=0; x<8; x++){ | ||
2743 | int d1, d2, ad1; | ||
2744 | int p0= src[x-2*stride]; | ||
2745 | int p1= src[x-1*stride]; | ||
2746 | int p2= src[x+0*stride]; | ||
2747 | int p3= src[x+1*stride]; | ||
2748 | int d = (p0 - p3 + 4*(p2 - p1)) / 8; | ||
2749 | |||
2750 | if (d<-2*strength) d1= 0; | ||
2751 | else if(d<- strength) d1=-2*strength - d; | ||
2752 | else if(d< strength) d1= d; | ||
2753 | else if(d< 2*strength) d1= 2*strength - d; | ||
2754 | else d1= 0; | ||
2755 | |||
2756 | p1 += d1; | ||
2757 | p2 -= d1; | ||
2758 | if(p1&256) p1= ~(p1>>31); | ||
2759 | if(p2&256) p2= ~(p2>>31); | ||
2760 | |||
2761 | src[x-1*stride] = p1; | ||
2762 | src[x+0*stride] = p2; | ||
2763 | |||
2764 | ad1= FFABS(d1)>>1; | ||
2765 | |||
2766 | d2= av_clip((p0-p3)/4, -ad1, ad1); | ||
2767 | |||
2768 | src[x-2*stride] = p0 - d2; | ||
2769 | src[x+ stride] = p3 + d2; | ||
2770 | } | ||
2771 | } | ||
2772 | } | ||
2773 | |||
2774 | static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){ | ||
2775 | if(CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { | ||
2776 | int y; | ||
2777 | const int strength= ff_h263_loop_filter_strength[qscale]; | ||
2778 | |||
2779 | for(y=0; y<8; y++){ | ||
2780 | int d1, d2, ad1; | ||
2781 | int p0= src[y*stride-2]; | ||
2782 | int p1= src[y*stride-1]; | ||
2783 | int p2= src[y*stride+0]; | ||
2784 | int p3= src[y*stride+1]; | ||
2785 | int d = (p0 - p3 + 4*(p2 - p1)) / 8; | ||
2786 | |||
2787 | if (d<-2*strength) d1= 0; | ||
2788 | else if(d<- strength) d1=-2*strength - d; | ||
2789 | else if(d< strength) d1= d; | ||
2790 | else if(d< 2*strength) d1= 2*strength - d; | ||
2791 | else d1= 0; | ||
2792 | |||
2793 | p1 += d1; | ||
2794 | p2 -= d1; | ||
2795 | if(p1&256) p1= ~(p1>>31); | ||
2796 | if(p2&256) p2= ~(p2>>31); | ||
2797 | |||
2798 | src[y*stride-1] = p1; | ||
2799 | src[y*stride+0] = p2; | ||
2800 | |||
2801 | ad1= FFABS(d1)>>1; | ||
2802 | |||
2803 | d2= av_clip((p0-p3)/4, -ad1, ad1); | ||
2804 | |||
2805 | src[y*stride-2] = p0 - d2; | ||
2806 | src[y*stride+1] = p3 + d2; | ||
2807 | } | ||
2808 | } | ||
2809 | } | ||
2810 | |||
2811 | static void h261_loop_filter_c(uint8_t *src, int stride){ | ||
2812 | int x,y,xy,yz; | ||
2813 | int temp[64]; | ||
2814 | |||
2815 | for(x=0; x<8; x++){ | ||
2816 | temp[x ] = 4*src[x ]; | ||
2817 | temp[x + 7*8] = 4*src[x + 7*stride]; | ||
2818 | } | ||
2819 | for(y=1; y<7; y++){ | ||
2820 | for(x=0; x<8; x++){ | ||
2821 | xy = y * stride + x; | ||
2822 | yz = y * 8 + x; | ||
2823 | temp[yz] = src[xy - stride] + 2*src[xy] + src[xy + stride]; | ||
2824 | } | ||
2825 | } | ||
2826 | |||
2827 | for(y=0; y<8; y++){ | ||
2828 | src[ y*stride] = (temp[ y*8] + 2)>>2; | ||
2829 | src[7+y*stride] = (temp[7+y*8] + 2)>>2; | ||
2830 | for(x=1; x<7; x++){ | ||
2831 | xy = y * stride + x; | ||
2832 | yz = y * 8 + x; | ||
2833 | src[xy] = (temp[yz-1] + 2*temp[yz] + temp[yz+1] + 8)>>4; | ||
2834 | } | ||
2835 | } | ||
2836 | } | ||
2837 | |||
2838 | static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2839 | { | ||
2840 | int s, i; | ||
2841 | |||
2842 | s = 0; | ||
2843 | for(i=0;i<h;i++) { | ||
2844 | s += abs(pix1[0] - pix2[0]); | ||
2845 | s += abs(pix1[1] - pix2[1]); | ||
2846 | s += abs(pix1[2] - pix2[2]); | ||
2847 | s += abs(pix1[3] - pix2[3]); | ||
2848 | s += abs(pix1[4] - pix2[4]); | ||
2849 | s += abs(pix1[5] - pix2[5]); | ||
2850 | s += abs(pix1[6] - pix2[6]); | ||
2851 | s += abs(pix1[7] - pix2[7]); | ||
2852 | s += abs(pix1[8] - pix2[8]); | ||
2853 | s += abs(pix1[9] - pix2[9]); | ||
2854 | s += abs(pix1[10] - pix2[10]); | ||
2855 | s += abs(pix1[11] - pix2[11]); | ||
2856 | s += abs(pix1[12] - pix2[12]); | ||
2857 | s += abs(pix1[13] - pix2[13]); | ||
2858 | s += abs(pix1[14] - pix2[14]); | ||
2859 | s += abs(pix1[15] - pix2[15]); | ||
2860 | pix1 += line_size; | ||
2861 | pix2 += line_size; | ||
2862 | } | ||
2863 | return s; | ||
2864 | } | ||
2865 | |||
2866 | static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2867 | { | ||
2868 | int s, i; | ||
2869 | |||
2870 | s = 0; | ||
2871 | for(i=0;i<h;i++) { | ||
2872 | s += abs(pix1[0] - avg2(pix2[0], pix2[1])); | ||
2873 | s += abs(pix1[1] - avg2(pix2[1], pix2[2])); | ||
2874 | s += abs(pix1[2] - avg2(pix2[2], pix2[3])); | ||
2875 | s += abs(pix1[3] - avg2(pix2[3], pix2[4])); | ||
2876 | s += abs(pix1[4] - avg2(pix2[4], pix2[5])); | ||
2877 | s += abs(pix1[5] - avg2(pix2[5], pix2[6])); | ||
2878 | s += abs(pix1[6] - avg2(pix2[6], pix2[7])); | ||
2879 | s += abs(pix1[7] - avg2(pix2[7], pix2[8])); | ||
2880 | s += abs(pix1[8] - avg2(pix2[8], pix2[9])); | ||
2881 | s += abs(pix1[9] - avg2(pix2[9], pix2[10])); | ||
2882 | s += abs(pix1[10] - avg2(pix2[10], pix2[11])); | ||
2883 | s += abs(pix1[11] - avg2(pix2[11], pix2[12])); | ||
2884 | s += abs(pix1[12] - avg2(pix2[12], pix2[13])); | ||
2885 | s += abs(pix1[13] - avg2(pix2[13], pix2[14])); | ||
2886 | s += abs(pix1[14] - avg2(pix2[14], pix2[15])); | ||
2887 | s += abs(pix1[15] - avg2(pix2[15], pix2[16])); | ||
2888 | pix1 += line_size; | ||
2889 | pix2 += line_size; | ||
2890 | } | ||
2891 | return s; | ||
2892 | } | ||
2893 | |||
2894 | static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2895 | { | ||
2896 | int s, i; | ||
2897 | uint8_t *pix3 = pix2 + line_size; | ||
2898 | |||
2899 | s = 0; | ||
2900 | for(i=0;i<h;i++) { | ||
2901 | s += abs(pix1[0] - avg2(pix2[0], pix3[0])); | ||
2902 | s += abs(pix1[1] - avg2(pix2[1], pix3[1])); | ||
2903 | s += abs(pix1[2] - avg2(pix2[2], pix3[2])); | ||
2904 | s += abs(pix1[3] - avg2(pix2[3], pix3[3])); | ||
2905 | s += abs(pix1[4] - avg2(pix2[4], pix3[4])); | ||
2906 | s += abs(pix1[5] - avg2(pix2[5], pix3[5])); | ||
2907 | s += abs(pix1[6] - avg2(pix2[6], pix3[6])); | ||
2908 | s += abs(pix1[7] - avg2(pix2[7], pix3[7])); | ||
2909 | s += abs(pix1[8] - avg2(pix2[8], pix3[8])); | ||
2910 | s += abs(pix1[9] - avg2(pix2[9], pix3[9])); | ||
2911 | s += abs(pix1[10] - avg2(pix2[10], pix3[10])); | ||
2912 | s += abs(pix1[11] - avg2(pix2[11], pix3[11])); | ||
2913 | s += abs(pix1[12] - avg2(pix2[12], pix3[12])); | ||
2914 | s += abs(pix1[13] - avg2(pix2[13], pix3[13])); | ||
2915 | s += abs(pix1[14] - avg2(pix2[14], pix3[14])); | ||
2916 | s += abs(pix1[15] - avg2(pix2[15], pix3[15])); | ||
2917 | pix1 += line_size; | ||
2918 | pix2 += line_size; | ||
2919 | pix3 += line_size; | ||
2920 | } | ||
2921 | return s; | ||
2922 | } | ||
2923 | |||
2924 | static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2925 | { | ||
2926 | int s, i; | ||
2927 | uint8_t *pix3 = pix2 + line_size; | ||
2928 | |||
2929 | s = 0; | ||
2930 | for(i=0;i<h;i++) { | ||
2931 | s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); | ||
2932 | s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); | ||
2933 | s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); | ||
2934 | s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); | ||
2935 | s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); | ||
2936 | s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); | ||
2937 | s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); | ||
2938 | s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); | ||
2939 | s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9])); | ||
2940 | s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10])); | ||
2941 | s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11])); | ||
2942 | s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12])); | ||
2943 | s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13])); | ||
2944 | s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14])); | ||
2945 | s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15])); | ||
2946 | s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16])); | ||
2947 | pix1 += line_size; | ||
2948 | pix2 += line_size; | ||
2949 | pix3 += line_size; | ||
2950 | } | ||
2951 | return s; | ||
2952 | } | ||
2953 | |||
2954 | static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2955 | { | ||
2956 | int s, i; | ||
2957 | |||
2958 | s = 0; | ||
2959 | for(i=0;i<h;i++) { | ||
2960 | s += abs(pix1[0] - pix2[0]); | ||
2961 | s += abs(pix1[1] - pix2[1]); | ||
2962 | s += abs(pix1[2] - pix2[2]); | ||
2963 | s += abs(pix1[3] - pix2[3]); | ||
2964 | s += abs(pix1[4] - pix2[4]); | ||
2965 | s += abs(pix1[5] - pix2[5]); | ||
2966 | s += abs(pix1[6] - pix2[6]); | ||
2967 | s += abs(pix1[7] - pix2[7]); | ||
2968 | pix1 += line_size; | ||
2969 | pix2 += line_size; | ||
2970 | } | ||
2971 | return s; | ||
2972 | } | ||
2973 | |||
2974 | static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2975 | { | ||
2976 | int s, i; | ||
2977 | |||
2978 | s = 0; | ||
2979 | for(i=0;i<h;i++) { | ||
2980 | s += abs(pix1[0] - avg2(pix2[0], pix2[1])); | ||
2981 | s += abs(pix1[1] - avg2(pix2[1], pix2[2])); | ||
2982 | s += abs(pix1[2] - avg2(pix2[2], pix2[3])); | ||
2983 | s += abs(pix1[3] - avg2(pix2[3], pix2[4])); | ||
2984 | s += abs(pix1[4] - avg2(pix2[4], pix2[5])); | ||
2985 | s += abs(pix1[5] - avg2(pix2[5], pix2[6])); | ||
2986 | s += abs(pix1[6] - avg2(pix2[6], pix2[7])); | ||
2987 | s += abs(pix1[7] - avg2(pix2[7], pix2[8])); | ||
2988 | pix1 += line_size; | ||
2989 | pix2 += line_size; | ||
2990 | } | ||
2991 | return s; | ||
2992 | } | ||
2993 | |||
2994 | static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
2995 | { | ||
2996 | int s, i; | ||
2997 | uint8_t *pix3 = pix2 + line_size; | ||
2998 | |||
2999 | s = 0; | ||
3000 | for(i=0;i<h;i++) { | ||
3001 | s += abs(pix1[0] - avg2(pix2[0], pix3[0])); | ||
3002 | s += abs(pix1[1] - avg2(pix2[1], pix3[1])); | ||
3003 | s += abs(pix1[2] - avg2(pix2[2], pix3[2])); | ||
3004 | s += abs(pix1[3] - avg2(pix2[3], pix3[3])); | ||
3005 | s += abs(pix1[4] - avg2(pix2[4], pix3[4])); | ||
3006 | s += abs(pix1[5] - avg2(pix2[5], pix3[5])); | ||
3007 | s += abs(pix1[6] - avg2(pix2[6], pix3[6])); | ||
3008 | s += abs(pix1[7] - avg2(pix2[7], pix3[7])); | ||
3009 | pix1 += line_size; | ||
3010 | pix2 += line_size; | ||
3011 | pix3 += line_size; | ||
3012 | } | ||
3013 | return s; | ||
3014 | } | ||
3015 | |||
3016 | static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) | ||
3017 | { | ||
3018 | int s, i; | ||
3019 | uint8_t *pix3 = pix2 + line_size; | ||
3020 | |||
3021 | s = 0; | ||
3022 | for(i=0;i<h;i++) { | ||
3023 | s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1])); | ||
3024 | s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2])); | ||
3025 | s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3])); | ||
3026 | s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4])); | ||
3027 | s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5])); | ||
3028 | s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6])); | ||
3029 | s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7])); | ||
3030 | s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8])); | ||
3031 | pix1 += line_size; | ||
3032 | pix2 += line_size; | ||
3033 | pix3 += line_size; | ||
3034 | } | ||
3035 | return s; | ||
3036 | } | ||
3037 | |||
3038 | static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){ | ||
3039 | MpegEncContext *c = v; | ||
3040 | int score1=0; | ||
3041 | int score2=0; | ||
3042 | int x,y; | ||
3043 | |||
3044 | for(y=0; y<h; y++){ | ||
3045 | for(x=0; x<16; x++){ | ||
3046 | score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]); | ||
3047 | } | ||
3048 | if(y+1<h){ | ||
3049 | for(x=0; x<15; x++){ | ||
3050 | score2+= FFABS( s1[x ] - s1[x +stride] | ||
3051 | - s1[x+1] + s1[x+1+stride]) | ||
3052 | -FFABS( s2[x ] - s2[x +stride] | ||
3053 | - s2[x+1] + s2[x+1+stride]); | ||
3054 | } | ||
3055 | } | ||
3056 | s1+= stride; | ||
3057 | s2+= stride; | ||
3058 | } | ||
3059 | |||
3060 | if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight; | ||
3061 | else return score1 + FFABS(score2)*8; | ||
3062 | } | ||
3063 | |||
3064 | static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){ | ||
3065 | MpegEncContext *c = v; | ||
3066 | int score1=0; | ||
3067 | int score2=0; | ||
3068 | int x,y; | ||
3069 | |||
3070 | for(y=0; y<h; y++){ | ||
3071 | for(x=0; x<8; x++){ | ||
3072 | score1+= (s1[x ] - s2[x ])*(s1[x ] - s2[x ]); | ||
3073 | } | ||
3074 | if(y+1<h){ | ||
3075 | for(x=0; x<7; x++){ | ||
3076 | score2+= FFABS( s1[x ] - s1[x +stride] | ||
3077 | - s1[x+1] + s1[x+1+stride]) | ||
3078 | -FFABS( s2[x ] - s2[x +stride] | ||
3079 | - s2[x+1] + s2[x+1+stride]); | ||
3080 | } | ||
3081 | } | ||
3082 | s1+= stride; | ||
3083 | s2+= stride; | ||
3084 | } | ||
3085 | |||
3086 | if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight; | ||
3087 | else return score1 + FFABS(score2)*8; | ||
3088 | } | ||
3089 | |||
3090 | static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){ | ||
3091 | int i; | ||
3092 | unsigned int sum=0; | ||
3093 | |||
3094 | for(i=0; i<8*8; i++){ | ||
3095 | int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT)); | ||
3096 | int w= weight[i]; | ||
3097 | b>>= RECON_SHIFT; | ||
3098 | assert(-512<b && b<512); | ||
3099 | |||
3100 | sum += (w*b)*(w*b)>>4; | ||
3101 | } | ||
3102 | return sum>>2; | ||
3103 | } | ||
3104 | |||
3105 | static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){ | ||
3106 | int i; | ||
3107 | |||
3108 | for(i=0; i<8*8; i++){ | ||
3109 | rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT); | ||
3110 | } | ||
3111 | } | ||
3112 | |||
3113 | /** | ||
3114 | * permutes an 8x8 block. | ||
3115 | * @param block the block which will be permuted according to the given permutation vector | ||
3116 | * @param permutation the permutation vector | ||
3117 | * @param last the last non zero coefficient in scantable order, used to speed the permutation up | ||
3118 | * @param scantable the used scantable, this is only used to speed the permutation up, the block is not | ||
3119 | * (inverse) permutated to scantable order! | ||
3120 | */ | ||
3121 | void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last) | ||
3122 | { | ||
3123 | int i; | ||
3124 | DCTELEM temp[64]; | ||
3125 | |||
3126 | if(last<=0) return; | ||
3127 | //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations | ||
3128 | |||
3129 | for(i=0; i<=last; i++){ | ||
3130 | const int j= scantable[i]; | ||
3131 | temp[j]= block[j]; | ||
3132 | block[j]=0; | ||
3133 | } | ||
3134 | |||
3135 | for(i=0; i<=last; i++){ | ||
3136 | const int j= scantable[i]; | ||
3137 | const int perm_j= permutation[j]; | ||
3138 | block[perm_j]= temp[j]; | ||
3139 | } | ||
3140 | } | ||
3141 | |||
3142 | static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){ | ||
3143 | return 0; | ||
3144 | } | ||
3145 | |||
3146 | void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){ | ||
3147 | int i; | ||
3148 | |||
3149 | memset(cmp, 0, sizeof(void*)*6); | ||
3150 | |||
3151 | for(i=0; i<6; i++){ | ||
3152 | switch(type&0xFF){ | ||
3153 | case FF_CMP_SAD: | ||
3154 | cmp[i]= c->sad[i]; | ||
3155 | break; | ||
3156 | case FF_CMP_SATD: | ||
3157 | cmp[i]= c->hadamard8_diff[i]; | ||
3158 | break; | ||
3159 | case FF_CMP_SSE: | ||
3160 | cmp[i]= c->sse[i]; | ||
3161 | break; | ||
3162 | case FF_CMP_DCT: | ||
3163 | cmp[i]= c->dct_sad[i]; | ||
3164 | break; | ||
3165 | case FF_CMP_DCT264: | ||
3166 | cmp[i]= c->dct264_sad[i]; | ||
3167 | break; | ||
3168 | case FF_CMP_DCTMAX: | ||
3169 | cmp[i]= c->dct_max[i]; | ||
3170 | break; | ||
3171 | case FF_CMP_PSNR: | ||
3172 | cmp[i]= c->quant_psnr[i]; | ||
3173 | break; | ||
3174 | case FF_CMP_BIT: | ||
3175 | cmp[i]= c->bit[i]; | ||
3176 | break; | ||
3177 | case FF_CMP_RD: | ||
3178 | cmp[i]= c->rd[i]; | ||
3179 | break; | ||
3180 | case FF_CMP_VSAD: | ||
3181 | cmp[i]= c->vsad[i]; | ||
3182 | break; | ||
3183 | case FF_CMP_VSSE: | ||
3184 | cmp[i]= c->vsse[i]; | ||
3185 | break; | ||
3186 | case FF_CMP_ZERO: | ||
3187 | cmp[i]= zero_cmp; | ||
3188 | break; | ||
3189 | case FF_CMP_NSSE: | ||
3190 | cmp[i]= c->nsse[i]; | ||
3191 | break; | ||
3192 | #if CONFIG_DWT | ||
3193 | case FF_CMP_W53: | ||
3194 | cmp[i]= c->w53[i]; | ||
3195 | break; | ||
3196 | case FF_CMP_W97: | ||
3197 | cmp[i]= c->w97[i]; | ||
3198 | break; | ||
3199 | #endif | ||
3200 | default: | ||
3201 | av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n"); | ||
3202 | } | ||
3203 | } | ||
3204 | } | ||
3205 | |||
3206 | static void clear_block_c(DCTELEM *block) | ||
3207 | { | ||
3208 | memset(block, 0, sizeof(DCTELEM)*64); | ||
3209 | } | ||
3210 | |||
3211 | /** | ||
3212 | * memset(blocks, 0, sizeof(DCTELEM)*6*64) | ||
3213 | */ | ||
3214 | static void clear_blocks_c(DCTELEM *blocks) | ||
3215 | { | ||
3216 | memset(blocks, 0, sizeof(DCTELEM)*6*64); | ||
3217 | } | ||
3218 | |||
3219 | static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){ | ||
3220 | long i; | ||
3221 | for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ | ||
3222 | long a = *(long*)(src+i); | ||
3223 | long b = *(long*)(dst+i); | ||
3224 | *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); | ||
3225 | } | ||
3226 | for(; i<w; i++) | ||
3227 | dst[i+0] += src[i+0]; | ||
3228 | } | ||
3229 | |||
3230 | static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ | ||
3231 | long i; | ||
3232 | for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ | ||
3233 | long a = *(long*)(src1+i); | ||
3234 | long b = *(long*)(src2+i); | ||
3235 | *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80); | ||
3236 | } | ||
3237 | for(; i<w; i++) | ||
3238 | dst[i] = src1[i]+src2[i]; | ||
3239 | } | ||
3240 | |||
3241 | static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){ | ||
3242 | long i; | ||
3243 | #if !HAVE_FAST_UNALIGNED | ||
3244 | if((long)src2 & (sizeof(long)-1)){ | ||
3245 | for(i=0; i+7<w; i+=8){ | ||
3246 | dst[i+0] = src1[i+0]-src2[i+0]; | ||
3247 | dst[i+1] = src1[i+1]-src2[i+1]; | ||
3248 | dst[i+2] = src1[i+2]-src2[i+2]; | ||
3249 | dst[i+3] = src1[i+3]-src2[i+3]; | ||
3250 | dst[i+4] = src1[i+4]-src2[i+4]; | ||
3251 | dst[i+5] = src1[i+5]-src2[i+5]; | ||
3252 | dst[i+6] = src1[i+6]-src2[i+6]; | ||
3253 | dst[i+7] = src1[i+7]-src2[i+7]; | ||
3254 | } | ||
3255 | }else | ||
3256 | #endif | ||
3257 | for(i=0; i<=w-sizeof(long); i+=sizeof(long)){ | ||
3258 | long a = *(long*)(src1+i); | ||
3259 | long b = *(long*)(src2+i); | ||
3260 | *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80); | ||
3261 | } | ||
3262 | for(; i<w; i++) | ||
3263 | dst[i+0] = src1[i+0]-src2[i+0]; | ||
3264 | } | ||
3265 | |||
3266 | static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *diff, int w, int *left, int *left_top){ | ||
3267 | int i; | ||
3268 | uint8_t l, lt; | ||
3269 | |||
3270 | l= *left; | ||
3271 | lt= *left_top; | ||
3272 | |||
3273 | for(i=0; i<w; i++){ | ||
3274 | l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i]; | ||
3275 | lt= src1[i]; | ||
3276 | dst[i]= l; | ||
3277 | } | ||
3278 | |||
3279 | *left= l; | ||
3280 | *left_top= lt; | ||
3281 | } | ||
3282 | |||
3283 | static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top){ | ||
3284 | int i; | ||
3285 | uint8_t l, lt; | ||
3286 | |||
3287 | l= *left; | ||
3288 | lt= *left_top; | ||
3289 | |||
3290 | for(i=0; i<w; i++){ | ||
3291 | const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF); | ||
3292 | lt= src1[i]; | ||
3293 | l= src2[i]; | ||
3294 | dst[i]= l - pred; | ||
3295 | } | ||
3296 | |||
3297 | *left= l; | ||
3298 | *left_top= lt; | ||
3299 | } | ||
3300 | |||
3301 | static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, int acc){ | ||
3302 | int i; | ||
3303 | |||
3304 | for(i=0; i<w-1; i++){ | ||
3305 | acc+= src[i]; | ||
3306 | dst[i]= acc; | ||
3307 | i++; | ||
3308 | acc+= src[i]; | ||
3309 | dst[i]= acc; | ||
3310 | } | ||
3311 | |||
3312 | for(; i<w; i++){ | ||
3313 | acc+= src[i]; | ||
3314 | dst[i]= acc; | ||
3315 | } | ||
3316 | |||
3317 | return acc; | ||
3318 | } | ||
3319 | |||
3320 | #if HAVE_BIGENDIAN | ||
3321 | #define B 3 | ||
3322 | #define G 2 | ||
3323 | #define R 1 | ||
3324 | #define A 0 | ||
3325 | #else | ||
3326 | #define B 0 | ||
3327 | #define G 1 | ||
3328 | #define R 2 | ||
3329 | #define A 3 | ||
3330 | #endif | ||
3331 | static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha){ | ||
3332 | int i; | ||
3333 | int r,g,b,a; | ||
3334 | r= *red; | ||
3335 | g= *green; | ||
3336 | b= *blue; | ||
3337 | a= *alpha; | ||
3338 | |||
3339 | for(i=0; i<w; i++){ | ||
3340 | b+= src[4*i+B]; | ||
3341 | g+= src[4*i+G]; | ||
3342 | r+= src[4*i+R]; | ||
3343 | a+= src[4*i+A]; | ||
3344 | |||
3345 | dst[4*i+B]= b; | ||
3346 | dst[4*i+G]= g; | ||
3347 | dst[4*i+R]= r; | ||
3348 | dst[4*i+A]= a; | ||
3349 | } | ||
3350 | |||
3351 | *red= r; | ||
3352 | *green= g; | ||
3353 | *blue= b; | ||
3354 | *alpha= a; | ||
3355 | } | ||
3356 | #undef B | ||
3357 | #undef G | ||
3358 | #undef R | ||
3359 | #undef A | ||
3360 | |||
3361 | #define BUTTERFLY2(o1,o2,i1,i2) \ | ||
3362 | o1= (i1)+(i2);\ | ||
3363 | o2= (i1)-(i2); | ||
3364 | |||
3365 | #define BUTTERFLY1(x,y) \ | ||
3366 | {\ | ||
3367 | int a,b;\ | ||
3368 | a= x;\ | ||
3369 | b= y;\ | ||
3370 | x= a+b;\ | ||
3371 | y= a-b;\ | ||
3372 | } | ||
3373 | |||
3374 | #define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y))) | ||
3375 | |||
3376 | static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){ | ||
3377 | int i; | ||
3378 | int temp[64]; | ||
3379 | int sum=0; | ||
3380 | |||
3381 | assert(h==8); | ||
3382 | |||
3383 | for(i=0; i<8; i++){ | ||
3384 | //FIXME try pointer walks | ||
3385 | BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]); | ||
3386 | BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]); | ||
3387 | BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]); | ||
3388 | BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]); | ||
3389 | |||
3390 | BUTTERFLY1(temp[8*i+0], temp[8*i+2]); | ||
3391 | BUTTERFLY1(temp[8*i+1], temp[8*i+3]); | ||
3392 | BUTTERFLY1(temp[8*i+4], temp[8*i+6]); | ||
3393 | BUTTERFLY1(temp[8*i+5], temp[8*i+7]); | ||
3394 | |||
3395 | BUTTERFLY1(temp[8*i+0], temp[8*i+4]); | ||
3396 | BUTTERFLY1(temp[8*i+1], temp[8*i+5]); | ||
3397 | BUTTERFLY1(temp[8*i+2], temp[8*i+6]); | ||
3398 | BUTTERFLY1(temp[8*i+3], temp[8*i+7]); | ||
3399 | } | ||
3400 | |||
3401 | for(i=0; i<8; i++){ | ||
3402 | BUTTERFLY1(temp[8*0+i], temp[8*1+i]); | ||
3403 | BUTTERFLY1(temp[8*2+i], temp[8*3+i]); | ||
3404 | BUTTERFLY1(temp[8*4+i], temp[8*5+i]); | ||
3405 | BUTTERFLY1(temp[8*6+i], temp[8*7+i]); | ||
3406 | |||
3407 | BUTTERFLY1(temp[8*0+i], temp[8*2+i]); | ||
3408 | BUTTERFLY1(temp[8*1+i], temp[8*3+i]); | ||
3409 | BUTTERFLY1(temp[8*4+i], temp[8*6+i]); | ||
3410 | BUTTERFLY1(temp[8*5+i], temp[8*7+i]); | ||
3411 | |||
3412 | sum += | ||
3413 | BUTTERFLYA(temp[8*0+i], temp[8*4+i]) | ||
3414 | +BUTTERFLYA(temp[8*1+i], temp[8*5+i]) | ||
3415 | +BUTTERFLYA(temp[8*2+i], temp[8*6+i]) | ||
3416 | +BUTTERFLYA(temp[8*3+i], temp[8*7+i]); | ||
3417 | } | ||
3418 | #if 0 | ||
3419 | static int maxi=0; | ||
3420 | if(sum>maxi){ | ||
3421 | maxi=sum; | ||
3422 | printf("MAX:%d\n", maxi); | ||
3423 | } | ||
3424 | #endif | ||
3425 | return sum; | ||
3426 | } | ||
3427 | |||
3428 | static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){ | ||
3429 | int i; | ||
3430 | int temp[64]; | ||
3431 | int sum=0; | ||
3432 | |||
3433 | assert(h==8); | ||
3434 | |||
3435 | for(i=0; i<8; i++){ | ||
3436 | //FIXME try pointer walks | ||
3437 | BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]); | ||
3438 | BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]); | ||
3439 | BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]); | ||
3440 | BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]); | ||
3441 | |||
3442 | BUTTERFLY1(temp[8*i+0], temp[8*i+2]); | ||
3443 | BUTTERFLY1(temp[8*i+1], temp[8*i+3]); | ||
3444 | BUTTERFLY1(temp[8*i+4], temp[8*i+6]); | ||
3445 | BUTTERFLY1(temp[8*i+5], temp[8*i+7]); | ||
3446 | |||
3447 | BUTTERFLY1(temp[8*i+0], temp[8*i+4]); | ||
3448 | BUTTERFLY1(temp[8*i+1], temp[8*i+5]); | ||
3449 | BUTTERFLY1(temp[8*i+2], temp[8*i+6]); | ||
3450 | BUTTERFLY1(temp[8*i+3], temp[8*i+7]); | ||
3451 | } | ||
3452 | |||
3453 | for(i=0; i<8; i++){ | ||
3454 | BUTTERFLY1(temp[8*0+i], temp[8*1+i]); | ||
3455 | BUTTERFLY1(temp[8*2+i], temp[8*3+i]); | ||
3456 | BUTTERFLY1(temp[8*4+i], temp[8*5+i]); | ||
3457 | BUTTERFLY1(temp[8*6+i], temp[8*7+i]); | ||
3458 | |||
3459 | BUTTERFLY1(temp[8*0+i], temp[8*2+i]); | ||
3460 | BUTTERFLY1(temp[8*1+i], temp[8*3+i]); | ||
3461 | BUTTERFLY1(temp[8*4+i], temp[8*6+i]); | ||
3462 | BUTTERFLY1(temp[8*5+i], temp[8*7+i]); | ||
3463 | |||
3464 | sum += | ||
3465 | BUTTERFLYA(temp[8*0+i], temp[8*4+i]) | ||
3466 | +BUTTERFLYA(temp[8*1+i], temp[8*5+i]) | ||
3467 | +BUTTERFLYA(temp[8*2+i], temp[8*6+i]) | ||
3468 | +BUTTERFLYA(temp[8*3+i], temp[8*7+i]); | ||
3469 | } | ||
3470 | |||
3471 | sum -= FFABS(temp[8*0] + temp[8*4]); // -mean | ||
3472 | |||
3473 | return sum; | ||
3474 | } | ||
3475 | |||
3476 | static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3477 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3478 | LOCAL_ALIGNED_16(DCTELEM, temp, [64]); | ||
3479 | |||
3480 | assert(h==8); | ||
3481 | |||
3482 | s->dsp.diff_pixels(temp, src1, src2, stride); | ||
3483 | s->dsp.fdct(temp); | ||
3484 | return s->dsp.sum_abs_dctelem(temp); | ||
3485 | } | ||
3486 | |||
3487 | #if CONFIG_GPL | ||
3488 | #define DCT8_1D {\ | ||
3489 | const int s07 = SRC(0) + SRC(7);\ | ||
3490 | const int s16 = SRC(1) + SRC(6);\ | ||
3491 | const int s25 = SRC(2) + SRC(5);\ | ||
3492 | const int s34 = SRC(3) + SRC(4);\ | ||
3493 | const int a0 = s07 + s34;\ | ||
3494 | const int a1 = s16 + s25;\ | ||
3495 | const int a2 = s07 - s34;\ | ||
3496 | const int a3 = s16 - s25;\ | ||
3497 | const int d07 = SRC(0) - SRC(7);\ | ||
3498 | const int d16 = SRC(1) - SRC(6);\ | ||
3499 | const int d25 = SRC(2) - SRC(5);\ | ||
3500 | const int d34 = SRC(3) - SRC(4);\ | ||
3501 | const int a4 = d16 + d25 + (d07 + (d07>>1));\ | ||
3502 | const int a5 = d07 - d34 - (d25 + (d25>>1));\ | ||
3503 | const int a6 = d07 + d34 - (d16 + (d16>>1));\ | ||
3504 | const int a7 = d16 - d25 + (d34 + (d34>>1));\ | ||
3505 | DST(0, a0 + a1 ) ;\ | ||
3506 | DST(1, a4 + (a7>>2)) ;\ | ||
3507 | DST(2, a2 + (a3>>1)) ;\ | ||
3508 | DST(3, a5 + (a6>>2)) ;\ | ||
3509 | DST(4, a0 - a1 ) ;\ | ||
3510 | DST(5, a6 - (a5>>2)) ;\ | ||
3511 | DST(6, (a2>>1) - a3 ) ;\ | ||
3512 | DST(7, (a4>>2) - a7 ) ;\ | ||
3513 | } | ||
3514 | |||
3515 | static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3516 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3517 | DCTELEM dct[8][8]; | ||
3518 | int i; | ||
3519 | int sum=0; | ||
3520 | |||
3521 | s->dsp.diff_pixels(dct[0], src1, src2, stride); | ||
3522 | |||
3523 | #define SRC(x) dct[i][x] | ||
3524 | #define DST(x,v) dct[i][x]= v | ||
3525 | for( i = 0; i < 8; i++ ) | ||
3526 | DCT8_1D | ||
3527 | #undef SRC | ||
3528 | #undef DST | ||
3529 | |||
3530 | #define SRC(x) dct[x][i] | ||
3531 | #define DST(x,v) sum += FFABS(v) | ||
3532 | for( i = 0; i < 8; i++ ) | ||
3533 | DCT8_1D | ||
3534 | #undef SRC | ||
3535 | #undef DST | ||
3536 | return sum; | ||
3537 | } | ||
3538 | #endif | ||
3539 | |||
3540 | static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3541 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3542 | LOCAL_ALIGNED_16(DCTELEM, temp, [64]); | ||
3543 | int sum=0, i; | ||
3544 | |||
3545 | assert(h==8); | ||
3546 | |||
3547 | s->dsp.diff_pixels(temp, src1, src2, stride); | ||
3548 | s->dsp.fdct(temp); | ||
3549 | |||
3550 | for(i=0; i<64; i++) | ||
3551 | sum= FFMAX(sum, FFABS(temp[i])); | ||
3552 | |||
3553 | return sum; | ||
3554 | } | ||
3555 | |||
3556 | static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3557 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3558 | LOCAL_ALIGNED_16(DCTELEM, temp, [64*2]); | ||
3559 | DCTELEM * const bak = temp+64; | ||
3560 | int sum=0, i; | ||
3561 | |||
3562 | assert(h==8); | ||
3563 | s->mb_intra=0; | ||
3564 | |||
3565 | s->dsp.diff_pixels(temp, src1, src2, stride); | ||
3566 | |||
3567 | memcpy(bak, temp, 64*sizeof(DCTELEM)); | ||
3568 | |||
3569 | s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); | ||
3570 | s->dct_unquantize_inter(s, temp, 0, s->qscale); | ||
3571 | ff_simple_idct(temp); //FIXME | ||
3572 | |||
3573 | for(i=0; i<64; i++) | ||
3574 | sum+= (temp[i]-bak[i])*(temp[i]-bak[i]); | ||
3575 | |||
3576 | return sum; | ||
3577 | } | ||
3578 | |||
3579 | static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3580 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3581 | const uint8_t *scantable= s->intra_scantable.permutated; | ||
3582 | LOCAL_ALIGNED_16(DCTELEM, temp, [64]); | ||
3583 | LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]); | ||
3584 | LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]); | ||
3585 | int i, last, run, bits, level, distortion, start_i; | ||
3586 | const int esc_length= s->ac_esc_length; | ||
3587 | uint8_t * length; | ||
3588 | uint8_t * last_length; | ||
3589 | |||
3590 | assert(h==8); | ||
3591 | |||
3592 | copy_block8(lsrc1, src1, 8, stride, 8); | ||
3593 | copy_block8(lsrc2, src2, 8, stride, 8); | ||
3594 | |||
3595 | s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8); | ||
3596 | |||
3597 | s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); | ||
3598 | |||
3599 | bits=0; | ||
3600 | |||
3601 | if (s->mb_intra) { | ||
3602 | start_i = 1; | ||
3603 | length = s->intra_ac_vlc_length; | ||
3604 | last_length= s->intra_ac_vlc_last_length; | ||
3605 | bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma | ||
3606 | } else { | ||
3607 | start_i = 0; | ||
3608 | length = s->inter_ac_vlc_length; | ||
3609 | last_length= s->inter_ac_vlc_last_length; | ||
3610 | } | ||
3611 | |||
3612 | if(last>=start_i){ | ||
3613 | run=0; | ||
3614 | for(i=start_i; i<last; i++){ | ||
3615 | int j= scantable[i]; | ||
3616 | level= temp[j]; | ||
3617 | |||
3618 | if(level){ | ||
3619 | level+=64; | ||
3620 | if((level&(~127)) == 0){ | ||
3621 | bits+= length[UNI_AC_ENC_INDEX(run, level)]; | ||
3622 | }else | ||
3623 | bits+= esc_length; | ||
3624 | run=0; | ||
3625 | }else | ||
3626 | run++; | ||
3627 | } | ||
3628 | i= scantable[last]; | ||
3629 | |||
3630 | level= temp[i] + 64; | ||
3631 | |||
3632 | assert(level - 64); | ||
3633 | |||
3634 | if((level&(~127)) == 0){ | ||
3635 | bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; | ||
3636 | }else | ||
3637 | bits+= esc_length; | ||
3638 | |||
3639 | } | ||
3640 | |||
3641 | if(last>=0){ | ||
3642 | if(s->mb_intra) | ||
3643 | s->dct_unquantize_intra(s, temp, 0, s->qscale); | ||
3644 | else | ||
3645 | s->dct_unquantize_inter(s, temp, 0, s->qscale); | ||
3646 | } | ||
3647 | |||
3648 | s->dsp.idct_add(lsrc2, 8, temp); | ||
3649 | |||
3650 | distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8); | ||
3651 | |||
3652 | return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7); | ||
3653 | } | ||
3654 | |||
3655 | static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){ | ||
3656 | MpegEncContext * const s= (MpegEncContext *)c; | ||
3657 | const uint8_t *scantable= s->intra_scantable.permutated; | ||
3658 | LOCAL_ALIGNED_16(DCTELEM, temp, [64]); | ||
3659 | int i, last, run, bits, level, start_i; | ||
3660 | const int esc_length= s->ac_esc_length; | ||
3661 | uint8_t * length; | ||
3662 | uint8_t * last_length; | ||
3663 | |||
3664 | assert(h==8); | ||
3665 | |||
3666 | s->dsp.diff_pixels(temp, src1, src2, stride); | ||
3667 | |||
3668 | s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); | ||
3669 | |||
3670 | bits=0; | ||
3671 | |||
3672 | if (s->mb_intra) { | ||
3673 | start_i = 1; | ||
3674 | length = s->intra_ac_vlc_length; | ||
3675 | last_length= s->intra_ac_vlc_last_length; | ||
3676 | bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma | ||
3677 | } else { | ||
3678 | start_i = 0; | ||
3679 | length = s->inter_ac_vlc_length; | ||
3680 | last_length= s->inter_ac_vlc_last_length; | ||
3681 | } | ||
3682 | |||
3683 | if(last>=start_i){ | ||
3684 | run=0; | ||
3685 | for(i=start_i; i<last; i++){ | ||
3686 | int j= scantable[i]; | ||
3687 | level= temp[j]; | ||
3688 | |||
3689 | if(level){ | ||
3690 | level+=64; | ||
3691 | if((level&(~127)) == 0){ | ||
3692 | bits+= length[UNI_AC_ENC_INDEX(run, level)]; | ||
3693 | }else | ||
3694 | bits+= esc_length; | ||
3695 | run=0; | ||
3696 | }else | ||
3697 | run++; | ||
3698 | } | ||
3699 | i= scantable[last]; | ||
3700 | |||
3701 | level= temp[i] + 64; | ||
3702 | |||
3703 | assert(level - 64); | ||
3704 | |||
3705 | if((level&(~127)) == 0){ | ||
3706 | bits+= last_length[UNI_AC_ENC_INDEX(run, level)]; | ||
3707 | }else | ||
3708 | bits+= esc_length; | ||
3709 | } | ||
3710 | |||
3711 | return bits; | ||
3712 | } | ||
3713 | |||
3714 | #define VSAD_INTRA(size) \ | ||
3715 | static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \ | ||
3716 | int score=0; \ | ||
3717 | int x,y; \ | ||
3718 | \ | ||
3719 | for(y=1; y<h; y++){ \ | ||
3720 | for(x=0; x<size; x+=4){ \ | ||
3721 | score+= FFABS(s[x ] - s[x +stride]) + FFABS(s[x+1] - s[x+1+stride]) \ | ||
3722 | +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]); \ | ||
3723 | } \ | ||
3724 | s+= stride; \ | ||
3725 | } \ | ||
3726 | \ | ||
3727 | return score; \ | ||
3728 | } | ||
3729 | VSAD_INTRA(8) | ||
3730 | VSAD_INTRA(16) | ||
3731 | |||
3732 | static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ | ||
3733 | int score=0; | ||
3734 | int x,y; | ||
3735 | |||
3736 | for(y=1; y<h; y++){ | ||
3737 | for(x=0; x<16; x++){ | ||
3738 | score+= FFABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); | ||
3739 | } | ||
3740 | s1+= stride; | ||
3741 | s2+= stride; | ||
3742 | } | ||
3743 | |||
3744 | return score; | ||
3745 | } | ||
3746 | |||
3747 | #define SQ(a) ((a)*(a)) | ||
3748 | #define VSSE_INTRA(size) \ | ||
3749 | static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \ | ||
3750 | int score=0; \ | ||
3751 | int x,y; \ | ||
3752 | \ | ||
3753 | for(y=1; y<h; y++){ \ | ||
3754 | for(x=0; x<size; x+=4){ \ | ||
3755 | score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) \ | ||
3756 | +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); \ | ||
3757 | } \ | ||
3758 | s+= stride; \ | ||
3759 | } \ | ||
3760 | \ | ||
3761 | return score; \ | ||
3762 | } | ||
3763 | VSSE_INTRA(8) | ||
3764 | VSSE_INTRA(16) | ||
3765 | |||
3766 | static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){ | ||
3767 | int score=0; | ||
3768 | int x,y; | ||
3769 | |||
3770 | for(y=1; y<h; y++){ | ||
3771 | for(x=0; x<16; x++){ | ||
3772 | score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); | ||
3773 | } | ||
3774 | s1+= stride; | ||
3775 | s2+= stride; | ||
3776 | } | ||
3777 | |||
3778 | return score; | ||
3779 | } | ||
3780 | |||
3781 | static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2, | ||
3782 | int size){ | ||
3783 | int score=0; | ||
3784 | int i; | ||
3785 | for(i=0; i<size; i++) | ||
3786 | score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]); | ||
3787 | return score; | ||
3788 | } | ||
3789 | |||
3790 | WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) | ||
3791 | WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c) | ||
3792 | WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) | ||
3793 | #if CONFIG_GPL | ||
3794 | WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c) | ||
3795 | #endif | ||
3796 | WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c) | ||
3797 | WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) | ||
3798 | WRAPPER8_16_SQ(rd8x8_c, rd16_c) | ||
3799 | WRAPPER8_16_SQ(bit8x8_c, bit16_c) | ||
3800 | |||
3801 | #endif /* 0 */ | ||
3802 | |||
3803 | static void vector_fmul_c(float *dst, const float *src, int len){ | ||
3804 | int i; | ||
3805 | for(i=0; i<len; i++) | ||
3806 | dst[i] *= src[i]; | ||
3807 | } | ||
3808 | |||
3809 | static void vector_fmul_reverse_c(float *dst, const float *src0, const float *src1, int len){ | ||
3810 | int i; | ||
3811 | src1 += len-1; | ||
3812 | for(i=0; i<len; i++) | ||
3813 | dst[i] = src0[i] * src1[-i]; | ||
3814 | } | ||
3815 | |||
3816 | static void vector_fmul_add_c(float *dst, const float *src0, const float *src1, const float *src2, int len){ | ||
3817 | int i; | ||
3818 | for(i=0; i<len; i++) | ||
3819 | dst[i] = src0[i] * src1[i] + src2[i]; | ||
3820 | } | ||
3821 | |||
3822 | void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){ | ||
3823 | int i,j; | ||
3824 | dst += len; | ||
3825 | win += len; | ||
3826 | src0+= len; | ||
3827 | for(i=-len, j=len-1; i<0; i++, j--) { | ||
3828 | float s0 = src0[i]; | ||
3829 | float s1 = src1[j]; | ||
3830 | float wi = win[i]; | ||
3831 | float wj = win[j]; | ||
3832 | dst[i] = s0*wj - s1*wi + add_bias; | ||
3833 | dst[j] = s0*wi + s1*wj + add_bias; | ||
3834 | } | ||
3835 | } | ||
3836 | |||
3837 | static void vector_fmul_scalar_c(float *dst, const float *src, float mul, | ||
3838 | int len) | ||
3839 | { | ||
3840 | int i; | ||
3841 | for (i = 0; i < len; i++) | ||
3842 | dst[i] = src[i] * mul; | ||
3843 | } | ||
3844 | #if 0 | ||
3845 | static void vector_fmul_sv_scalar_2_c(float *dst, const float *src, | ||
3846 | const float **sv, float mul, int len) | ||
3847 | { | ||
3848 | int i; | ||
3849 | for (i = 0; i < len; i += 2, sv++) { | ||
3850 | dst[i ] = src[i ] * sv[0][0] * mul; | ||
3851 | dst[i+1] = src[i+1] * sv[0][1] * mul; | ||
3852 | } | ||
3853 | } | ||
3854 | |||
3855 | static void vector_fmul_sv_scalar_4_c(float *dst, const float *src, | ||
3856 | const float **sv, float mul, int len) | ||
3857 | { | ||
3858 | int i; | ||
3859 | for (i = 0; i < len; i += 4, sv++) { | ||
3860 | dst[i ] = src[i ] * sv[0][0] * mul; | ||
3861 | dst[i+1] = src[i+1] * sv[0][1] * mul; | ||
3862 | dst[i+2] = src[i+2] * sv[0][2] * mul; | ||
3863 | dst[i+3] = src[i+3] * sv[0][3] * mul; | ||
3864 | } | ||
3865 | } | ||
3866 | |||
3867 | static void sv_fmul_scalar_2_c(float *dst, const float **sv, float mul, | ||
3868 | int len) | ||
3869 | { | ||
3870 | int i; | ||
3871 | for (i = 0; i < len; i += 2, sv++) { | ||
3872 | dst[i ] = sv[0][0] * mul; | ||
3873 | dst[i+1] = sv[0][1] * mul; | ||
3874 | } | ||
3875 | } | ||
3876 | |||
3877 | static void sv_fmul_scalar_4_c(float *dst, const float **sv, float mul, | ||
3878 | int len) | ||
3879 | { | ||
3880 | int i; | ||
3881 | for (i = 0; i < len; i += 4, sv++) { | ||
3882 | dst[i ] = sv[0][0] * mul; | ||
3883 | dst[i+1] = sv[0][1] * mul; | ||
3884 | dst[i+2] = sv[0][2] * mul; | ||
3885 | dst[i+3] = sv[0][3] * mul; | ||
3886 | } | ||
3887 | } | ||
3888 | |||
3889 | static void butterflies_float_c(float *restrict v1, float *restrict v2, | ||
3890 | int len) | ||
3891 | { | ||
3892 | int i; | ||
3893 | for (i = 0; i < len; i++) { | ||
3894 | float t = v1[i] - v2[i]; | ||
3895 | v1[i] += v2[i]; | ||
3896 | v2[i] = t; | ||
3897 | } | ||
3898 | } | ||
3899 | |||
3900 | static float scalarproduct_float_c(const float *v1, const float *v2, int len) | ||
3901 | { | ||
3902 | float p = 0.0; | ||
3903 | int i; | ||
3904 | |||
3905 | for (i = 0; i < len; i++) | ||
3906 | p += v1[i] * v2[i]; | ||
3907 | |||
3908 | return p; | ||
3909 | } | ||
3910 | |||
3911 | static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){ | ||
3912 | int i; | ||
3913 | for(i=0; i<len; i++) | ||
3914 | dst[i] = src[i] * mul; | ||
3915 | } | ||
3916 | |||
3917 | |||
3918 | static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini, | ||
3919 | uint32_t maxi, uint32_t maxisign) | ||
3920 | { | ||
3921 | |||
3922 | if(a > mini) return mini; | ||
3923 | else if((a^(1<<31)) > maxisign) return maxi; | ||
3924 | else return a; | ||
3925 | } | ||
3926 | |||
3927 | static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *min, float *max, int len){ | ||
3928 | int i; | ||
3929 | uint32_t mini = *(uint32_t*)min; | ||
3930 | uint32_t maxi = *(uint32_t*)max; | ||
3931 | uint32_t maxisign = maxi ^ (1<<31); | ||
3932 | uint32_t *dsti = (uint32_t*)dst; | ||
3933 | const uint32_t *srci = (const uint32_t*)src; | ||
3934 | for(i=0; i<len; i+=8) { | ||
3935 | dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign); | ||
3936 | dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign); | ||
3937 | dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign); | ||
3938 | dsti[i + 3] = clipf_c_one(srci[i + 3], mini, maxi, maxisign); | ||
3939 | dsti[i + 4] = clipf_c_one(srci[i + 4], mini, maxi, maxisign); | ||
3940 | dsti[i + 5] = clipf_c_one(srci[i + 5], mini, maxi, maxisign); | ||
3941 | dsti[i + 6] = clipf_c_one(srci[i + 6], mini, maxi, maxisign); | ||
3942 | dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign); | ||
3943 | } | ||
3944 | } | ||
3945 | static void vector_clipf_c(float *dst, const float *src, float min, float max, int len){ | ||
3946 | int i; | ||
3947 | if(min < 0 && max > 0) { | ||
3948 | vector_clipf_c_opposite_sign(dst, src, &min, &max, len); | ||
3949 | } else { | ||
3950 | for(i=0; i < len; i+=8) { | ||
3951 | dst[i ] = av_clipf(src[i ], min, max); | ||
3952 | dst[i + 1] = av_clipf(src[i + 1], min, max); | ||
3953 | dst[i + 2] = av_clipf(src[i + 2], min, max); | ||
3954 | dst[i + 3] = av_clipf(src[i + 3], min, max); | ||
3955 | dst[i + 4] = av_clipf(src[i + 4], min, max); | ||
3956 | dst[i + 5] = av_clipf(src[i + 5], min, max); | ||
3957 | dst[i + 6] = av_clipf(src[i + 6], min, max); | ||
3958 | dst[i + 7] = av_clipf(src[i + 7], min, max); | ||
3959 | } | ||
3960 | } | ||
3961 | } | ||
3962 | |||
3963 | static av_always_inline int float_to_int16_one(const float *src){ | ||
3964 | int_fast32_t tmp = *(const int32_t*)src; | ||
3965 | if(tmp & 0xf0000){ | ||
3966 | tmp = (0x43c0ffff - tmp)>>31; | ||
3967 | // is this faster on some gcc/cpu combinations? | ||
3968 | // if(tmp > 0x43c0ffff) tmp = 0xFFFF; | ||
3969 | // else tmp = 0; | ||
3970 | } | ||
3971 | return tmp - 0x8000; | ||
3972 | } | ||
3973 | |||
3974 | void ff_float_to_int16_c(int16_t *dst, const float *src, long len){ | ||
3975 | int i; | ||
3976 | for(i=0; i<len; i++) | ||
3977 | dst[i] = float_to_int16_one(src+i); | ||
3978 | } | ||
3979 | |||
3980 | void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels){ | ||
3981 | int i,j,c; | ||
3982 | if(channels==2){ | ||
3983 | for(i=0; i<len; i++){ | ||
3984 | dst[2*i] = float_to_int16_one(src[0]+i); | ||
3985 | dst[2*i+1] = float_to_int16_one(src[1]+i); | ||
3986 | } | ||
3987 | }else{ | ||
3988 | for(c=0; c<channels; c++) | ||
3989 | for(i=0, j=c; i<len; i++, j+=channels) | ||
3990 | dst[j] = float_to_int16_one(src[c]+i); | ||
3991 | } | ||
3992 | } | ||
3993 | |||
3994 | static int32_t scalarproduct_int16_c(int16_t * v1, int16_t * v2, int order, int shift) | ||
3995 | { | ||
3996 | int res = 0; | ||
3997 | |||
3998 | while (order--) | ||
3999 | res += (*v1++ * *v2++) >> shift; | ||
4000 | |||
4001 | return res; | ||
4002 | } | ||
4003 | |||
4004 | static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul) | ||
4005 | { | ||
4006 | int res = 0; | ||
4007 | while (order--) { | ||
4008 | res += *v1 * *v2++; | ||
4009 | *v1++ += mul * *v3++; | ||
4010 | } | ||
4011 | return res; | ||
4012 | } | ||
4013 | |||
4014 | #define W0 2048 | ||
4015 | #define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ | ||
4016 | #define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ | ||
4017 | #define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ | ||
4018 | #define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ | ||
4019 | #define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ | ||
4020 | #define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ | ||
4021 | #define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ | ||
4022 | |||
4023 | static void wmv2_idct_row(short * b) | ||
4024 | { | ||
4025 | int s1,s2; | ||
4026 | int a0,a1,a2,a3,a4,a5,a6,a7; | ||
4027 | /*step 1*/ | ||
4028 | a1 = W1*b[1]+W7*b[7]; | ||
4029 | a7 = W7*b[1]-W1*b[7]; | ||
4030 | a5 = W5*b[5]+W3*b[3]; | ||
4031 | a3 = W3*b[5]-W5*b[3]; | ||
4032 | a2 = W2*b[2]+W6*b[6]; | ||
4033 | a6 = W6*b[2]-W2*b[6]; | ||
4034 | a0 = W0*b[0]+W0*b[4]; | ||
4035 | a4 = W0*b[0]-W0*b[4]; | ||
4036 | /*step 2*/ | ||
4037 | s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7, | ||
4038 | s2 = (181*(a1-a5-a7+a3)+128)>>8; | ||
4039 | /*step 3*/ | ||
4040 | b[0] = (a0+a2+a1+a5 + (1<<7))>>8; | ||
4041 | b[1] = (a4+a6 +s1 + (1<<7))>>8; | ||
4042 | b[2] = (a4-a6 +s2 + (1<<7))>>8; | ||
4043 | b[3] = (a0-a2+a7+a3 + (1<<7))>>8; | ||
4044 | b[4] = (a0-a2-a7-a3 + (1<<7))>>8; | ||
4045 | b[5] = (a4-a6 -s2 + (1<<7))>>8; | ||
4046 | b[6] = (a4+a6 -s1 + (1<<7))>>8; | ||
4047 | b[7] = (a0+a2-a1-a5 + (1<<7))>>8; | ||
4048 | } | ||
4049 | static void wmv2_idct_col(short * b) | ||
4050 | { | ||
4051 | int s1,s2; | ||
4052 | int a0,a1,a2,a3,a4,a5,a6,a7; | ||
4053 | /*step 1, with extended precision*/ | ||
4054 | a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3; | ||
4055 | a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3; | ||
4056 | a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3; | ||
4057 | a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3; | ||
4058 | a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3; | ||
4059 | a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3; | ||
4060 | a0 = (W0*b[8*0]+W0*b[8*4] )>>3; | ||
4061 | a4 = (W0*b[8*0]-W0*b[8*4] )>>3; | ||
4062 | /*step 2*/ | ||
4063 | s1 = (181*(a1-a5+a7-a3)+128)>>8; | ||
4064 | s2 = (181*(a1-a5-a7+a3)+128)>>8; | ||
4065 | /*step 3*/ | ||
4066 | b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14; | ||
4067 | b[8*1] = (a4+a6 +s1 + (1<<13))>>14; | ||
4068 | b[8*2] = (a4-a6 +s2 + (1<<13))>>14; | ||
4069 | b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14; | ||
4070 | |||
4071 | b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14; | ||
4072 | b[8*5] = (a4-a6 -s2 + (1<<13))>>14; | ||
4073 | b[8*6] = (a4+a6 -s1 + (1<<13))>>14; | ||
4074 | b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14; | ||
4075 | } | ||
4076 | void ff_wmv2_idct_c(short * block){ | ||
4077 | int i; | ||
4078 | |||
4079 | for(i=0;i<64;i+=8){ | ||
4080 | wmv2_idct_row(block+i); | ||
4081 | } | ||
4082 | for(i=0;i<8;i++){ | ||
4083 | wmv2_idct_col(block+i); | ||
4084 | } | ||
4085 | } | ||
4086 | /* XXX: those functions should be suppressed ASAP when all IDCTs are | ||
4087 | converted */ | ||
4088 | static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block) | ||
4089 | { | ||
4090 | ff_wmv2_idct_c(block); | ||
4091 | put_pixels_clamped_c(block, dest, line_size); | ||
4092 | } | ||
4093 | static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block) | ||
4094 | { | ||
4095 | ff_wmv2_idct_c(block); | ||
4096 | add_pixels_clamped_c(block, dest, line_size); | ||
4097 | } | ||
4098 | static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block) | ||
4099 | { | ||
4100 | j_rev_dct (block); | ||
4101 | put_pixels_clamped_c(block, dest, line_size); | ||
4102 | } | ||
4103 | static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block) | ||
4104 | { | ||
4105 | j_rev_dct (block); | ||
4106 | add_pixels_clamped_c(block, dest, line_size); | ||
4107 | } | ||
4108 | |||
4109 | static void ff_jref_idct4_put(uint8_t *dest, int line_size, DCTELEM *block) | ||
4110 | { | ||
4111 | j_rev_dct4 (block); | ||
4112 | put_pixels_clamped4_c(block, dest, line_size); | ||
4113 | } | ||
4114 | static void ff_jref_idct4_add(uint8_t *dest, int line_size, DCTELEM *block) | ||
4115 | { | ||
4116 | j_rev_dct4 (block); | ||
4117 | add_pixels_clamped4_c(block, dest, line_size); | ||
4118 | } | ||
4119 | |||
4120 | static void ff_jref_idct2_put(uint8_t *dest, int line_size, DCTELEM *block) | ||
4121 | { | ||
4122 | j_rev_dct2 (block); | ||
4123 | put_pixels_clamped2_c(block, dest, line_size); | ||
4124 | } | ||
4125 | static void ff_jref_idct2_add(uint8_t *dest, int line_size, DCTELEM *block) | ||
4126 | { | ||
4127 | j_rev_dct2 (block); | ||
4128 | add_pixels_clamped2_c(block, dest, line_size); | ||
4129 | } | ||
4130 | |||
4131 | static void ff_jref_idct1_put(uint8_t *dest, int line_size, DCTELEM *block) | ||
4132 | { | ||
4133 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
4134 | |||
4135 | dest[0] = cm[(block[0] + 4)>>3]; | ||
4136 | } | ||
4137 | static void ff_jref_idct1_add(uint8_t *dest, int line_size, DCTELEM *block) | ||
4138 | { | ||
4139 | uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | ||
4140 | |||
4141 | dest[0] = cm[dest[0] + ((block[0] + 4)>>3)]; | ||
4142 | } | ||
4143 | |||
4144 | static void just_return(void *mem av_unused, int stride av_unused, int h av_unused) { return; } | ||
4145 | |||
4146 | /* init static data */ | ||
4147 | av_cold void dsputil_static_init(void) | ||
4148 | { | ||
4149 | int i; | ||
4150 | |||
4151 | for(i=0;i<256;i++) ff_cropTbl[i + MAX_NEG_CROP] = i; | ||
4152 | for(i=0;i<MAX_NEG_CROP;i++) { | ||
4153 | ff_cropTbl[i] = 0; | ||
4154 | ff_cropTbl[i + MAX_NEG_CROP + 256] = 255; | ||
4155 | } | ||
4156 | |||
4157 | for(i=0;i<512;i++) { | ||
4158 | ff_squareTbl[i] = (i - 256) * (i - 256); | ||
4159 | } | ||
4160 | |||
4161 | for(i=0; i<64; i++) inv_zigzag_direct16[ff_zigzag_direct[i]]= i+1; | ||
4162 | } | ||
4163 | |||
4164 | int ff_check_alignment(void){ | ||
4165 | static int did_fail=0; | ||
4166 | DECLARE_ALIGNED(16, int, aligned); | ||
4167 | |||
4168 | if((intptr_t)&aligned & 15){ | ||
4169 | if(!did_fail){ | ||
4170 | #if HAVE_MMX || HAVE_ALTIVEC | ||
4171 | av_log(NULL, AV_LOG_ERROR, | ||
4172 | "Compiler did not align stack variables. Libavcodec has been miscompiled\n" | ||
4173 | "and may be very slow or crash. This is not a bug in libavcodec,\n" | ||
4174 | "but in the compiler. You may try recompiling using gcc >= 4.2.\n" | ||
4175 | "Do not report crashes to FFmpeg developers.\n"); | ||
4176 | #endif | ||
4177 | did_fail=1; | ||
4178 | } | ||
4179 | return -1; | ||
4180 | } | ||
4181 | return 0; | ||
4182 | } | ||
4183 | #endif | ||
4184 | av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) | ||
4185 | { | ||
4186 | #if 0 | ||
4187 | int i; | ||
4188 | |||
4189 | ff_check_alignment(); | ||
4190 | |||
4191 | #if CONFIG_ENCODERS | ||
4192 | if(avctx->dct_algo==FF_DCT_FASTINT) { | ||
4193 | c->fdct = fdct_ifast; | ||
4194 | c->fdct248 = fdct_ifast248; | ||
4195 | } | ||
4196 | else if(avctx->dct_algo==FF_DCT_FAAN) { | ||
4197 | c->fdct = ff_faandct; | ||
4198 | c->fdct248 = ff_faandct248; | ||
4199 | } | ||
4200 | else { | ||
4201 | c->fdct = ff_jpeg_fdct_islow; //slow/accurate/default | ||
4202 | c->fdct248 = ff_fdct248_islow; | ||
4203 | } | ||
4204 | #endif //CONFIG_ENCODERS | ||
4205 | |||
4206 | if(avctx->lowres==1){ | ||
4207 | if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){ | ||
4208 | c->idct_put= ff_jref_idct4_put; | ||
4209 | c->idct_add= ff_jref_idct4_add; | ||
4210 | }else{ | ||
4211 | c->idct_put= ff_h264_lowres_idct_put_c; | ||
4212 | c->idct_add= ff_h264_lowres_idct_add_c; | ||
4213 | } | ||
4214 | c->idct = j_rev_dct4; | ||
4215 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4216 | }else if(avctx->lowres==2){ | ||
4217 | c->idct_put= ff_jref_idct2_put; | ||
4218 | c->idct_add= ff_jref_idct2_add; | ||
4219 | c->idct = j_rev_dct2; | ||
4220 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4221 | }else if(avctx->lowres==3){ | ||
4222 | c->idct_put= ff_jref_idct1_put; | ||
4223 | c->idct_add= ff_jref_idct1_add; | ||
4224 | c->idct = j_rev_dct1; | ||
4225 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4226 | }else{ | ||
4227 | if(avctx->idct_algo==FF_IDCT_INT){ | ||
4228 | c->idct_put= ff_jref_idct_put; | ||
4229 | c->idct_add= ff_jref_idct_add; | ||
4230 | c->idct = j_rev_dct; | ||
4231 | c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM; | ||
4232 | }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER ) && | ||
4233 | avctx->idct_algo==FF_IDCT_VP3){ | ||
4234 | c->idct_put= ff_vp3_idct_put_c; | ||
4235 | c->idct_add= ff_vp3_idct_add_c; | ||
4236 | c->idct = ff_vp3_idct_c; | ||
4237 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4238 | }else if(avctx->idct_algo==FF_IDCT_WMV2){ | ||
4239 | c->idct_put= ff_wmv2_idct_put_c; | ||
4240 | c->idct_add= ff_wmv2_idct_add_c; | ||
4241 | c->idct = ff_wmv2_idct_c; | ||
4242 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4243 | }else if(avctx->idct_algo==FF_IDCT_FAAN){ | ||
4244 | c->idct_put= ff_faanidct_put; | ||
4245 | c->idct_add= ff_faanidct_add; | ||
4246 | c->idct = ff_faanidct; | ||
4247 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4248 | }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) { | ||
4249 | c->idct_put= ff_ea_idct_put_c; | ||
4250 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4251 | }else if(CONFIG_BINK_DECODER && avctx->idct_algo==FF_IDCT_BINK) { | ||
4252 | c->idct = ff_bink_idct_c; | ||
4253 | c->idct_add = ff_bink_idct_add_c; | ||
4254 | c->idct_put = ff_bink_idct_put_c; | ||
4255 | c->idct_permutation_type = FF_NO_IDCT_PERM; | ||
4256 | }else{ //accurate/default | ||
4257 | c->idct_put= ff_simple_idct_put; | ||
4258 | c->idct_add= ff_simple_idct_add; | ||
4259 | c->idct = ff_simple_idct; | ||
4260 | c->idct_permutation_type= FF_NO_IDCT_PERM; | ||
4261 | } | ||
4262 | } | ||
4263 | |||
4264 | c->get_pixels = get_pixels_c; | ||
4265 | c->diff_pixels = diff_pixels_c; | ||
4266 | c->put_pixels_clamped = put_pixels_clamped_c; | ||
4267 | c->put_signed_pixels_clamped = put_signed_pixels_clamped_c; | ||
4268 | c->put_pixels_nonclamped = put_pixels_nonclamped_c; | ||
4269 | c->add_pixels_clamped = add_pixels_clamped_c; | ||
4270 | c->add_pixels8 = add_pixels8_c; | ||
4271 | c->add_pixels4 = add_pixels4_c; | ||
4272 | c->sum_abs_dctelem = sum_abs_dctelem_c; | ||
4273 | c->gmc1 = gmc1_c; | ||
4274 | c->gmc = ff_gmc_c; | ||
4275 | c->clear_block = clear_block_c; | ||
4276 | c->clear_blocks = clear_blocks_c; | ||
4277 | c->pix_sum = pix_sum_c; | ||
4278 | c->pix_norm1 = pix_norm1_c; | ||
4279 | |||
4280 | c->fill_block_tab[0] = fill_block16_c; | ||
4281 | c->fill_block_tab[1] = fill_block8_c; | ||
4282 | c->scale_block = scale_block_c; | ||
4283 | |||
4284 | /* TODO [0] 16 [1] 8 */ | ||
4285 | c->pix_abs[0][0] = pix_abs16_c; | ||
4286 | c->pix_abs[0][1] = pix_abs16_x2_c; | ||
4287 | c->pix_abs[0][2] = pix_abs16_y2_c; | ||
4288 | c->pix_abs[0][3] = pix_abs16_xy2_c; | ||
4289 | c->pix_abs[1][0] = pix_abs8_c; | ||
4290 | c->pix_abs[1][1] = pix_abs8_x2_c; | ||
4291 | c->pix_abs[1][2] = pix_abs8_y2_c; | ||
4292 | c->pix_abs[1][3] = pix_abs8_xy2_c; | ||
4293 | |||
4294 | #define dspfunc(PFX, IDX, NUM) \ | ||
4295 | c->PFX ## _pixels_tab[IDX][0] = PFX ## _pixels ## NUM ## _c; \ | ||
4296 | c->PFX ## _pixels_tab[IDX][1] = PFX ## _pixels ## NUM ## _x2_c; \ | ||
4297 | c->PFX ## _pixels_tab[IDX][2] = PFX ## _pixels ## NUM ## _y2_c; \ | ||
4298 | c->PFX ## _pixels_tab[IDX][3] = PFX ## _pixels ## NUM ## _xy2_c | ||
4299 | |||
4300 | dspfunc(put, 0, 16); | ||
4301 | dspfunc(put_no_rnd, 0, 16); | ||
4302 | dspfunc(put, 1, 8); | ||
4303 | dspfunc(put_no_rnd, 1, 8); | ||
4304 | dspfunc(put, 2, 4); | ||
4305 | dspfunc(put, 3, 2); | ||
4306 | |||
4307 | dspfunc(avg, 0, 16); | ||
4308 | dspfunc(avg_no_rnd, 0, 16); | ||
4309 | dspfunc(avg, 1, 8); | ||
4310 | dspfunc(avg_no_rnd, 1, 8); | ||
4311 | dspfunc(avg, 2, 4); | ||
4312 | dspfunc(avg, 3, 2); | ||
4313 | #undef dspfunc | ||
4314 | |||
4315 | c->put_no_rnd_pixels_l2[0]= put_no_rnd_pixels16_l2_c; | ||
4316 | c->put_no_rnd_pixels_l2[1]= put_no_rnd_pixels8_l2_c; | ||
4317 | |||
4318 | c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c; | ||
4319 | c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c; | ||
4320 | c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c; | ||
4321 | c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c; | ||
4322 | c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c; | ||
4323 | c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c; | ||
4324 | c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c; | ||
4325 | c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c; | ||
4326 | c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c; | ||
4327 | |||
4328 | c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c; | ||
4329 | c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c; | ||
4330 | c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c; | ||
4331 | c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c; | ||
4332 | c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c; | ||
4333 | c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c; | ||
4334 | c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c; | ||
4335 | c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c; | ||
4336 | c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c; | ||
4337 | |||
4338 | #define dspfunc(PFX, IDX, NUM) \ | ||
4339 | c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \ | ||
4340 | c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \ | ||
4341 | c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \ | ||
4342 | c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \ | ||
4343 | c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \ | ||
4344 | c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \ | ||
4345 | c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \ | ||
4346 | c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \ | ||
4347 | c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \ | ||
4348 | c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \ | ||
4349 | c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \ | ||
4350 | c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \ | ||
4351 | c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \ | ||
4352 | c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_c; \ | ||
4353 | c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_c; \ | ||
4354 | c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c | ||
4355 | |||
4356 | dspfunc(put_qpel, 0, 16); | ||
4357 | dspfunc(put_no_rnd_qpel, 0, 16); | ||
4358 | |||
4359 | dspfunc(avg_qpel, 0, 16); | ||
4360 | /* dspfunc(avg_no_rnd_qpel, 0, 16); */ | ||
4361 | |||
4362 | dspfunc(put_qpel, 1, 8); | ||
4363 | dspfunc(put_no_rnd_qpel, 1, 8); | ||
4364 | |||
4365 | dspfunc(avg_qpel, 1, 8); | ||
4366 | /* dspfunc(avg_no_rnd_qpel, 1, 8); */ | ||
4367 | |||
4368 | dspfunc(put_h264_qpel, 0, 16); | ||
4369 | dspfunc(put_h264_qpel, 1, 8); | ||
4370 | dspfunc(put_h264_qpel, 2, 4); | ||
4371 | dspfunc(put_h264_qpel, 3, 2); | ||
4372 | dspfunc(avg_h264_qpel, 0, 16); | ||
4373 | dspfunc(avg_h264_qpel, 1, 8); | ||
4374 | dspfunc(avg_h264_qpel, 2, 4); | ||
4375 | |||
4376 | #undef dspfunc | ||
4377 | c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_c; | ||
4378 | c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_c; | ||
4379 | c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_c; | ||
4380 | c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_c; | ||
4381 | c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_c; | ||
4382 | c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_c; | ||
4383 | c->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c; | ||
4384 | c->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c; | ||
4385 | |||
4386 | c->draw_edges = draw_edges_c; | ||
4387 | |||
4388 | #if CONFIG_CAVS_DECODER | ||
4389 | ff_cavsdsp_init(c,avctx); | ||
4390 | #endif | ||
4391 | |||
4392 | #if CONFIG_MLP_DECODER || CONFIG_TRUEHD_DECODER | ||
4393 | ff_mlp_init(c, avctx); | ||
4394 | #endif | ||
4395 | #if CONFIG_VC1_DECODER | ||
4396 | ff_vc1dsp_init(c,avctx); | ||
4397 | #endif | ||
4398 | #if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER | ||
4399 | ff_intrax8dsp_init(c,avctx); | ||
4400 | #endif | ||
4401 | #if CONFIG_RV30_DECODER | ||
4402 | ff_rv30dsp_init(c,avctx); | ||
4403 | #endif | ||
4404 | #if CONFIG_RV40_DECODER | ||
4405 | ff_rv40dsp_init(c,avctx); | ||
4406 | c->put_rv40_qpel_pixels_tab[0][15] = put_rv40_qpel16_mc33_c; | ||
4407 | c->avg_rv40_qpel_pixels_tab[0][15] = avg_rv40_qpel16_mc33_c; | ||
4408 | c->put_rv40_qpel_pixels_tab[1][15] = put_rv40_qpel8_mc33_c; | ||
4409 | c->avg_rv40_qpel_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c; | ||
4410 | #endif | ||
4411 | |||
4412 | c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c; | ||
4413 | c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c; | ||
4414 | c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c; | ||
4415 | c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c; | ||
4416 | c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c; | ||
4417 | c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c; | ||
4418 | c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c; | ||
4419 | c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c; | ||
4420 | |||
4421 | #define SET_CMP_FUNC(name) \ | ||
4422 | c->name[0]= name ## 16_c;\ | ||
4423 | c->name[1]= name ## 8x8_c; | ||
4424 | |||
4425 | SET_CMP_FUNC(hadamard8_diff) | ||
4426 | c->hadamard8_diff[4]= hadamard8_intra16_c; | ||
4427 | c->hadamard8_diff[5]= hadamard8_intra8x8_c; | ||
4428 | SET_CMP_FUNC(dct_sad) | ||
4429 | SET_CMP_FUNC(dct_max) | ||
4430 | #if CONFIG_GPL | ||
4431 | SET_CMP_FUNC(dct264_sad) | ||
4432 | #endif | ||
4433 | c->sad[0]= pix_abs16_c; | ||
4434 | c->sad[1]= pix_abs8_c; | ||
4435 | c->sse[0]= sse16_c; | ||
4436 | c->sse[1]= sse8_c; | ||
4437 | c->sse[2]= sse4_c; | ||
4438 | SET_CMP_FUNC(quant_psnr) | ||
4439 | SET_CMP_FUNC(rd) | ||
4440 | SET_CMP_FUNC(bit) | ||
4441 | c->vsad[0]= vsad16_c; | ||
4442 | c->vsad[4]= vsad_intra16_c; | ||
4443 | c->vsad[5]= vsad_intra8_c; | ||
4444 | c->vsse[0]= vsse16_c; | ||
4445 | c->vsse[4]= vsse_intra16_c; | ||
4446 | c->vsse[5]= vsse_intra8_c; | ||
4447 | c->nsse[0]= nsse16_c; | ||
4448 | c->nsse[1]= nsse8_c; | ||
4449 | #if CONFIG_DWT | ||
4450 | ff_dsputil_init_dwt(c); | ||
4451 | #endif | ||
4452 | |||
4453 | c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c; | ||
4454 | |||
4455 | c->add_bytes= add_bytes_c; | ||
4456 | c->add_bytes_l2= add_bytes_l2_c; | ||
4457 | c->diff_bytes= diff_bytes_c; | ||
4458 | c->add_hfyu_median_prediction= add_hfyu_median_prediction_c; | ||
4459 | c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c; | ||
4460 | c->add_hfyu_left_prediction = add_hfyu_left_prediction_c; | ||
4461 | c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c; | ||
4462 | c->bswap_buf= bswap_buf; | ||
4463 | #if CONFIG_PNG_DECODER | ||
4464 | c->add_png_paeth_prediction= ff_add_png_paeth_prediction; | ||
4465 | #endif | ||
4466 | |||
4467 | if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { | ||
4468 | c->h263_h_loop_filter= h263_h_loop_filter_c; | ||
4469 | c->h263_v_loop_filter= h263_v_loop_filter_c; | ||
4470 | } | ||
4471 | |||
4472 | if (CONFIG_VP3_DECODER) { | ||
4473 | c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c; | ||
4474 | c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c; | ||
4475 | } | ||
4476 | if (CONFIG_VP6_DECODER) { | ||
4477 | c->vp6_filter_diag4= ff_vp6_filter_diag4_c; | ||
4478 | } | ||
4479 | |||
4480 | c->h261_loop_filter= h261_loop_filter_c; | ||
4481 | |||
4482 | c->try_8x8basis= try_8x8basis_c; | ||
4483 | c->add_8x8basis= add_8x8basis_c; | ||
4484 | |||
4485 | #if CONFIG_VORBIS_DECODER | ||
4486 | c->vorbis_inverse_coupling = vorbis_inverse_coupling; | ||
4487 | #endif | ||
4488 | #if CONFIG_AC3_DECODER | ||
4489 | c->ac3_downmix = ff_ac3_downmix_c; | ||
4490 | #endif | ||
4491 | #if CONFIG_LPC | ||
4492 | c->lpc_compute_autocorr = ff_lpc_compute_autocorr; | ||
4493 | #endif | ||
4494 | |||
4495 | #endif /* 0 */ | ||
4496 | c->vector_fmul = vector_fmul_c; | ||
4497 | c->vector_fmul_reverse = vector_fmul_reverse_c; | ||
4498 | c->vector_fmul_add = vector_fmul_add_c; | ||
4499 | c->vector_fmul_window = ff_vector_fmul_window_c; | ||
4500 | //c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; | ||
4501 | //c->vector_clipf = vector_clipf_c; | ||
4502 | //c->float_to_int16 = ff_float_to_int16_c; | ||
4503 | //c->float_to_int16_interleave = ff_float_to_int16_interleave_c; | ||
4504 | //c->scalarproduct_int16 = scalarproduct_int16_c; | ||
4505 | //c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c; | ||
4506 | //c->scalarproduct_float = scalarproduct_float_c; | ||
4507 | //c->butterflies_float = butterflies_float_c; | ||
4508 | c->vector_fmul_scalar = vector_fmul_scalar_c; | ||
4509 | #if 0 | ||
4510 | c->vector_fmul_sv_scalar[0] = vector_fmul_sv_scalar_2_c; | ||
4511 | c->vector_fmul_sv_scalar[1] = vector_fmul_sv_scalar_4_c; | ||
4512 | |||
4513 | c->sv_fmul_scalar[0] = sv_fmul_scalar_2_c; | ||
4514 | c->sv_fmul_scalar[1] = sv_fmul_scalar_4_c; | ||
4515 | |||
4516 | c->shrink[0]= ff_img_copy_plane; | ||
4517 | c->shrink[1]= ff_shrink22; | ||
4518 | c->shrink[2]= ff_shrink44; | ||
4519 | c->shrink[3]= ff_shrink88; | ||
4520 | |||
4521 | c->prefetch= just_return; | ||
4522 | |||
4523 | memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab)); | ||
4524 | memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab)); | ||
4525 | |||
4526 | if (HAVE_MMX) dsputil_init_mmx (c, avctx); | ||
4527 | if (ARCH_ARM) dsputil_init_arm (c, avctx); | ||
4528 | if (CONFIG_MLIB) dsputil_init_mlib (c, avctx); | ||
4529 | if (HAVE_VIS) dsputil_init_vis (c, avctx); | ||
4530 | if (ARCH_ALPHA) dsputil_init_alpha (c, avctx); | ||
4531 | if (ARCH_PPC) dsputil_init_ppc (c, avctx); | ||
4532 | if (HAVE_MMI) dsputil_init_mmi (c, avctx); | ||
4533 | if (ARCH_SH4) dsputil_init_sh4 (c, avctx); | ||
4534 | if (ARCH_BFIN) dsputil_init_bfin (c, avctx); | ||
4535 | |||
4536 | for(i=0; i<64; i++){ | ||
4537 | if(!c->put_2tap_qpel_pixels_tab[0][i]) | ||
4538 | c->put_2tap_qpel_pixels_tab[0][i]= c->put_h264_qpel_pixels_tab[0][i]; | ||
4539 | if(!c->avg_2tap_qpel_pixels_tab[0][i]) | ||
4540 | c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; | ||
4541 | } | ||
4542 | |||
4543 | switch(c->idct_permutation_type){ | ||
4544 | case FF_NO_IDCT_PERM: | ||
4545 | for(i=0; i<64; i++) | ||
4546 | c->idct_permutation[i]= i; | ||
4547 | break; | ||
4548 | case FF_LIBMPEG2_IDCT_PERM: | ||
4549 | for(i=0; i<64; i++) | ||
4550 | c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); | ||
4551 | break; | ||
4552 | case FF_SIMPLE_IDCT_PERM: | ||
4553 | for(i=0; i<64; i++) | ||
4554 | c->idct_permutation[i]= simple_mmx_permutation[i]; | ||
4555 | break; | ||
4556 | case FF_TRANSPOSE_IDCT_PERM: | ||
4557 | for(i=0; i<64; i++) | ||
4558 | c->idct_permutation[i]= ((i&7)<<3) | (i>>3); | ||
4559 | break; | ||
4560 | case FF_PARTTRANS_IDCT_PERM: | ||
4561 | for(i=0; i<64; i++) | ||
4562 | c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3); | ||
4563 | break; | ||
4564 | case FF_SSE2_IDCT_PERM: | ||
4565 | for(i=0; i<64; i++) | ||
4566 | c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7]; | ||
4567 | break; | ||
4568 | default: | ||
4569 | av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); | ||
4570 | } | ||
4571 | #endif /* 0 */ | ||
4572 | } | ||
diff --git a/apps/codecs/libwmapro/dsputil.h b/apps/codecs/libwmapro/dsputil.h deleted file mode 100644 index 80bc3ab262..0000000000 --- a/apps/codecs/libwmapro/dsputil.h +++ /dev/null | |||
@@ -1,808 +0,0 @@ | |||
1 | /* | ||
2 | * DSP utils | ||
3 | * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | ||
4 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg 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 GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | /** | ||
24 | * @file libavcodec/dsputil.h | ||
25 | * DSP utils. | ||
26 | * note, many functions in here may use MMX which trashes the FPU state, it is | ||
27 | * absolutely necessary to call emms_c() between dsp & float/double code | ||
28 | */ | ||
29 | |||
30 | #ifndef AVCODEC_DSPUTIL_H | ||
31 | #define AVCODEC_DSPUTIL_H | ||
32 | |||
33 | #include "libavutil/intreadwrite.h" | ||
34 | #include "avcodec.h" | ||
35 | |||
36 | |||
37 | //#define DEBUG | ||
38 | /* dct code */ | ||
39 | typedef short DCTELEM; | ||
40 | |||
41 | void fdct_ifast (DCTELEM *data); | ||
42 | void fdct_ifast248 (DCTELEM *data); | ||
43 | void ff_jpeg_fdct_islow (DCTELEM *data); | ||
44 | void ff_fdct248_islow (DCTELEM *data); | ||
45 | |||
46 | void j_rev_dct (DCTELEM *data); | ||
47 | void j_rev_dct4 (DCTELEM *data); | ||
48 | void j_rev_dct2 (DCTELEM *data); | ||
49 | void j_rev_dct1 (DCTELEM *data); | ||
50 | void ff_wmv2_idct_c(DCTELEM *data); | ||
51 | |||
52 | void ff_fdct_mmx(DCTELEM *block); | ||
53 | void ff_fdct_mmx2(DCTELEM *block); | ||
54 | void ff_fdct_sse2(DCTELEM *block); | ||
55 | |||
56 | void ff_h264_idct8_add_c(uint8_t *dst, DCTELEM *block, int stride); | ||
57 | void ff_h264_idct_add_c(uint8_t *dst, DCTELEM *block, int stride); | ||
58 | void ff_h264_idct8_dc_add_c(uint8_t *dst, DCTELEM *block, int stride); | ||
59 | void ff_h264_idct_dc_add_c(uint8_t *dst, DCTELEM *block, int stride); | ||
60 | void ff_h264_lowres_idct_add_c(uint8_t *dst, int stride, DCTELEM *block); | ||
61 | void ff_h264_lowres_idct_put_c(uint8_t *dst, int stride, DCTELEM *block); | ||
62 | void ff_h264_idct_add16_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); | ||
63 | void ff_h264_idct_add16intra_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); | ||
64 | void ff_h264_idct8_add4_c(uint8_t *dst, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); | ||
65 | void ff_h264_idct_add8_c(uint8_t **dest, const int *blockoffset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]); | ||
66 | |||
67 | void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, | ||
68 | const float *win, float add_bias, int len); | ||
69 | void ff_float_to_int16_c(int16_t *dst, const float *src, long len); | ||
70 | void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels); | ||
71 | |||
72 | /* encoding scans */ | ||
73 | extern const uint8_t ff_alternate_horizontal_scan[64]; | ||
74 | extern const uint8_t ff_alternate_vertical_scan[64]; | ||
75 | extern const uint8_t ff_zigzag_direct[64]; | ||
76 | extern const uint8_t ff_zigzag248_direct[64]; | ||
77 | |||
78 | /* pixel operations */ | ||
79 | #define MAX_NEG_CROP 1024 | ||
80 | |||
81 | /* temporary */ | ||
82 | extern uint32_t ff_squareTbl[512]; | ||
83 | extern uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP]; | ||
84 | |||
85 | /* VP3 DSP functions */ | ||
86 | void ff_vp3_idct_c(DCTELEM *block/* align 16*/); | ||
87 | void ff_vp3_idct_put_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | ||
88 | void ff_vp3_idct_add_c(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | ||
89 | |||
90 | void ff_vp3_v_loop_filter_c(uint8_t *src, int stride, int *bounding_values); | ||
91 | void ff_vp3_h_loop_filter_c(uint8_t *src, int stride, int *bounding_values); | ||
92 | |||
93 | /* VP6 DSP functions */ | ||
94 | void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride, | ||
95 | const int16_t *h_weights, const int16_t *v_weights); | ||
96 | |||
97 | /* Bink functions */ | ||
98 | void ff_bink_idct_c (DCTELEM *block); | ||
99 | void ff_bink_idct_add_c(uint8_t *dest, int linesize, DCTELEM *block); | ||
100 | void ff_bink_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); | ||
101 | |||
102 | /* CAVS functions */ | ||
103 | void ff_put_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride); | ||
104 | void ff_avg_cavs_qpel8_mc00_c(uint8_t *dst, uint8_t *src, int stride); | ||
105 | void ff_put_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride); | ||
106 | void ff_avg_cavs_qpel16_mc00_c(uint8_t *dst, uint8_t *src, int stride); | ||
107 | |||
108 | /* VC1 functions */ | ||
109 | void ff_put_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd); | ||
110 | void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int rnd); | ||
111 | |||
112 | /* EA functions */ | ||
113 | void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block); | ||
114 | |||
115 | /* 1/2^n downscaling functions from imgconvert.c */ | ||
116 | void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); | ||
117 | void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); | ||
118 | void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); | ||
119 | void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); | ||
120 | |||
121 | void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy, | ||
122 | int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height); | ||
123 | |||
124 | /* minimum alignment rules ;) | ||
125 | If you notice errors in the align stuff, need more alignment for some ASM code | ||
126 | for some CPU or need to use a function with less aligned data then send a mail | ||
127 | to the ffmpeg-devel mailing list, ... | ||
128 | |||
129 | !warning These alignments might not match reality, (missing attribute((align)) | ||
130 | stuff somewhere possible). | ||
131 | I (Michael) did not check them, these are just the alignments which I think | ||
132 | could be reached easily ... | ||
133 | |||
134 | !future video codecs might need functions with less strict alignment | ||
135 | */ | ||
136 | |||
137 | /* | ||
138 | void get_pixels_c(DCTELEM *block, const uint8_t *pixels, int line_size); | ||
139 | void diff_pixels_c(DCTELEM *block, const uint8_t *s1, const uint8_t *s2, int stride); | ||
140 | void put_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size); | ||
141 | void add_pixels_clamped_c(const DCTELEM *block, uint8_t *pixels, int line_size); | ||
142 | void clear_blocks_c(DCTELEM *blocks); | ||
143 | */ | ||
144 | |||
145 | /* add and put pixel (decoding) */ | ||
146 | // blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16 | ||
147 | //h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller then 4 | ||
148 | typedef void (*op_pixels_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int h); | ||
149 | typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h); | ||
150 | typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); | ||
151 | typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y); | ||
152 | |||
153 | typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h); | ||
154 | |||
155 | #define DEF_OLD_QPEL(name)\ | ||
156 | void ff_put_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\ | ||
157 | void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride);\ | ||
158 | void ff_avg_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, int stride); | ||
159 | |||
160 | DEF_OLD_QPEL(qpel16_mc11_old_c) | ||
161 | DEF_OLD_QPEL(qpel16_mc31_old_c) | ||
162 | DEF_OLD_QPEL(qpel16_mc12_old_c) | ||
163 | DEF_OLD_QPEL(qpel16_mc32_old_c) | ||
164 | DEF_OLD_QPEL(qpel16_mc13_old_c) | ||
165 | DEF_OLD_QPEL(qpel16_mc33_old_c) | ||
166 | DEF_OLD_QPEL(qpel8_mc11_old_c) | ||
167 | DEF_OLD_QPEL(qpel8_mc31_old_c) | ||
168 | DEF_OLD_QPEL(qpel8_mc12_old_c) | ||
169 | DEF_OLD_QPEL(qpel8_mc32_old_c) | ||
170 | DEF_OLD_QPEL(qpel8_mc13_old_c) | ||
171 | DEF_OLD_QPEL(qpel8_mc33_old_c) | ||
172 | |||
173 | #define CALL_2X_PIXELS(a, b, n)\ | ||
174 | static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\ | ||
175 | b(block , pixels , line_size, h);\ | ||
176 | b(block+n, pixels+n, line_size, h);\ | ||
177 | } | ||
178 | |||
179 | /* motion estimation */ | ||
180 | // h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller then 2 | ||
181 | // although currently h<4 is not used as functions with width <8 are neither used nor implemented | ||
182 | typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/; | ||
183 | |||
184 | /** | ||
185 | * Scantable. | ||
186 | */ | ||
187 | typedef struct ScanTable{ | ||
188 | const uint8_t *scantable; | ||
189 | uint8_t permutated[64]; | ||
190 | uint8_t raster_end[64]; | ||
191 | #if ARCH_PPC | ||
192 | /** Used by dct_quantize_altivec to find last-non-zero */ | ||
193 | DECLARE_ALIGNED(16, uint8_t, inverse)[64]; | ||
194 | #endif | ||
195 | } ScanTable; | ||
196 | |||
197 | void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable); | ||
198 | |||
199 | void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, | ||
200 | int block_w, int block_h, | ||
201 | int src_x, int src_y, int w, int h); | ||
202 | |||
203 | /** | ||
204 | * DSPContext. | ||
205 | */ | ||
206 | typedef struct DSPContext { | ||
207 | /* pixel ops : interface with DCT */ | ||
208 | void (*get_pixels)(DCTELEM *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size); | ||
209 | void (*diff_pixels)(DCTELEM *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride); | ||
210 | void (*put_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | ||
211 | void (*put_signed_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | ||
212 | void (*put_pixels_nonclamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | ||
213 | void (*add_pixels_clamped)(const DCTELEM *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size); | ||
214 | void (*add_pixels8)(uint8_t *pixels, DCTELEM *block, int line_size); | ||
215 | void (*add_pixels4)(uint8_t *pixels, DCTELEM *block, int line_size); | ||
216 | int (*sum_abs_dctelem)(DCTELEM *block/*align 16*/); | ||
217 | /** | ||
218 | * translational global motion compensation. | ||
219 | */ | ||
220 | void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder); | ||
221 | /** | ||
222 | * global motion compensation. | ||
223 | */ | ||
224 | void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy, | ||
225 | int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height); | ||
226 | void (*clear_block)(DCTELEM *block/*align 16*/); | ||
227 | void (*clear_blocks)(DCTELEM *blocks/*align 16*/); | ||
228 | int (*pix_sum)(uint8_t * pix, int line_size); | ||
229 | int (*pix_norm1)(uint8_t * pix, int line_size); | ||
230 | // 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4 | ||
231 | |||
232 | me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */ | ||
233 | me_cmp_func sse[6]; | ||
234 | me_cmp_func hadamard8_diff[6]; | ||
235 | me_cmp_func dct_sad[6]; | ||
236 | me_cmp_func quant_psnr[6]; | ||
237 | me_cmp_func bit[6]; | ||
238 | me_cmp_func rd[6]; | ||
239 | me_cmp_func vsad[6]; | ||
240 | me_cmp_func vsse[6]; | ||
241 | me_cmp_func nsse[6]; | ||
242 | me_cmp_func w53[6]; | ||
243 | me_cmp_func w97[6]; | ||
244 | me_cmp_func dct_max[6]; | ||
245 | me_cmp_func dct264_sad[6]; | ||
246 | |||
247 | me_cmp_func me_pre_cmp[6]; | ||
248 | me_cmp_func me_cmp[6]; | ||
249 | me_cmp_func me_sub_cmp[6]; | ||
250 | me_cmp_func mb_cmp[6]; | ||
251 | me_cmp_func ildct_cmp[6]; //only width 16 used | ||
252 | me_cmp_func frame_skip_cmp[6]; //only width 8 used | ||
253 | |||
254 | int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, | ||
255 | int size); | ||
256 | |||
257 | /** | ||
258 | * Halfpel motion compensation with rounding (a+b+1)>>1. | ||
259 | * this is an array[4][4] of motion compensation functions for 4 | ||
260 | * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | ||
261 | * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | ||
262 | * @param block destination where the result is stored | ||
263 | * @param pixels source | ||
264 | * @param line_size number of bytes in a horizontal line of block | ||
265 | * @param h height | ||
266 | */ | ||
267 | op_pixels_func put_pixels_tab[4][4]; | ||
268 | |||
269 | /** | ||
270 | * Halfpel motion compensation with rounding (a+b+1)>>1. | ||
271 | * This is an array[4][4] of motion compensation functions for 4 | ||
272 | * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | ||
273 | * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | ||
274 | * @param block destination into which the result is averaged (a+b+1)>>1 | ||
275 | * @param pixels source | ||
276 | * @param line_size number of bytes in a horizontal line of block | ||
277 | * @param h height | ||
278 | */ | ||
279 | op_pixels_func avg_pixels_tab[4][4]; | ||
280 | |||
281 | /** | ||
282 | * Halfpel motion compensation with no rounding (a+b)>>1. | ||
283 | * this is an array[2][4] of motion compensation functions for 2 | ||
284 | * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | ||
285 | * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | ||
286 | * @param block destination where the result is stored | ||
287 | * @param pixels source | ||
288 | * @param line_size number of bytes in a horizontal line of block | ||
289 | * @param h height | ||
290 | */ | ||
291 | op_pixels_func put_no_rnd_pixels_tab[4][4]; | ||
292 | |||
293 | /** | ||
294 | * Halfpel motion compensation with no rounding (a+b)>>1. | ||
295 | * this is an array[2][4] of motion compensation functions for 2 | ||
296 | * horizontal blocksizes (8,16) and the 4 halfpel positions<br> | ||
297 | * *pixels_tab[ 0->16xH 1->8xH ][ xhalfpel + 2*yhalfpel ] | ||
298 | * @param block destination into which the result is averaged (a+b)>>1 | ||
299 | * @param pixels source | ||
300 | * @param line_size number of bytes in a horizontal line of block | ||
301 | * @param h height | ||
302 | */ | ||
303 | op_pixels_func avg_no_rnd_pixels_tab[4][4]; | ||
304 | |||
305 | void (*put_no_rnd_pixels_l2[2])(uint8_t *block/*align width (8 or 16)*/, const uint8_t *a/*align 1*/, const uint8_t *b/*align 1*/, int line_size, int h); | ||
306 | |||
307 | /** | ||
308 | * Thirdpel motion compensation with rounding (a+b+1)>>1. | ||
309 | * this is an array[12] of motion compensation functions for the 9 thirdpe | ||
310 | * positions<br> | ||
311 | * *pixels_tab[ xthirdpel + 4*ythirdpel ] | ||
312 | * @param block destination where the result is stored | ||
313 | * @param pixels source | ||
314 | * @param line_size number of bytes in a horizontal line of block | ||
315 | * @param h height | ||
316 | */ | ||
317 | tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width? | ||
318 | tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width? | ||
319 | |||
320 | qpel_mc_func put_qpel_pixels_tab[2][16]; | ||
321 | qpel_mc_func avg_qpel_pixels_tab[2][16]; | ||
322 | qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16]; | ||
323 | qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16]; | ||
324 | qpel_mc_func put_mspel_pixels_tab[8]; | ||
325 | |||
326 | /** | ||
327 | * h264 Chroma MC | ||
328 | */ | ||
329 | h264_chroma_mc_func put_h264_chroma_pixels_tab[3]; | ||
330 | h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]; | ||
331 | /* This is really one func used in VC-1 decoding */ | ||
332 | h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3]; | ||
333 | h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3]; | ||
334 | |||
335 | qpel_mc_func put_h264_qpel_pixels_tab[4][16]; | ||
336 | qpel_mc_func avg_h264_qpel_pixels_tab[4][16]; | ||
337 | |||
338 | qpel_mc_func put_2tap_qpel_pixels_tab[4][16]; | ||
339 | qpel_mc_func avg_2tap_qpel_pixels_tab[4][16]; | ||
340 | |||
341 | /* AVS specific */ | ||
342 | qpel_mc_func put_cavs_qpel_pixels_tab[2][16]; | ||
343 | qpel_mc_func avg_cavs_qpel_pixels_tab[2][16]; | ||
344 | void (*cavs_filter_lv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); | ||
345 | void (*cavs_filter_lh)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); | ||
346 | void (*cavs_filter_cv)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); | ||
347 | void (*cavs_filter_ch)(uint8_t *pix, int stride, int alpha, int beta, int tc, int bs1, int bs2); | ||
348 | void (*cavs_idct8_add)(uint8_t *dst, DCTELEM *block, int stride); | ||
349 | |||
350 | me_cmp_func pix_abs[2][4]; | ||
351 | |||
352 | /* huffyuv specific */ | ||
353 | void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w); | ||
354 | void (*add_bytes_l2)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 16*/, int w); | ||
355 | void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w); | ||
356 | /** | ||
357 | * subtract huffyuv's variant of median prediction | ||
358 | * note, this might read from src1[-1], src2[-1] | ||
359 | */ | ||
360 | void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top); | ||
361 | void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top); | ||
362 | int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left); | ||
363 | void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha); | ||
364 | /* this might write to dst[w] */ | ||
365 | void (*add_png_paeth_prediction)(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp); | ||
366 | void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w); | ||
367 | |||
368 | void (*h263_v_loop_filter)(uint8_t *src, int stride, int qscale); | ||
369 | void (*h263_h_loop_filter)(uint8_t *src, int stride, int qscale); | ||
370 | |||
371 | void (*h261_loop_filter)(uint8_t *src, int stride); | ||
372 | |||
373 | void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale); | ||
374 | void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale); | ||
375 | |||
376 | void (*vp3_v_loop_filter)(uint8_t *src, int stride, int *bounding_values); | ||
377 | void (*vp3_h_loop_filter)(uint8_t *src, int stride, int *bounding_values); | ||
378 | |||
379 | void (*vp6_filter_diag4)(uint8_t *dst, uint8_t *src, int stride, | ||
380 | const int16_t *h_weights,const int16_t *v_weights); | ||
381 | |||
382 | /* assume len is a multiple of 4, and arrays are 16-byte aligned */ | ||
383 | void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize); | ||
384 | void (*ac3_downmix)(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len); | ||
385 | /* no alignment needed */ | ||
386 | void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag, double *autoc); | ||
387 | /* assume len is a multiple of 8, and arrays are 16-byte aligned */ | ||
388 | void (*vector_fmul)(float *dst, const float *src, int len); | ||
389 | void (*vector_fmul_reverse)(float *dst, const float *src0, const float *src1, int len); | ||
390 | /* assume len is a multiple of 8, and src arrays are 16-byte aligned */ | ||
391 | void (*vector_fmul_add)(float *dst, const float *src0, const float *src1, const float *src2, int len); | ||
392 | /* assume len is a multiple of 4, and arrays are 16-byte aligned */ | ||
393 | void (*vector_fmul_window)(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len); | ||
394 | /* assume len is a multiple of 8, and arrays are 16-byte aligned */ | ||
395 | void (*int32_to_float_fmul_scalar)(float *dst, const int *src, float mul, int len); | ||
396 | void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */); | ||
397 | /** | ||
398 | * Multiply a vector of floats by a scalar float. Source and | ||
399 | * destination vectors must overlap exactly or not at all. | ||
400 | * @param dst result vector, 16-byte aligned | ||
401 | * @param src input vector, 16-byte aligned | ||
402 | * @param mul scalar value | ||
403 | * @param len length of vector, multiple of 4 | ||
404 | */ | ||
405 | void (*vector_fmul_scalar)(float *dst, const float *src, float mul, | ||
406 | int len); | ||
407 | /** | ||
408 | * Multiply a vector of floats by concatenated short vectors of | ||
409 | * floats and by a scalar float. Source and destination vectors | ||
410 | * must overlap exactly or not at all. | ||
411 | * [0]: short vectors of length 2, 8-byte aligned | ||
412 | * [1]: short vectors of length 4, 16-byte aligned | ||
413 | * @param dst output vector, 16-byte aligned | ||
414 | * @param src input vector, 16-byte aligned | ||
415 | * @param sv array of pointers to short vectors | ||
416 | * @param mul scalar value | ||
417 | * @param len number of elements in src and dst, multiple of 4 | ||
418 | */ | ||
419 | void (*vector_fmul_sv_scalar[2])(float *dst, const float *src, | ||
420 | const float **sv, float mul, int len); | ||
421 | /** | ||
422 | * Multiply short vectors of floats by a scalar float, store | ||
423 | * concatenated result. | ||
424 | * [0]: short vectors of length 2, 8-byte aligned | ||
425 | * [1]: short vectors of length 4, 16-byte aligned | ||
426 | * @param dst output vector, 16-byte aligned | ||
427 | * @param sv array of pointers to short vectors | ||
428 | * @param mul scalar value | ||
429 | * @param len number of output elements, multiple of 4 | ||
430 | */ | ||
431 | void (*sv_fmul_scalar[2])(float *dst, const float **sv, | ||
432 | float mul, int len); | ||
433 | /** | ||
434 | * Calculate the scalar product of two vectors of floats. | ||
435 | * @param v1 first vector, 16-byte aligned | ||
436 | * @param v2 second vector, 16-byte aligned | ||
437 | * @param len length of vectors, multiple of 4 | ||
438 | */ | ||
439 | float (*scalarproduct_float)(const float *v1, const float *v2, int len); | ||
440 | /** | ||
441 | * Calculate the sum and difference of two vectors of floats. | ||
442 | * @param v1 first input vector, sum output, 16-byte aligned | ||
443 | * @param v2 second input vector, difference output, 16-byte aligned | ||
444 | * @param len length of vectors, multiple of 4 | ||
445 | */ | ||
446 | void (*butterflies_float)(float * v1, float * v2, int len); | ||
447 | |||
448 | /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767] | ||
449 | * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */ | ||
450 | void (*float_to_int16)(int16_t *dst, const float *src, long len); | ||
451 | void (*float_to_int16_interleave)(int16_t *dst, const float **src, long len, int channels); | ||
452 | |||
453 | /* (I)DCT */ | ||
454 | void (*fdct)(DCTELEM *block/* align 16*/); | ||
455 | void (*fdct248)(DCTELEM *block/* align 16*/); | ||
456 | |||
457 | /* IDCT really*/ | ||
458 | void (*idct)(DCTELEM *block/* align 16*/); | ||
459 | |||
460 | /** | ||
461 | * block -> idct -> clip to unsigned 8 bit -> dest. | ||
462 | * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...) | ||
463 | * @param line_size size in bytes of a horizontal line of dest | ||
464 | */ | ||
465 | void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | ||
466 | |||
467 | /** | ||
468 | * block -> idct -> add dest -> clip to unsigned 8 bit -> dest. | ||
469 | * @param line_size size in bytes of a horizontal line of dest | ||
470 | */ | ||
471 | void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, DCTELEM *block/*align 16*/); | ||
472 | |||
473 | /** | ||
474 | * idct input permutation. | ||
475 | * several optimized IDCTs need a permutated input (relative to the normal order of the reference | ||
476 | * IDCT) | ||
477 | * this permutation must be performed before the idct_put/add, note, normally this can be merged | ||
478 | * with the zigzag/alternate scan<br> | ||
479 | * an example to avoid confusion: | ||
480 | * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...) | ||
481 | * - (x -> referece dct -> reference idct -> x) | ||
482 | * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) | ||
483 | * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...) | ||
484 | */ | ||
485 | uint8_t idct_permutation[64]; | ||
486 | int idct_permutation_type; | ||
487 | #define FF_NO_IDCT_PERM 1 | ||
488 | #define FF_LIBMPEG2_IDCT_PERM 2 | ||
489 | #define FF_SIMPLE_IDCT_PERM 3 | ||
490 | #define FF_TRANSPOSE_IDCT_PERM 4 | ||
491 | #define FF_PARTTRANS_IDCT_PERM 5 | ||
492 | #define FF_SSE2_IDCT_PERM 6 | ||
493 | |||
494 | int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale); | ||
495 | void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale); | ||
496 | #define BASIS_SHIFT 16 | ||
497 | #define RECON_SHIFT 6 | ||
498 | |||
499 | void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w); | ||
500 | #define EDGE_WIDTH 16 | ||
501 | |||
502 | void (*prefetch)(void *mem, int stride, int h); | ||
503 | |||
504 | void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height); | ||
505 | |||
506 | /* mlp/truehd functions */ | ||
507 | void (*mlp_filter_channel)(int32_t *state, const int32_t *coeff, | ||
508 | int firorder, int iirorder, | ||
509 | unsigned int filter_shift, int32_t mask, int blocksize, | ||
510 | int32_t *sample_buffer); | ||
511 | |||
512 | /* vc1 functions */ | ||
513 | void (*vc1_inv_trans_8x8)(DCTELEM *b); | ||
514 | void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block); | ||
515 | void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block); | ||
516 | void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block); | ||
517 | void (*vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block); | ||
518 | void (*vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block); | ||
519 | void (*vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block); | ||
520 | void (*vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block); | ||
521 | void (*vc1_v_overlap)(uint8_t* src, int stride); | ||
522 | void (*vc1_h_overlap)(uint8_t* src, int stride); | ||
523 | void (*vc1_v_loop_filter4)(uint8_t *src, int stride, int pq); | ||
524 | void (*vc1_h_loop_filter4)(uint8_t *src, int stride, int pq); | ||
525 | void (*vc1_v_loop_filter8)(uint8_t *src, int stride, int pq); | ||
526 | void (*vc1_h_loop_filter8)(uint8_t *src, int stride, int pq); | ||
527 | void (*vc1_v_loop_filter16)(uint8_t *src, int stride, int pq); | ||
528 | void (*vc1_h_loop_filter16)(uint8_t *src, int stride, int pq); | ||
529 | /* put 8x8 block with bicubic interpolation and quarterpel precision | ||
530 | * last argument is actually round value instead of height | ||
531 | */ | ||
532 | op_pixels_func put_vc1_mspel_pixels_tab[16]; | ||
533 | op_pixels_func avg_vc1_mspel_pixels_tab[16]; | ||
534 | |||
535 | /* intrax8 functions */ | ||
536 | void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize); | ||
537 | void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize, | ||
538 | int * range, int * sum, int edges); | ||
539 | |||
540 | /** | ||
541 | * Calculate scalar product of two vectors. | ||
542 | * @param len length of vectors, should be multiple of 16 | ||
543 | * @param shift number of bits to discard from product | ||
544 | */ | ||
545 | int32_t (*scalarproduct_int16)(int16_t *v1, int16_t *v2/*align 16*/, int len, int shift); | ||
546 | /* ape functions */ | ||
547 | /** | ||
548 | * Calculate scalar product of v1 and v2, | ||
549 | * and v1[i] += v3[i] * mul | ||
550 | * @param len length of vectors, should be multiple of 16 | ||
551 | */ | ||
552 | int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, int16_t *v2, int16_t *v3, int len, int mul); | ||
553 | |||
554 | /* rv30 functions */ | ||
555 | qpel_mc_func put_rv30_tpel_pixels_tab[4][16]; | ||
556 | qpel_mc_func avg_rv30_tpel_pixels_tab[4][16]; | ||
557 | |||
558 | /* rv40 functions */ | ||
559 | qpel_mc_func put_rv40_qpel_pixels_tab[4][16]; | ||
560 | qpel_mc_func avg_rv40_qpel_pixels_tab[4][16]; | ||
561 | h264_chroma_mc_func put_rv40_chroma_pixels_tab[3]; | ||
562 | h264_chroma_mc_func avg_rv40_chroma_pixels_tab[3]; | ||
563 | |||
564 | /* bink functions */ | ||
565 | op_fill_func fill_block_tab[2]; | ||
566 | void (*scale_block)(const uint8_t src[64]/*align 8*/, uint8_t *dst/*align 8*/, int linesize); | ||
567 | } DSPContext; | ||
568 | |||
569 | void dsputil_static_init(void); | ||
570 | void dsputil_init(DSPContext* p, AVCodecContext *avctx); | ||
571 | |||
572 | int ff_check_alignment(void); | ||
573 | |||
574 | /** | ||
575 | * permute block according to permuatation. | ||
576 | * @param last last non zero element in scantable order | ||
577 | */ | ||
578 | void ff_block_permute(DCTELEM *block, uint8_t *permutation, const uint8_t *scantable, int last); | ||
579 | |||
580 | void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type); | ||
581 | |||
582 | #define BYTE_VEC32(c) ((c)*0x01010101UL) | ||
583 | |||
584 | static inline uint32_t rnd_avg32(uint32_t a, uint32_t b) | ||
585 | { | ||
586 | return (a | b) - (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); | ||
587 | } | ||
588 | |||
589 | static inline uint32_t no_rnd_avg32(uint32_t a, uint32_t b) | ||
590 | { | ||
591 | return (a & b) + (((a ^ b) & ~BYTE_VEC32(0x01)) >> 1); | ||
592 | } | ||
593 | |||
594 | static inline int get_penalty_factor(int lambda, int lambda2, int type){ | ||
595 | switch(type&0xFF){ | ||
596 | default: | ||
597 | case FF_CMP_SAD: | ||
598 | return lambda>>FF_LAMBDA_SHIFT; | ||
599 | case FF_CMP_DCT: | ||
600 | return (3*lambda)>>(FF_LAMBDA_SHIFT+1); | ||
601 | case FF_CMP_W53: | ||
602 | return (4*lambda)>>(FF_LAMBDA_SHIFT); | ||
603 | case FF_CMP_W97: | ||
604 | return (2*lambda)>>(FF_LAMBDA_SHIFT); | ||
605 | case FF_CMP_SATD: | ||
606 | case FF_CMP_DCT264: | ||
607 | return (2*lambda)>>FF_LAMBDA_SHIFT; | ||
608 | case FF_CMP_RD: | ||
609 | case FF_CMP_PSNR: | ||
610 | case FF_CMP_SSE: | ||
611 | case FF_CMP_NSSE: | ||
612 | return lambda2>>FF_LAMBDA_SHIFT; | ||
613 | case FF_CMP_BIT: | ||
614 | return 1; | ||
615 | } | ||
616 | } | ||
617 | |||
618 | /** | ||
619 | * Empty mmx state. | ||
620 | * this must be called between any dsp function and float/double code. | ||
621 | * for example sin(); dsp->idct_put(); emms_c(); cos() | ||
622 | */ | ||
623 | #define emms_c() | ||
624 | |||
625 | /* should be defined by architectures supporting | ||
626 | one or more MultiMedia extension */ | ||
627 | int mm_support(void); | ||
628 | extern int mm_flags; | ||
629 | |||
630 | void dsputil_init_alpha(DSPContext* c, AVCodecContext *avctx); | ||
631 | void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx); | ||
632 | void dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx); | ||
633 | void dsputil_init_mlib(DSPContext* c, AVCodecContext *avctx); | ||
634 | void dsputil_init_mmi(DSPContext* c, AVCodecContext *avctx); | ||
635 | void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx); | ||
636 | void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx); | ||
637 | void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx); | ||
638 | void dsputil_init_vis(DSPContext* c, AVCodecContext *avctx); | ||
639 | |||
640 | void ff_dsputil_init_dwt(DSPContext *c); | ||
641 | void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx); | ||
642 | void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx); | ||
643 | void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx); | ||
644 | void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx); | ||
645 | void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx); | ||
646 | void ff_mlp_init(DSPContext* c, AVCodecContext *avctx); | ||
647 | void ff_mlp_init_x86(DSPContext* c, AVCodecContext *avctx); | ||
648 | |||
649 | #if HAVE_MMX | ||
650 | |||
651 | #undef emms_c | ||
652 | |||
653 | static inline void emms(void) | ||
654 | { | ||
655 | __asm__ volatile ("emms;":::"memory"); | ||
656 | } | ||
657 | |||
658 | |||
659 | #define emms_c() \ | ||
660 | {\ | ||
661 | if (mm_flags & FF_MM_MMX)\ | ||
662 | emms();\ | ||
663 | } | ||
664 | |||
665 | #elif ARCH_ARM | ||
666 | |||
667 | #if HAVE_NEON | ||
668 | # define STRIDE_ALIGN 16 | ||
669 | #endif | ||
670 | |||
671 | #elif ARCH_PPC | ||
672 | |||
673 | #define STRIDE_ALIGN 16 | ||
674 | |||
675 | #elif HAVE_MMI | ||
676 | |||
677 | #define STRIDE_ALIGN 16 | ||
678 | |||
679 | #else | ||
680 | |||
681 | #define mm_flags 0 | ||
682 | #define mm_support() 0 | ||
683 | |||
684 | #endif | ||
685 | |||
686 | #ifndef STRIDE_ALIGN | ||
687 | # define STRIDE_ALIGN 8 | ||
688 | #endif | ||
689 | |||
690 | #define LOCAL_ALIGNED(a, t, v, s, ...) \ | ||
691 | uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)]; \ | ||
692 | t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a) | ||
693 | |||
694 | #if HAVE_LOCAL_ALIGNED_8 | ||
695 | # define LOCAL_ALIGNED_8(t, v, s, ...) DECLARE_ALIGNED(8, t, v) s __VA_ARGS__ | ||
696 | #else | ||
697 | # define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__) | ||
698 | #endif | ||
699 | |||
700 | #if HAVE_LOCAL_ALIGNED_16 | ||
701 | # define LOCAL_ALIGNED_16(t, v, s, ...) DECLARE_ALIGNED(16, t, v) s __VA_ARGS__ | ||
702 | #else | ||
703 | # define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__) | ||
704 | #endif | ||
705 | |||
706 | /* PSNR */ | ||
707 | void get_psnr(uint8_t *orig_image[3], uint8_t *coded_image[3], | ||
708 | int orig_linesize[3], int coded_linesize, | ||
709 | AVCodecContext *avctx); | ||
710 | |||
711 | #define WRAPPER8_16(name8, name16)\ | ||
712 | static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ | ||
713 | return name8(s, dst , src , stride, h)\ | ||
714 | +name8(s, dst+8 , src+8 , stride, h);\ | ||
715 | } | ||
716 | |||
717 | #define WRAPPER8_16_SQ(name8, name16)\ | ||
718 | static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ | ||
719 | int score=0;\ | ||
720 | score +=name8(s, dst , src , stride, 8);\ | ||
721 | score +=name8(s, dst+8 , src+8 , stride, 8);\ | ||
722 | if(h==16){\ | ||
723 | dst += 8*stride;\ | ||
724 | src += 8*stride;\ | ||
725 | score +=name8(s, dst , src , stride, 8);\ | ||
726 | score +=name8(s, dst+8 , src+8 , stride, 8);\ | ||
727 | }\ | ||
728 | return score;\ | ||
729 | } | ||
730 | |||
731 | |||
732 | static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
733 | { | ||
734 | int i; | ||
735 | for(i=0; i<h; i++) | ||
736 | { | ||
737 | AV_WN16(dst , AV_RN16(src )); | ||
738 | dst+=dstStride; | ||
739 | src+=srcStride; | ||
740 | } | ||
741 | } | ||
742 | |||
743 | static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
744 | { | ||
745 | int i; | ||
746 | for(i=0; i<h; i++) | ||
747 | { | ||
748 | AV_WN32(dst , AV_RN32(src )); | ||
749 | dst+=dstStride; | ||
750 | src+=srcStride; | ||
751 | } | ||
752 | } | ||
753 | |||
754 | static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
755 | { | ||
756 | int i; | ||
757 | for(i=0; i<h; i++) | ||
758 | { | ||
759 | AV_WN32(dst , AV_RN32(src )); | ||
760 | AV_WN32(dst+4 , AV_RN32(src+4 )); | ||
761 | dst+=dstStride; | ||
762 | src+=srcStride; | ||
763 | } | ||
764 | } | ||
765 | |||
766 | static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
767 | { | ||
768 | int i; | ||
769 | for(i=0; i<h; i++) | ||
770 | { | ||
771 | AV_WN32(dst , AV_RN32(src )); | ||
772 | AV_WN32(dst+4 , AV_RN32(src+4 )); | ||
773 | dst[8]= src[8]; | ||
774 | dst+=dstStride; | ||
775 | src+=srcStride; | ||
776 | } | ||
777 | } | ||
778 | |||
779 | static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
780 | { | ||
781 | int i; | ||
782 | for(i=0; i<h; i++) | ||
783 | { | ||
784 | AV_WN32(dst , AV_RN32(src )); | ||
785 | AV_WN32(dst+4 , AV_RN32(src+4 )); | ||
786 | AV_WN32(dst+8 , AV_RN32(src+8 )); | ||
787 | AV_WN32(dst+12, AV_RN32(src+12)); | ||
788 | dst+=dstStride; | ||
789 | src+=srcStride; | ||
790 | } | ||
791 | } | ||
792 | |||
793 | static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h) | ||
794 | { | ||
795 | int i; | ||
796 | for(i=0; i<h; i++) | ||
797 | { | ||
798 | AV_WN32(dst , AV_RN32(src )); | ||
799 | AV_WN32(dst+4 , AV_RN32(src+4 )); | ||
800 | AV_WN32(dst+8 , AV_RN32(src+8 )); | ||
801 | AV_WN32(dst+12, AV_RN32(src+12)); | ||
802 | dst[16]= src[16]; | ||
803 | dst+=dstStride; | ||
804 | src+=srcStride; | ||
805 | } | ||
806 | } | ||
807 | |||
808 | #endif /* AVCODEC_DSPUTIL_H */ | ||
diff --git a/apps/codecs/libwmapro/fft.c b/apps/codecs/libwmapro/fft.c deleted file mode 100644 index 0b43fea1a3..0000000000 --- a/apps/codecs/libwmapro/fft.c +++ /dev/null | |||
@@ -1,368 +0,0 @@ | |||
1 | /* | ||
2 | * FFT/IFFT transforms | ||
3 | * Copyright (c) 2008 Loren Merritt | ||
4 | * Copyright (c) 2002 Fabrice Bellard | ||
5 | * Partly based on libdjbfft by D. J. Bernstein | ||
6 | * | ||
7 | * This file is part of FFmpeg. | ||
8 | * | ||
9 | * FFmpeg is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU Lesser General Public | ||
11 | * License as published by the Free Software Foundation; either | ||
12 | * version 2.1 of the License, or (at your option) any later version. | ||
13 | * | ||
14 | * FFmpeg is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
17 | * Lesser General Public License for more details. | ||
18 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with FFmpeg; if not, write to the Free Software | ||
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | /** | ||
25 | * @file libavcodec/fft.c | ||
26 | * FFT/IFFT transforms. | ||
27 | */ | ||
28 | |||
29 | #include <stdlib.h> | ||
30 | #include <string.h> | ||
31 | #include "libavutil/mathematics.h" | ||
32 | #include "fft.h" | ||
33 | |||
34 | /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ | ||
35 | #if !CONFIG_HARDCODED_TABLES | ||
36 | COSTABLE(16); | ||
37 | COSTABLE(32); | ||
38 | COSTABLE(64); | ||
39 | COSTABLE(128); | ||
40 | COSTABLE(256); | ||
41 | COSTABLE(512); | ||
42 | COSTABLE(1024); | ||
43 | COSTABLE(2048); | ||
44 | COSTABLE(4096); | ||
45 | COSTABLE(8192); | ||
46 | COSTABLE(16384); | ||
47 | COSTABLE(32768); | ||
48 | COSTABLE(65536); | ||
49 | #endif | ||
50 | COSTABLE_CONST FFTSample * const ff_cos_tabs[] = { | ||
51 | NULL, NULL, NULL, NULL, | ||
52 | ff_cos_16, ff_cos_32, ff_cos_64, ff_cos_128, ff_cos_256, ff_cos_512, ff_cos_1024, | ||
53 | ff_cos_2048, ff_cos_4096, ff_cos_8192, ff_cos_16384, ff_cos_32768, ff_cos_65536, | ||
54 | }; | ||
55 | |||
56 | static int split_radix_permutation(int i, int n, int inverse) | ||
57 | { | ||
58 | int m; | ||
59 | if(n <= 2) return i&1; | ||
60 | m = n >> 1; | ||
61 | if(!(i&m)) return split_radix_permutation(i, m, inverse)*2; | ||
62 | m >>= 1; | ||
63 | if(inverse == !(i&m)) return split_radix_permutation(i, m, inverse)*4 + 1; | ||
64 | else return split_radix_permutation(i, m, inverse)*4 - 1; | ||
65 | } | ||
66 | |||
67 | av_cold void ff_init_ff_cos_tabs(int index) | ||
68 | { | ||
69 | #if !CONFIG_HARDCODED_TABLES | ||
70 | int i; | ||
71 | int m = 1<<index; | ||
72 | double freq = 2*M_PI/m; | ||
73 | FFTSample *tab = ff_cos_tabs[index]; | ||
74 | for(i=0; i<=m/4; i++) | ||
75 | tab[i] = cos(i*freq); | ||
76 | for(i=1; i<m/4; i++) | ||
77 | tab[m/2-i] = tab[i]; | ||
78 | #endif | ||
79 | } | ||
80 | |||
81 | av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) | ||
82 | { | ||
83 | int i, j, m, n; | ||
84 | float alpha, c1, s1, s2; | ||
85 | int av_unused has_vectors; | ||
86 | |||
87 | if (nbits < 2 || nbits > 16) | ||
88 | goto fail; | ||
89 | s->nbits = nbits; | ||
90 | n = 1 << nbits; | ||
91 | |||
92 | s->tmp_buf = NULL; | ||
93 | s->exptab = av_malloc((n / 2) * sizeof(FFTComplex)); | ||
94 | if (!s->exptab) | ||
95 | goto fail; | ||
96 | s->revtab = av_malloc(n * sizeof(uint16_t)); | ||
97 | if (!s->revtab) | ||
98 | goto fail; | ||
99 | s->inverse = inverse; | ||
100 | |||
101 | s2 = inverse ? 1.0 : -1.0; | ||
102 | |||
103 | s->fft_permute = ff_fft_permute_c; | ||
104 | s->fft_calc = fff_fft_calc_c; | ||
105 | //#if CONFIG_MDCT | ||
106 | s->imdct_calc = ff_imdct_calc_c; | ||
107 | s->imdct_half = fff_imdct_half_c; | ||
108 | s->mdct_calc = ff_mdct_calc_c; | ||
109 | //#endif | ||
110 | s->exptab1 = NULL; | ||
111 | s->split_radix = 1; | ||
112 | #if 0 | ||
113 | if (ARCH_ARM) ff_fft_init_arm(s); | ||
114 | if (HAVE_ALTIVEC) ff_fft_init_altivec(s); | ||
115 | if (HAVE_MMX) ff_fft_init_mmx(s); | ||
116 | #endif | ||
117 | if (s->split_radix) { | ||
118 | for(j=4; j<=nbits; j++) { | ||
119 | ff_init_ff_cos_tabs(j); | ||
120 | } | ||
121 | for(i=0; i<n; i++) | ||
122 | s->revtab[-split_radix_permutation(i, n, s->inverse) & (n-1)] = i; | ||
123 | s->tmp_buf = av_malloc(n * sizeof(FFTComplex)); | ||
124 | } else { | ||
125 | int np, nblocks, np2, l; | ||
126 | FFTComplex *q; | ||
127 | |||
128 | for(i=0; i<(n/2); i++) { | ||
129 | alpha = 2 * M_PI * (float)i / (float)n; | ||
130 | c1 = cos(alpha); | ||
131 | s1 = sin(alpha) * s2; | ||
132 | s->exptab[i].re = c1; | ||
133 | s->exptab[i].im = s1; | ||
134 | } | ||
135 | |||
136 | np = 1 << nbits; | ||
137 | nblocks = np >> 3; | ||
138 | np2 = np >> 1; | ||
139 | s->exptab1 = av_malloc(np * 2 * sizeof(FFTComplex)); | ||
140 | if (!s->exptab1) | ||
141 | goto fail; | ||
142 | q = s->exptab1; | ||
143 | do { | ||
144 | for(l = 0; l < np2; l += 2 * nblocks) { | ||
145 | *q++ = s->exptab[l]; | ||
146 | *q++ = s->exptab[l + nblocks]; | ||
147 | |||
148 | q->re = -s->exptab[l].im; | ||
149 | q->im = s->exptab[l].re; | ||
150 | q++; | ||
151 | q->re = -s->exptab[l + nblocks].im; | ||
152 | q->im = s->exptab[l + nblocks].re; | ||
153 | q++; | ||
154 | } | ||
155 | nblocks = nblocks >> 1; | ||
156 | } while (nblocks != 0); | ||
157 | av_freep(&s->exptab); | ||
158 | |||
159 | /* compute bit reverse table */ | ||
160 | for(i=0;i<n;i++) { | ||
161 | m=0; | ||
162 | for(j=0;j<nbits;j++) { | ||
163 | m |= ((i >> j) & 1) << (nbits-j-1); | ||
164 | } | ||
165 | s->revtab[i]=m; | ||
166 | } | ||
167 | } | ||
168 | |||
169 | return 0; | ||
170 | fail: | ||
171 | av_freep(&s->revtab); | ||
172 | av_freep(&s->exptab); | ||
173 | av_freep(&s->exptab1); | ||
174 | av_freep(&s->tmp_buf); | ||
175 | return -1; | ||
176 | } | ||
177 | |||
178 | void ff_fft_permute_c(FFTContext *s, FFTComplex *z) | ||
179 | { | ||
180 | int j, k, np; | ||
181 | FFTComplex tmp; | ||
182 | const uint16_t *revtab = s->revtab; | ||
183 | np = 1 << s->nbits; | ||
184 | |||
185 | if (s->tmp_buf) { | ||
186 | /* TODO: handle split-radix permute in a more optimal way, probably in-place */ | ||
187 | for(j=0;j<np;j++) s->tmp_buf[revtab[j]] = z[j]; | ||
188 | memcpy(z, s->tmp_buf, np * sizeof(FFTComplex)); | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | /* reverse */ | ||
193 | for(j=0;j<np;j++) { | ||
194 | k = revtab[j]; | ||
195 | if (k < j) { | ||
196 | tmp = z[k]; | ||
197 | z[k] = z[j]; | ||
198 | z[j] = tmp; | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | |||
203 | av_cold void ff_fft_end(FFTContext *s) | ||
204 | { | ||
205 | av_freep(&s->revtab); | ||
206 | av_freep(&s->exptab); | ||
207 | av_freep(&s->exptab1); | ||
208 | av_freep(&s->tmp_buf); | ||
209 | } | ||
210 | |||
211 | #define sqrthalf (float)M_SQRT1_2 | ||
212 | |||
213 | #define BF(x,y,a,b) {\ | ||
214 | x = a - b;\ | ||
215 | y = a + b;\ | ||
216 | } | ||
217 | |||
218 | #define BUTTERFLIES(a0,a1,a2,a3) {\ | ||
219 | BF(t3, t5, t5, t1);\ | ||
220 | BF(a2.re, a0.re, a0.re, t5);\ | ||
221 | BF(a3.im, a1.im, a1.im, t3);\ | ||
222 | BF(t4, t6, t2, t6);\ | ||
223 | BF(a3.re, a1.re, a1.re, t4);\ | ||
224 | BF(a2.im, a0.im, a0.im, t6);\ | ||
225 | } | ||
226 | |||
227 | // force loading all the inputs before storing any. | ||
228 | // this is slightly slower for small data, but avoids store->load aliasing | ||
229 | // for addresses separated by large powers of 2. | ||
230 | #define BUTTERFLIES_BIG(a0,a1,a2,a3) {\ | ||
231 | FFTSample r0=a0.re, i0=a0.im, r1=a1.re, i1=a1.im;\ | ||
232 | BF(t3, t5, t5, t1);\ | ||
233 | BF(a2.re, a0.re, r0, t5);\ | ||
234 | BF(a3.im, a1.im, i1, t3);\ | ||
235 | BF(t4, t6, t2, t6);\ | ||
236 | BF(a3.re, a1.re, r1, t4);\ | ||
237 | BF(a2.im, a0.im, i0, t6);\ | ||
238 | } | ||
239 | |||
240 | #define TRANSFORM(a0,a1,a2,a3,wre,wim) {\ | ||
241 | t1 = a2.re * wre + a2.im * wim;\ | ||
242 | t2 = a2.im * wre - a2.re * wim;\ | ||
243 | t5 = a3.re * wre - a3.im * wim;\ | ||
244 | t6 = a3.im * wre + a3.re * wim;\ | ||
245 | BUTTERFLIES(a0,a1,a2,a3)\ | ||
246 | } | ||
247 | |||
248 | #define TRANSFORM_ZERO(a0,a1,a2,a3) {\ | ||
249 | t1 = a2.re;\ | ||
250 | t2 = a2.im;\ | ||
251 | t5 = a3.re;\ | ||
252 | t6 = a3.im;\ | ||
253 | BUTTERFLIES(a0,a1,a2,a3)\ | ||
254 | } | ||
255 | |||
256 | /* z[0...8n-1], w[1...2n-1] */ | ||
257 | #define PASS(name)\ | ||
258 | static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\ | ||
259 | {\ | ||
260 | FFTSample t1, t2, t3, t4, t5, t6;\ | ||
261 | int o1 = 2*n;\ | ||
262 | int o2 = 4*n;\ | ||
263 | int o3 = 6*n;\ | ||
264 | const FFTSample *wim = wre+o1;\ | ||
265 | n--;\ | ||
266 | \ | ||
267 | TRANSFORM_ZERO(z[0],z[o1],z[o2],z[o3]);\ | ||
268 | TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ | ||
269 | do {\ | ||
270 | z += 2;\ | ||
271 | wre += 2;\ | ||
272 | wim -= 2;\ | ||
273 | TRANSFORM(z[0],z[o1],z[o2],z[o3],wre[0],wim[0]);\ | ||
274 | TRANSFORM(z[1],z[o1+1],z[o2+1],z[o3+1],wre[1],wim[-1]);\ | ||
275 | } while(--n);\ | ||
276 | } | ||
277 | |||
278 | PASS(pass) | ||
279 | #undef BUTTERFLIES | ||
280 | #define BUTTERFLIES BUTTERFLIES_BIG | ||
281 | PASS(pass_big) | ||
282 | |||
283 | #define DECL_FFT(n,n2,n4)\ | ||
284 | static void fft##n(FFTComplex *z)\ | ||
285 | {\ | ||
286 | fft##n2(z);\ | ||
287 | fft##n4(z+n4*2);\ | ||
288 | fft##n4(z+n4*3);\ | ||
289 | pass(z,ff_cos_##n,n4/2);\ | ||
290 | } | ||
291 | |||
292 | static void fft4(FFTComplex *z) | ||
293 | { | ||
294 | FFTSample t1, t2, t3, t4, t5, t6, t7, t8; | ||
295 | |||
296 | BF(t3, t1, z[0].re, z[1].re); | ||
297 | BF(t8, t6, z[3].re, z[2].re); | ||
298 | BF(z[2].re, z[0].re, t1, t6); | ||
299 | BF(t4, t2, z[0].im, z[1].im); | ||
300 | BF(t7, t5, z[2].im, z[3].im); | ||
301 | BF(z[3].im, z[1].im, t4, t8); | ||
302 | BF(z[3].re, z[1].re, t3, t7); | ||
303 | BF(z[2].im, z[0].im, t2, t5); | ||
304 | } | ||
305 | |||
306 | static void fft8(FFTComplex *z) | ||
307 | { | ||
308 | FFTSample t1, t2, t3, t4, t5, t6, t7, t8; | ||
309 | |||
310 | fft4(z); | ||
311 | |||
312 | BF(t1, z[5].re, z[4].re, -z[5].re); | ||
313 | BF(t2, z[5].im, z[4].im, -z[5].im); | ||
314 | BF(t3, z[7].re, z[6].re, -z[7].re); | ||
315 | BF(t4, z[7].im, z[6].im, -z[7].im); | ||
316 | BF(t8, t1, t3, t1); | ||
317 | BF(t7, t2, t2, t4); | ||
318 | BF(z[4].re, z[0].re, z[0].re, t1); | ||
319 | BF(z[4].im, z[0].im, z[0].im, t2); | ||
320 | BF(z[6].re, z[2].re, z[2].re, t7); | ||
321 | BF(z[6].im, z[2].im, z[2].im, t8); | ||
322 | |||
323 | TRANSFORM(z[1],z[3],z[5],z[7],sqrthalf,sqrthalf); | ||
324 | } | ||
325 | |||
326 | #if !CONFIG_SMALL | ||
327 | static void fft16(FFTComplex *z) | ||
328 | { | ||
329 | FFTSample t1, t2, t3, t4, t5, t6; | ||
330 | |||
331 | fft8(z); | ||
332 | fft4(z+8); | ||
333 | fft4(z+12); | ||
334 | |||
335 | TRANSFORM_ZERO(z[0],z[4],z[8],z[12]); | ||
336 | TRANSFORM(z[2],z[6],z[10],z[14],sqrthalf,sqrthalf); | ||
337 | TRANSFORM(z[1],z[5],z[9],z[13],ff_cos_16[1],ff_cos_16[3]); | ||
338 | TRANSFORM(z[3],z[7],z[11],z[15],ff_cos_16[3],ff_cos_16[1]); | ||
339 | } | ||
340 | #else | ||
341 | DECL_FFT(16,8,4) | ||
342 | #endif | ||
343 | DECL_FFT(32,16,8) | ||
344 | DECL_FFT(64,32,16) | ||
345 | DECL_FFT(128,64,32) | ||
346 | DECL_FFT(256,128,64) | ||
347 | DECL_FFT(512,256,128) | ||
348 | #if !CONFIG_SMALL | ||
349 | #define pass pass_big | ||
350 | #endif | ||
351 | DECL_FFT(1024,512,256) | ||
352 | DECL_FFT(2048,1024,512) | ||
353 | DECL_FFT(4096,2048,1024) | ||
354 | DECL_FFT(8192,4096,2048) | ||
355 | DECL_FFT(16384,8192,4096) | ||
356 | DECL_FFT(32768,16384,8192) | ||
357 | DECL_FFT(65536,32768,16384) | ||
358 | |||
359 | static void (* const fft_dispatch[])(FFTComplex*) = { | ||
360 | fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, | ||
361 | fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, | ||
362 | }; | ||
363 | |||
364 | void fff_fft_calc_c(FFTContext *s, FFTComplex *z) | ||
365 | { | ||
366 | fft_dispatch[s->nbits-2](z); | ||
367 | } | ||
368 | |||
diff --git a/apps/codecs/libwmapro/fft.h b/apps/codecs/libwmapro/fft.h deleted file mode 100644 index 8614a1b2a3..0000000000 --- a/apps/codecs/libwmapro/fft.h +++ /dev/null | |||
@@ -1,240 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000, 2001, 2002 Fabrice Bellard | ||
3 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg 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 GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | #ifndef AVCODEC_FFT_H | ||
23 | #define AVCODEC_FFT_H | ||
24 | |||
25 | #include <stdint.h> | ||
26 | //#include "config.h" | ||
27 | #include "libavutil/mem.h" | ||
28 | #include "avfft.h" | ||
29 | |||
30 | /* FFT computation */ | ||
31 | |||
32 | struct FFTContext { | ||
33 | int nbits; | ||
34 | int inverse; | ||
35 | uint16_t *revtab; | ||
36 | FFTComplex *exptab; | ||
37 | FFTComplex *exptab1; /* only used by SSE code */ | ||
38 | FFTComplex *tmp_buf; | ||
39 | int mdct_size; /* size of MDCT (i.e. number of input data * 2) */ | ||
40 | int mdct_bits; /* n = 2^nbits */ | ||
41 | /* pre/post rotation tables */ | ||
42 | FFTSample *tcos; | ||
43 | FFTSample *tsin; | ||
44 | void (*fft_permute)(struct FFTContext *s, FFTComplex *z); | ||
45 | void (*fft_calc)(struct FFTContext *s, FFTComplex *z); | ||
46 | void (*imdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | ||
47 | void (*imdct_half)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | ||
48 | void (*mdct_calc)(struct FFTContext *s, FFTSample *output, const FFTSample *input); | ||
49 | int split_radix; | ||
50 | int permutation; | ||
51 | #define FF_MDCT_PERM_NONE 0 | ||
52 | #define FF_MDCT_PERM_INTERLEAVE 1 | ||
53 | }; | ||
54 | |||
55 | #if CONFIG_HARDCODED_TABLES | ||
56 | #define COSTABLE_CONST const | ||
57 | #define SINTABLE_CONST const | ||
58 | #define SINETABLE_CONST const | ||
59 | #else | ||
60 | #define COSTABLE_CONST | ||
61 | #define SINTABLE_CONST | ||
62 | #define SINETABLE_CONST | ||
63 | #endif | ||
64 | |||
65 | #define COSTABLE(size) \ | ||
66 | COSTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_cos_##size)[size/2] | ||
67 | #define SINTABLE(size) \ | ||
68 | SINTABLE_CONST DECLARE_ALIGNED(16, FFTSample, ff_sin_##size)[size/2] | ||
69 | #define SINETABLE(size) \ | ||
70 | SINETABLE_CONST DECLARE_ALIGNED(16, float, ff_sine_##size)[size] | ||
71 | extern COSTABLE(16); | ||
72 | extern COSTABLE(32); | ||
73 | extern COSTABLE(64); | ||
74 | extern COSTABLE(128); | ||
75 | extern COSTABLE(256); | ||
76 | extern COSTABLE(512); | ||
77 | extern COSTABLE(1024); | ||
78 | extern COSTABLE(2048); | ||
79 | extern COSTABLE(4096); | ||
80 | extern COSTABLE(8192); | ||
81 | extern COSTABLE(16384); | ||
82 | extern COSTABLE(32768); | ||
83 | extern COSTABLE(65536); | ||
84 | extern COSTABLE_CONST FFTSample* const ff_cos_tabs[17]; | ||
85 | |||
86 | /** | ||
87 | * Initializes the cosine table in ff_cos_tabs[index] | ||
88 | * \param index index in ff_cos_tabs array of the table to initialize | ||
89 | */ | ||
90 | void ff_init_ff_cos_tabs(int index); | ||
91 | |||
92 | extern SINTABLE(16); | ||
93 | extern SINTABLE(32); | ||
94 | extern SINTABLE(64); | ||
95 | extern SINTABLE(128); | ||
96 | extern SINTABLE(256); | ||
97 | extern SINTABLE(512); | ||
98 | extern SINTABLE(1024); | ||
99 | extern SINTABLE(2048); | ||
100 | extern SINTABLE(4096); | ||
101 | extern SINTABLE(8192); | ||
102 | extern SINTABLE(16384); | ||
103 | extern SINTABLE(32768); | ||
104 | extern SINTABLE(65536); | ||
105 | |||
106 | /** | ||
107 | * Sets up a complex FFT. | ||
108 | * @param nbits log2 of the length of the input array | ||
109 | * @param inverse if 0 perform the forward transform, if 1 perform the inverse | ||
110 | */ | ||
111 | int ff_fft_init(FFTContext *s, int nbits, int inverse); | ||
112 | void ff_fft_permute_c(FFTContext *s, FFTComplex *z); | ||
113 | void fff_fft_calc_c(FFTContext *s, FFTComplex *z); | ||
114 | |||
115 | void ff_fft_init_altivec(FFTContext *s); | ||
116 | void ff_fft_init_mmx(FFTContext *s); | ||
117 | void ff_fft_init_arm(FFTContext *s); | ||
118 | |||
119 | /** | ||
120 | * Do the permutation needed BEFORE calling ff_fft_calc(). | ||
121 | */ | ||
122 | static inline void ff_fft_permute(FFTContext *s, FFTComplex *z) | ||
123 | { | ||
124 | s->fft_permute(s, z); | ||
125 | } | ||
126 | /** | ||
127 | * Do a complex FFT with the parameters defined in ff_fft_init(). The | ||
128 | * input data must be permuted before. No 1.0/sqrt(n) normalization is done. | ||
129 | */ | ||
130 | static inline void fff_fft_calc(FFTContext *s, FFTComplex *z) | ||
131 | { | ||
132 | s->fft_calc(s, z); | ||
133 | } | ||
134 | void ff_fft_end(FFTContext *s); | ||
135 | |||
136 | /* MDCT computation */ | ||
137 | |||
138 | static inline void fff_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input) | ||
139 | { | ||
140 | s->imdct_calc(s, output, input); | ||
141 | } | ||
142 | static inline void fff_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input) | ||
143 | { | ||
144 | s->imdct_half(s, output, input); | ||
145 | } | ||
146 | |||
147 | static inline void ff_mdct_calc(FFTContext *s, FFTSample *output, | ||
148 | const FFTSample *input) | ||
149 | { | ||
150 | s->mdct_calc(s, output, input); | ||
151 | } | ||
152 | |||
153 | /** | ||
154 | * Generate a Kaiser-Bessel Derived Window. | ||
155 | * @param window pointer to half window | ||
156 | * @param alpha determines window shape | ||
157 | * @param n size of half window | ||
158 | */ | ||
159 | void ff_kbd_window_init(float *window, float alpha, int n); | ||
160 | |||
161 | /** | ||
162 | * Generate a sine window. | ||
163 | * @param window pointer to half window | ||
164 | * @param n size of half window | ||
165 | */ | ||
166 | void ff_sine_window_init(float *window, int n); | ||
167 | |||
168 | /** | ||
169 | * initialize the specified entry of ff_sine_windows | ||
170 | */ | ||
171 | void ff_init_ff_sine_windows(int index); | ||
172 | extern SINETABLE( 32); | ||
173 | extern SINETABLE( 64); | ||
174 | extern SINETABLE( 128); | ||
175 | extern SINETABLE( 256); | ||
176 | extern SINETABLE( 512); | ||
177 | extern SINETABLE(1024); | ||
178 | extern SINETABLE(2048); | ||
179 | extern SINETABLE(4096); | ||
180 | extern SINETABLE_CONST float * const ff_sine_windows[13]; | ||
181 | |||
182 | int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale); | ||
183 | void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
184 | void fff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
185 | void ff_mdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input); | ||
186 | void ff_mdct_end(FFTContext *s); | ||
187 | |||
188 | /* Real Discrete Fourier Transform */ | ||
189 | |||
190 | struct RDFTContext { | ||
191 | int nbits; | ||
192 | int inverse; | ||
193 | int sign_convention; | ||
194 | |||
195 | /* pre/post rotation tables */ | ||
196 | const FFTSample *tcos; | ||
197 | SINTABLE_CONST FFTSample *tsin; | ||
198 | FFTContext fft; | ||
199 | void (*rdft_calc)(struct RDFTContext *s, FFTSample *z); | ||
200 | }; | ||
201 | |||
202 | /** | ||
203 | * Sets up a real FFT. | ||
204 | * @param nbits log2 of the length of the input array | ||
205 | * @param trans the type of transform | ||
206 | */ | ||
207 | int ff_rdft_init(RDFTContext *s, int nbits, enum RDFTransformType trans); | ||
208 | void ff_rdft_end(RDFTContext *s); | ||
209 | |||
210 | void ff_rdft_init_arm(RDFTContext *s); | ||
211 | |||
212 | static av_always_inline void ff_rdft_calc(RDFTContext *s, FFTSample *data) | ||
213 | { | ||
214 | s->rdft_calc(s, data); | ||
215 | } | ||
216 | |||
217 | /* Discrete Cosine Transform */ | ||
218 | |||
219 | struct DCTContext { | ||
220 | int nbits; | ||
221 | int inverse; | ||
222 | RDFTContext rdft; | ||
223 | const float *costab; | ||
224 | FFTSample *csc2; | ||
225 | void (*dct_calc)(struct DCTContext *s, FFTSample *data); | ||
226 | }; | ||
227 | |||
228 | /** | ||
229 | * Sets up DCT. | ||
230 | * @param nbits size of the input array: | ||
231 | * (1 << nbits) for DCT-II, DCT-III and DST-I | ||
232 | * (1 << nbits) + 1 for DCT-I | ||
233 | * | ||
234 | * @note the first element of the input of DST-I is ignored | ||
235 | */ | ||
236 | int ff_dct_init(DCTContext *s, int nbits, enum DCTTransformType type); | ||
237 | void ff_dct_calc(DCTContext *s, FFTSample *data); | ||
238 | void ff_dct_end (DCTContext *s); | ||
239 | |||
240 | #endif /* AVCODEC_FFT_H */ | ||
diff --git a/apps/codecs/libwmapro/get_bits.h b/apps/codecs/libwmapro/get_bits.h index ecbfc6967b..84853d8b8b 100644 --- a/apps/codecs/libwmapro/get_bits.h +++ b/apps/codecs/libwmapro/get_bits.h | |||
@@ -30,10 +30,20 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | //#include <assert.h> | 31 | //#include <assert.h> |
32 | #include "libavutil/bswap.h" | 32 | #include "libavutil/bswap.h" |
33 | #include "libavutil/common.h" | 33 | //#include "libavutil/common.h" |
34 | #include "libavutil/intreadwrite.h" | 34 | #include "libavutil/intreadwrite.h" |
35 | #include "libavutil/log.h" | 35 | //#include "libavutil/log.h" |
36 | #include "mathops.h" | 36 | |
37 | #define av_log(...) | ||
38 | |||
39 | /* NEG_* were taken from mathops.h */ | ||
40 | #ifndef NEG_SSR32 | ||
41 | # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) | ||
42 | #endif | ||
43 | |||
44 | #ifndef NEG_USR32 | ||
45 | # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) | ||
46 | #endif | ||
37 | 47 | ||
38 | #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) | 48 | #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER) |
39 | # define ALT_BITSTREAM_READER | 49 | # define ALT_BITSTREAM_READER |
@@ -321,24 +331,6 @@ static inline void skip_bits_long(GetBitContext *s, int n){ | |||
321 | 331 | ||
322 | #endif | 332 | #endif |
323 | 333 | ||
324 | /** | ||
325 | * read mpeg1 dc style vlc (sign bit + mantisse with no MSB). | ||
326 | * if MSB not set it is negative | ||
327 | * @param n length in bits | ||
328 | * @author BERO | ||
329 | */ | ||
330 | static inline int get_xbits(GetBitContext *s, int n){ | ||
331 | register int sign; | ||
332 | register int32_t cache; | ||
333 | OPEN_READER(re, s) | ||
334 | UPDATE_CACHE(re, s) | ||
335 | cache = GET_CACHE(re,s); | ||
336 | sign=(~cache)>>31; | ||
337 | LAST_SKIP_BITS(re, s, n) | ||
338 | CLOSE_READER(re, s) | ||
339 | return (NEG_USR32(sign ^ cache, n) ^ sign) - sign; | ||
340 | } | ||
341 | |||
342 | static inline int get_sbits(GetBitContext *s, int n){ | 334 | static inline int get_sbits(GetBitContext *s, int n){ |
343 | register int tmp; | 335 | register int tmp; |
344 | OPEN_READER(re, s) | 336 | OPEN_READER(re, s) |
@@ -429,13 +421,6 @@ static inline unsigned int get_bits_long(GetBitContext *s, int n){ | |||
429 | } | 421 | } |
430 | 422 | ||
431 | /** | 423 | /** |
432 | * reads 0-32 bits as a signed integer. | ||
433 | */ | ||
434 | static inline int get_sbits_long(GetBitContext *s, int n) { | ||
435 | return sign_extend(get_bits_long(s, n), n); | ||
436 | } | ||
437 | |||
438 | /** | ||
439 | * shows 0-32 bits. | 424 | * shows 0-32 bits. |
440 | */ | 425 | */ |
441 | static inline unsigned int show_bits_long(GetBitContext *s, int n){ | 426 | static inline unsigned int show_bits_long(GetBitContext *s, int n){ |
@@ -446,15 +431,6 @@ static inline unsigned int show_bits_long(GetBitContext *s, int n){ | |||
446 | } | 431 | } |
447 | } | 432 | } |
448 | 433 | ||
449 | static inline int check_marker(GetBitContext *s, const char *msg) | ||
450 | { | ||
451 | int bit= get_bits1(s); | ||
452 | if(!bit) | ||
453 | av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg); | ||
454 | |||
455 | return bit; | ||
456 | } | ||
457 | |||
458 | /** | 434 | /** |
459 | * init GetBitContext. | 435 | * init GetBitContext. |
460 | * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits | 436 | * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits |
@@ -594,7 +570,7 @@ void free_vlc(VLC *vlc); | |||
594 | * read the longest vlc code | 570 | * read the longest vlc code |
595 | * = (max_vlc_length + bits - 1) / bits | 571 | * = (max_vlc_length + bits - 1) / bits |
596 | */ | 572 | */ |
597 | static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], | 573 | static inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2], |
598 | int bits, int max_depth) | 574 | int bits, int max_depth) |
599 | { | 575 | { |
600 | int code; | 576 | int code; |
diff --git a/apps/codecs/libwmapro/internal.h b/apps/codecs/libwmapro/internal.h deleted file mode 100644 index 7ce019c12a..0000000000 --- a/apps/codecs/libwmapro/internal.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of FFmpeg. | ||
3 | * | ||
4 | * FFmpeg is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * FFmpeg is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with FFmpeg; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | |||
19 | /** | ||
20 | * @file libavcodec/internal.h | ||
21 | * common internal api header. | ||
22 | */ | ||
23 | |||
24 | #ifndef AVCODEC_INTERNAL_H | ||
25 | #define AVCODEC_INTERNAL_H | ||
26 | |||
27 | #include <stdint.h> | ||
28 | #include "avcodec.h" | ||
29 | |||
30 | /** | ||
31 | * Determines whether pix_fmt is a hardware accelerated format. | ||
32 | */ | ||
33 | int ff_is_hwaccel_pix_fmt(enum PixelFormat pix_fmt); | ||
34 | |||
35 | /** | ||
36 | * Returns the hardware accelerated codec for codec codec_id and | ||
37 | * pixel format pix_fmt. | ||
38 | * | ||
39 | * @param codec_id the codec to match | ||
40 | * @param pix_fmt the pixel format to match | ||
41 | * @return the hardware accelerated codec, or NULL if none was found. | ||
42 | */ | ||
43 | AVHWAccel *ff_find_hwaccel(enum CodecID codec_id, enum PixelFormat pix_fmt); | ||
44 | |||
45 | /** | ||
46 | * Return the index into tab at which {a,b} match elements {[0],[1]} of tab. | ||
47 | * If there is no such matching pair then size is returned. | ||
48 | */ | ||
49 | int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); | ||
50 | |||
51 | #endif /* AVCODEC_INTERNAL_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/attributes.h b/apps/codecs/libwmapro/libavutil/attributes.h deleted file mode 100644 index 1208bc0c72..0000000000 --- a/apps/codecs/libwmapro/libavutil/attributes.h +++ /dev/null | |||
@@ -1,113 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/attributes.h | ||
23 | * Macro definitions for various function/variable attributes | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_ATTRIBUTES_H | ||
27 | #define AVUTIL_ATTRIBUTES_H | ||
28 | |||
29 | #ifdef __GNUC__ | ||
30 | # define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) | ||
31 | #else | ||
32 | # define AV_GCC_VERSION_AT_LEAST(x,y) 0 | ||
33 | #endif | ||
34 | |||
35 | #ifndef av_always_inline | ||
36 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
37 | # define av_always_inline __attribute__((always_inline)) inline | ||
38 | #else | ||
39 | # define av_always_inline inline | ||
40 | #endif | ||
41 | #endif | ||
42 | |||
43 | #ifndef av_noinline | ||
44 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
45 | # define av_noinline __attribute__((noinline)) | ||
46 | #else | ||
47 | # define av_noinline | ||
48 | #endif | ||
49 | #endif | ||
50 | |||
51 | #ifndef av_pure | ||
52 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
53 | # define av_pure __attribute__((pure)) | ||
54 | #else | ||
55 | # define av_pure | ||
56 | #endif | ||
57 | #endif | ||
58 | |||
59 | #ifndef av_const | ||
60 | #if AV_GCC_VERSION_AT_LEAST(2,6) | ||
61 | # define av_const __attribute__((const)) | ||
62 | #else | ||
63 | # define av_const | ||
64 | #endif | ||
65 | #endif | ||
66 | |||
67 | #ifndef av_cold | ||
68 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
69 | # define av_cold __attribute__((cold)) | ||
70 | #else | ||
71 | # define av_cold | ||
72 | #endif | ||
73 | #endif | ||
74 | |||
75 | #ifndef av_flatten | ||
76 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,1) | ||
77 | # define av_flatten __attribute__((flatten)) | ||
78 | #else | ||
79 | # define av_flatten | ||
80 | #endif | ||
81 | #endif | ||
82 | |||
83 | #ifndef attribute_deprecated | ||
84 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
85 | # define attribute_deprecated __attribute__((deprecated)) | ||
86 | #else | ||
87 | # define attribute_deprecated | ||
88 | #endif | ||
89 | #endif | ||
90 | |||
91 | #ifndef av_unused | ||
92 | #if defined(__GNUC__) | ||
93 | # define av_unused __attribute__((unused)) | ||
94 | #else | ||
95 | # define av_unused | ||
96 | #endif | ||
97 | #endif | ||
98 | |||
99 | #ifndef av_uninit | ||
100 | #if defined(__GNUC__) && !defined(__ICC) | ||
101 | # define av_uninit(x) x=x | ||
102 | #else | ||
103 | # define av_uninit(x) x | ||
104 | #endif | ||
105 | #endif | ||
106 | |||
107 | #ifdef __GNUC__ | ||
108 | # define av_builtin_constant_p __builtin_constant_p | ||
109 | #else | ||
110 | # define av_builtin_constant_p(x) 0 | ||
111 | #endif | ||
112 | |||
113 | #endif /* AVUTIL_ATTRIBUTES_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/avutil.h b/apps/codecs/libwmapro/libavutil/avutil.h deleted file mode 100644 index fd6e313b59..0000000000 --- a/apps/codecs/libwmapro/libavutil/avutil.h +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef AVUTIL_AVUTIL_H | ||
22 | #define AVUTIL_AVUTIL_H | ||
23 | |||
24 | /** | ||
25 | * @file libavutil/avutil.h | ||
26 | * external API header | ||
27 | */ | ||
28 | |||
29 | |||
30 | #define AV_STRINGIFY(s) AV_TOSTRING(s) | ||
31 | #define AV_TOSTRING(s) #s | ||
32 | |||
33 | #define AV_GLUE(a, b) a ## b | ||
34 | #define AV_JOIN(a, b) AV_GLUE(a, b) | ||
35 | |||
36 | #define AV_PRAGMA(s) _Pragma(#s) | ||
37 | |||
38 | #define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) | ||
39 | #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c | ||
40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | ||
41 | |||
42 | #define LIBAVUTIL_VERSION_MAJOR 50 | ||
43 | #define LIBAVUTIL_VERSION_MINOR 14 | ||
44 | #define LIBAVUTIL_VERSION_MICRO 0 | ||
45 | |||
46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | ||
47 | LIBAVUTIL_VERSION_MINOR, \ | ||
48 | LIBAVUTIL_VERSION_MICRO) | ||
49 | #define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ | ||
50 | LIBAVUTIL_VERSION_MINOR, \ | ||
51 | LIBAVUTIL_VERSION_MICRO) | ||
52 | #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT | ||
53 | |||
54 | #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) | ||
55 | |||
56 | /** | ||
57 | * Returns the LIBAVUTIL_VERSION_INT constant. | ||
58 | */ | ||
59 | unsigned avutil_version(void); | ||
60 | |||
61 | /** | ||
62 | * Returns the libavutil build-time configuration. | ||
63 | */ | ||
64 | const char *avutil_configuration(void); | ||
65 | |||
66 | /** | ||
67 | * Returns the libavutil license. | ||
68 | */ | ||
69 | const char *avutil_license(void); | ||
70 | |||
71 | enum AVMediaType { | ||
72 | AVMEDIA_TYPE_UNKNOWN = -1, | ||
73 | AVMEDIA_TYPE_VIDEO, | ||
74 | AVMEDIA_TYPE_AUDIO, | ||
75 | AVMEDIA_TYPE_DATA, | ||
76 | AVMEDIA_TYPE_SUBTITLE, | ||
77 | AVMEDIA_TYPE_ATTACHMENT, | ||
78 | AVMEDIA_TYPE_NB | ||
79 | }; | ||
80 | |||
81 | #include "common.h" | ||
82 | //#include "error.h" | ||
83 | #include "mathematics.h" | ||
84 | //#include "rational.h" | ||
85 | //#include "intfloat_readwrite.h" | ||
86 | #include "log.h" | ||
87 | //#include "pixfmt.h" | ||
88 | |||
89 | #endif /* AVUTIL_AVUTIL_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/bswap.h b/apps/codecs/libwmapro/libavutil/bswap.h index e15501778b..82ed2271ac 100644 --- a/apps/codecs/libwmapro/libavutil/bswap.h +++ b/apps/codecs/libwmapro/libavutil/bswap.h | |||
@@ -28,10 +28,9 @@ | |||
28 | 28 | ||
29 | #include <stdint.h> | 29 | #include <stdint.h> |
30 | //#include "config.h" | 30 | //#include "config.h" |
31 | #include "attributes.h" | ||
32 | 31 | ||
33 | #ifndef bswap_16 | 32 | #ifndef bswap_16 |
34 | static av_always_inline av_const uint16_t bswap_16(uint16_t x) | 33 | static inline uint16_t bswap_16(uint16_t x) |
35 | { | 34 | { |
36 | x= (x>>8) | (x<<8); | 35 | x= (x>>8) | (x<<8); |
37 | return x; | 36 | return x; |
@@ -39,7 +38,7 @@ static av_always_inline av_const uint16_t bswap_16(uint16_t x) | |||
39 | #endif | 38 | #endif |
40 | 39 | ||
41 | #ifndef bswap_32 | 40 | #ifndef bswap_32 |
42 | static av_always_inline av_const uint32_t bswap_32(uint32_t x) | 41 | static inline uint32_t bswap_32(uint32_t x) |
43 | { | 42 | { |
44 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | 43 | x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); |
45 | x= (x>>16) | (x<<16); | 44 | x= (x>>16) | (x<<16); |
@@ -48,7 +47,7 @@ static av_always_inline av_const uint32_t bswap_32(uint32_t x) | |||
48 | #endif | 47 | #endif |
49 | 48 | ||
50 | #ifndef bswap_64 | 49 | #ifndef bswap_64 |
51 | static inline uint64_t av_const bswap_64(uint64_t x) | 50 | static inline uint64_t bswap_64(uint64_t x) |
52 | { | 51 | { |
53 | #if 0 | 52 | #if 0 |
54 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | 53 | x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); |
diff --git a/apps/codecs/libwmapro/libavutil/common.h b/apps/codecs/libwmapro/libavutil/common.h deleted file mode 100644 index 48732a29dd..0000000000 --- a/apps/codecs/libwmapro/libavutil/common.h +++ /dev/null | |||
@@ -1,298 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/common.h | ||
23 | * common internal and external API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_COMMON_H | ||
27 | #define AVUTIL_COMMON_H | ||
28 | |||
29 | #include <ctype.h> | ||
30 | #include <errno.h> | ||
31 | #include <inttypes.h> | ||
32 | #include <limits.h> | ||
33 | #include <math.h> | ||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <string.h> | ||
37 | #include "attributes.h" | ||
38 | |||
39 | //rounded division & shift | ||
40 | #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) | ||
41 | /* assume b>0 */ | ||
42 | #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) | ||
43 | #define FFABS(a) ((a) >= 0 ? (a) : (-(a))) | ||
44 | #define FFSIGN(a) ((a) > 0 ? 1 : -1) | ||
45 | |||
46 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
47 | #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) | ||
48 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
49 | #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) | ||
50 | |||
51 | #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) | ||
52 | #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) | ||
53 | #define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) | ||
54 | |||
55 | /* misc math functions */ | ||
56 | extern const uint8_t ff_log2_tab[256]; | ||
57 | |||
58 | extern const uint8_t av_reverse[256]; | ||
59 | |||
60 | static inline av_const int av_log2_c(unsigned int v) | ||
61 | { | ||
62 | int n = 0; | ||
63 | if (v & 0xffff0000) { | ||
64 | v >>= 16; | ||
65 | n += 16; | ||
66 | } | ||
67 | if (v & 0xff00) { | ||
68 | v >>= 8; | ||
69 | n += 8; | ||
70 | } | ||
71 | n += ff_log2_tab[v]; | ||
72 | |||
73 | return n; | ||
74 | } | ||
75 | |||
76 | static inline av_const int av_log2_16bit_c(unsigned int v) | ||
77 | { | ||
78 | int n = 0; | ||
79 | if (v & 0xff00) { | ||
80 | v >>= 8; | ||
81 | n += 8; | ||
82 | } | ||
83 | n += ff_log2_tab[v]; | ||
84 | |||
85 | return n; | ||
86 | } | ||
87 | |||
88 | #ifdef HAVE_AV_CONFIG_H | ||
89 | # include "config.h" | ||
90 | # include "intmath.h" | ||
91 | #endif | ||
92 | |||
93 | #ifndef av_log2 | ||
94 | # define av_log2 av_log2_c | ||
95 | #endif | ||
96 | #ifndef av_log2_16bit | ||
97 | # define av_log2_16bit av_log2_16bit_c | ||
98 | #endif | ||
99 | |||
100 | /** | ||
101 | * Clips a signed integer value into the amin-amax range. | ||
102 | * @param a value to clip | ||
103 | * @param amin minimum value of the clip range | ||
104 | * @param amax maximum value of the clip range | ||
105 | * @return clipped value | ||
106 | */ | ||
107 | static inline av_const int av_clip(int a, int amin, int amax) | ||
108 | { | ||
109 | if (a < amin) return amin; | ||
110 | else if (a > amax) return amax; | ||
111 | else return a; | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * Clips a signed integer value into the 0-255 range. | ||
116 | * @param a value to clip | ||
117 | * @return clipped value | ||
118 | */ | ||
119 | static inline av_const uint8_t av_clip_uint8(int a) | ||
120 | { | ||
121 | if (a&(~255)) return (-a)>>31; | ||
122 | else return a; | ||
123 | } | ||
124 | |||
125 | /** | ||
126 | * Clips a signed integer value into the 0-65535 range. | ||
127 | * @param a value to clip | ||
128 | * @return clipped value | ||
129 | */ | ||
130 | static inline av_const uint16_t av_clip_uint16(int a) | ||
131 | { | ||
132 | if (a&(~65535)) return (-a)>>31; | ||
133 | else return a; | ||
134 | } | ||
135 | |||
136 | /** | ||
137 | * Clips a signed integer value into the -32768,32767 range. | ||
138 | * @param a value to clip | ||
139 | * @return clipped value | ||
140 | */ | ||
141 | static inline av_const int16_t av_clip_int16(int a) | ||
142 | { | ||
143 | if ((a+32768) & ~65535) return (a>>31) ^ 32767; | ||
144 | else return a; | ||
145 | } | ||
146 | |||
147 | /** | ||
148 | * Clips a float value into the amin-amax range. | ||
149 | * @param a value to clip | ||
150 | * @param amin minimum value of the clip range | ||
151 | * @param amax maximum value of the clip range | ||
152 | * @return clipped value | ||
153 | */ | ||
154 | static inline av_const float av_clipf(float a, float amin, float amax) | ||
155 | { | ||
156 | if (a < amin) return amin; | ||
157 | else if (a > amax) return amax; | ||
158 | else return a; | ||
159 | } | ||
160 | |||
161 | /** Computes ceil(log2(x)). | ||
162 | * @param x value used to compute ceil(log2(x)) | ||
163 | * @return computed ceiling of log2(x) | ||
164 | */ | ||
165 | static inline av_const int av_ceil_log2(int x) | ||
166 | { | ||
167 | return av_log2((x - 1) << 1); | ||
168 | } | ||
169 | |||
170 | #define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) | ||
171 | #define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) | ||
172 | |||
173 | /*! | ||
174 | * \def GET_UTF8(val, GET_BYTE, ERROR) | ||
175 | * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form | ||
176 | * \param val is the output and should be of type uint32_t. It holds the converted | ||
177 | * UCS-4 character and should be a left value. | ||
178 | * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be | ||
179 | * a function or a statement whose return value or evaluated value is of type | ||
180 | * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, | ||
181 | * and up to 7 times in the general case. | ||
182 | * \param ERROR action that should be taken when an invalid UTF-8 byte is returned | ||
183 | * from GET_BYTE. It should be a statement that jumps out of the macro, | ||
184 | * like exit(), goto, return, break, or continue. | ||
185 | */ | ||
186 | #define GET_UTF8(val, GET_BYTE, ERROR)\ | ||
187 | val= GET_BYTE;\ | ||
188 | {\ | ||
189 | int ones= 7 - av_log2(val ^ 255);\ | ||
190 | if(ones==1)\ | ||
191 | ERROR\ | ||
192 | val&= 127>>ones;\ | ||
193 | while(--ones > 0){\ | ||
194 | int tmp= GET_BYTE - 128;\ | ||
195 | if(tmp>>6)\ | ||
196 | ERROR\ | ||
197 | val= (val<<6) + tmp;\ | ||
198 | }\ | ||
199 | } | ||
200 | |||
201 | /*! | ||
202 | * \def GET_UTF16(val, GET_16BIT, ERROR) | ||
203 | * Converts a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form | ||
204 | * \param val is the output and should be of type uint32_t. It holds the converted | ||
205 | * UCS-4 character and should be a left value. | ||
206 | * \param GET_16BIT gets two bytes of UTF-16 encoded data converted to native endianness. | ||
207 | * It can be a function or a statement whose return value or evaluated value is of type | ||
208 | * uint16_t. It will be executed up to 2 times. | ||
209 | * \param ERROR action that should be taken when an invalid UTF-16 surrogate is | ||
210 | * returned from GET_BYTE. It should be a statement that jumps out of the macro, | ||
211 | * like exit(), goto, return, break, or continue. | ||
212 | */ | ||
213 | #define GET_UTF16(val, GET_16BIT, ERROR)\ | ||
214 | val = GET_16BIT;\ | ||
215 | {\ | ||
216 | unsigned int hi = val - 0xD800;\ | ||
217 | if (hi < 0x800) {\ | ||
218 | val = GET_16BIT - 0xDC00;\ | ||
219 | if (val > 0x3FFU || hi > 0x3FFU)\ | ||
220 | ERROR\ | ||
221 | val += (hi<<10) + 0x10000;\ | ||
222 | }\ | ||
223 | }\ | ||
224 | |||
225 | /*! | ||
226 | * \def PUT_UTF8(val, tmp, PUT_BYTE) | ||
227 | * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). | ||
228 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
229 | * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If | ||
230 | * val is given as a function it is executed only once. | ||
231 | * \param tmp is a temporary variable and should be of type uint8_t. It | ||
232 | * represents an intermediate value during conversion that is to be | ||
233 | * output by PUT_BYTE. | ||
234 | * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. | ||
235 | * It could be a function or a statement, and uses tmp as the input byte. | ||
236 | * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be | ||
237 | * executed up to 4 times for values in the valid UTF-8 range and up to | ||
238 | * 7 times in the general case, depending on the length of the converted | ||
239 | * Unicode character. | ||
240 | */ | ||
241 | #define PUT_UTF8(val, tmp, PUT_BYTE)\ | ||
242 | {\ | ||
243 | int bytes, shift;\ | ||
244 | uint32_t in = val;\ | ||
245 | if (in < 0x80) {\ | ||
246 | tmp = in;\ | ||
247 | PUT_BYTE\ | ||
248 | } else {\ | ||
249 | bytes = (av_log2(in) + 4) / 5;\ | ||
250 | shift = (bytes - 1) * 6;\ | ||
251 | tmp = (256 - (256 >> bytes)) | (in >> shift);\ | ||
252 | PUT_BYTE\ | ||
253 | while (shift >= 6) {\ | ||
254 | shift -= 6;\ | ||
255 | tmp = 0x80 | ((in >> shift) & 0x3f);\ | ||
256 | PUT_BYTE\ | ||
257 | }\ | ||
258 | }\ | ||
259 | } | ||
260 | |||
261 | /*! | ||
262 | * \def PUT_UTF16(val, tmp, PUT_16BIT) | ||
263 | * Converts a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). | ||
264 | * \param val is an input-only argument and should be of type uint32_t. It holds | ||
265 | * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If | ||
266 | * val is given as a function it is executed only once. | ||
267 | * \param tmp is a temporary variable and should be of type uint16_t. It | ||
268 | * represents an intermediate value during conversion that is to be | ||
269 | * output by PUT_16BIT. | ||
270 | * \param PUT_16BIT writes the converted UTF-16 data to any proper destination | ||
271 | * in desired endianness. It could be a function or a statement, and uses tmp | ||
272 | * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" | ||
273 | * PUT_BYTE will be executed 1 or 2 times depending on input character. | ||
274 | */ | ||
275 | #define PUT_UTF16(val, tmp, PUT_16BIT)\ | ||
276 | {\ | ||
277 | uint32_t in = val;\ | ||
278 | if (in < 0x10000) {\ | ||
279 | tmp = in;\ | ||
280 | PUT_16BIT\ | ||
281 | } else {\ | ||
282 | tmp = 0xD800 | ((in - 0x10000) >> 10);\ | ||
283 | PUT_16BIT\ | ||
284 | tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ | ||
285 | PUT_16BIT\ | ||
286 | }\ | ||
287 | }\ | ||
288 | |||
289 | |||
290 | |||
291 | #include "mem.h" | ||
292 | |||
293 | //#ifdef HAVE_AV_CONFIG_H | ||
294 | #if 1 | ||
295 | # include "internal.h" | ||
296 | #endif /* HAVE_AV_CONFIG_H */ | ||
297 | |||
298 | #endif /* AVUTIL_COMMON_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/internal.h b/apps/codecs/libwmapro/libavutil/internal.h deleted file mode 100644 index 87a4d3ec10..0000000000 --- a/apps/codecs/libwmapro/libavutil/internal.h +++ /dev/null | |||
@@ -1,210 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/internal.h | ||
23 | * common internal API header | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_INTERNAL_H | ||
27 | #define AVUTIL_INTERNAL_H | ||
28 | |||
29 | #if !defined(DEBUG) && !defined(NDEBUG) | ||
30 | # define NDEBUG | ||
31 | #endif | ||
32 | |||
33 | #include <limits.h> | ||
34 | #include <stdint.h> | ||
35 | #include <stddef.h> | ||
36 | //#include <assert.h> | ||
37 | //#include "config.h" | ||
38 | #include "attributes.h" | ||
39 | //#include "timer.h" | ||
40 | |||
41 | #ifndef attribute_align_arg | ||
42 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,2) | ||
43 | # define attribute_align_arg __attribute__((force_align_arg_pointer)) | ||
44 | #else | ||
45 | # define attribute_align_arg | ||
46 | #endif | ||
47 | #endif | ||
48 | |||
49 | #ifndef attribute_used | ||
50 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
51 | # define attribute_used __attribute__((used)) | ||
52 | #else | ||
53 | # define attribute_used | ||
54 | #endif | ||
55 | #endif | ||
56 | |||
57 | #ifndef av_alias | ||
58 | //#if HAVE_ATTRIBUTE_MAY_ALIAS && (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(3,3) | ||
59 | #if 0 | ||
60 | # define av_alias __attribute__((may_alias)) | ||
61 | #else | ||
62 | # define av_alias | ||
63 | #endif | ||
64 | #endif | ||
65 | |||
66 | #ifndef INT16_MIN | ||
67 | #define INT16_MIN (-0x7fff - 1) | ||
68 | #endif | ||
69 | |||
70 | #ifndef INT16_MAX | ||
71 | #define INT16_MAX 0x7fff | ||
72 | #endif | ||
73 | |||
74 | #ifndef INT32_MIN | ||
75 | #define INT32_MIN (-0x7fffffff - 1) | ||
76 | #endif | ||
77 | |||
78 | #ifndef INT32_MAX | ||
79 | #define INT32_MAX 0x7fffffff | ||
80 | #endif | ||
81 | |||
82 | #ifndef UINT32_MAX | ||
83 | #define UINT32_MAX 0xffffffff | ||
84 | #endif | ||
85 | |||
86 | #ifndef INT64_MIN | ||
87 | #define INT64_MIN (-0x7fffffffffffffffLL - 1) | ||
88 | #endif | ||
89 | |||
90 | #ifndef INT64_MAX | ||
91 | #define INT64_MAX INT64_C(9223372036854775807) | ||
92 | #endif | ||
93 | |||
94 | #ifndef UINT64_MAX | ||
95 | #define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) | ||
96 | #endif | ||
97 | |||
98 | #ifndef INT_BIT | ||
99 | # define INT_BIT (CHAR_BIT * sizeof(int)) | ||
100 | #endif | ||
101 | |||
102 | #ifndef offsetof | ||
103 | # define offsetof(T, F) ((unsigned int)((char *)&((T *)0)->F)) | ||
104 | #endif | ||
105 | |||
106 | /* Use to export labels from asm. */ | ||
107 | #define LABEL_MANGLE(a) EXTERN_PREFIX #a | ||
108 | |||
109 | // Use rip-relative addressing if compiling PIC code on x86-64. | ||
110 | //#if ARCH_X86_64 && defined(PIC) | ||
111 | #if 0 | ||
112 | # define LOCAL_MANGLE(a) #a "(%%rip)" | ||
113 | #else | ||
114 | # define LOCAL_MANGLE(a) #a | ||
115 | #endif | ||
116 | |||
117 | #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) | ||
118 | |||
119 | /* debug stuff */ | ||
120 | |||
121 | /* dprintf macros */ | ||
122 | #ifdef DEBUG | ||
123 | # define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) | ||
124 | #else | ||
125 | # define dprintf(pctx, ...) | ||
126 | #endif | ||
127 | |||
128 | #define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) | ||
129 | |||
130 | /* math */ | ||
131 | |||
132 | //#if ARCH_X86 | ||
133 | #if 0 | ||
134 | #define MASK_ABS(mask, level)\ | ||
135 | __asm__ volatile(\ | ||
136 | "cltd \n\t"\ | ||
137 | "xorl %1, %0 \n\t"\ | ||
138 | "subl %1, %0 \n\t"\ | ||
139 | : "+a" (level), "=&d" (mask)\ | ||
140 | ); | ||
141 | #else | ||
142 | #define MASK_ABS(mask, level)\ | ||
143 | mask = level >> 31;\ | ||
144 | level = (level ^ mask) - mask; | ||
145 | #endif | ||
146 | |||
147 | /* avoid usage of dangerous/inappropriate system functions */ | ||
148 | //#undef malloc | ||
149 | //#define malloc please_use_av_malloc | ||
150 | #undef free | ||
151 | #define free please_use_av_free | ||
152 | #undef realloc | ||
153 | #define realloc please_use_av_realloc | ||
154 | #undef time | ||
155 | #define time time_is_forbidden_due_to_security_issues | ||
156 | #undef rand | ||
157 | #define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get | ||
158 | #undef srand | ||
159 | #define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init | ||
160 | #undef random | ||
161 | #define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get | ||
162 | #undef sprintf | ||
163 | #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf | ||
164 | #undef strcat | ||
165 | #define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat | ||
166 | #undef exit | ||
167 | #define exit exit_is_forbidden | ||
168 | #ifndef LIBAVFORMAT_BUILD | ||
169 | //#undef printf | ||
170 | //#define printf please_use_av_log_instead_of_printf | ||
171 | #undef fprintf | ||
172 | #define fprintf please_use_av_log_instead_of_fprintf | ||
173 | #undef puts | ||
174 | #define puts please_use_av_log_instead_of_puts | ||
175 | #undef perror | ||
176 | #define perror please_use_av_log_instead_of_perror | ||
177 | #endif | ||
178 | |||
179 | #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ | ||
180 | {\ | ||
181 | p = av_malloc(size);\ | ||
182 | if (p == NULL && (size) != 0) {\ | ||
183 | av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ | ||
184 | goto label;\ | ||
185 | }\ | ||
186 | } | ||
187 | |||
188 | #define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)\ | ||
189 | {\ | ||
190 | p = av_mallocz(size);\ | ||
191 | if (p == NULL && (size) != 0) {\ | ||
192 | av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ | ||
193 | goto label;\ | ||
194 | }\ | ||
195 | } | ||
196 | |||
197 | //#include "libm.h" | ||
198 | |||
199 | /** | ||
200 | * Returns NULL if CONFIG_SMALL is true, otherwise the argument | ||
201 | * without modification. Used to disable the definition of strings | ||
202 | * (for example AVCodec long_names). | ||
203 | */ | ||
204 | //#if CONFIG_SMALL | ||
205 | //# define NULL_IF_CONFIG_SMALL(x) NULL | ||
206 | //#else | ||
207 | //# define NULL_IF_CONFIG_SMALL(x) x | ||
208 | //#endif | ||
209 | |||
210 | #endif /* AVUTIL_INTERNAL_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/intreadwrite.h b/apps/codecs/libwmapro/libavutil/intreadwrite.h index a88ffa80f6..32dfcf2cad 100644 --- a/apps/codecs/libwmapro/libavutil/intreadwrite.h +++ b/apps/codecs/libwmapro/libavutil/intreadwrite.h | |||
@@ -22,28 +22,7 @@ | |||
22 | #include <stdint.h> | 22 | #include <stdint.h> |
23 | //#include "config.h" | 23 | //#include "config.h" |
24 | #include "bswap.h" | 24 | #include "bswap.h" |
25 | #include "common.h" | 25 | //#include "common.h" |
26 | |||
27 | typedef union { | ||
28 | uint64_t u64; | ||
29 | uint32_t u32[2]; | ||
30 | uint16_t u16[4]; | ||
31 | uint8_t u8 [8]; | ||
32 | double f64; | ||
33 | float f32[2]; | ||
34 | } av_alias av_alias64; | ||
35 | |||
36 | typedef union { | ||
37 | uint32_t u32; | ||
38 | uint16_t u16[2]; | ||
39 | uint8_t u8 [4]; | ||
40 | float f32; | ||
41 | } av_alias av_alias32; | ||
42 | |||
43 | typedef union { | ||
44 | uint16_t u16; | ||
45 | uint8_t u8 [2]; | ||
46 | } av_alias av_alias16; | ||
47 | 26 | ||
48 | /* | 27 | /* |
49 | * Arch-specific headers can provide any combination of | 28 | * Arch-specific headers can provide any combination of |
diff --git a/apps/codecs/libwmapro/libavutil/log.c b/apps/codecs/libwmapro/libavutil/log.c deleted file mode 100644 index f93a0d6677..0000000000 --- a/apps/codecs/libwmapro/libavutil/log.c +++ /dev/null | |||
@@ -1,95 +0,0 @@ | |||
1 | /* | ||
2 | * log functions | ||
3 | * Copyright (c) 2003 Michel Bardiaux | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg 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 GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file libavutil/log.c | ||
24 | * logging functions | ||
25 | */ | ||
26 | |||
27 | #include "avutil.h" | ||
28 | #include "log.h" | ||
29 | /* disable sprintf functions */ | ||
30 | #define snprintf(...) | ||
31 | #define vsnprintf snprintf | ||
32 | |||
33 | #if LIBAVUTIL_VERSION_MAJOR > 50 | ||
34 | static | ||
35 | #endif | ||
36 | int av_log_level = AV_LOG_INFO; | ||
37 | |||
38 | void av_log_default_callback(void* ptr, int level) | ||
39 | { | ||
40 | static int print_prefix=1; | ||
41 | static int count; | ||
42 | static char line[1024], prev[1024]; | ||
43 | AVClass* avc= ptr ? *(AVClass**)ptr : NULL; | ||
44 | if(level>av_log_level) | ||
45 | return; | ||
46 | #undef fprintf | ||
47 | if(print_prefix && avc) { | ||
48 | snprintf(line, sizeof(line), "[%s @ %p]", avc->item_name(ptr), ptr); | ||
49 | }else | ||
50 | line[0]=0; | ||
51 | |||
52 | vsnprintf(line + strlen(line), sizeof(line) - strlen(line), fmt, vl); | ||
53 | |||
54 | print_prefix= line[strlen(line)-1] == '\n'; | ||
55 | if(print_prefix && !strcmp(line, prev)){ | ||
56 | count++; | ||
57 | return; | ||
58 | } | ||
59 | if(count>0){ | ||
60 | //fprintf(stderr, " Last message repeated %d times\n", count); | ||
61 | count=0; | ||
62 | } | ||
63 | //fputs(line, stderr); | ||
64 | strcpy(prev, line); | ||
65 | } | ||
66 | |||
67 | static void (*av_log_callback)(void*, int = av_log_default_callback; | ||
68 | |||
69 | void av_log(void* avcl, int level) | ||
70 | { | ||
71 | va_list vl; | ||
72 | va_start(vl, fmt); | ||
73 | av_vlog(avcl, level, fmt, vl); | ||
74 | va_end(vl); | ||
75 | } | ||
76 | |||
77 | void av_vlog(void* avcl, int level, const char *fmt, va_list vl) | ||
78 | { | ||
79 | av_log_callback(avcl, level, fmt, vl); | ||
80 | } | ||
81 | |||
82 | int av_log_get_level(void) | ||
83 | { | ||
84 | return av_log_level; | ||
85 | } | ||
86 | |||
87 | void av_log_set_level(int level) | ||
88 | { | ||
89 | av_log_level = level; | ||
90 | } | ||
91 | |||
92 | void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) | ||
93 | { | ||
94 | av_log_callback = callback; | ||
95 | } | ||
diff --git a/apps/codecs/libwmapro/libavutil/log.h b/apps/codecs/libwmapro/libavutil/log.h deleted file mode 100644 index 43228e4985..0000000000 --- a/apps/codecs/libwmapro/libavutil/log.h +++ /dev/null | |||
@@ -1,115 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef AVUTIL_LOG_H | ||
22 | #define AVUTIL_LOG_H | ||
23 | |||
24 | #include <stdarg.h> | ||
25 | #include "avutil.h" | ||
26 | |||
27 | /** | ||
28 | * Describes the class of an AVClass context structure. That is an | ||
29 | * arbitrary struct of which the first field is a pointer to an | ||
30 | * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). | ||
31 | */ | ||
32 | typedef struct { | ||
33 | /** | ||
34 | * The name of the class; usually it is the same name as the | ||
35 | * context structure type to which the AVClass is associated. | ||
36 | */ | ||
37 | const char* class_name; | ||
38 | |||
39 | /** | ||
40 | * A pointer to a function which returns the name of a context | ||
41 | * instance ctx associated with the class. | ||
42 | */ | ||
43 | const char* (*item_name)(void* ctx); | ||
44 | |||
45 | /** | ||
46 | * a pointer to the first option specified in the class if any or NULL | ||
47 | * | ||
48 | * @see av_set_default_options() | ||
49 | */ | ||
50 | const struct AVOption *option; | ||
51 | } AVClass; | ||
52 | |||
53 | /* av_log API */ | ||
54 | |||
55 | #define AV_LOG_QUIET -8 | ||
56 | |||
57 | /** | ||
58 | * Something went really wrong and we will crash now. | ||
59 | */ | ||
60 | #define AV_LOG_PANIC 0 | ||
61 | |||
62 | /** | ||
63 | * Something went wrong and recovery is not possible. | ||
64 | * For example, no header was found for a format which depends | ||
65 | * on headers or an illegal combination of parameters is used. | ||
66 | */ | ||
67 | #define AV_LOG_FATAL 8 | ||
68 | |||
69 | /** | ||
70 | * Something went wrong and cannot losslessly be recovered. | ||
71 | * However, not all future data is affected. | ||
72 | */ | ||
73 | #define AV_LOG_ERROR 16 | ||
74 | |||
75 | /** | ||
76 | * Something somehow does not look correct. This may or may not | ||
77 | * lead to problems. An example would be the use of '-vstrict -2'. | ||
78 | */ | ||
79 | #define AV_LOG_WARNING 24 | ||
80 | |||
81 | #define AV_LOG_INFO 32 | ||
82 | #define AV_LOG_VERBOSE 40 | ||
83 | |||
84 | /** | ||
85 | * Stuff which is only useful for libav* developers. | ||
86 | */ | ||
87 | #define AV_LOG_DEBUG 48 | ||
88 | |||
89 | /** | ||
90 | * Sends the specified message to the log if the level is less than or equal | ||
91 | * to the current av_log_level. By default, all logging messages are sent to | ||
92 | * stderr. This behavior can be altered by setting a different av_vlog callback | ||
93 | * function. | ||
94 | * | ||
95 | * @param avcl A pointer to an arbitrary struct of which the first field is a | ||
96 | * pointer to an AVClass struct. | ||
97 | * @param level The importance level of the message, lower values signifying | ||
98 | * higher importance. | ||
99 | * @param fmt The format string (printf-compatible) that specifies how | ||
100 | * subsequent arguments are converted to output. | ||
101 | * @see av_vlog | ||
102 | */ | ||
103 | #ifdef __GNUC__ | ||
104 | void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4))); | ||
105 | #else | ||
106 | void av_log(void*, int level, const char *fmt, ...); | ||
107 | #endif | ||
108 | |||
109 | void av_vlog(void*, int level, const char *fmt, va_list); | ||
110 | int av_log_get_level(void); | ||
111 | void av_log_set_level(int); | ||
112 | void av_log_set_callback(void (*)(void*, int, const char*, va_list)); | ||
113 | void av_log_default_callback(void* ptr, int level); | ||
114 | |||
115 | #endif /* AVUTIL_LOG_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.c b/apps/codecs/libwmapro/libavutil/mathematics.c deleted file mode 100644 index f607d68b6e..0000000000 --- a/apps/codecs/libwmapro/libavutil/mathematics.c +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/mathematics.c | ||
23 | * miscellaneous math routines and tables | ||
24 | */ | ||
25 | |||
26 | //#include <assert.h> | ||
27 | #include <stdint.h> | ||
28 | #include <limits.h> | ||
29 | #include "mathematics.h" | ||
30 | |||
31 | const uint8_t ff_sqrt_tab[256]={ | ||
32 | 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, | ||
33 | 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, | ||
34 | 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, | ||
35 | 157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, | ||
36 | 182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, | ||
37 | 203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, | ||
38 | 222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, | ||
39 | 240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 | ||
40 | }; | ||
41 | |||
42 | const uint8_t ff_log2_tab[256]={ | ||
43 | 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, | ||
44 | 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, | ||
45 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
46 | 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, | ||
47 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
48 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
49 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, | ||
50 | 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 | ||
51 | }; | ||
52 | |||
53 | const uint8_t av_reverse[256]={ | ||
54 | 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, | ||
55 | 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, | ||
56 | 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, | ||
57 | 0x0C,0x8C,0x4C,0xCC,0x2C,0xAC,0x6C,0xEC,0x1C,0x9C,0x5C,0xDC,0x3C,0xBC,0x7C,0xFC, | ||
58 | 0x02,0x82,0x42,0xC2,0x22,0xA2,0x62,0xE2,0x12,0x92,0x52,0xD2,0x32,0xB2,0x72,0xF2, | ||
59 | 0x0A,0x8A,0x4A,0xCA,0x2A,0xAA,0x6A,0xEA,0x1A,0x9A,0x5A,0xDA,0x3A,0xBA,0x7A,0xFA, | ||
60 | 0x06,0x86,0x46,0xC6,0x26,0xA6,0x66,0xE6,0x16,0x96,0x56,0xD6,0x36,0xB6,0x76,0xF6, | ||
61 | 0x0E,0x8E,0x4E,0xCE,0x2E,0xAE,0x6E,0xEE,0x1E,0x9E,0x5E,0xDE,0x3E,0xBE,0x7E,0xFE, | ||
62 | 0x01,0x81,0x41,0xC1,0x21,0xA1,0x61,0xE1,0x11,0x91,0x51,0xD1,0x31,0xB1,0x71,0xF1, | ||
63 | 0x09,0x89,0x49,0xC9,0x29,0xA9,0x69,0xE9,0x19,0x99,0x59,0xD9,0x39,0xB9,0x79,0xF9, | ||
64 | 0x05,0x85,0x45,0xC5,0x25,0xA5,0x65,0xE5,0x15,0x95,0x55,0xD5,0x35,0xB5,0x75,0xF5, | ||
65 | 0x0D,0x8D,0x4D,0xCD,0x2D,0xAD,0x6D,0xED,0x1D,0x9D,0x5D,0xDD,0x3D,0xBD,0x7D,0xFD, | ||
66 | 0x03,0x83,0x43,0xC3,0x23,0xA3,0x63,0xE3,0x13,0x93,0x53,0xD3,0x33,0xB3,0x73,0xF3, | ||
67 | 0x0B,0x8B,0x4B,0xCB,0x2B,0xAB,0x6B,0xEB,0x1B,0x9B,0x5B,0xDB,0x3B,0xBB,0x7B,0xFB, | ||
68 | 0x07,0x87,0x47,0xC7,0x27,0xA7,0x67,0xE7,0x17,0x97,0x57,0xD7,0x37,0xB7,0x77,0xF7, | ||
69 | 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, | ||
70 | }; | ||
71 | |||
72 | int64_t av_gcd(int64_t a, int64_t b){ | ||
73 | if(b) return av_gcd(b, a%b); | ||
74 | else return a; | ||
75 | } | ||
76 | |||
77 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ | ||
78 | int64_t r=0; | ||
79 | //assert(c > 0); | ||
80 | //assert(b >=0); | ||
81 | //assert(rnd >=0 && rnd<=5 && rnd!=4); | ||
82 | |||
83 | if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); | ||
84 | |||
85 | if(rnd==AV_ROUND_NEAR_INF) r= c/2; | ||
86 | else if(rnd&1) r= c-1; | ||
87 | |||
88 | if(b<=INT_MAX && c<=INT_MAX){ | ||
89 | if(a<=INT_MAX) | ||
90 | return (a * b + r)/c; | ||
91 | else | ||
92 | return a/c*b + (a%c*b + r)/c; | ||
93 | }else{ | ||
94 | #if 1 | ||
95 | uint64_t a0= a&0xFFFFFFFF; | ||
96 | uint64_t a1= a>>32; | ||
97 | uint64_t b0= b&0xFFFFFFFF; | ||
98 | uint64_t b1= b>>32; | ||
99 | uint64_t t1= a0*b1 + a1*b0; | ||
100 | uint64_t t1a= t1<<32; | ||
101 | int i; | ||
102 | |||
103 | a0 = a0*b0 + t1a; | ||
104 | a1 = a1*b1 + (t1>>32) + (a0<t1a); | ||
105 | a0 += r; | ||
106 | a1 += a0<(unsigned)r; | ||
107 | |||
108 | for(i=63; i>=0; i--){ | ||
109 | // int o= a1 & 0x8000000000000000ULL; | ||
110 | a1+= a1 + ((a0>>i)&1); | ||
111 | t1+=t1; | ||
112 | if(/*o || */(unsigned)c <= a1){ | ||
113 | a1 -= c; | ||
114 | t1++; | ||
115 | } | ||
116 | } | ||
117 | return t1; | ||
118 | } | ||
119 | #else | ||
120 | AVInteger ai; | ||
121 | ai= av_mul_i(av_int2i(a), av_int2i(b)); | ||
122 | ai= av_add_i(ai, av_int2i(r)); | ||
123 | |||
124 | return av_i2int(av_div_i(ai, av_int2i(c))); | ||
125 | } | ||
126 | #endif | ||
127 | } | ||
128 | |||
129 | int64_t av_rescale(int64_t a, int64_t b, int64_t c){ | ||
130 | return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); | ||
131 | } | ||
132 | #if 0 | ||
133 | int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq){ | ||
134 | int64_t b= bq.num * (int64_t)cq.den; | ||
135 | int64_t c= cq.num * (int64_t)bq.den; | ||
136 | return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); | ||
137 | } | ||
138 | |||
139 | int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){ | ||
140 | int64_t a= tb_a.num * (int64_t)tb_b.den; | ||
141 | int64_t b= tb_b.num * (int64_t)tb_a.den; | ||
142 | if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1; | ||
143 | if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1; | ||
144 | return 0; | ||
145 | } | ||
146 | #endif | ||
147 | #ifdef TEST | ||
148 | #include "integer.h" | ||
149 | #undef printf | ||
150 | int main(void){ | ||
151 | int64_t a,b,c,d,e; | ||
152 | |||
153 | for(a=7; a<(1LL<<62); a+=a/3+1){ | ||
154 | for(b=3; b<(1LL<<62); b+=b/4+1){ | ||
155 | for(c=9; c<(1LL<<62); c+=(c*2)/5+3){ | ||
156 | int64_t r= c/2; | ||
157 | AVInteger ai; | ||
158 | ai= av_mul_i(av_int2i(a), av_int2i(b)); | ||
159 | ai= av_add_i(ai, av_int2i(r)); | ||
160 | |||
161 | d= av_i2int(av_div_i(ai, av_int2i(c))); | ||
162 | |||
163 | e= av_rescale(a,b,c); | ||
164 | |||
165 | if((double)a * (double)b / (double)c > (1LL<<63)) | ||
166 | continue; | ||
167 | |||
168 | if(d!=e) printf("%"PRId64"*%"PRId64"/%"PRId64"= %"PRId64"=%"PRId64"\n", a, b, c, d, e); | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | return 0; | ||
173 | } | ||
174 | #endif | ||
diff --git a/apps/codecs/libwmapro/libavutil/mathematics.h b/apps/codecs/libwmapro/libavutil/mathematics.h deleted file mode 100644 index a09d3e9ad8..0000000000 --- a/apps/codecs/libwmapro/libavutil/mathematics.h +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2005 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | #ifndef AVUTIL_MATHEMATICS_H | ||
22 | #define AVUTIL_MATHEMATICS_H | ||
23 | |||
24 | #include <stdint.h> | ||
25 | #include <math.h> | ||
26 | #include "attributes.h" | ||
27 | //#include "rational.h" | ||
28 | |||
29 | #ifndef M_E | ||
30 | #define M_E 2.7182818284590452354 /* e */ | ||
31 | #endif | ||
32 | #ifndef M_LN2 | ||
33 | #define M_LN2 0.69314718055994530942 /* log_e 2 */ | ||
34 | #endif | ||
35 | #ifndef M_LN10 | ||
36 | #define M_LN10 2.30258509299404568402 /* log_e 10 */ | ||
37 | #endif | ||
38 | #ifndef M_LOG2_10 | ||
39 | #define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ | ||
40 | #endif | ||
41 | #ifndef M_PI | ||
42 | #define M_PI 3.14159265358979323846 /* pi */ | ||
43 | #endif | ||
44 | #ifndef M_SQRT1_2 | ||
45 | #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ | ||
46 | #endif | ||
47 | #ifndef M_SQRT2 | ||
48 | #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ | ||
49 | #endif | ||
50 | #ifndef NAN | ||
51 | #define NAN (0.0/0.0) | ||
52 | #endif | ||
53 | #ifndef INFINITY | ||
54 | #define INFINITY (1.0/0.0) | ||
55 | #endif | ||
56 | |||
57 | enum AVRounding { | ||
58 | AV_ROUND_ZERO = 0, ///< Round toward zero. | ||
59 | AV_ROUND_INF = 1, ///< Round away from zero. | ||
60 | AV_ROUND_DOWN = 2, ///< Round toward -infinity. | ||
61 | AV_ROUND_UP = 3, ///< Round toward +infinity. | ||
62 | AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. | ||
63 | }; | ||
64 | |||
65 | /** | ||
66 | * Returns the greatest common divisor of a and b. | ||
67 | * If both a and b are 0 or either or both are <0 then behavior is | ||
68 | * undefined. | ||
69 | */ | ||
70 | int64_t av_const av_gcd(int64_t a, int64_t b); | ||
71 | |||
72 | /** | ||
73 | * Rescales a 64-bit integer with rounding to nearest. | ||
74 | * A simple a*b/c isn't possible as it can overflow. | ||
75 | */ | ||
76 | int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; | ||
77 | |||
78 | /** | ||
79 | * Rescales a 64-bit integer with specified rounding. | ||
80 | * A simple a*b/c isn't possible as it can overflow. | ||
81 | */ | ||
82 | int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; | ||
83 | |||
84 | /** | ||
85 | * Rescales a 64-bit integer by 2 rational numbers. | ||
86 | */ | ||
87 | //int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; | ||
88 | |||
89 | /** | ||
90 | * Compares 2 timestamps each in its own timebases. | ||
91 | * The result of the function is undefined if one of the timestamps | ||
92 | * is outside the int64_t range when represented in the others timebase. | ||
93 | * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position | ||
94 | */ | ||
95 | //int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); | ||
96 | |||
97 | |||
98 | #endif /* AVUTIL_MATHEMATICS_H */ | ||
diff --git a/apps/codecs/libwmapro/libavutil/mem.c b/apps/codecs/libwmapro/libavutil/mem.c deleted file mode 100644 index 7c37e9be9f..0000000000 --- a/apps/codecs/libwmapro/libavutil/mem.c +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
1 | /* | ||
2 | * default memory allocator for libavutil | ||
3 | * Copyright (c) 2002 Fabrice Bellard | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg 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 GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file libavutil/mem.c | ||
24 | * default memory allocator for libavutil | ||
25 | */ | ||
26 | |||
27 | //#include "config.h" | ||
28 | |||
29 | #include <limits.h> | ||
30 | #include <stdlib.h> | ||
31 | #include <string.h> | ||
32 | #if HAVE_MALLOC_H | ||
33 | #include <malloc.h> | ||
34 | #endif | ||
35 | |||
36 | #include "avutil.h" | ||
37 | #include "mem.h" | ||
38 | |||
39 | /* here we can use OS-dependent allocation functions */ | ||
40 | #undef free | ||
41 | #undef malloc | ||
42 | #undef realloc | ||
43 | |||
44 | #ifdef MALLOC_PREFIX | ||
45 | |||
46 | #define malloc AV_JOIN(MALLOC_PREFIX, malloc) | ||
47 | #define memalign AV_JOIN(MALLOC_PREFIX, memalign) | ||
48 | #define posix_memalign AV_JOIN(MALLOC_PREFIX, posix_memalign) | ||
49 | #define realloc AV_JOIN(MALLOC_PREFIX, realloc) | ||
50 | #define free AV_JOIN(MALLOC_PREFIX, free) | ||
51 | |||
52 | void *malloc(size_t size); | ||
53 | void *memalign(size_t align, size_t size); | ||
54 | int posix_memalign(void **ptr, size_t align, size_t size); | ||
55 | void *realloc(void *ptr, size_t size); | ||
56 | void free(void *ptr); | ||
57 | |||
58 | #endif /* MALLOC_PREFIX */ | ||
59 | |||
60 | /* You can redefine av_malloc and av_free in your project to use your | ||
61 | memory allocator. You do not need to suppress this file because the | ||
62 | linker will do it automatically. */ | ||
63 | |||
64 | void *av_malloc(unsigned int size) | ||
65 | { | ||
66 | void *ptr = NULL; | ||
67 | #if CONFIG_MEMALIGN_HACK | ||
68 | long diff; | ||
69 | #endif | ||
70 | |||
71 | /* let's disallow possible ambiguous cases */ | ||
72 | if(size > (INT_MAX-16) ) | ||
73 | return NULL; | ||
74 | |||
75 | #if CONFIG_MEMALIGN_HACK | ||
76 | ptr = malloc(size+16); | ||
77 | if(!ptr) | ||
78 | return ptr; | ||
79 | diff= ((-(long)ptr - 1)&15) + 1; | ||
80 | ptr = (char*)ptr + diff; | ||
81 | ((char*)ptr)[-1]= diff; | ||
82 | #elif HAVE_POSIX_MEMALIGN | ||
83 | if (posix_memalign(&ptr,16,size)) | ||
84 | ptr = NULL; | ||
85 | #elif HAVE_MEMALIGN | ||
86 | ptr = memalign(16,size); | ||
87 | /* Why 64? | ||
88 | Indeed, we should align it: | ||
89 | on 4 for 386 | ||
90 | on 16 for 486 | ||
91 | on 32 for 586, PPro - K6-III | ||
92 | on 64 for K7 (maybe for P3 too). | ||
93 | Because L1 and L2 caches are aligned on those values. | ||
94 | But I don't want to code such logic here! | ||
95 | */ | ||
96 | /* Why 16? | ||
97 | Because some CPUs need alignment, for example SSE2 on P4, & most RISC CPUs | ||
98 | it will just trigger an exception and the unaligned load will be done in the | ||
99 | exception handler or it will just segfault (SSE2 on P4). | ||
100 | Why not larger? Because I did not see a difference in benchmarks ... | ||
101 | */ | ||
102 | /* benchmarks with P3 | ||
103 | memalign(64)+1 3071,3051,3032 | ||
104 | memalign(64)+2 3051,3032,3041 | ||
105 | memalign(64)+4 2911,2896,2915 | ||
106 | memalign(64)+8 2545,2554,2550 | ||
107 | memalign(64)+16 2543,2572,2563 | ||
108 | memalign(64)+32 2546,2545,2571 | ||
109 | memalign(64)+64 2570,2533,2558 | ||
110 | |||
111 | BTW, malloc seems to do 8-byte alignment by default here. | ||
112 | */ | ||
113 | #else | ||
114 | ptr = malloc(size); | ||
115 | #endif | ||
116 | return ptr; | ||
117 | } | ||
118 | |||
119 | void *av_realloc(void *ptr, unsigned int size) | ||
120 | { | ||
121 | #if CONFIG_MEMALIGN_HACK | ||
122 | int diff; | ||
123 | #endif | ||
124 | |||
125 | /* let's disallow possible ambiguous cases */ | ||
126 | if(size > (INT_MAX-16) ) | ||
127 | return NULL; | ||
128 | |||
129 | #if CONFIG_MEMALIGN_HACK | ||
130 | //FIXME this isn't aligned correctly, though it probably isn't needed | ||
131 | if(!ptr) return av_malloc(size); | ||
132 | diff= ((char*)ptr)[-1]; | ||
133 | return (char*)realloc((char*)ptr - diff, size + diff) + diff; | ||
134 | #else | ||
135 | return realloc(ptr, size); | ||
136 | #endif | ||
137 | } | ||
138 | |||
139 | void av_free(void *ptr) | ||
140 | { | ||
141 | /* XXX: this test should not be needed on most libcs */ | ||
142 | if (ptr) | ||
143 | #if CONFIG_MEMALIGN_HACK | ||
144 | free((char*)ptr - ((char*)ptr)[-1]); | ||
145 | #else | ||
146 | free(ptr); | ||
147 | #endif | ||
148 | } | ||
149 | |||
150 | void av_freep(void *arg) | ||
151 | { | ||
152 | void **ptr= (void**)arg; | ||
153 | av_free(*ptr); | ||
154 | *ptr = NULL; | ||
155 | } | ||
156 | |||
157 | void *av_mallocz(unsigned int size) | ||
158 | { | ||
159 | void *ptr = av_malloc(size); | ||
160 | if (ptr) | ||
161 | memset(ptr, 0, size); | ||
162 | return ptr; | ||
163 | } | ||
164 | |||
165 | char *av_strdup(const char *s) | ||
166 | { | ||
167 | char *ptr= NULL; | ||
168 | if(s){ | ||
169 | int len = strlen(s) + 1; | ||
170 | ptr = av_malloc(len); | ||
171 | if (ptr) | ||
172 | memcpy(ptr, s, len); | ||
173 | } | ||
174 | return ptr; | ||
175 | } | ||
176 | |||
diff --git a/apps/codecs/libwmapro/libavutil/mem.h b/apps/codecs/libwmapro/libavutil/mem.h deleted file mode 100644 index fffbb872ae..0000000000 --- a/apps/codecs/libwmapro/libavutil/mem.h +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | /* | ||
2 | * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | ||
3 | * | ||
4 | * This file is part of FFmpeg. | ||
5 | * | ||
6 | * FFmpeg is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * FFmpeg 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 GNU | ||
14 | * Lesser General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU Lesser General Public | ||
17 | * License along with FFmpeg; if not, write to the Free Software | ||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file libavutil/mem.h | ||
23 | * memory handling functions | ||
24 | */ | ||
25 | |||
26 | #ifndef AVUTIL_MEM_H | ||
27 | #define AVUTIL_MEM_H | ||
28 | |||
29 | #include "attributes.h" | ||
30 | |||
31 | #if defined(__ICC) || defined(__SUNPRO_C) | ||
32 | #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v | ||
33 | #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v | ||
34 | #elif defined(__TI_COMPILER_VERSION__) | ||
35 | #define DECLARE_ALIGNED(n,t,v) \ | ||
36 | AV_PRAGMA(DATA_ALIGN(v,n)) \ | ||
37 | t __attribute__((aligned(n))) v | ||
38 | #define DECLARE_ASM_CONST(n,t,v) \ | ||
39 | AV_PRAGMA(DATA_ALIGN(v,n)) \ | ||
40 | static const t __attribute__((aligned(n))) v | ||
41 | #elif defined(__GNUC__) | ||
42 | #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v | ||
43 | #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v | ||
44 | #elif defined(_MSC_VER) | ||
45 | #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v | ||
46 | #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v | ||
47 | #else | ||
48 | #define DECLARE_ALIGNED(n,t,v) t v | ||
49 | #define DECLARE_ASM_CONST(n,t,v) static const t v | ||
50 | #endif | ||
51 | |||
52 | #if AV_GCC_VERSION_AT_LEAST(3,1) | ||
53 | #define av_malloc_attrib __attribute__((__malloc__)) | ||
54 | #else | ||
55 | #define av_malloc_attrib | ||
56 | #endif | ||
57 | |||
58 | #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) | ||
59 | #define av_alloc_size(n) __attribute__((alloc_size(n))) | ||
60 | #else | ||
61 | #define av_alloc_size(n) | ||
62 | #endif | ||
63 | |||
64 | /** | ||
65 | * Allocates a block of size bytes with alignment suitable for all | ||
66 | * memory accesses (including vectors if available on the CPU). | ||
67 | * @param size Size in bytes for the memory block to be allocated. | ||
68 | * @return Pointer to the allocated block, NULL if the block cannot | ||
69 | * be allocated. | ||
70 | * @see av_mallocz() | ||
71 | */ | ||
72 | void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
73 | |||
74 | /** | ||
75 | * Allocates or reallocates a block of memory. | ||
76 | * If ptr is NULL and size > 0, allocates a new block. If | ||
77 | * size is zero, frees the memory block pointed to by ptr. | ||
78 | * @param size Size in bytes for the memory block to be allocated or | ||
79 | * reallocated. | ||
80 | * @param ptr Pointer to a memory block already allocated with | ||
81 | * av_malloc(z)() or av_realloc() or NULL. | ||
82 | * @return Pointer to a newly reallocated block or NULL if the block | ||
83 | * cannot be reallocated or the function is used to free the memory block. | ||
84 | * @see av_fast_realloc() | ||
85 | */ | ||
86 | void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); | ||
87 | |||
88 | /** | ||
89 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
90 | * av_realloc(). | ||
91 | * @param ptr Pointer to the memory block which should be freed. | ||
92 | * @note ptr = NULL is explicitly allowed. | ||
93 | * @note It is recommended that you use av_freep() instead. | ||
94 | * @see av_freep() | ||
95 | */ | ||
96 | void av_free(void *ptr); | ||
97 | |||
98 | /** | ||
99 | * Allocates a block of size bytes with alignment suitable for all | ||
100 | * memory accesses (including vectors if available on the CPU) and | ||
101 | * zeroes all the bytes of the block. | ||
102 | * @param size Size in bytes for the memory block to be allocated. | ||
103 | * @return Pointer to the allocated block, NULL if it cannot be allocated. | ||
104 | * @see av_malloc() | ||
105 | */ | ||
106 | void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); | ||
107 | |||
108 | /** | ||
109 | * Duplicates the string s. | ||
110 | * @param s string to be duplicated | ||
111 | * @return Pointer to a newly allocated string containing a | ||
112 | * copy of s or NULL if the string cannot be allocated. | ||
113 | */ | ||
114 | char *av_strdup(const char *s) av_malloc_attrib; | ||
115 | |||
116 | /** | ||
117 | * Frees a memory block which has been allocated with av_malloc(z)() or | ||
118 | * av_realloc() and set the pointer pointing to it to NULL. | ||
119 | * @param ptr Pointer to the pointer to the memory block which should | ||
120 | * be freed. | ||
121 | * @see av_free() | ||
122 | */ | ||
123 | void av_freep(void *ptr); | ||
124 | |||
125 | #endif /* AVUTIL_MEM_H */ | ||
diff --git a/apps/codecs/libwmapro/mathops.h b/apps/codecs/libwmapro/mathops.h deleted file mode 100644 index f6555dda21..0000000000 --- a/apps/codecs/libwmapro/mathops.h +++ /dev/null | |||
@@ -1,136 +0,0 @@ | |||
1 | /* | ||
2 | * simple math operations | ||
3 | * Copyright (c) 2001, 2002 Fabrice Bellard | ||
4 | * Copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> et al | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg 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 GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | #ifndef AVCODEC_MATHOPS_H | ||
23 | #define AVCODEC_MATHOPS_H | ||
24 | |||
25 | #include "libavutil/common.h" | ||
26 | |||
27 | /* generic implementation */ | ||
28 | |||
29 | #ifndef MULL | ||
30 | # define MULL(a,b,s) (((int64_t)(a) * (int64_t)(b)) >> (s)) | ||
31 | #endif | ||
32 | |||
33 | #ifndef MULH | ||
34 | //gcc 3.4 creates an incredibly bloated mess out of this | ||
35 | //# define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) | ||
36 | |||
37 | static av_always_inline int MULH(int a, int b){ | ||
38 | return ((int64_t)(a) * (int64_t)(b))>>32; | ||
39 | } | ||
40 | #endif | ||
41 | |||
42 | #ifndef UMULH | ||
43 | static av_always_inline unsigned UMULH(unsigned a, unsigned b){ | ||
44 | return ((uint64_t)(a) * (uint64_t)(b))>>32; | ||
45 | } | ||
46 | #endif | ||
47 | |||
48 | #ifndef MUL64 | ||
49 | # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) | ||
50 | #endif | ||
51 | |||
52 | #ifndef MAC64 | ||
53 | # define MAC64(d, a, b) ((d) += MUL64(a, b)) | ||
54 | #endif | ||
55 | |||
56 | #ifndef MLS64 | ||
57 | # define MLS64(d, a, b) ((d) -= MUL64(a, b)) | ||
58 | #endif | ||
59 | |||
60 | /* signed 16x16 -> 32 multiply add accumulate */ | ||
61 | #ifndef MAC16 | ||
62 | # define MAC16(rt, ra, rb) rt += (ra) * (rb) | ||
63 | #endif | ||
64 | |||
65 | /* signed 16x16 -> 32 multiply */ | ||
66 | #ifndef MUL16 | ||
67 | # define MUL16(ra, rb) ((ra) * (rb)) | ||
68 | #endif | ||
69 | |||
70 | #ifndef MLS16 | ||
71 | # define MLS16(rt, ra, rb) ((rt) -= (ra) * (rb)) | ||
72 | #endif | ||
73 | |||
74 | /* median of 3 */ | ||
75 | #ifndef mid_pred | ||
76 | #define mid_pred mid_pred | ||
77 | static inline av_const int mid_pred(int a, int b, int c) | ||
78 | { | ||
79 | #if 0 | ||
80 | int t= (a-b)&((a-b)>>31); | ||
81 | a-=t; | ||
82 | b+=t; | ||
83 | b-= (b-c)&((b-c)>>31); | ||
84 | b+= (a-b)&((a-b)>>31); | ||
85 | |||
86 | return b; | ||
87 | #else | ||
88 | if(a>b){ | ||
89 | if(c>b){ | ||
90 | if(c>a) b=a; | ||
91 | else b=c; | ||
92 | } | ||
93 | }else{ | ||
94 | if(b>c){ | ||
95 | if(c>a) b=c; | ||
96 | else b=a; | ||
97 | } | ||
98 | } | ||
99 | return b; | ||
100 | #endif | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | #ifndef sign_extend | ||
105 | static inline av_const int sign_extend(int val, unsigned bits) | ||
106 | { | ||
107 | return (val << (INT_BIT - bits)) >> (INT_BIT - bits); | ||
108 | } | ||
109 | #endif | ||
110 | |||
111 | #ifndef zero_extend | ||
112 | static inline av_const unsigned zero_extend(unsigned val, unsigned bits) | ||
113 | { | ||
114 | return (val << (INT_BIT - bits)) >> (INT_BIT - bits); | ||
115 | } | ||
116 | #endif | ||
117 | |||
118 | #ifndef COPY3_IF_LT | ||
119 | #define COPY3_IF_LT(x, y, a, b, c, d)\ | ||
120 | if ((y) < (x)) {\ | ||
121 | (x) = (y);\ | ||
122 | (a) = (b);\ | ||
123 | (c) = (d);\ | ||
124 | } | ||
125 | #endif | ||
126 | |||
127 | #ifndef NEG_SSR32 | ||
128 | # define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) | ||
129 | #endif | ||
130 | |||
131 | #ifndef NEG_USR32 | ||
132 | # define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) | ||
133 | #endif | ||
134 | |||
135 | #endif /* AVCODEC_MATHOPS_H */ | ||
136 | |||
diff --git a/apps/codecs/libwmapro/mdct.c b/apps/codecs/libwmapro/mdct.c deleted file mode 100644 index 03e067fb30..0000000000 --- a/apps/codecs/libwmapro/mdct.c +++ /dev/null | |||
@@ -1,232 +0,0 @@ | |||
1 | /* | ||
2 | * MDCT/IMDCT transforms | ||
3 | * Copyright (c) 2002 Fabrice Bellard | ||
4 | * | ||
5 | * This file is part of FFmpeg. | ||
6 | * | ||
7 | * FFmpeg is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * FFmpeg 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 GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with FFmpeg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | */ | ||
21 | |||
22 | #include <stdlib.h> | ||
23 | #include <string.h> | ||
24 | #include "libavutil/common.h" | ||
25 | #include "libavutil/mathematics.h" | ||
26 | #include "fft.h" | ||
27 | |||
28 | /** | ||
29 | * @file libavcodec/mdct.c | ||
30 | * MDCT/IMDCT transforms. | ||
31 | */ | ||
32 | |||
33 | // Generate a Kaiser-Bessel Derived Window. | ||
34 | #define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation | ||
35 | av_cold void ff_kbd_window_init(float *window, float alpha, int n) | ||
36 | { | ||
37 | int i, j; | ||
38 | double sum = 0.0, bessel, tmp; | ||
39 | double local_window[n]; | ||
40 | double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); | ||
41 | |||
42 | for (i = 0; i < n; i++) { | ||
43 | tmp = i * (n - i) * alpha2; | ||
44 | bessel = 1.0; | ||
45 | for (j = BESSEL_I0_ITER; j > 0; j--) | ||
46 | bessel = bessel * tmp / (j * j) + 1; | ||
47 | sum += bessel; | ||
48 | local_window[i] = sum; | ||
49 | } | ||
50 | |||
51 | sum++; | ||
52 | for (i = 0; i < n; i++) | ||
53 | window[i] = sqrt(local_window[i] / sum); | ||
54 | } | ||
55 | |||
56 | #include "mdct_tablegen.h" | ||
57 | |||
58 | /** | ||
59 | * init MDCT or IMDCT computation. | ||
60 | */ | ||
61 | av_cold int ff_mdct_init(FFTContext *s, int nbits, int inverse, double scale) | ||
62 | { | ||
63 | int n, n4, i; | ||
64 | double alpha, theta; | ||
65 | int tstep; | ||
66 | |||
67 | memset(s, 0, sizeof(*s)); | ||
68 | n = 1 << nbits; | ||
69 | s->mdct_bits = nbits; | ||
70 | s->mdct_size = n; | ||
71 | n4 = n >> 2; | ||
72 | s->permutation = FF_MDCT_PERM_NONE; | ||
73 | |||
74 | if (ff_fft_init(s, s->mdct_bits - 2, inverse) < 0) | ||
75 | goto fail; | ||
76 | |||
77 | s->tcos = av_malloc(n/2 * sizeof(FFTSample)); | ||
78 | if (!s->tcos) | ||
79 | goto fail; | ||
80 | |||
81 | switch (s->permutation) { | ||
82 | case FF_MDCT_PERM_NONE: | ||
83 | s->tsin = s->tcos + n4; | ||
84 | tstep = 1; | ||
85 | break; | ||
86 | case FF_MDCT_PERM_INTERLEAVE: | ||
87 | s->tsin = s->tcos + 1; | ||
88 | tstep = 2; | ||
89 | break; | ||
90 | default: | ||
91 | goto fail; | ||
92 | } | ||
93 | |||
94 | theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0); | ||
95 | scale = sqrt(fabs(scale)); | ||
96 | for(i=0;i<n4;i++) { | ||
97 | alpha = 2 * M_PI * (i + theta) / n; | ||
98 | s->tcos[i*tstep] = -cos(alpha) * scale; | ||
99 | s->tsin[i*tstep] = -sin(alpha) * scale; | ||
100 | } | ||
101 | return 0; | ||
102 | fail: | ||
103 | ff_mdct_end(s); | ||
104 | return -1; | ||
105 | } | ||
106 | |||
107 | /* complex multiplication: p = a * b */ | ||
108 | #define CMUL(pre, pim, are, aim, bre, bim) \ | ||
109 | {\ | ||
110 | FFTSample _are = (are);\ | ||
111 | FFTSample _aim = (aim);\ | ||
112 | FFTSample _bre = (bre);\ | ||
113 | FFTSample _bim = (bim);\ | ||
114 | (pre) = _are * _bre - _aim * _bim;\ | ||
115 | (pim) = _are * _bim + _aim * _bre;\ | ||
116 | } | ||
117 | |||
118 | /** | ||
119 | * Compute the middle half of the inverse MDCT of size N = 2^nbits, | ||
120 | * thus excluding the parts that can be derived by symmetry | ||
121 | * @param output N/2 samples | ||
122 | * @param input N/2 samples | ||
123 | */ | ||
124 | void fff_imdct_half_c(FFTContext *s, FFTSample *output, const FFTSample *input) | ||
125 | { | ||
126 | int k, n8, n4, n2, n, j; | ||
127 | const uint16_t *revtab = s->revtab; | ||
128 | const FFTSample *tcos = s->tcos; | ||
129 | const FFTSample *tsin = s->tsin; | ||
130 | const FFTSample *in1, *in2; | ||
131 | FFTComplex *z = (FFTComplex *)output; | ||
132 | |||
133 | n = 1 << s->mdct_bits; | ||
134 | n2 = n >> 1; | ||
135 | n4 = n >> 2; | ||
136 | n8 = n >> 3; | ||
137 | |||
138 | /* pre rotation */ | ||
139 | in1 = input; | ||
140 | in2 = input + n2 - 1; | ||
141 | for(k = 0; k < n4; k++) { | ||
142 | j=revtab[k]; | ||
143 | CMUL(z[j].re, z[j].im, *in2, *in1, tcos[k], tsin[k]); | ||
144 | in1 += 2; | ||
145 | in2 -= 2; | ||
146 | } | ||
147 | |||
148 | fff_fft_calc(s, z); | ||
149 | /* post rotation + reordering */ | ||
150 | for(k = 0; k < n8; k++) { | ||
151 | FFTSample r0, i0, r1, i1; | ||
152 | CMUL(r0, i1, z[n8-k-1].im, z[n8-k-1].re, tsin[n8-k-1], tcos[n8-k-1]); | ||
153 | CMUL(r1, i0, z[n8+k ].im, z[n8+k ].re, tsin[n8+k ], tcos[n8+k ]); | ||
154 | z[n8-k-1].re = r0; | ||
155 | z[n8-k-1].im = i0; | ||
156 | z[n8+k ].re = r1; | ||
157 | z[n8+k ].im = i1; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * Compute inverse MDCT of size N = 2^nbits | ||
163 | * @param output N samples | ||
164 | * @param input N/2 samples | ||
165 | */ | ||
166 | void ff_imdct_calc_c(FFTContext *s, FFTSample *output, const FFTSample *input) | ||
167 | { | ||
168 | int k; | ||
169 | int n = 1 << s->mdct_bits; | ||
170 | int n2 = n >> 1; | ||
171 | int n4 = n >> 2; | ||
172 | |||
173 | fff_imdct_half_c(s, output+n4, input); | ||
174 | |||
175 | for(k = 0; k < n4; k++) { | ||
176 | output[k] = -output[n2-k-1]; | ||
177 | output[n-k-1] = output[n2+k]; | ||
178 | } | ||
179 | } | ||
180 | |||
181 | /** | ||
182 | * Compute MDCT of size N = 2^nbits | ||
183 | * @param input N samples | ||
184 | * @param out N/2 samples | ||
185 | */ | ||
186 | void ff_mdct_calc_c(FFTContext *s, FFTSample *out, const FFTSample *input) | ||
187 | { | ||
188 | int i, j, n, n8, n4, n2, n3; | ||
189 | FFTSample re, im; | ||
190 | const uint16_t *revtab = s->revtab; | ||
191 | const FFTSample *tcos = s->tcos; | ||
192 | const FFTSample *tsin = s->tsin; | ||
193 | FFTComplex *x = (FFTComplex *)out; | ||
194 | |||
195 | n = 1 << s->mdct_bits; | ||
196 | n2 = n >> 1; | ||
197 | n4 = n >> 2; | ||
198 | n8 = n >> 3; | ||
199 | n3 = 3 * n4; | ||
200 | |||
201 | /* pre rotation */ | ||
202 | for(i=0;i<n8;i++) { | ||
203 | re = -input[2*i+3*n4] - input[n3-1-2*i]; | ||
204 | im = -input[n4+2*i] + input[n4-1-2*i]; | ||
205 | j = revtab[i]; | ||
206 | CMUL(x[j].re, x[j].im, re, im, -tcos[i], tsin[i]); | ||
207 | |||
208 | re = input[2*i] - input[n2-1-2*i]; | ||
209 | im = -(input[n2+2*i] + input[n-1-2*i]); | ||
210 | j = revtab[n8 + i]; | ||
211 | CMUL(x[j].re, x[j].im, re, im, -tcos[n8 + i], tsin[n8 + i]); | ||
212 | } | ||
213 | |||
214 | fff_fft_calc(s, x); | ||
215 | |||
216 | /* post rotation */ | ||
217 | for(i=0;i<n8;i++) { | ||
218 | FFTSample r0, i0, r1, i1; | ||
219 | CMUL(i1, r0, x[n8-i-1].re, x[n8-i-1].im, -tsin[n8-i-1], -tcos[n8-i-1]); | ||
220 | CMUL(i0, r1, x[n8+i ].re, x[n8+i ].im, -tsin[n8+i ], -tcos[n8+i ]); | ||
221 | x[n8-i-1].re = r0; | ||
222 | x[n8-i-1].im = i0; | ||
223 | x[n8+i ].re = r1; | ||
224 | x[n8+i ].im = i1; | ||
225 | } | ||
226 | } | ||
227 | |||
228 | av_cold void ff_mdct_end(FFTContext *s) | ||
229 | { | ||
230 | av_freep(&s->tcos); | ||
231 | ff_fft_end(s); | ||
232 | } | ||
diff --git a/apps/codecs/libwmapro/mdct_tablegen.h b/apps/codecs/libwmapro/mdct_tablegen.h deleted file mode 100644 index 998f86f283..0000000000 --- a/apps/codecs/libwmapro/mdct_tablegen.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | * Header file for hardcoded MDCT tables | ||
3 | * | ||
4 | * Copyright (c) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de> | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg 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 GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | //#include <assert.h> | ||
24 | // do not use libavutil/mathematics.h since this is compiled both | ||
25 | // for the host and the target and config.h is only valid for the target | ||
26 | #include <math.h> | ||
27 | #include "libavutil/attributes.h" | ||
28 | |||
29 | #if !CONFIG_HARDCODED_TABLES | ||
30 | SINETABLE( 32); | ||
31 | SINETABLE( 64); | ||
32 | SINETABLE( 128); | ||
33 | SINETABLE( 256); | ||
34 | SINETABLE( 512); | ||
35 | SINETABLE(1024); | ||
36 | SINETABLE(2048); | ||
37 | SINETABLE(4096); | ||
38 | #else | ||
39 | #include "libavcodec/mdct_tables.h" | ||
40 | #endif | ||
41 | |||
42 | SINETABLE_CONST float * const ff_sine_windows[] = { | ||
43 | NULL, NULL, NULL, NULL, NULL, // unused | ||
44 | ff_sine_32 , ff_sine_64 , | ||
45 | ff_sine_128, ff_sine_256, ff_sine_512, ff_sine_1024, ff_sine_2048, ff_sine_4096 | ||
46 | }; | ||
47 | |||
48 | // Generate a sine window. | ||
49 | av_cold void ff_sine_window_init(float *window, int n) { | ||
50 | int i; | ||
51 | for(i = 0; i < n; i++) | ||
52 | window[i] = sinf((i + 0.5) * (M_PI / (2.0 * n))); | ||
53 | } | ||
54 | |||
55 | av_cold void ff_init_ff_sine_windows(int index) { | ||
56 | //assert(index >= 0 && index < FF_ARRAY_ELEMS(ff_sine_windows)); | ||
57 | #if !CONFIG_HARDCODED_TABLES | ||
58 | ff_sine_window_init(ff_sine_windows[index], 1 << index); | ||
59 | #endif | ||
60 | } | ||
diff --git a/apps/codecs/libwmapro/put_bits.h b/apps/codecs/libwmapro/put_bits.h index 91401ff3fa..a3c458b0be 100644 --- a/apps/codecs/libwmapro/put_bits.h +++ b/apps/codecs/libwmapro/put_bits.h | |||
@@ -30,10 +30,11 @@ | |||
30 | #include <stdlib.h> | 30 | #include <stdlib.h> |
31 | //#include <assert.h> | 31 | //#include <assert.h> |
32 | #include "libavutil/bswap.h" | 32 | #include "libavutil/bswap.h" |
33 | #include "libavutil/common.h" | 33 | //#include "libavutil/common.h" |
34 | #include "libavutil/intreadwrite.h" | 34 | //#include "libavutil/intreadwrite.h" |
35 | #include "libavutil/log.h" | 35 | //#include "libavutil/log.h" |
36 | #include "mathops.h" | 36 | |
37 | #define av_log(...) | ||
37 | 38 | ||
38 | //#define ALT_BITSTREAM_WRITER | 39 | //#define ALT_BITSTREAM_WRITER |
39 | //#define ALIGNED_BITSTREAM_WRITER | 40 | //#define ALIGNED_BITSTREAM_WRITER |
@@ -270,22 +271,6 @@ static inline void put_sbits(PutBitContext *pb, int n, int32_t value) | |||
270 | } | 271 | } |
271 | 272 | ||
272 | /** | 273 | /** |
273 | * Writes exactly 32 bits into a bitstream. | ||
274 | */ | ||
275 | static void av_unused put_bits32(PutBitContext *s, uint32_t value) | ||
276 | { | ||
277 | int lo = value & 0xffff; | ||
278 | int hi = value >> 16; | ||
279 | #ifdef BITSTREAM_WRITER_LE | ||
280 | put_bits(s, 16, lo); | ||
281 | put_bits(s, 16, hi); | ||
282 | #else | ||
283 | put_bits(s, 16, hi); | ||
284 | put_bits(s, 16, lo); | ||
285 | #endif | ||
286 | } | ||
287 | |||
288 | /** | ||
289 | * Returns the pointer to the byte where the bitstream writer will put | 274 | * Returns the pointer to the byte where the bitstream writer will put |
290 | * the next bit. | 275 | * the next bit. |
291 | */ | 276 | */ |
diff --git a/apps/codecs/libwmapro/wma.c b/apps/codecs/libwmapro/wma.c index 30fb9e022a..80f1907fd8 100644 --- a/apps/codecs/libwmapro/wma.c +++ b/apps/codecs/libwmapro/wma.c | |||
@@ -19,7 +19,7 @@ | |||
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include "avcodec.h" | 22 | //#include "avcodec.h" |
23 | #include "wma.h" | 23 | #include "wma.h" |
24 | //#include "wmadata.h" | 24 | //#include "wmadata.h" |
25 | 25 | ||
@@ -74,7 +74,7 @@ static void init_coef_vlc(VLC *vlc, uint16_t **prun_table, | |||
74 | *@param decode_flags codec compression features | 74 | *@param decode_flags codec compression features |
75 | *@return log2 of the number of output samples per frame | 75 | *@return log2 of the number of output samples per frame |
76 | */ | 76 | */ |
77 | int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, | 77 | int ff_wma_get_frame_len_bits(int sample_rate, int version, |
78 | unsigned int decode_flags) | 78 | unsigned int decode_flags) |
79 | { | 79 | { |
80 | 80 | ||
diff --git a/apps/codecs/libwmapro/wma.h b/apps/codecs/libwmapro/wma.h index e4a1601515..6586d74b7e 100644 --- a/apps/codecs/libwmapro/wma.h +++ b/apps/codecs/libwmapro/wma.h | |||
@@ -61,11 +61,9 @@ typedef struct CoefVLCTable { | |||
61 | } CoefVLCTable; | 61 | } CoefVLCTable; |
62 | 62 | ||
63 | 63 | ||
64 | int av_cold ff_wma_get_frame_len_bits(int sample_rate, int version, | 64 | int ff_wma_get_frame_len_bits(int sample_rate, int version, |
65 | unsigned int decode_flags); | 65 | unsigned int decode_flags); |
66 | int ff_wma_init(AVCodecContext * avctx, int flags2); | ||
67 | int ff_wma_total_gain_to_bits(int total_gain); | 66 | int ff_wma_total_gain_to_bits(int total_gain); |
68 | int ff_wma_end(AVCodecContext *avctx); | ||
69 | unsigned int ff_wma_get_large_val(GetBitContext* gb); | 67 | unsigned int ff_wma_get_large_val(GetBitContext* gb); |
70 | int ff_wma_run_level_decode(GetBitContext* gb, | 68 | int ff_wma_run_level_decode(GetBitContext* gb, |
71 | VLC *vlc, | 69 | VLC *vlc, |
diff --git a/apps/codecs/libwmapro/wmapro_mainbuild.patch b/apps/codecs/libwmapro/wmapro_mainbuild.patch deleted file mode 100644 index 79623df9a4..0000000000 --- a/apps/codecs/libwmapro/wmapro_mainbuild.patch +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | Index: ../codecs.make | ||
2 | =================================================================== | ||
3 | --- ../codecs.make (revision 27008) | ||
4 | +++ ../codecs.make (working copy) | ||
5 | @@ -37,6 +37,7 @@ | ||
6 | include $(APPSDIR)/codecs/libtremor/libtremor.make | ||
7 | include $(APPSDIR)/codecs/libwavpack/libwavpack.make | ||
8 | include $(APPSDIR)/codecs/libwma/libwma.make | ||
9 | +include $(APPSDIR)/codecs/libwmapro/libwmapro.make | ||
10 | include $(APPSDIR)/codecs/libcook/libcook.make | ||
11 | include $(APPSDIR)/codecs/librm/librm.make | ||
12 | include $(APPSDIR)/codecs/libatrac/libatrac.make | ||
13 | @@ -58,7 +59,7 @@ | ||
14 | CODECLIBS := $(DEMACLIB) $(A52LIB) $(ALACLIB) $(ASAPLIB) \ | ||
15 | $(FAADLIB) $(FFMPEGFLACLIB) $(M4ALIB) $(MADLIB) $(MUSEPACKLIB) \ | ||
16 | $(SPCLIB) $(SPEEXLIB) $(TREMORLIB) $(WAVPACKLIB) $(WMALIB) $(COOKLIB) \ | ||
17 | - $(ATRACLIB) \ | ||
18 | + $(ATRACLIB) $(WMAPROLIB) \ | ||
19 | $(CODECLIB) | ||
20 | |||
21 | $(CODECS): $(CODEC_CRT0) $(CODECLINK_LDS) | ||
22 | @@ -83,6 +84,7 @@ | ||
23 | $(CODECDIR)/ape-pre.map : $(CODECDIR)/libdemac-pre.a | ||
24 | $(CODECDIR)/ape.codec : $(CODECDIR)/libdemac.a | ||
25 | $(CODECDIR)/wma.codec : $(CODECDIR)/libwma.a $(CODECDIR)/libasf.a | ||
26 | +$(CODECDIR)/wmapro.codec : $(CODECDIR)/libwmapro.a $(CODECDIR)/libasf.a | ||
27 | $(CODECDIR)/wavpack_enc.codec: $(CODECDIR)/libwavpack.a | ||
28 | $(CODECDIR)/asap.codec : $(CODECDIR)/libasap.a | ||
29 | $(CODECDIR)/cook.codec : $(CODECDIR)/libcook.a $(CODECDIR)/librm.a | ||
30 | Index: ../SOURCES | ||
31 | =================================================================== | ||
32 | --- ../SOURCES (revision 27008) | ||
33 | +++ ../SOURCES (working copy) | ||
34 | @@ -16,6 +16,7 @@ | ||
35 | atrac3_oma.c | ||
36 | mpc.c | ||
37 | wma.c | ||
38 | +wmapro.c | ||
39 | sid.c | ||
40 | ape.c | ||
41 | nsf.c | ||
diff --git a/apps/codecs/libwmapro/wmapro_math.h b/apps/codecs/libwmapro/wmapro_math.h index b339d8616d..4614bcbe56 100644 --- a/apps/codecs/libwmapro/wmapro_math.h +++ b/apps/codecs/libwmapro/wmapro_math.h | |||
@@ -48,4 +48,10 @@ static inline void vector_fixmul_scalar(FIXED *dst, const FIXED *src, FIXED mul, | |||
48 | dst[i] = fixmulshift(src[i],mul,shift); | 48 | dst[i] = fixmulshift(src[i],mul,shift); |
49 | } | 49 | } |
50 | 50 | ||
51 | static inline int av_clip(int a, int amin, int amax) | ||
52 | { | ||
53 | if (a < amin) return amin; | ||
54 | else if (a > amax) return amax; | ||
55 | else return a; | ||
56 | } | ||
51 | #endif /* _WMAPRO_MATH_H_ */ | 57 | #endif /* _WMAPRO_MATH_H_ */ |
diff --git a/apps/codecs/libwmapro/wmaprodec.c b/apps/codecs/libwmapro/wmaprodec.c index 2dd2a6a1e4..1fc4386bd5 100644 --- a/apps/codecs/libwmapro/wmaprodec.c +++ b/apps/codecs/libwmapro/wmaprodec.c | |||
@@ -86,8 +86,6 @@ | |||
86 | * subframe in order to reconstruct the output samples. | 86 | * subframe in order to reconstruct the output samples. |
87 | */ | 87 | */ |
88 | 88 | ||
89 | #include "avcodec.h" | ||
90 | #include "internal.h" | ||
91 | #include "get_bits.h" | 89 | #include "get_bits.h" |
92 | #include "put_bits.h" | 90 | #include "put_bits.h" |
93 | #include "wmaprodata.h" | 91 | #include "wmaprodata.h" |
@@ -99,6 +97,8 @@ | |||
99 | #include "types.h" | 97 | #include "types.h" |
100 | #include "wmapro_math.h" | 98 | #include "wmapro_math.h" |
101 | #include "codecs.h" | 99 | #include "codecs.h" |
100 | #include "codeclib.h" | ||
101 | #include "../libasf/asf.h" | ||
102 | 102 | ||
103 | /* Uncomment the following line to enable some debug output */ | 103 | /* Uncomment the following line to enable some debug output */ |
104 | //#define WMAPRO_DUMP_CTX_EN | 104 | //#define WMAPRO_DUMP_CTX_EN |
@@ -115,6 +115,16 @@ | |||
115 | #define AVERROR_PATCHWELCOME -2 | 115 | #define AVERROR_PATCHWELCOME -2 |
116 | #define av_log_ask_for_sample(...) | 116 | #define av_log_ask_for_sample(...) |
117 | 117 | ||
118 | /* Taken from avcodec.h */ | ||
119 | #define FF_INPUT_BUFFER_PADDING_SIZE 8 | ||
120 | |||
121 | /* Taken from libavutil/mem.h */ | ||
122 | #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v | ||
123 | |||
124 | /* Taken from libavutil/common.h */ | ||
125 | #define FFMIN(a,b) ((a) > (b) ? (b) : (a)) | ||
126 | #define FFMAX(a,b) ((a) > (b) ? (a) : (b)) | ||
127 | |||
118 | /** current decoder limitations */ | 128 | /** current decoder limitations */ |
119 | #define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels | 129 | #define WMAPRO_MAX_CHANNELS 8 ///< max number of handled channels |
120 | #define MAX_SUBFRAMES 32 ///< max number of subframes per channel | 130 | #define MAX_SUBFRAMES 32 ///< max number of subframes per channel |
@@ -183,7 +193,6 @@ typedef struct { | |||
183 | */ | 193 | */ |
184 | typedef struct WMAProDecodeCtx { | 194 | typedef struct WMAProDecodeCtx { |
185 | /* generic decoder variables */ | 195 | /* generic decoder variables */ |
186 | AVCodecContext* avctx; ///< codec context for av_log | ||
187 | uint8_t frame_data[MAX_FRAMESIZE + | 196 | uint8_t frame_data[MAX_FRAMESIZE + |
188 | FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data | 197 | FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data |
189 | PutBitContext pb; ///< context for filling the frame_data buffer | 198 | PutBitContext pb; ///< context for filling the frame_data buffer |
@@ -218,7 +227,7 @@ typedef struct WMAProDecodeCtx { | |||
218 | uint8_t packet_done; ///< set when a packet is fully decoded | 227 | uint8_t packet_done; ///< set when a packet is fully decoded |
219 | 228 | ||
220 | /* frame decode state */ | 229 | /* frame decode state */ |
221 | uint32_t frame_num; ///< current frame number (not used for decoding) | 230 | uint32_t frame_num; ///< current frame number |
222 | GetBitContext gb; ///< bitstream reader context | 231 | GetBitContext gb; ///< bitstream reader context |
223 | int buf_bit_size; ///< buffer size in bits | 232 | int buf_bit_size; ///< buffer size in bits |
224 | FIXED* samples; | 233 | FIXED* samples; |
@@ -250,7 +259,7 @@ static WMAProDecodeCtx globWMAProDecCtx; | |||
250 | *@param s context | 259 | *@param s context |
251 | */ | 260 | */ |
252 | #ifdef WMAPRO_DUMP_CTX_EN | 261 | #ifdef WMAPRO_DUMP_CTX_EN |
253 | static void av_cold dump_context(WMAProDecodeCtx *s) | 262 | static void dump_context(WMAProDecodeCtx *s) |
254 | { | 263 | { |
255 | #define PRINT(a, b) printf(" %s = %d\n", a, b); | 264 | #define PRINT(a, b) printf(" %s = %d\n", a, b); |
256 | #define PRINT_HEX(a, b) printf(" %s = %x\n", a, b); | 265 | #define PRINT_HEX(a, b) printf(" %s = %x\n", a, b); |
@@ -270,28 +279,26 @@ static void av_cold dump_context(WMAProDecodeCtx *s) | |||
270 | *@param avctx codec context | 279 | *@param avctx codec context |
271 | *@return 0 on success, -1 otherwise | 280 | *@return 0 on success, -1 otherwise |
272 | */ | 281 | */ |
273 | av_cold int decode_init(AVCodecContext *avctx) | 282 | int decode_init(asf_waveformatex_t *wfx) |
274 | { | 283 | { |
275 | avctx->priv_data = &globWMAProDecCtx; | 284 | memset(&globWMAProDecCtx, 0, sizeof(WMAProDecodeCtx)); |
276 | memset(avctx->priv_data, 0, sizeof(WMAProDecodeCtx)); | 285 | WMAProDecodeCtx *s = &globWMAProDecCtx; |
277 | WMAProDecodeCtx *s = avctx->priv_data; | 286 | uint8_t *edata_ptr = wfx->data; |
278 | uint8_t *edata_ptr = avctx->extradata; | ||
279 | unsigned int channel_mask; | 287 | unsigned int channel_mask; |
280 | int i; | 288 | int i; |
281 | int log2_max_num_subframes; | 289 | int log2_max_num_subframes; |
282 | int num_possible_block_sizes; | 290 | int num_possible_block_sizes; |
283 | 291 | ||
284 | s->avctx = avctx; | ||
285 | init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); | 292 | init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); |
286 | 293 | ||
287 | if (avctx->extradata_size >= 18) { | 294 | if (wfx->datalen >= 18) { |
288 | s->decode_flags = AV_RL16(edata_ptr+14); | 295 | s->decode_flags = AV_RL16(edata_ptr+14); |
289 | channel_mask = AV_RL32(edata_ptr+2); | 296 | channel_mask = AV_RL32(edata_ptr+2); |
290 | s->bits_per_sample = AV_RL16(edata_ptr); | 297 | s->bits_per_sample = AV_RL16(edata_ptr); |
291 | /** dump the extradata */ | 298 | /** dump the extradata */ |
292 | for (i = 0; i < avctx->extradata_size; i++) | 299 | for (i = 0; i < wfx->datalen; i++) |
293 | dprintf(avctx, "[%x] ", avctx->extradata[i]); | 300 | DEBUGF("[%x] ", wfx->data[i]); |
294 | dprintf(avctx, "\n"); | 301 | DEBUGF("\n"); |
295 | 302 | ||
296 | } else { | 303 | } else { |
297 | DEBUGF("Unknown extradata size\n"); | 304 | DEBUGF("Unknown extradata size\n"); |
@@ -299,7 +306,7 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
299 | } | 306 | } |
300 | 307 | ||
301 | /** generic init */ | 308 | /** generic init */ |
302 | s->log2_frame_size = av_log2(avctx->block_align) + 4; | 309 | s->log2_frame_size = av_log2(wfx->blockalign) + 4; |
303 | 310 | ||
304 | /** frame info */ | 311 | /** frame info */ |
305 | s->skip_frame = 1; /** skip first frame */ | 312 | s->skip_frame = 1; /** skip first frame */ |
@@ -312,11 +319,11 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
312 | } | 319 | } |
313 | 320 | ||
314 | /** get frame len */ | 321 | /** get frame len */ |
315 | s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate, | 322 | s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(wfx->rate, |
316 | 3, s->decode_flags); | 323 | 3, s->decode_flags); |
317 | 324 | ||
318 | /** init previous block len */ | 325 | /** init previous block len */ |
319 | for (i = 0; i < avctx->channels; i++) | 326 | for (i = 0; i < wfx->channels; i++) |
320 | s->channel[i].prev_block_len = s->samples_per_frame; | 327 | s->channel[i].prev_block_len = s->samples_per_frame; |
321 | 328 | ||
322 | /** subframe info */ | 329 | /** subframe info */ |
@@ -336,7 +343,7 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
336 | return AVERROR_INVALIDDATA; | 343 | return AVERROR_INVALIDDATA; |
337 | } | 344 | } |
338 | 345 | ||
339 | s->num_channels = avctx->channels; | 346 | s->num_channels = wfx->channels; |
340 | 347 | ||
341 | /** extract lfe channel position */ | 348 | /** extract lfe channel position */ |
342 | s->lfe_channel = -1; | 349 | s->lfe_channel = -1; |
@@ -396,7 +403,7 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
396 | 403 | ||
397 | for (x = 0; x < MAX_BANDS-1 && s->sfb_offsets[i][band - 1] < subframe_len; x++) { | 404 | for (x = 0; x < MAX_BANDS-1 && s->sfb_offsets[i][band - 1] < subframe_len; x++) { |
398 | int offset = (subframe_len * 2 * critical_freq[x]) | 405 | int offset = (subframe_len * 2 * critical_freq[x]) |
399 | / s->avctx->sample_rate + 2; | 406 | / wfx->rate + 2; |
400 | offset &= ~3; | 407 | offset &= ~3; |
401 | if (offset > s->sfb_offsets[i][band - 1]) | 408 | if (offset > s->sfb_offsets[i][band - 1]) |
402 | s->sfb_offsets[i][band++] = offset; | 409 | s->sfb_offsets[i][band++] = offset; |
@@ -429,8 +436,8 @@ av_cold int decode_init(AVCodecContext *avctx) | |||
429 | /** calculate subwoofer cutoff values */ | 436 | /** calculate subwoofer cutoff values */ |
430 | for (i = 0; i < num_possible_block_sizes; i++) { | 437 | for (i = 0; i < num_possible_block_sizes; i++) { |
431 | int block_size = s->samples_per_frame >> i; | 438 | int block_size = s->samples_per_frame >> i; |
432 | int cutoff = (440*block_size + 3 * (s->avctx->sample_rate >> 1) - 1) | 439 | int cutoff = (440*block_size + 3 * (wfx->rate >> 1) - 1) |
433 | / s->avctx->sample_rate; | 440 | / wfx->rate; |
434 | s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); | 441 | s->subwoofer_cutoffs[i] = av_clip(cutoff, 4, block_size); |
435 | } | 442 | } |
436 | 443 | ||
@@ -576,7 +583,7 @@ static int decode_tilehdr(WMAProDecodeCtx *s) | |||
576 | int i; | 583 | int i; |
577 | int offset = 0; | 584 | int offset = 0; |
578 | for (i = 0; i < s->channel[c].num_subframes; i++) { | 585 | for (i = 0; i < s->channel[c].num_subframes; i++) { |
579 | dprintf(s->avctx, "frame[%i] channel[%i] subframe[%i]" | 586 | DEBUGF("frame[%i] channel[%i] subframe[%i]" |
580 | " len %i\n", s->frame_num, c, i, | 587 | " len %i\n", s->frame_num, c, i, |
581 | s->channel[c].subframe_len[i]); | 588 | s->channel[c].subframe_len[i]); |
582 | s->channel[c].subframe_offset[i] = offset; | 589 | s->channel[c].subframe_offset[i] = offset; |
@@ -789,7 +796,7 @@ static int decode_coeffs(WMAProDecodeCtx *s, int c) | |||
789 | const uint16_t* run; | 796 | const uint16_t* run; |
790 | const FIXED* level; | 797 | const FIXED* level; |
791 | 798 | ||
792 | dprintf(s->avctx, "decode coefficients for channel %i\n", c); | 799 | DEBUGF("decode coefficients for channel %i\n", c); |
793 | 800 | ||
794 | vlctable = get_bits1(&s->gb); | 801 | vlctable = get_bits1(&s->gb); |
795 | vlc = &coef_vlc[vlctable]; | 802 | vlc = &coef_vlc[vlctable]; |
@@ -1080,8 +1087,7 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1080 | } | 1087 | } |
1081 | } | 1088 | } |
1082 | 1089 | ||
1083 | dprintf(s->avctx, | 1090 | DEBUGF("processing subframe with offset %i len %i\n", offset, subframe_len); |
1084 | "processing subframe with offset %i len %i\n", offset, subframe_len); | ||
1085 | 1091 | ||
1086 | /** get a list of all channels that contain the estimated block */ | 1092 | /** get a list of all channels that contain the estimated block */ |
1087 | s->channels_for_cur_subframe = 0; | 1093 | s->channels_for_cur_subframe = 0; |
@@ -1107,8 +1113,7 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1107 | s->parsed_all_subframes = 1; | 1113 | s->parsed_all_subframes = 1; |
1108 | 1114 | ||
1109 | 1115 | ||
1110 | dprintf(s->avctx, "subframe is part of %i channels\n", | 1116 | DEBUGF("subframe is part of %i channels\n", s->channels_for_cur_subframe); |
1111 | s->channels_for_cur_subframe); | ||
1112 | 1117 | ||
1113 | /** calculate number of scale factor bands and their offsets */ | 1118 | /** calculate number of scale factor bands and their offsets */ |
1114 | s->table_idx = av_log2(s->samples_per_frame/subframe_len); | 1119 | s->table_idx = av_log2(s->samples_per_frame/subframe_len); |
@@ -1207,7 +1212,7 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1207 | return AVERROR_INVALIDDATA; | 1212 | return AVERROR_INVALIDDATA; |
1208 | } | 1213 | } |
1209 | 1214 | ||
1210 | dprintf(s->avctx, "BITSTREAM: subframe header length was %i\n", | 1215 | DEBUGF("BITSTREAM: subframe header length was %i\n", |
1211 | get_bits_count(&s->gb) - s->subframe_offset); | 1216 | get_bits_count(&s->gb) - s->subframe_offset); |
1212 | 1217 | ||
1213 | /** parse coefficients */ | 1218 | /** parse coefficients */ |
@@ -1222,7 +1227,7 @@ static int decode_subframe(WMAProDecodeCtx *s) | |||
1222 | } | 1227 | } |
1223 | } | 1228 | } |
1224 | 1229 | ||
1225 | dprintf(s->avctx, "BITSTREAM: subframe length was %i\n", | 1230 | DEBUGF("BITSTREAM: subframe length was %i\n", |
1226 | get_bits_count(&s->gb) - s->subframe_offset); | 1231 | get_bits_count(&s->gb) - s->subframe_offset); |
1227 | 1232 | ||
1228 | if (transmit_coeffs) { | 1233 | if (transmit_coeffs) { |
@@ -1306,7 +1311,7 @@ static int decode_frame(WMAProDecodeCtx *s) | |||
1306 | if (s->len_prefix) | 1311 | if (s->len_prefix) |
1307 | len = get_bits(gb, s->log2_frame_size); | 1312 | len = get_bits(gb, s->log2_frame_size); |
1308 | 1313 | ||
1309 | dprintf(s->avctx, "decoding frame with length %x\n", len); | 1314 | DEBUGF("decoding frame with length %x\n", len); |
1310 | 1315 | ||
1311 | /** decode tile information */ | 1316 | /** decode tile information */ |
1312 | if (decode_tilehdr(s)) { | 1317 | if (decode_tilehdr(s)) { |
@@ -1324,7 +1329,7 @@ static int decode_frame(WMAProDecodeCtx *s) | |||
1324 | /** read drc info */ | 1329 | /** read drc info */ |
1325 | if (s->dynamic_range_compression) { | 1330 | if (s->dynamic_range_compression) { |
1326 | s->drc_gain = get_bits(gb, 8); | 1331 | s->drc_gain = get_bits(gb, 8); |
1327 | dprintf(s->avctx, "drc_gain %i\n", s->drc_gain); | 1332 | DEBUGF("drc_gain %i\n", s->drc_gain); |
1328 | } | 1333 | } |
1329 | 1334 | ||
1330 | /** no idea what these are for, might be the number of samples | 1335 | /** no idea what these are for, might be the number of samples |
@@ -1335,18 +1340,18 @@ static int decode_frame(WMAProDecodeCtx *s) | |||
1335 | /** usually true for the first frame */ | 1340 | /** usually true for the first frame */ |
1336 | if (get_bits1(gb)) { | 1341 | if (get_bits1(gb)) { |
1337 | skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); | 1342 | skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); |
1338 | dprintf(s->avctx, "start skip: %i\n", skip); | 1343 | DEBUGF("start skip: %i\n", skip); |
1339 | } | 1344 | } |
1340 | 1345 | ||
1341 | /** sometimes true for the last frame */ | 1346 | /** sometimes true for the last frame */ |
1342 | if (get_bits1(gb)) { | 1347 | if (get_bits1(gb)) { |
1343 | skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); | 1348 | skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); |
1344 | dprintf(s->avctx, "end skip: %i\n", skip); | 1349 | DEBUGF("end skip: %i\n", skip); |
1345 | } | 1350 | } |
1346 | 1351 | ||
1347 | } | 1352 | } |
1348 | 1353 | ||
1349 | dprintf(s->avctx, "BITSTREAM: frame header length was %i\n", | 1354 | DEBUGF("BITSTREAM: frame header length was %i\n", |
1350 | get_bits_count(gb) - s->frame_offset); | 1355 | get_bits_count(gb) - s->frame_offset); |
1351 | 1356 | ||
1352 | /** reset subframe states */ | 1357 | /** reset subframe states */ |
@@ -1477,13 +1482,13 @@ static void save_bits(WMAProDecodeCtx *s, GetBitContext* gb, int len, | |||
1477 | *@param avpkt input packet | 1482 | *@param avpkt input packet |
1478 | *@return number of bytes that were read from the input buffer | 1483 | *@return number of bytes that were read from the input buffer |
1479 | */ | 1484 | */ |
1480 | int decode_packet(AVCodecContext *avctx, | 1485 | int decode_packet(asf_waveformatex_t *wfx, void *data, int *data_size, |
1481 | void *data, int *data_size, AVPacket* avpkt) | 1486 | void* pktdata, int size) |
1482 | { | 1487 | { |
1483 | WMAProDecodeCtx *s = avctx->priv_data; | 1488 | WMAProDecodeCtx *s = &globWMAProDecCtx; |
1484 | GetBitContext* gb = &s->pgb; | 1489 | GetBitContext* gb = &s->pgb; |
1485 | const uint8_t* buf = avpkt->data; | 1490 | const uint8_t* buf = pktdata; |
1486 | int buf_size = avpkt->size; | 1491 | int buf_size = size; |
1487 | int num_bits_prev_frame; | 1492 | int num_bits_prev_frame; |
1488 | int packet_sequence_number; | 1493 | int packet_sequence_number; |
1489 | 1494 | ||
@@ -1496,10 +1501,10 @@ int decode_packet(AVCodecContext *avctx, | |||
1496 | s->buf_bit_size = buf_size << 3; | 1501 | s->buf_bit_size = buf_size << 3; |
1497 | 1502 | ||
1498 | /** sanity check for the buffer length */ | 1503 | /** sanity check for the buffer length */ |
1499 | if (buf_size < avctx->block_align) | 1504 | if (buf_size < wfx->blockalign) |
1500 | return 0; | 1505 | return 0; |
1501 | 1506 | ||
1502 | buf_size = avctx->block_align; | 1507 | buf_size = wfx->blockalign; |
1503 | 1508 | ||
1504 | /** parse packet header */ | 1509 | /** parse packet header */ |
1505 | init_get_bits(gb, buf, s->buf_bit_size); | 1510 | init_get_bits(gb, buf, s->buf_bit_size); |
@@ -1508,7 +1513,7 @@ int decode_packet(AVCodecContext *avctx, | |||
1508 | 1513 | ||
1509 | /** get number of bits that need to be added to the previous frame */ | 1514 | /** get number of bits that need to be added to the previous frame */ |
1510 | num_bits_prev_frame = get_bits(gb, s->log2_frame_size); | 1515 | num_bits_prev_frame = get_bits(gb, s->log2_frame_size); |
1511 | dprintf(avctx, "packet[%d]: nbpf %x\n", avctx->frame_number, | 1516 | DEBUGF("packet[%d]: nbpf %x\n", s->frame_num, |
1512 | num_bits_prev_frame); | 1517 | num_bits_prev_frame); |
1513 | 1518 | ||
1514 | /** check for packet loss */ | 1519 | /** check for packet loss */ |
@@ -1524,14 +1529,14 @@ int decode_packet(AVCodecContext *avctx, | |||
1524 | /** append the previous frame data to the remaining data from the | 1529 | /** append the previous frame data to the remaining data from the |
1525 | previous packet to create a full frame */ | 1530 | previous packet to create a full frame */ |
1526 | save_bits(s, gb, num_bits_prev_frame, 1); | 1531 | save_bits(s, gb, num_bits_prev_frame, 1); |
1527 | dprintf(avctx, "accumulated %x bits of frame data\n", | 1532 | DEBUGF("accumulated %x bits of frame data\n", |
1528 | s->num_saved_bits - s->frame_offset); | 1533 | s->num_saved_bits - s->frame_offset); |
1529 | 1534 | ||
1530 | /** decode the cross packet frame if it is valid */ | 1535 | /** decode the cross packet frame if it is valid */ |
1531 | if (!s->packet_loss) | 1536 | if (!s->packet_loss) |
1532 | decode_frame(s); | 1537 | decode_frame(s); |
1533 | } else if (s->num_saved_bits - s->frame_offset) { | 1538 | } else if (s->num_saved_bits - s->frame_offset) { |
1534 | dprintf(avctx, "ignoring %x previously saved bits\n", | 1539 | DEBUGF("ignoring %x previously saved bits\n", |
1535 | s->num_saved_bits - s->frame_offset); | 1540 | s->num_saved_bits - s->frame_offset); |
1536 | } | 1541 | } |
1537 | 1542 | ||
@@ -1539,8 +1544,8 @@ int decode_packet(AVCodecContext *avctx, | |||
1539 | 1544 | ||
1540 | } else { | 1545 | } else { |
1541 | int frame_size; | 1546 | int frame_size; |
1542 | s->buf_bit_size = avpkt->size << 3; | 1547 | s->buf_bit_size = size << 3; |
1543 | init_get_bits(gb, avpkt->data, s->buf_bit_size); | 1548 | init_get_bits(gb, pktdata, s->buf_bit_size); |
1544 | skip_bits(gb, s->packet_offset); | 1549 | skip_bits(gb, s->packet_offset); |
1545 | if (remaining_bits(s, gb) > s->log2_frame_size && | 1550 | if (remaining_bits(s, gb) > s->log2_frame_size && |
1546 | (frame_size = show_bits(gb, s->log2_frame_size)) && | 1551 | (frame_size = show_bits(gb, s->log2_frame_size)) && |
@@ -1561,6 +1566,7 @@ int decode_packet(AVCodecContext *avctx, | |||
1561 | *data_size = (int8_t *)s->samples - (int8_t *)data; | 1566 | *data_size = (int8_t *)s->samples - (int8_t *)data; |
1562 | s->packet_offset = get_bits_count(gb) & 7; | 1567 | s->packet_offset = get_bits_count(gb) & 7; |
1563 | 1568 | ||
1569 | s->frame_num++; | ||
1564 | return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; | 1570 | return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; |
1565 | } | 1571 | } |
1566 | 1572 | ||
diff --git a/apps/codecs/libwmapro/wmaprodec.h b/apps/codecs/libwmapro/wmaprodec.h index 045481b529..40f3a60db6 100644 --- a/apps/codecs/libwmapro/wmaprodec.h +++ b/apps/codecs/libwmapro/wmaprodec.h | |||
@@ -1,6 +1,5 @@ | |||
1 | #include "avcodec.h" | 1 | #include "../libasf/asf.h" |
2 | 2 | ||
3 | av_cold int decode_end(AVCodecContext *avctx); | 3 | int decode_init(asf_waveformatex_t *wfx); |
4 | av_cold int decode_init(AVCodecContext *avctx); | 4 | int decode_packet(asf_waveformatex_t *wfx, |
5 | int decode_packet(AVCodecContext *avctx, | 5 | void *data, int *data_size, void* pktdata, int size); |
6 | void *data, int *data_size, AVPacket* avpkt); | ||
diff --git a/apps/codecs/wmapro.c b/apps/codecs/wmapro.c index ba19e2925c..33032f3b16 100644 --- a/apps/codecs/wmapro.c +++ b/apps/codecs/wmapro.c | |||
@@ -30,27 +30,6 @@ CODEC_HEADER | |||
30 | #define BUFSIZE MAXCHANNELS * MAXSAMPLES | 30 | #define BUFSIZE MAXCHANNELS * MAXSAMPLES |
31 | int32_t decoded[BUFSIZE]; | 31 | int32_t decoded[BUFSIZE]; |
32 | 32 | ||
33 | AVCodecContext avctx; | ||
34 | AVPacket avpkt; | ||
35 | |||
36 | /* This function initialises AVCodecContext with the data needed for the wmapro | ||
37 | * decoder to work. The required data is taken from asf_waveformatex_t because that's | ||
38 | * what the rockbox asf metadata parser fill/work with. In the future, when the | ||
39 | * codec is being optimised for on-target playback this function should not be needed, | ||
40 | * as we will be working directly with WMAProDecodeCtx (declared in wmaprodec.c) */ | ||
41 | static void init_codec_ctx(AVCodecContext *avctx, asf_waveformatex_t *wfx) | ||
42 | { | ||
43 | /* Copy the extra-data */ | ||
44 | avctx->extradata_size = wfx->datalen; | ||
45 | avctx->extradata = (uint8_t *)malloc(wfx->datalen*sizeof(uint8_t)); | ||
46 | memcpy(avctx->extradata, wfx->data, wfx->datalen*sizeof(uint8_t)); | ||
47 | |||
48 | avctx->block_align = wfx->blockalign; | ||
49 | avctx->sample_rate = wfx->rate; | ||
50 | avctx->channels = wfx->channels; | ||
51 | |||
52 | } | ||
53 | |||
54 | /* this is the codec entry point */ | 33 | /* this is the codec entry point */ |
55 | enum codec_status codec_main(void) | 34 | enum codec_status codec_main(void) |
56 | { | 35 | { |
@@ -64,6 +43,8 @@ enum codec_status codec_main(void) | |||
64 | int packetlength = 0; /* Logical packet size (minus the header size) */ | 43 | int packetlength = 0; /* Logical packet size (minus the header size) */ |
65 | int outlen = 0; /* Number of bytes written to the output buffer */ | 44 | int outlen = 0; /* Number of bytes written to the output buffer */ |
66 | int pktcnt = 0; /* Count of the packets played */ | 45 | int pktcnt = 0; /* Count of the packets played */ |
46 | uint8_t *data; /* Pointer to decoder input buffer */ | ||
47 | int size; /* Size of the input frame to the decoder */ | ||
67 | 48 | ||
68 | /* Generic codec initialisation */ | 49 | /* Generic codec initialisation */ |
69 | ci->configure(DSP_SET_SAMPLE_DEPTH, 17); | 50 | ci->configure(DSP_SET_SAMPLE_DEPTH, 17); |
@@ -94,11 +75,8 @@ next_track: | |||
94 | ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? | 75 | ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? |
95 | STEREO_MONO : STEREO_INTERLEAVED); | 76 | STEREO_MONO : STEREO_INTERLEAVED); |
96 | codec_set_replaygain(ci->id3); | 77 | codec_set_replaygain(ci->id3); |
97 | |||
98 | /* Initialise the AVCodecContext */ | ||
99 | init_codec_ctx(&avctx, &wfx); | ||
100 | 78 | ||
101 | if (decode_init(&avctx) < 0) { | 79 | if (decode_init(&wfx) < 0) { |
102 | LOGF("(WMA PRO) Error: Unsupported or corrupt file\n"); | 80 | LOGF("(WMA PRO) Error: Unsupported or corrupt file\n"); |
103 | retval = CODEC_ERROR; | 81 | retval = CODEC_ERROR; |
104 | goto done; | 82 | goto done; |
@@ -143,20 +121,19 @@ next_track: | |||
143 | LOGF("(WMA PRO) Warning: asf_read_packet returned %d", res); | 121 | LOGF("(WMA PRO) Warning: asf_read_packet returned %d", res); |
144 | goto done; | 122 | goto done; |
145 | } else { | 123 | } else { |
146 | avpkt.data = audiobuf; | 124 | data = audiobuf; |
147 | avpkt.size = audiobufsize; | 125 | size = audiobufsize; |
148 | pktcnt++; | 126 | pktcnt++; |
149 | 127 | ||
150 | /* We now loop on the packet, decoding and outputting the subframes | 128 | /* We now loop on the packet, decoding and outputting the subframes |
151 | * one-by-one. For more information about how wma pro structures its | 129 | * one-by-one. For more information about how wma pro structures its |
152 | * audio frames, see libwmapro/wmaprodec.c */ | 130 | * audio frames, see libwmapro/wmaprodec.c */ |
153 | while(avpkt.size > 0) | 131 | while(size > 0) |
154 | { | 132 | { |
155 | outlen = BUFSIZE; /* decode_packet needs to know the size of the output buffer */ | 133 | outlen = BUFSIZE; /* decode_packet needs to know the size of the output buffer */ |
156 | res = decode_packet(&avctx, decoded, &outlen, &avpkt); | 134 | res = decode_packet(&wfx, decoded, &outlen, data, size); |
157 | avpkt.data += res; | 135 | data += res; |
158 | avpkt.size -= res; | 136 | size -= res; |
159 | avctx.frame_number++; | ||
160 | if(outlen) { | 137 | if(outlen) { |
161 | ci->yield (); | 138 | ci->yield (); |
162 | /* outlen now holds the size of the data in bytes - we want the | 139 | /* outlen now holds the size of the data in bytes - we want the |