avcodec/mips/mpegvideo: Set denoise_dct only for encoder
The C version is set in ff_dct_encode_init(), yet the MIPS version is set in dct_init() (in ff_mpv_common_init() and therefore also for decoders). This commit fixes this inconsistency. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
adb1521385
commit
8327828205
@ -31,7 +31,8 @@ OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_init_mips.o
|
||||
OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_init_mips.o
|
||||
OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_init_mips.o
|
||||
OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_init_mips.o
|
||||
OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_init_mips.o
|
||||
OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoenc_init_mips.o \
|
||||
mips/mpegvideoencdsp_init_mips.o
|
||||
OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_init_mips.o
|
||||
OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvididct_init_mips.o
|
||||
OBJS-$(CONFIG_VC1DSP) += mips/vc1dsp_init_mips.o
|
||||
@ -76,6 +77,7 @@ MMI-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o
|
||||
MMI-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o
|
||||
MMI-OBJS-$(CONFIG_H264PRED) += mips/h264pred_mmi.o
|
||||
MMI-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_mmi.o
|
||||
MMI-OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoenc_mmi.o
|
||||
MMI-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_mmi.o \
|
||||
mips/simple_idct_mmi.o
|
||||
MMI-OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvid_idct_mmi.o
|
||||
|
@ -36,8 +36,6 @@ av_cold void ff_mpv_common_init_mips(MpegEncContext *s)
|
||||
if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT))
|
||||
if (!s->q_scale_type)
|
||||
s->dct_unquantize_mpeg2_intra = ff_dct_unquantize_mpeg2_intra_mmi;
|
||||
|
||||
s->denoise_dct= ff_denoise_dct_mmi;
|
||||
}
|
||||
|
||||
if (have_msa(cpu_flags)) {
|
||||
|
@ -434,75 +434,3 @@ void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block,
|
||||
|
||||
block[0]= block0;
|
||||
}
|
||||
|
||||
void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block)
|
||||
{
|
||||
const int intra = s->mb_intra;
|
||||
int *sum = s->dct_error_sum[intra];
|
||||
uint16_t *offset = s->dct_offset[intra];
|
||||
double ftmp[8];
|
||||
mips_reg addr[1];
|
||||
DECLARE_VAR_ALL64;
|
||||
|
||||
s->dct_count[intra]++;
|
||||
|
||||
__asm__ volatile(
|
||||
"pxor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
|
||||
"1: \n\t"
|
||||
MMI_LDC1(%[ftmp1], %[block], 0x00)
|
||||
"pxor %[ftmp2], %[ftmp2], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp3], %[block], 0x08)
|
||||
"pxor %[ftmp4], %[ftmp4], %[ftmp4] \n\t"
|
||||
"pcmpgth %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp4], %[ftmp4], %[ftmp3] \n\t"
|
||||
"pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
"psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
MMI_LDC1(%[ftmp6], %[offset], 0x00)
|
||||
"mov.d %[ftmp5], %[ftmp1] \n\t"
|
||||
"psubush %[ftmp1], %[ftmp1], %[ftmp6] \n\t"
|
||||
MMI_LDC1(%[ftmp6], %[offset], 0x08)
|
||||
"mov.d %[ftmp7], %[ftmp3] \n\t"
|
||||
"psubush %[ftmp3], %[ftmp3], %[ftmp6] \n\t"
|
||||
"pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
"psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
MMI_SDC1(%[ftmp1], %[block], 0x00)
|
||||
MMI_SDC1(%[ftmp3], %[block], 0x08)
|
||||
"mov.d %[ftmp1], %[ftmp5] \n\t"
|
||||
"mov.d %[ftmp3], %[ftmp7] \n\t"
|
||||
"punpcklhw %[ftmp5], %[ftmp5], %[ftmp0] \n\t"
|
||||
"punpckhhw %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
|
||||
"punpcklhw %[ftmp7], %[ftmp7], %[ftmp0] \n\t"
|
||||
"punpckhhw %[ftmp3], %[ftmp3], %[ftmp0] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x00)
|
||||
"paddw %[ftmp5], %[ftmp5], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x08)
|
||||
"paddw %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x10)
|
||||
"paddw %[ftmp7], %[ftmp7], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x18)
|
||||
"paddw %[ftmp3], %[ftmp3], %[ftmp2] \n\t"
|
||||
MMI_SDC1(%[ftmp5], %[sum], 0x00)
|
||||
MMI_SDC1(%[ftmp1], %[sum], 0x08)
|
||||
MMI_SDC1(%[ftmp7], %[sum], 0x10)
|
||||
MMI_SDC1(%[ftmp3], %[sum], 0x18)
|
||||
PTR_ADDIU "%[block], %[block], 0x10 \n\t"
|
||||
PTR_ADDIU "%[sum], %[sum], 0x20 \n\t"
|
||||
PTR_SUBU "%[addr0], %[block1], %[block] \n\t"
|
||||
PTR_ADDIU "%[offset], %[offset], 0x10 \n\t"
|
||||
"bgtz %[addr0], 1b \n\t"
|
||||
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
|
||||
[ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]),
|
||||
[ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
|
||||
[ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]),
|
||||
RESTRICT_ASM_ALL64
|
||||
[addr0]"=&r"(addr[0]),
|
||||
[block]"+&r"(block), [sum]"+&r"(sum),
|
||||
[offset]"+&r"(offset)
|
||||
: [block1]"r"(block+64)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
33
libavcodec/mips/mpegvideoenc_init_mips.c
Normal file
33
libavcodec/mips/mpegvideoenc_init_mips.c
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com)
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "libavutil/attributes.h"
|
||||
#include "libavutil/mips/cpu.h"
|
||||
#include "libavcodec/mpegvideoenc.h"
|
||||
#include "mpegvideo_mips.h"
|
||||
|
||||
av_cold void ff_mpvenc_dct_init_mips(MpegEncContext *s)
|
||||
{
|
||||
int cpu_flags = av_get_cpu_flags();
|
||||
|
||||
if (have_mmi(cpu_flags)) {
|
||||
s->denoise_dct = ff_denoise_dct_mmi;
|
||||
}
|
||||
}
|
98
libavcodec/mips/mpegvideoenc_mmi.c
Normal file
98
libavcodec/mips/mpegvideoenc_mmi.c
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Loongson SIMD optimized mpegvideo
|
||||
*
|
||||
* Copyright (c) 2015 Loongson Technology Corporation Limited
|
||||
* Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
|
||||
* Zhang Shuangshuang <zhangshuangshuang@ict.ac.cn>
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* FFmpeg is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with FFmpeg; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "mpegvideo_mips.h"
|
||||
#include "libavutil/mips/mmiutils.h"
|
||||
|
||||
void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block)
|
||||
{
|
||||
const int intra = s->mb_intra;
|
||||
int *sum = s->dct_error_sum[intra];
|
||||
uint16_t *offset = s->dct_offset[intra];
|
||||
double ftmp[8];
|
||||
mips_reg addr[1];
|
||||
DECLARE_VAR_ALL64;
|
||||
|
||||
s->dct_count[intra]++;
|
||||
|
||||
__asm__ volatile(
|
||||
"pxor %[ftmp0], %[ftmp0], %[ftmp0] \n\t"
|
||||
"1: \n\t"
|
||||
MMI_LDC1(%[ftmp1], %[block], 0x00)
|
||||
"pxor %[ftmp2], %[ftmp2], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp3], %[block], 0x08)
|
||||
"pxor %[ftmp4], %[ftmp4], %[ftmp4] \n\t"
|
||||
"pcmpgth %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp4], %[ftmp4], %[ftmp3] \n\t"
|
||||
"pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
"psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
MMI_LDC1(%[ftmp6], %[offset], 0x00)
|
||||
"mov.d %[ftmp5], %[ftmp1] \n\t"
|
||||
"psubush %[ftmp1], %[ftmp1], %[ftmp6] \n\t"
|
||||
MMI_LDC1(%[ftmp6], %[offset], 0x08)
|
||||
"mov.d %[ftmp7], %[ftmp3] \n\t"
|
||||
"psubush %[ftmp3], %[ftmp3], %[ftmp6] \n\t"
|
||||
"pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
"psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t"
|
||||
MMI_SDC1(%[ftmp1], %[block], 0x00)
|
||||
MMI_SDC1(%[ftmp3], %[block], 0x08)
|
||||
"mov.d %[ftmp1], %[ftmp5] \n\t"
|
||||
"mov.d %[ftmp3], %[ftmp7] \n\t"
|
||||
"punpcklhw %[ftmp5], %[ftmp5], %[ftmp0] \n\t"
|
||||
"punpckhhw %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
|
||||
"punpcklhw %[ftmp7], %[ftmp7], %[ftmp0] \n\t"
|
||||
"punpckhhw %[ftmp3], %[ftmp3], %[ftmp0] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x00)
|
||||
"paddw %[ftmp5], %[ftmp5], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x08)
|
||||
"paddw %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x10)
|
||||
"paddw %[ftmp7], %[ftmp7], %[ftmp2] \n\t"
|
||||
MMI_LDC1(%[ftmp2], %[sum], 0x18)
|
||||
"paddw %[ftmp3], %[ftmp3], %[ftmp2] \n\t"
|
||||
MMI_SDC1(%[ftmp5], %[sum], 0x00)
|
||||
MMI_SDC1(%[ftmp1], %[sum], 0x08)
|
||||
MMI_SDC1(%[ftmp7], %[sum], 0x10)
|
||||
MMI_SDC1(%[ftmp3], %[sum], 0x18)
|
||||
PTR_ADDIU "%[block], %[block], 0x10 \n\t"
|
||||
PTR_ADDIU "%[sum], %[sum], 0x20 \n\t"
|
||||
PTR_SUBU "%[addr0], %[block1], %[block] \n\t"
|
||||
PTR_ADDIU "%[offset], %[offset], 0x10 \n\t"
|
||||
"bgtz %[addr0], 1b \n\t"
|
||||
: [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
|
||||
[ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]),
|
||||
[ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]),
|
||||
[ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]),
|
||||
RESTRICT_ASM_ALL64
|
||||
[addr0]"=&r"(addr[0]),
|
||||
[block]"+&r"(block), [sum]"+&r"(sum),
|
||||
[offset]"+&r"(offset)
|
||||
: [block1]"r"(block+64)
|
||||
: "memory"
|
||||
);
|
||||
}
|
@ -293,7 +293,9 @@ static void mpv_encode_defaults(MpegEncContext *s)
|
||||
|
||||
av_cold int ff_dct_encode_init(MpegEncContext *s)
|
||||
{
|
||||
#if ARCH_X86
|
||||
#if ARCH_MIPS
|
||||
ff_mpvenc_dct_init_mips(s);
|
||||
#elif ARCH_X86
|
||||
ff_dct_encode_init_x86(s);
|
||||
#endif
|
||||
|
||||
|
@ -146,6 +146,7 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s
|
||||
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
|
||||
|
||||
int ff_dct_encode_init(MpegEncContext *s);
|
||||
void ff_mpvenc_dct_init_mips(MpegEncContext *s);
|
||||
void ff_dct_encode_init_x86(MpegEncContext *s);
|
||||
|
||||
void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64],
|
||||
|
Loading…
Reference in New Issue
Block a user