2 * Copyright (c) 2000,2001 Fabrice Bellard.
4 * MMI optimization by Leon van Stuivenberg
6 * This file is part of FFmpeg.
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.
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.
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
23 #include "libavcodec/avcodec.h"
24 #include "libavcodec/dsputil.h"
25 #include "libavcodec/mpegvideo.h"
27 static void dct_unquantize_h263_mmi(MpegEncContext
*s
,
28 DCTELEM
*block
, int n
, int qscale
)
30 int level
=0, qmul
, qadd
;
33 assert(s
->block_last_index
[n
]>=0);
35 qadd
= (qscale
- 1) | 1;
41 level
= block
[0] * s
->y_dc_scale
;
43 level
= block
[0] * s
->c_dc_scale
;
48 nCoeffs
= 63; //does not always use zigzag table
50 nCoeffs
= s
->intra_scantable
.raster_end
[ s
->block_last_index
[n
] ];
54 "add $14, $0, %3 \n\t"
55 "pcpyld $8, %0, %0 \n\t"
56 "pcpyh $8, $8 \n\t" //r8 = qmul
57 "pcpyld $9, %1, %1 \n\t"
58 "pcpyh $9, $9 \n\t" //r9 = qadd
61 "lq $10, 0($14) \n\t" //r10 = level
62 "addi $14, $14, 16 \n\t" //block+=8
63 "addi %2, %2, -8 \n\t"
64 "pcgth $11, $0, $10 \n\t" //r11 = level < 0 ? -1 : 0
65 "pcgth $12, $10, $0 \n\t" //r12 = level > 0 ? -1 : 0
66 "por $12, $11, $12 \n\t"
67 "pmulth $10, $10, $8 \n\t"
68 "paddh $13, $9, $11 \n\t"
69 "pxor $13, $13, $11 \n\t" //r13 = level < 0 ? -qadd : qadd
71 "pinteh $10, $11, $10 \n\t" //r10 = level * qmul
72 "paddh $10, $10, $13 \n\t"
73 "pand $10, $10, $12 \n\t"
74 "sq $10, -16($14) \n\t"
76 :: "r"(qmul
), "r" (qadd
), "r" (nCoeffs
), "r" (block
) : "$8", "$9", "$10", "$11", "$12", "$13", "$14", "memory" );
83 void MPV_common_init_mmi(MpegEncContext
*s
)
85 s
->dct_unquantize_h263_intra
=
86 s
->dct_unquantize_h263_inter
= dct_unquantize_h263_mmi
;