FFmpeg
Loading...
Searching...
No Matches
mpegvideo.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Mans Rullgard
3 * Copyright (c) 2014 James Yu <james.yu@linaro.org>
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 <arm_neon.h>
23
24#include "config.h"
25
27#include "libavutil/cpu.h"
28#if ARCH_AARCH64
30#elif ARCH_ARM
31# include "libavutil/arm/cpu.h"
32#endif
33
36
37static void inline ff_dct_unquantize_h263_neon(int qscale, int qadd, int nCoeffs,
38 int16_t *block)
39{
40 int16x8_t q0s16, q2s16, q3s16, q8s16, q10s16, q11s16, q13s16;
41 int16x8_t q14s16, q15s16, qzs16;
42 uint16x8_t q1u16, q9u16;
43
44 qzs16 = vdupq_n_s16(0);
45
46 q15s16 = vdupq_n_s16(qscale << 1);
47 q14s16 = vdupq_n_s16(qadd);
48 q13s16 = vnegq_s16(q14s16);
49
50 if (nCoeffs > 4) {
51 for (; nCoeffs > 8; nCoeffs -= 16, block += 16) {
52 q0s16 = vld1q_s16(block);
53 q3s16 = vreinterpretq_s16_u16(vcltq_s16(q0s16, qzs16));
54 q8s16 = vld1q_s16(block + 8);
55 q1u16 = vceqq_s16(q0s16, qzs16);
56 q2s16 = vmulq_s16(q0s16, q15s16);
57 q11s16 = vreinterpretq_s16_u16(vcltq_s16(q8s16, qzs16));
58 q10s16 = vmulq_s16(q8s16, q15s16);
59 q3s16 = vbslq_s16(vreinterpretq_u16_s16(q3s16), q13s16, q14s16);
60 q11s16 = vbslq_s16(vreinterpretq_u16_s16(q11s16), q13s16, q14s16);
61 q2s16 = vaddq_s16(q2s16, q3s16);
62 q9u16 = vceqq_s16(q8s16, qzs16);
63 q10s16 = vaddq_s16(q10s16, q11s16);
64 q0s16 = vbslq_s16(q1u16, q0s16, q2s16);
65 q8s16 = vbslq_s16(q9u16, q8s16, q10s16);
66 vst1q_s16(block, q0s16);
67 vst1q_s16(block + 8, q8s16);
68 }
69 }
70 if (nCoeffs <= 0)
71 return;
72
73 q0s16 = vld1q_s16(block);
74 q3s16 = vreinterpretq_s16_u16(vcltq_s16(q0s16, qzs16));
75 q1u16 = vceqq_s16(q0s16, qzs16);
76 q2s16 = vmulq_s16(q0s16, q15s16);
77 q3s16 = vbslq_s16(vreinterpretq_u16_s16(q3s16), q13s16, q14s16);
78 q2s16 = vaddq_s16(q2s16, q3s16);
79 q0s16 = vbslq_s16(q1u16, q0s16, q2s16);
80 vst1q_s16(block, q0s16);
81}
82
83static void dct_unquantize_h263_inter_neon(const MPVContext *s, int16_t *block,
84 int n, int qscale)
85{
86 int nCoeffs = s->inter_scantable.raster_end[s->block_last_index[n]];
87 int qadd = (qscale - 1) | 1;
88
89 ff_dct_unquantize_h263_neon(qscale, qadd, nCoeffs + 1, block);
90}
91
92static void dct_unquantize_h263_intra_neon(const MPVContext *s, int16_t *block,
93 int n, int qscale)
94{
95 int qadd;
96 int nCoeffs, blk0;
97
98 if (!s->h263_aic) {
99 if (n < 4)
100 block[0] *= s->y_dc_scale;
101 else
102 block[0] *= s->c_dc_scale;
103 qadd = (qscale - 1) | 1;
104 } else {
105 qadd = 0;
106 }
107
108 if (s->ac_pred) {
109 nCoeffs = 63;
110 } else {
111 nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
112 if (nCoeffs <= 0)
113 return;
114 }
115
116 blk0 = block[0];
117
118 ff_dct_unquantize_h263_neon(qscale, qadd, nCoeffs + 1, block);
119
120 block[0] = blk0;
121}
122
123
125{
127
128 if (have_neon(cpu_flags)) {
129 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_neon;
130 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_neon;
131 }
132}
#define s(width, name)
Definition cbs_vp9.c:198
static int16_t block[64]
Definition dct.c:125
#define have_neon(flags)
Definition cpu.h:26
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
mpegvideo header.
static void dct_unquantize_h263_inter_neon(const MPVContext *s, int16_t *block, int n, int qscale)
Definition mpegvideo.c:83
av_cold void ff_mpv_unquantize_init_neon(MPVUnquantDSPContext *s, int bitexact)
Definition mpegvideo.c:124
static void dct_unquantize_h263_intra_neon(const MPVContext *s, int16_t *block, int n, int qscale)
Definition mpegvideo.c:92
static void ff_dct_unquantize_h263_neon(int qscale, int qadd, int nCoeffs, int16_t *block)
Definition mpegvideo.c:37
#define blk0(i)
Definition sha.c:54