This is in preparation for only keeping the actually used unquantize functions in MpegEncContext.
Unified · Split
| @@ -147,6 +147,7 @@ OBJS-$(CONFIG_MPEGAUDIOHEADER) += mpegaudiodecheader.o mpegaudiotabs.o · 146 unmodified lines | ||
| 147 | 147 | OBJS-$(CONFIG_MPEG4AUDIO) += mpeg4audio.o mpeg4audio_sample_rates.o |
| 148 | 148 | OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o rl.o \ |
| 149 | 149 | mpegvideo_motion.o \ |
| 150 | + mpegvideo_unquantize.o \ | |
| 150 | 151 | mpegvideodata.o mpegpicture.o \ |
| 151 | 152 | to_upper4.o |
| 152 | 153 | OBJS-$(CONFIG_MPEGVIDEODEC) += mpegvideo_dec.o mpegutils.o |
| @@ -24,6 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "libavutil/arm/cpu.h" |
| 25 | 25 | #include "libavcodec/avcodec.h" |
| 26 | 26 | #include "libavcodec/mpegvideo.h" |
| 27 | +#include "libavcodec/mpegvideo_unquantize.h" | |
| 27 | 28 | #include "mpegvideo_arm.h" |
| 28 | 29 | #include "asm-offsets.h" |
| 29 | 30 | |
| @@ -20,6 +20,7 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include "libavutil/attributes.h" |
| 22 | 22 | #include "libavutil/mips/cpu.h" |
| 23 | +#include "libavcodec/mpegvideo_unquantize.h" | |
| 23 | 24 | #include "h263dsp_mips.h" |
| 24 | 25 | #include "mpegvideo_mips.h" |
| 25 | 26 | |
| @@ -41,221 +41,9 @@ · 40 unmodified lines | ||
| 41 | 41 | #include "mpegutils.h" |
| 42 | 42 | #include "mpegvideo.h" |
| 43 | 43 | #include "mpegvideodata.h" |
| 44 | +#include "mpegvideo_unquantize.h" | |
| 44 | 45 | #include "libavutil/refstruct.h" |
| 45 | 46 | |
| 46 | −static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, | |
| 47 | − int16_t *block, int n, int qscale) | |
| 48 | −{ | |
| 49 | − int i, level, nCoeffs; | |
| 50 | − const uint16_t *quant_matrix; | |
| 51 | − | |
| 52 | − nCoeffs= s->block_last_index[n]; | |
| 53 | − | |
| 54 | − block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 55 | − /* XXX: only MPEG-1 */ | |
| 56 | − quant_matrix = s->intra_matrix; | |
| 57 | − for(i=1;i<=nCoeffs;i++) { | |
| 58 | − int j= s->intra_scantable.permutated[i]; | |
| 59 | − level = block[j]; | |
| 60 | − if (level) { | |
| 61 | − if (level < 0) { | |
| 62 | − level = -level; | |
| 63 | − level = (int)(level * qscale * quant_matrix[j]) >> 3; | |
| 64 | − level = (level - 1) | 1; | |
| 65 | − level = -level; | |
| 66 | − } else { | |
| 67 | − level = (int)(level * qscale * quant_matrix[j]) >> 3; | |
| 68 | − level = (level - 1) | 1; | |
| 69 | − } | |
| 70 | − block[j] = level; | |
| 71 | − } | |
| 72 | − } | |
| 73 | −} | |
| 74 | − | |
| 75 | −static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, | |
| 76 | − int16_t *block, int n, int qscale) | |
| 77 | −{ | |
| 78 | − int i, level, nCoeffs; | |
| 79 | − const uint16_t *quant_matrix; | |
| 80 | − | |
| 81 | − nCoeffs= s->block_last_index[n]; | |
| 82 | − | |
| 83 | − quant_matrix = s->inter_matrix; | |
| 84 | − for(i=0; i<=nCoeffs; i++) { | |
| 85 | − int j= s->intra_scantable.permutated[i]; | |
| 86 | − level = block[j]; | |
| 87 | − if (level) { | |
| 88 | − if (level < 0) { | |
| 89 | − level = -level; | |
| 90 | − level = (((level << 1) + 1) * qscale * | |
| 91 | − ((int) (quant_matrix[j]))) >> 4; | |
| 92 | − level = (level - 1) | 1; | |
| 93 | − level = -level; | |
| 94 | − } else { | |
| 95 | − level = (((level << 1) + 1) * qscale * | |
| 96 | − ((int) (quant_matrix[j]))) >> 4; | |
| 97 | − level = (level - 1) | 1; | |
| 98 | − } | |
| 99 | − block[j] = level; | |
| 100 | − } | |
| 101 | − } | |
| 102 | −} | |
| 103 | − | |
| 104 | −static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, | |
| 105 | − int16_t *block, int n, int qscale) | |
| 106 | −{ | |
| 107 | − int i, level, nCoeffs; | |
| 108 | − const uint16_t *quant_matrix; | |
| 109 | − | |
| 110 | − if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 111 | − else qscale <<= 1; | |
| 112 | − | |
| 113 | − nCoeffs= s->block_last_index[n]; | |
| 114 | − | |
| 115 | − block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 116 | − quant_matrix = s->intra_matrix; | |
| 117 | − for(i=1;i<=nCoeffs;i++) { | |
| 118 | − int j= s->intra_scantable.permutated[i]; | |
| 119 | − level = block[j]; | |
| 120 | − if (level) { | |
| 121 | − if (level < 0) { | |
| 122 | − level = -level; | |
| 123 | − level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 124 | − level = -level; | |
| 125 | − } else { | |
| 126 | − level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 127 | − } | |
| 128 | − block[j] = level; | |
| 129 | − } | |
| 130 | − } | |
| 131 | −} | |
| 132 | − | |
| 133 | −static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, | |
| 134 | − int16_t *block, int n, int qscale) | |
| 135 | −{ | |
| 136 | − int i, level, nCoeffs; | |
| 137 | − const uint16_t *quant_matrix; | |
| 138 | − int sum=-1; | |
| 139 | − | |
| 140 | − if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 141 | − else qscale <<= 1; | |
| 142 | − | |
| 143 | − nCoeffs= s->block_last_index[n]; | |
| 144 | − | |
| 145 | − block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 146 | − sum += block[0]; | |
| 147 | − quant_matrix = s->intra_matrix; | |
| 148 | − for(i=1;i<=nCoeffs;i++) { | |
| 149 | − int j= s->intra_scantable.permutated[i]; | |
| 150 | − level = block[j]; | |
| 151 | − if (level) { | |
| 152 | − if (level < 0) { | |
| 153 | − level = -level; | |
| 154 | − level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 155 | − level = -level; | |
| 156 | − } else { | |
| 157 | − level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 158 | − } | |
| 159 | − block[j] = level; | |
| 160 | − sum+=level; | |
| 161 | − } | |
| 162 | − } | |
| 163 | − block[63]^=sum&1; | |
| 164 | −} | |
| 165 | − | |
| 166 | −static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, | |
| 167 | − int16_t *block, int n, int qscale) | |
| 168 | −{ | |
| 169 | − int i, level, nCoeffs; | |
| 170 | − const uint16_t *quant_matrix; | |
| 171 | − int sum=-1; | |
| 172 | − | |
| 173 | − if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 174 | − else qscale <<= 1; | |
| 175 | − | |
| 176 | − nCoeffs= s->block_last_index[n]; | |
| 177 | − | |
| 178 | − quant_matrix = s->inter_matrix; | |
| 179 | − for(i=0; i<=nCoeffs; i++) { | |
| 180 | − int j= s->intra_scantable.permutated[i]; | |
| 181 | − level = block[j]; | |
| 182 | − if (level) { | |
| 183 | − if (level < 0) { | |
| 184 | − level = -level; | |
| 185 | − level = (((level << 1) + 1) * qscale * | |
| 186 | − ((int) (quant_matrix[j]))) >> 5; | |
| 187 | − level = -level; | |
| 188 | − } else { | |
| 189 | − level = (((level << 1) + 1) * qscale * | |
| 190 | − ((int) (quant_matrix[j]))) >> 5; | |
| 191 | − } | |
| 192 | − block[j] = level; | |
| 193 | − sum+=level; | |
| 194 | − } | |
| 195 | − } | |
| 196 | − block[63]^=sum&1; | |
| 197 | −} | |
| 198 | − | |
| 199 | −static void dct_unquantize_h263_intra_c(MpegEncContext *s, | |
| 200 | − int16_t *block, int n, int qscale) | |
| 201 | −{ | |
| 202 | − int i, level, qmul, qadd; | |
| 203 | − int nCoeffs; | |
| 204 | − | |
| 205 | − av_assert2(s->block_last_index[n]>=0 || s->h263_aic); | |
| 206 | − | |
| 207 | − qmul = qscale << 1; | |
| 208 | − | |
| 209 | − if (!s->h263_aic) { | |
| 210 | − block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 211 | − qadd = (qscale - 1) | 1; | |
| 212 | − }else{ | |
| 213 | − qadd = 0; | |
| 214 | − } | |
| 215 | − if(s->ac_pred) | |
| 216 | − nCoeffs=63; | |
| 217 | − else | |
| 218 | − nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; | |
| 219 | − | |
| 220 | − for(i=1; i<=nCoeffs; i++) { | |
| 221 | − level = block[i]; | |
| 222 | − if (level) { | |
| 223 | − if (level < 0) { | |
| 224 | − level = level * qmul - qadd; | |
| 225 | − } else { | |
| 226 | − level = level * qmul + qadd; | |
| 227 | − } | |
| 228 | − block[i] = level; | |
| 229 | − } | |
| 230 | − } | |
| 231 | −} | |
| 232 | − | |
| 233 | −static void dct_unquantize_h263_inter_c(MpegEncContext *s, | |
| 234 | − int16_t *block, int n, int qscale) | |
| 235 | −{ | |
| 236 | − int i, level, qmul, qadd; | |
| 237 | − int nCoeffs; | |
| 238 | − | |
| 239 | − av_assert2(s->block_last_index[n]>=0); | |
| 240 | − | |
| 241 | − qadd = (qscale - 1) | 1; | |
| 242 | − qmul = qscale << 1; | |
| 243 | − | |
| 244 | − nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; | |
| 245 | − | |
| 246 | − for(i=0; i<=nCoeffs; i++) { | |
| 247 | − level = block[i]; | |
| 248 | − if (level) { | |
| 249 | − if (level < 0) { | |
| 250 | − level = level * qmul - qadd; | |
| 251 | − } else { | |
| 252 | − level = level * qmul + qadd; | |
| 253 | − } | |
| 254 | − block[i] = level; | |
| 255 | − } | |
| 256 | − } | |
| 257 | −} | |
| 258 | − | |
| 259 | 47 | |
| 260 | 48 | static void gray16(uint8_t *dst, const uint8_t *src, ptrdiff_t linesize, int h) |
| 261 | 49 | { |
| @@ -325,28 +113,7 @@ av_cold void ff_mpv_idct_init(MpegEncContext *s) · 63 unmodified lines | ||
| 325 | 113 | ff_permute_scantable(s->permutated_intra_v_scantable, ff_alternate_vertical_scan, |
| 326 | 114 | s->idsp.idct_permutation); |
| 327 | 115 | |
| 328 | − s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; | |
| 329 | − s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; | |
| 330 | − s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; | |
| 331 | − s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; | |
| 332 | − s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; | |
| 333 | − if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT) | |
| 334 | − s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; | |
| 335 | − s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; | |
| 336 | − | |
| 337 | −#if HAVE_INTRINSICS_NEON | |
| 338 | − ff_mpv_common_init_neon(s); | |
| 339 | −#endif | |
| 340 | − | |
| 341 | −#if ARCH_ARM | |
| 342 | − ff_mpv_common_init_arm(s); | |
| 343 | −#elif ARCH_PPC | |
| 344 | − ff_mpv_common_init_ppc(s); | |
| 345 | −#elif ARCH_X86 | |
| 346 | − ff_mpv_common_init_x86(s); | |
| 347 | −#elif ARCH_MIPS | |
| 348 | − ff_mpv_common_init_mips(s); | |
| 349 | −#endif | |
| 116 | + ff_mpv_unquantize_init(s); | |
| 350 | 117 | } |
| 351 | 118 | |
| 352 | 119 | static av_cold int init_duplicate_context(MpegEncContext *s) |
| @@ -362,11 +362,6 @@ typedef struct MpegEncContext { · 361 unmodified lines | ||
| 362 | 362 | void ff_mpv_common_defaults(MpegEncContext *s); |
| 363 | 363 | |
| 364 | 364 | int ff_mpv_common_init(MpegEncContext *s); |
| 365 | −void ff_mpv_common_init_arm(MpegEncContext *s); | |
| 366 | −void ff_mpv_common_init_neon(MpegEncContext *s); | |
| 367 | −void ff_mpv_common_init_ppc(MpegEncContext *s); | |
| 368 | −void ff_mpv_common_init_x86(MpegEncContext *s); | |
| 369 | −void ff_mpv_common_init_mips(MpegEncContext *s); | |
| 370 | 365 | /** |
| 371 | 366 | * Initialize an MpegEncContext's thread contexts. Presumes that |
| 372 | 367 | * slice_context_count is already set and that all the fields |
| @@ -0,0 +1,273 @@ | ||
| 1 | +/* | |
| 2 | + * Unquantize functions for mpegvideo | |
| 3 | + * Copyright (c) 2000,2001 Fabrice Bellard | |
| 4 | + * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
| 5 | + * | |
| 6 | + * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> | |
| 7 | + * | |
| 8 | + * This file is part of FFmpeg. | |
| 9 | + * | |
| 10 | + * FFmpeg is free software; you can redistribute it and/or | |
| 11 | + * modify it under the terms of the GNU Lesser General Public | |
| 12 | + * License as published by the Free Software Foundation; either | |
| 13 | + * version 2.1 of the License, or (at your option) any later version. | |
| 14 | + * | |
| 15 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 | + * Lesser General Public License for more details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU Lesser General Public | |
| 21 | + * License along with FFmpeg; if not, write to the Free Software | |
| 22 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 23 | + */ | |
| 24 | + | |
| 25 | +#include <stdint.h> | |
| 26 | + | |
| 27 | +#include "config.h" | |
| 28 | + | |
| 29 | +#include "libavutil/attributes.h" | |
| 30 | +#include "libavutil/avassert.h" | |
| 31 | +#include "avcodec.h" | |
| 32 | +#include "mpegvideo.h" | |
| 33 | +#include "mpegvideodata.h" | |
| 34 | +#include "mpegvideo_unquantize.h" | |
| 35 | + | |
| 36 | +static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, | |
| 37 | + int16_t *block, int n, int qscale) | |
| 38 | +{ | |
| 39 | + int i, level, nCoeffs; | |
| 40 | + const uint16_t *quant_matrix; | |
| 41 | + | |
| 42 | + nCoeffs= s->block_last_index[n]; | |
| 43 | + | |
| 44 | + block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 45 | + /* XXX: only MPEG-1 */ | |
| 46 | + quant_matrix = s->intra_matrix; | |
| 47 | + for(i=1;i<=nCoeffs;i++) { | |
| 48 | + int j= s->intra_scantable.permutated[i]; | |
| 49 | + level = block[j]; | |
| 50 | + if (level) { | |
| 51 | + if (level < 0) { | |
| 52 | + level = -level; | |
| 53 | + level = (int)(level * qscale * quant_matrix[j]) >> 3; | |
| 54 | + level = (level - 1) | 1; | |
| 55 | + level = -level; | |
| 56 | + } else { | |
| 57 | + level = (int)(level * qscale * quant_matrix[j]) >> 3; | |
| 58 | + level = (level - 1) | 1; | |
| 59 | + } | |
| 60 | + block[j] = level; | |
| 61 | + } | |
| 62 | + } | |
| 63 | +} | |
| 64 | + | |
| 65 | +static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s, | |
| 66 | + int16_t *block, int n, int qscale) | |
| 67 | +{ | |
| 68 | + int i, level, nCoeffs; | |
| 69 | + const uint16_t *quant_matrix; | |
| 70 | + | |
| 71 | + nCoeffs= s->block_last_index[n]; | |
| 72 | + | |
| 73 | + quant_matrix = s->inter_matrix; | |
| 74 | + for(i=0; i<=nCoeffs; i++) { | |
| 75 | + int j= s->intra_scantable.permutated[i]; | |
| 76 | + level = block[j]; | |
| 77 | + if (level) { | |
| 78 | + if (level < 0) { | |
| 79 | + level = -level; | |
| 80 | + level = (((level << 1) + 1) * qscale * | |
| 81 | + ((int) (quant_matrix[j]))) >> 4; | |
| 82 | + level = (level - 1) | 1; | |
| 83 | + level = -level; | |
| 84 | + } else { | |
| 85 | + level = (((level << 1) + 1) * qscale * | |
| 86 | + ((int) (quant_matrix[j]))) >> 4; | |
| 87 | + level = (level - 1) | 1; | |
| 88 | + } | |
| 89 | + block[j] = level; | |
| 90 | + } | |
| 91 | + } | |
| 92 | +} | |
| 93 | + | |
| 94 | +static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, | |
| 95 | + int16_t *block, int n, int qscale) | |
| 96 | +{ | |
| 97 | + int i, level, nCoeffs; | |
| 98 | + const uint16_t *quant_matrix; | |
| 99 | + | |
| 100 | + if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 101 | + else qscale <<= 1; | |
| 102 | + | |
| 103 | + nCoeffs= s->block_last_index[n]; | |
| 104 | + | |
| 105 | + block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 106 | + quant_matrix = s->intra_matrix; | |
| 107 | + for(i=1;i<=nCoeffs;i++) { | |
| 108 | + int j= s->intra_scantable.permutated[i]; | |
| 109 | + level = block[j]; | |
| 110 | + if (level) { | |
| 111 | + if (level < 0) { | |
| 112 | + level = -level; | |
| 113 | + level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 114 | + level = -level; | |
| 115 | + } else { | |
| 116 | + level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 117 | + } | |
| 118 | + block[j] = level; | |
| 119 | + } | |
| 120 | + } | |
| 121 | +} | |
| 122 | + | |
| 123 | +static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, | |
| 124 | + int16_t *block, int n, int qscale) | |
| 125 | +{ | |
| 126 | + int i, level, nCoeffs; | |
| 127 | + const uint16_t *quant_matrix; | |
| 128 | + int sum=-1; | |
| 129 | + | |
| 130 | + if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 131 | + else qscale <<= 1; | |
| 132 | + | |
| 133 | + nCoeffs= s->block_last_index[n]; | |
| 134 | + | |
| 135 | + block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 136 | + sum += block[0]; | |
| 137 | + quant_matrix = s->intra_matrix; | |
| 138 | + for(i=1;i<=nCoeffs;i++) { | |
| 139 | + int j= s->intra_scantable.permutated[i]; | |
| 140 | + level = block[j]; | |
| 141 | + if (level) { | |
| 142 | + if (level < 0) { | |
| 143 | + level = -level; | |
| 144 | + level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 145 | + level = -level; | |
| 146 | + } else { | |
| 147 | + level = (int)(level * qscale * quant_matrix[j]) >> 4; | |
| 148 | + } | |
| 149 | + block[j] = level; | |
| 150 | + sum+=level; | |
| 151 | + } | |
| 152 | + } | |
| 153 | + block[63]^=sum&1; | |
| 154 | +} | |
| 155 | + | |
| 156 | +static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s, | |
| 157 | + int16_t *block, int n, int qscale) | |
| 158 | +{ | |
| 159 | + int i, level, nCoeffs; | |
| 160 | + const uint16_t *quant_matrix; | |
| 161 | + int sum=-1; | |
| 162 | + | |
| 163 | + if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; | |
| 164 | + else qscale <<= 1; | |
| 165 | + | |
| 166 | + nCoeffs= s->block_last_index[n]; | |
| 167 | + | |
| 168 | + quant_matrix = s->inter_matrix; | |
| 169 | + for(i=0; i<=nCoeffs; i++) { | |
| 170 | + int j= s->intra_scantable.permutated[i]; | |
| 171 | + level = block[j]; | |
| 172 | + if (level) { | |
| 173 | + if (level < 0) { | |
| 174 | + level = -level; | |
| 175 | + level = (((level << 1) + 1) * qscale * | |
| 176 | + ((int) (quant_matrix[j]))) >> 5; | |
| 177 | + level = -level; | |
| 178 | + } else { | |
| 179 | + level = (((level << 1) + 1) * qscale * | |
| 180 | + ((int) (quant_matrix[j]))) >> 5; | |
| 181 | + } | |
| 182 | + block[j] = level; | |
| 183 | + sum+=level; | |
| 184 | + } | |
| 185 | + } | |
| 186 | + block[63]^=sum&1; | |
| 187 | +} | |
| 188 | + | |
| 189 | +static void dct_unquantize_h263_intra_c(MpegEncContext *s, | |
| 190 | + int16_t *block, int n, int qscale) | |
| 191 | +{ | |
| 192 | + int i, level, qmul, qadd; | |
| 193 | + int nCoeffs; | |
| 194 | + | |
| 195 | + av_assert2(s->block_last_index[n]>=0 || s->h263_aic); | |
| 196 | + | |
| 197 | + qmul = qscale << 1; | |
| 198 | + | |
| 199 | + if (!s->h263_aic) { | |
| 200 | + block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; | |
| 201 | + qadd = (qscale - 1) | 1; | |
| 202 | + }else{ | |
| 203 | + qadd = 0; | |
| 204 | + } | |
| 205 | + if(s->ac_pred) | |
| 206 | + nCoeffs=63; | |
| 207 | + else | |
| 208 | + nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; | |
| 209 | + | |
| 210 | + for(i=1; i<=nCoeffs; i++) { | |
| 211 | + level = block[i]; | |
| 212 | + if (level) { | |
| 213 | + if (level < 0) { | |
| 214 | + level = level * qmul - qadd; | |
| 215 | + } else { | |
| 216 | + level = level * qmul + qadd; | |
| 217 | + } | |
| 218 | + block[i] = level; | |
| 219 | + } | |
| 220 | + } | |
| 221 | +} | |
| 222 | + | |
| 223 | +static void dct_unquantize_h263_inter_c(MpegEncContext *s, | |
| 224 | + int16_t *block, int n, int qscale) | |
| 225 | +{ | |
| 226 | + int i, level, qmul, qadd; | |
| 227 | + int nCoeffs; | |
| 228 | + | |
| 229 | + av_assert2(s->block_last_index[n]>=0); | |
| 230 | + | |
| 231 | + qadd = (qscale - 1) | 1; | |
| 232 | + qmul = qscale << 1; | |
| 233 | + | |
| 234 | + nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ]; | |
| 235 | + | |
| 236 | + for(i=0; i<=nCoeffs; i++) { | |
| 237 | + level = block[i]; | |
| 238 | + if (level) { | |
| 239 | + if (level < 0) { | |
| 240 | + level = level * qmul - qadd; | |
| 241 | + } else { | |
| 242 | + level = level * qmul + qadd; | |
| 243 | + } | |
| 244 | + block[i] = level; | |
| 245 | + } | |
| 246 | + } | |
| 247 | +} | |
| 248 | + | |
| 249 | +av_cold void ff_mpv_unquantize_init(MpegEncContext *s) | |
| 250 | +{ | |
| 251 | + s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; | |
| 252 | + s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; | |
| 253 | + s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; | |
| 254 | + s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; | |
| 255 | + s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; | |
| 256 | + if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT) | |
| 257 | + s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; | |
| 258 | + s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; | |
| 259 | + | |
| 260 | +#if HAVE_INTRINSICS_NEON | |
| 261 | + ff_mpv_common_init_neon(s); | |
| 262 | +#endif | |
| 263 | + | |
| 264 | +#if ARCH_ARM | |
| 265 | + ff_mpv_common_init_arm(s); | |
| 266 | +#elif ARCH_PPC | |
| 267 | + ff_mpv_common_init_ppc(s); | |
| 268 | +#elif ARCH_X86 | |
| 269 | + ff_mpv_common_init_x86(s); | |
| 270 | +#elif ARCH_MIPS | |
| 271 | + ff_mpv_common_init_mips(s); | |
| 272 | +#endif | |
| 273 | +} | |
| @@ -0,0 +1,37 @@ | ||
| 1 | +/* | |
| 2 | + * Unquantize functions for mpegvideo | |
| 3 | + * Copyright (c) 2000,2001 Fabrice Bellard | |
| 4 | + * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | |
| 5 | + * | |
| 6 | + * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at> | |
| 7 | + * | |
| 8 | + * This file is part of FFmpeg. | |
| 9 | + * | |
| 10 | + * FFmpeg is free software; you can redistribute it and/or | |
| 11 | + * modify it under the terms of the GNU Lesser General Public | |
| 12 | + * License as published by the Free Software Foundation; either | |
| 13 | + * version 2.1 of the License, or (at your option) any later version. | |
| 14 | + * | |
| 15 | + * FFmpeg is distributed in the hope that it will be useful, | |
| 16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 18 | + * Lesser General Public License for more details. | |
| 19 | + * | |
| 20 | + * You should have received a copy of the GNU Lesser General Public | |
| 21 | + * License along with FFmpeg; if not, write to the Free Software | |
| 22 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 23 | + */ | |
| 24 | + | |
| 25 | +#ifndef AVCODEC_MPEGVIDEO_UNQUANTIZE_H | |
| 26 | +#define AVCODEC_MPEGVIDEO_UNQUANTIZE_H | |
| 27 | + | |
| 28 | +typedef struct MpegEncContext MpegEncContext; | |
| 29 | + | |
| 30 | +void ff_mpv_unquantize_init(MpegEncContext *s); | |
| 31 | +void ff_mpv_common_init_arm(MpegEncContext *s); | |
| 32 | +void ff_mpv_common_init_neon(MpegEncContext *s); | |
| 33 | +void ff_mpv_common_init_ppc(MpegEncContext *s); | |
| 34 | +void ff_mpv_common_init_x86(MpegEncContext *s); | |
| 35 | +void ff_mpv_common_init_mips(MpegEncContext *s); | |
| 36 | + | |
| 37 | +#endif /* AVCODEC_MPEGVIDEO_UNQUANTIZE_H */ | |
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | 34 | #include "libavcodec/mpegvideo.h" |
| 35 | +#include "libavcodec/mpegvideo_unquantize.h" | |
| 35 | 36 | |
| 36 | 37 | static void inline ff_dct_unquantize_h263_neon(int qscale, int qadd, int nCoeffs, |
| 37 | 38 | int16_t *block) |
| @@ -33,6 +33,7 @@ · 32 unmodified lines | ||
| 33 | 33 | #include "libavutil/ppc/util_altivec.h" |
| 34 | 34 | |
| 35 | 35 | #include "libavcodec/mpegvideo.h" |
| 36 | +#include "libavcodec/mpegvideo_unquantize.h" | |
| 36 | 37 | |
| 37 | 38 | #if HAVE_ALTIVEC |
| 38 | 39 | |
| @@ -26,6 +26,7 @@ · 25 unmodified lines | ||
| 26 | 26 | #include "libavcodec/avcodec.h" |
| 27 | 27 | #include "libavcodec/mpegvideo.h" |
| 28 | 28 | #include "libavcodec/mpegvideodata.h" |
| 29 | +#include "libavcodec/mpegvideo_unquantize.h" | |
| 29 | 30 | |
| 30 | 31 | #if HAVE_MMX_INLINE |
| 31 | 32 | |