annotate ps2/mpegvideo_mmi.c @ 5382:7f96f6e16f81 libavcodec

Return AVERROR(ENOMEM) on memory allocation failure of avcodec_open.
author takis
date Fri, 20 Jul 2007 15:08:10 +0000
parents 470601203f44
children f7cbb7733146
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
1 /*
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
2 * Copyright (c) 2000,2001 Fabrice Bellard.
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
3 *
5214
470601203f44 Group all copyright and author notices together.
diego
parents: 5010
diff changeset
4 * MMI optimization by Leon van Stuivenberg
470601203f44 Group all copyright and author notices together.
diego
parents: 5010
diff changeset
5 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
6 * This file is part of FFmpeg.
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
7 *
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
8 * FFmpeg is free software; you can redistribute it and/or
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
10 * License as published by the Free Software Foundation; either
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
11 * version 2.1 of the License, or (at your option) any later version.
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
12 *
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
13 * FFmpeg is distributed in the hope that it will be useful,
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
16 * Lesser General Public License for more details.
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
17 *
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
3947
c8c591fe26f8 Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 3036
diff changeset
19 * License along with FFmpeg; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
21 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
22
5010
d5ba514e3f4a Add libavcodec to compiler include flags in order to simplify header
diego
parents: 4795
diff changeset
23 #include "dsputil.h"
d5ba514e3f4a Add libavcodec to compiler include flags in order to simplify header
diego
parents: 4795
diff changeset
24 #include "mpegvideo.h"
d5ba514e3f4a Add libavcodec to compiler include flags in order to simplify header
diego
parents: 4795
diff changeset
25 #include "avcodec.h"
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
26
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
27 static void dct_unquantize_h263_mmi(MpegEncContext *s,
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
28 DCTELEM *block, int n, int qscale)
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
29 {
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
30 int level=0, qmul, qadd;
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
31 int nCoeffs;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
32
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
33 assert(s->block_last_index[n]>=0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
34
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
35 qadd = (qscale - 1) | 1;
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
36 qmul = qscale << 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
37
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
38 if (s->mb_intra) {
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
39 if (!s->h263_aic) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
40 if (n < 4)
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
41 level = block[0] * s->y_dc_scale;
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
42 else
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
43 level = block[0] * s->c_dc_scale;
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
44 }else {
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
45 qadd = 0;
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
46 level = block[0];
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
47 }
4795
522e52c630bd typos/grammar
diego
parents: 3947
diff changeset
48 nCoeffs= 63; //does not always use zigzag table
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
49 } else {
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
50 nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ];
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
51 }
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
52
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
53 asm volatile(
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
54 "add $14, $0, %3 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
55 "pcpyld $8, %0, %0 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
56 "pcpyh $8, $8 \n\t" //r8 = qmul
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
57 "pcpyld $9, %1, %1 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
58 "pcpyh $9, $9 \n\t" //r9 = qadd
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
59 ".p2align 2 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
60 "1: \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
61 "lq $10, 0($14) \n\t" //r10 = level
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
62 "addi $14, $14, 16 \n\t" //block+=8
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
63 "addi %2, %2, -8 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
64 "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
65 "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
66 "por $12, $11, $12 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
67 "pmulth $10, $10, $8 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
68 "paddh $13, $9, $11 \n\t"
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
69 "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
70 "pmfhl.uw $11 \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
71 "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
72 "paddh $10, $10, $13 \n\t"
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
73 "pand $10, $10, $12 \n\t"
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
74 "sq $10, -16($14) \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
75 "bgez %2, 1b \n\t"
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
76 :: "r"(qmul), "r" (qadd), "r" (nCoeffs), "r" (block) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
77
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
78 if(s->mb_intra)
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
79 block[0]= level;
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
80 }
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
81
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
82
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
83 void MPV_common_init_mmi(MpegEncContext *s)
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
84 {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 1876
diff changeset
85 s->dct_unquantize_h263_intra =
1835
michael
parents: 1092
diff changeset
86 s->dct_unquantize_h263_inter = dct_unquantize_h263_mmi;
721
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
87 }
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
88
71f669e9f633 ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
michaelni
parents:
diff changeset
89