]> git.sesse.net Git - ffmpeg/blob - libavcodec/arm/mpegvideo_armv5te.c
Add add_pixels4/8() to h264dsp, and remove add_pixels4 from dsputil.
[ffmpeg] / libavcodec / arm / mpegvideo_armv5te.c
1 /*
2  * Optimization of some functions from mpegvideo.c for armv5te
3  * Copyright (c) 2007 Siarhei Siamashka <ssvb@users.sourceforge.net>
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 "libavutil/attributes.h"
23 #include "libavutil/avassert.h"
24 #include "libavcodec/avcodec.h"
25 #include "libavcodec/dsputil.h"
26 #include "libavcodec/mpegvideo.h"
27 #include "mpegvideo_arm.h"
28
29 void ff_dct_unquantize_h263_armv5te(int16_t *block, int qmul, int qadd, int count);
30
31 #ifdef ENABLE_ARM_TESTS
32 /**
33  * h263 dequantizer supplementary function, it is performance critical and needs to
34  * have optimized implementations for each architecture. Is also used as a reference
35  * implementation in regression tests
36  */
37 static inline void dct_unquantize_h263_helper_c(int16_t *block, int qmul, int qadd, int count)
38 {
39     int i, level;
40     for (i = 0; i < count; i++) {
41         level = block[i];
42         if (level) {
43             if (level < 0) {
44                 level = level * qmul - qadd;
45             } else {
46                 level = level * qmul + qadd;
47             }
48             block[i] = level;
49         }
50     }
51 }
52 #endif
53
54 static void dct_unquantize_h263_intra_armv5te(MpegEncContext *s,
55                                   int16_t *block, int n, int qscale)
56 {
57     int level, qmul, qadd;
58     int nCoeffs;
59
60     av_assert2(s->block_last_index[n]>=0);
61
62     qmul = qscale << 1;
63
64     if (!s->h263_aic) {
65         if (n < 4)
66             level = block[0] * s->y_dc_scale;
67         else
68             level = block[0] * s->c_dc_scale;
69         qadd = (qscale - 1) | 1;
70     }else{
71         qadd = 0;
72         level = block[0];
73     }
74     if(s->ac_pred)
75         nCoeffs=63;
76     else
77         nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
78
79     ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
80     block[0] = level;
81 }
82
83 static void dct_unquantize_h263_inter_armv5te(MpegEncContext *s,
84                                   int16_t *block, int n, int qscale)
85 {
86     int qmul, qadd;
87     int nCoeffs;
88
89     av_assert2(s->block_last_index[n]>=0);
90
91     qadd = (qscale - 1) | 1;
92     qmul = qscale << 1;
93
94     nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
95
96     ff_dct_unquantize_h263_armv5te(block, qmul, qadd, nCoeffs + 1);
97 }
98
99 av_cold void ff_MPV_common_init_armv5te(MpegEncContext *s)
100 {
101     s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_armv5te;
102     s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_armv5te;
103 }