diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index eaedd7f8f5..25813e7adf 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -22,3 +22,4 @@ OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_init_mips.o OBJS-$(CONFIG_H264DSP) += mips/h264dsp_init_mips.o MSA-OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_msa.o MSA-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_msa.o +LOONGSON3-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o diff --git a/libavcodec/mips/h264dsp_init_mips.c b/libavcodec/mips/h264dsp_init_mips.c index 8d3d76085f..d9182f28a5 100644 --- a/libavcodec/mips/h264dsp_init_mips.c +++ b/libavcodec/mips/h264dsp_init_mips.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 Parag Salasakar (Parag.Salasakar@imgtec.com) + * Copyright (c) 2015 Zhou Xiaoyong * * This file is part of FFmpeg. * @@ -65,10 +66,30 @@ static av_cold void h264dsp_init_msa(H264DSPContext *c, } #endif // #if HAVE_MSA +#if HAVE_LOONGSON3 +static av_cold void h264dsp_init_mmi(H264DSPContext * c, + const int bit_depth, + const int chroma_format_idc) +{ + if (bit_depth == 8) { + c->weight_h264_pixels_tab[0] = ff_h264_weight_pixels16_8_mmi; + c->weight_h264_pixels_tab[1] = ff_h264_weight_pixels8_8_mmi; + c->weight_h264_pixels_tab[2] = ff_h264_weight_pixels4_8_mmi; + + c->biweight_h264_pixels_tab[0] = ff_h264_biweight_pixels16_8_mmi; + c->biweight_h264_pixels_tab[1] = ff_h264_biweight_pixels8_8_mmi; + c->biweight_h264_pixels_tab[2] = ff_h264_biweight_pixels4_8_mmi; + } +} +#endif /* HAVE_LOONGSON3 */ + av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { #if HAVE_MSA h264dsp_init_msa(c, bit_depth, chroma_format_idc); #endif // #if HAVE_MSA +#if HAVE_LOONGSON3 + h264dsp_init_mmi(c, bit_depth, chroma_format_idc); +#endif /* HAVE_LOONGSON3 */ } diff --git a/libavcodec/mips/h264dsp_mips.h b/libavcodec/mips/h264dsp_mips.h index df9b0b29d7..319f6d3bbd 100644 --- a/libavcodec/mips/h264dsp_mips.h +++ b/libavcodec/mips/h264dsp_mips.h @@ -68,4 +68,20 @@ void ff_weight_h264_pixels8_8_msa(uint8_t *src, int stride, int height, void ff_weight_h264_pixels4_8_msa(uint8_t *src, int stride, int height, int log2_denom, int weight, int offset); +void ff_h264_weight_pixels16_8_mmi(uint8_t *block, int stride, int height, + int log2_denom, int weight, int offset); +void ff_h264_biweight_pixels16_8_mmi(uint8_t *dst, uint8_t *src, + int stride, int height, int log2_denom, int weightd, int weights, + int offset); +void ff_h264_weight_pixels8_8_mmi(uint8_t *block, int stride, int height, + int log2_denom, int weight, int offset); +void ff_h264_biweight_pixels8_8_mmi(uint8_t *dst, uint8_t *src, + int stride, int height, int log2_denom, int weightd, int weights, + int offset); +void ff_h264_weight_pixels4_8_mmi(uint8_t *block, int stride, int height, + int log2_denom, int weight, int offset); +void ff_h264_biweight_pixels4_8_mmi(uint8_t *dst, uint8_t *src, + int stride, int height, int log2_denom, int weightd, int weights, + int offset); + #endif // #ifndef H264_DSP_MIPS_H diff --git a/libavcodec/mips/h264dsp_mmi.c b/libavcodec/mips/h264dsp_mmi.c new file mode 100644 index 0000000000..641cd2f483 --- /dev/null +++ b/libavcodec/mips/h264dsp_mmi.c @@ -0,0 +1,278 @@ +/* + * Loongson SIMD optimized h264dsp + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * Zhang Shuangshuang + * + * 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 "libavcodec/bit_depth_template.c" +#include "h264dsp_mips.h" + +void ff_h264_weight_pixels16_8_mmi(uint8_t *block, int stride, + int height, int log2_denom, int weight, int offset) +{ + int y; + + offset <<= log2_denom; + + if (log2_denom) + offset += 1 << (log2_denom - 1); + + for (y=0; y