annotate ppc/mpegvideo_ppc.c @ 2074:2faafe7a3db6 libavcodec

mpeg2 chroma422/444 support, may be slower, may be faster for other codecs
author iive
date Fri, 11 Jun 2004 07:59:12 +0000
parents 9241d99f7443
children 4c0ab7ed2642
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
1 /*
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
2 * Copyright (c) 2002 Dieter Shirley
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
3 *
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
4 * This library is free software; you can redistribute it and/or
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
7 * version 2 of the License, or (at your option) any later version.
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
8 *
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
9 * This library is distributed in the hope that it will be useful,
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
12 * Lesser General Public License for more details.
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
13 *
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
15 * License along with this library; if not, write to the Free Software
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
17 */
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
18
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
19 #include "../dsputil.h"
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
20 #include "../mpegvideo.h"
974
5c4cefa5d068 removed redundant includes
bellard
parents: 828
diff changeset
21 #include <time.h>
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
22
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
23 #ifdef HAVE_ALTIVEC
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
24 #include "dsputil_altivec.h"
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
25 #endif
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
26
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
27 extern int dct_quantize_altivec(MpegEncContext *s,
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
28 DCTELEM *block, int n,
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
29 int qscale, int *overflow);
1001
95cbffdc98a9 dct_unquantize_h263_altivec by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents: 974
diff changeset
30 extern void dct_unquantize_h263_altivec(MpegEncContext *s,
95cbffdc98a9 dct_unquantize_h263_altivec by (Romain Dolbeau <dolbeaur at club-internet dot fr>)
michaelni
parents: 974
diff changeset
31 DCTELEM *block, int n, int qscale);
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
32
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1009
diff changeset
33 extern void idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1009
diff changeset
34 extern void idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
35
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
36
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
37 void MPV_common_init_ppc(MpegEncContext *s)
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
38 {
1511
587258262aa5 recommit (of patch, as cvslog msg didnt apply cleanly)
michael
parents: 1107
diff changeset
39 #ifdef HAVE_ALTIVEC
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
40 if (has_altivec())
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
41 {
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
42 if ((s->avctx->idct_algo == FF_IDCT_AUTO) ||
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
43 (s->avctx->idct_algo == FF_IDCT_ALTIVEC))
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
44 {
1107
28f0e53706a7 altivec compilation fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents: 1064
diff changeset
45 s->dsp.idct_put = idct_put_altivec;
28f0e53706a7 altivec compilation fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents: 1064
diff changeset
46 s->dsp.idct_add = idct_add_altivec;
1009
3b7cc8e4b83f AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents: 1001
diff changeset
47 #ifndef ALTIVEC_USE_REFERENCE_C_CODE
1107
28f0e53706a7 altivec compilation fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents: 1064
diff changeset
48 s->dsp.idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
1009
3b7cc8e4b83f AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents: 1001
diff changeset
49 #else /* ALTIVEC_USE_REFERENCE_C_CODE */
1107
28f0e53706a7 altivec compilation fixes by (Magnus Damm <damm at opensource dot se>)
michaelni
parents: 1064
diff changeset
50 s->dsp.idct_permutation_type = FF_NO_IDCT_PERM;
1009
3b7cc8e4b83f AltiVec perf (take 2), plus a couple AltiVec functions by (Romain Dolbeau <dolbeau at irisa dot fr>)
michaelni
parents: 1001
diff changeset
51 #endif /* ALTIVEC_USE_REFERENCE_C_CODE */
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
52 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
53
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
54 // Test to make sure that the dct required alignments are met.
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
55 if ((((long)(s->q_intra_matrix) & 0x0f) != 0) ||
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
56 (((long)(s->q_inter_matrix) & 0x0f) != 0))
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
57 {
1828
bc8f5e1635b9 av_log() patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents: 1693
diff changeset
58 av_log(s->avctx, AV_LOG_INFO, "Internal Error: q-matrix blocks must be 16-byte aligned "
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
59 "to use Altivec DCT. Reverting to non-altivec version.\n");
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
60 return;
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
61 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
62
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
63 if (((long)(s->intra_scantable.inverse) & 0x0f) != 0)
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
64 {
1828
bc8f5e1635b9 av_log() patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents: 1693
diff changeset
65 av_log(s->avctx, AV_LOG_INFO, "Internal Error: scan table blocks must be 16-byte aligned "
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
66 "to use Altivec DCT. Reverting to non-altivec version.\n");
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
67 return;
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
68 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
69
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
70
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
71 if ((s->avctx->dct_algo == FF_DCT_AUTO) ||
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
72 (s->avctx->dct_algo == FF_DCT_ALTIVEC))
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
73 {
1942
9241d99f7443 forgotten copyright & dct_quantize_altivec disabled patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents: 1828
diff changeset
74 #if 0 /* seems to cause trouble under some circumstances */
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
75 s->dct_quantize = dct_quantize_altivec;
1942
9241d99f7443 forgotten copyright & dct_quantize_altivec disabled patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
michael
parents: 1828
diff changeset
76 #endif
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1511
diff changeset
77 s->dct_unquantize_h263_intra = dct_unquantize_h263_altivec;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1511
diff changeset
78 s->dct_unquantize_h263_inter = dct_unquantize_h263_altivec;
828
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
79 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
80 } else
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
81 #endif
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
82 {
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
83 /* Non-AltiVec PPC optimisations here */
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
84 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
85 }
ace3ccd18dd2 Altivec Patch (Mark III) by (Dieter Shirley <dieters at schemasoft dot com>)
michaelni
parents:
diff changeset
86