~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/armv4l/mpegvideo_iwmmxt.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * copyright (c) 2004 AGAWA Koji
 
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
#include "../dsputil.h"
 
22
#include "../mpegvideo.h"
 
23
#include "../avcodec.h"
 
24
 
 
25
static void dct_unquantize_h263_intra_iwmmxt(MpegEncContext *s,
 
26
                                             DCTELEM *block, int n, int qscale)
 
27
{
 
28
    int level, qmul, qadd;
 
29
    int nCoeffs;
 
30
    DCTELEM *block_orig = block;
 
31
 
 
32
    assert(s->block_last_index[n]>=0);
 
33
 
 
34
    qmul = qscale << 1;
 
35
 
 
36
    if (!s->h263_aic) {
 
37
        if (n < 4)
 
38
            level = block[0] * s->y_dc_scale;
 
39
        else
 
40
            level = block[0] * s->c_dc_scale;
 
41
        qadd = (qscale - 1) | 1;
 
42
    }else{
 
43
        qadd = 0;
 
44
        level = block[0];
 
45
    }
 
46
    if(s->ac_pred)
 
47
        nCoeffs=63;
 
48
    else
 
49
        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
 
50
 
 
51
    __asm__ __volatile__ (
 
52
/*      "movd %1, %%mm6                 \n\t" //qmul */
 
53
/*      "packssdw %%mm6, %%mm6          \n\t" */
 
54
/*      "packssdw %%mm6, %%mm6          \n\t" */
 
55
        "tbcsth wr6, %[qmul]            \n\t"
 
56
/*      "movd %2, %%mm5                 \n\t" //qadd */
 
57
/*      "packssdw %%mm5, %%mm5          \n\t" */
 
58
/*      "packssdw %%mm5, %%mm5          \n\t" */
 
59
        "tbcsth wr5, %[qadd]            \n\t"
 
60
        "wzero wr7                      \n\t" /* "pxor %%mm7, %%mm7             \n\t" */
 
61
        "wzero wr4                      \n\t" /* "pxor %%mm4, %%mm4             \n\t" */
 
62
        "wsubh wr7, wr5, wr7            \n\t" /* "psubw %%mm5, %%mm7            \n\t" */
 
63
        "1:                             \n\t"
 
64
        "wldrd wr2, [%[block]]          \n\t" /* "movq (%0, %3), %%mm0          \n\t" */
 
65
        "wldrd wr3, [%[block], #8]      \n\t" /* "movq 8(%0, %3), %%mm1         \n\t" */
 
66
        "wmulsl wr0, wr6, wr2           \n\t" /* "pmullw %%mm6, %%mm0           \n\t" */
 
67
        "wmulsl wr1, wr6, wr3           \n\t" /* "pmullw %%mm6, %%mm1           \n\t" */
 
68
/*      "movq (%0, %3), %%mm2           \n\t" */
 
69
/*      "movq 8(%0, %3), %%mm3          \n\t" */
 
70
        "wcmpgtsh wr2, wr4, wr2         \n\t" /* "pcmpgtw %%mm4, %%mm2          \n\t" // block[i] < 0 ? -1 : 0 */
 
71
        "wcmpgtsh wr3, wr4, wr2         \n\t" /* "pcmpgtw %%mm4, %%mm3          \n\t" // block[i] < 0 ? -1 : 0 */
 
72
        "wxor wr0, wr2, wr0             \n\t" /* "pxor %%mm2, %%mm0             \n\t" */
 
73
        "wxor wr1, wr3, wr1             \n\t" /* "pxor %%mm3, %%mm1             \n\t" */
 
74
        "waddh wr0, wr7, wr0            \n\t" /* "paddw %%mm7, %%mm0            \n\t" */
 
75
        "waddh wr1, wr7, wr1            \n\t" /* "paddw %%mm7, %%mm1            \n\t" */
 
76
        "wxor wr2, wr0, wr2             \n\t" /* "pxor %%mm0, %%mm2             \n\t" */
 
77
        "wxor wr3, wr1, wr3             \n\t" /* "pxor %%mm1, %%mm3             \n\t" */
 
78
        "wcmpeqh wr0, wr7, wr0          \n\t" /* "pcmpeqw %%mm7, %%mm0          \n\t" // block[i] == 0 ? -1 : 0 */
 
79
        "wcmpeqh wr1, wr7, wr1          \n\t" /* "pcmpeqw %%mm7, %%mm1          \n\t" // block[i] == 0 ? -1 : 0 */
 
80
        "wandn wr0, wr2, wr0            \n\t" /* "pandn %%mm2, %%mm0            \n\t" */
 
81
        "wandn wr1, wr3, wr1            \n\t" /* "pandn %%mm3, %%mm1            \n\t" */
 
82
        "wstrd wr0, [%[block]]          \n\t" /* "movq %%mm0, (%0, %3)          \n\t" */
 
83
        "wstrd wr1, [%[block], #8]      \n\t" /* "movq %%mm1, 8(%0, %3)         \n\t" */
 
84
        "add %[block], %[block], #16    \n\t" /* "addl $16, %3                  \n\t" */
 
85
        "subs %[i], %[i], #1            \n\t"
 
86
        "bne 1b                         \n\t" /* "jng 1b                                \n\t" */
 
87
        :[block]"+r"(block)
 
88
        :[i]"r"((nCoeffs + 8) / 8), [qmul]"r"(qmul), [qadd]"r"(qadd)
 
89
        :"memory");
 
90
 
 
91
    block_orig[0] = level;
 
92
}
 
93
 
 
94
#if 0
 
95
static void dct_unquantize_h263_inter_iwmmxt(MpegEncContext *s,
 
96
                                             DCTELEM *block, int n, int qscale)
 
97
{
 
98
    int nCoeffs;
 
99
 
 
100
    assert(s->block_last_index[n]>=0);
 
101
 
 
102
    if(s->ac_pred)
 
103
        nCoeffs=63;
 
104
    else
 
105
        nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
 
106
 
 
107
    ippiQuantInvInter_Compact_H263_16s_I(block, nCoeffs+1, qscale);
 
108
}
 
109
#endif
 
110
 
 
111
void MPV_common_init_iwmmxt(MpegEncContext *s)
 
112
{
 
113
    if (!(mm_flags & MM_IWMMXT)) return;
 
114
 
 
115
    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_iwmmxt;
 
116
#if 0
 
117
    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_iwmmxt;
 
118
#endif
 
119
}