Commit 3e35f8ef authored by 周晓勇's avatar 周晓勇 Committed by Michael Niedermayer

avcodec: loongson optimize pixblockdsp with mmi

Signed-off-by: 's avatarZhouXiaoyong <zhouxiaoyong@loongson.cn>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 6b2bb3d2
...@@ -68,3 +68,4 @@ MMI-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_mmi.o \ ...@@ -68,3 +68,4 @@ MMI-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_mmi.o \
mips/simple_idct_mmi.o mips/simple_idct_mmi.o
MMI-OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvid_idct_mmi.o MMI-OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvid_idct_mmi.o
MMI-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_mmi.o MMI-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_mmi.o
MMI-OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_mmi.o
/* /*
* Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
* Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
* *
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
...@@ -44,10 +45,25 @@ static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c, ...@@ -44,10 +45,25 @@ static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c,
} }
#endif // #if HAVE_MSA #endif // #if HAVE_MSA
#if HAVE_MMI
static av_cold void pixblockdsp_init_mmi(PixblockDSPContext *c,
AVCodecContext *avctx, unsigned high_bit_depth)
{
c->diff_pixels = ff_diff_pixels_mmi;
if (!high_bit_depth || avctx->codec_type != AVMEDIA_TYPE_VIDEO) {
c->get_pixels = ff_get_pixels_8_mmi;
}
}
#endif /* HAVE_MMI */
void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
unsigned high_bit_depth) unsigned high_bit_depth)
{ {
#if HAVE_MSA #if HAVE_MSA
pixblockdsp_init_msa(c, avctx, high_bit_depth); pixblockdsp_init_msa(c, avctx, high_bit_depth);
#endif // #if HAVE_MSA #endif // #if HAVE_MSA
#if HAVE_MMI
pixblockdsp_init_mmi(c, avctx, high_bit_depth);
#endif /* HAVE_MMI */
} }
/* /*
* Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com) * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
* Zhou Xiaoyong <zhouxiaoyong@loongson.cn>
* *
* This file is part of FFmpeg. * This file is part of FFmpeg.
* *
...@@ -30,4 +31,9 @@ void ff_get_pixels_16_msa(int16_t *restrict dst, const uint8_t *src, ...@@ -30,4 +31,9 @@ void ff_get_pixels_16_msa(int16_t *restrict dst, const uint8_t *src,
void ff_get_pixels_8_msa(int16_t *restrict dst, const uint8_t *src, void ff_get_pixels_8_msa(int16_t *restrict dst, const uint8_t *src,
ptrdiff_t stride); ptrdiff_t stride);
void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels,
ptrdiff_t line_size);
void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1,
const uint8_t *src2, int stride);
#endif // #ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H #endif // #ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H
/*
* Loongson SIMD optimized pixblockdsp
*
* Copyright (c) 2015 Loongson Technology Corporation Limited
* Copyright (c) 2015 Zhou Xiaoyong <zhouxiaoyong@loongson.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 "pixblockdsp_mips.h"
void ff_get_pixels_8_mmi(int16_t *av_restrict block, const uint8_t *pixels,
ptrdiff_t line_size)
{
__asm__ volatile (
"move $8, $0 \n\t"
"xor $f0, $f0, $f0 \n\t"
"1: \n\t"
"gsldlc1 $f2, 7(%1) \n\t"
"gsldrc1 $f2, 0(%1) \n\t"
"punpcklbh $f4, $f2, $f0 \n\t"
"punpckhbh $f6, $f2, $f0 \n\t"
"gssdxc1 $f4, 0(%0, $8) \n\t"
"gssdxc1 $f6, 8(%0, $8) \n\t"
"daddiu $8, $8, 16 \n\t"
"daddu %1, %1, %2 \n\t"
"daddi %3, %3, -1 \n\t"
"bnez %3, 1b \n\t"
::"r"((uint8_t *)block),"r"(pixels),"r"(line_size),"r"(8)
: "$8","memory"
);
}
void ff_diff_pixels_mmi(int16_t *av_restrict block, const uint8_t *src1,
const uint8_t *src2, int stride)
{
__asm__ volatile (
"dli $2, 8 \n\t"
"xor $f14, $f14, $f14 \n\t"
"1: \n\t"
"gsldlc1 $f0, 7(%1) \n\t"
"gsldrc1 $f0, 0(%1) \n\t"
"or $f2, $f0, $f0 \n\t"
"gsldlc1 $f4, 7(%2) \n\t"
"gsldrc1 $f4, 0(%2) \n\t"
"or $f6, $f4, $f4 \n\t"
"punpcklbh $f0, $f0, $f14 \n\t"
"punpckhbh $f2, $f2, $f14 \n\t"
"punpcklbh $f4, $f4, $f14 \n\t"
"punpckhbh $f6, $f6, $f14 \n\t"
"psubh $f0, $f0, $f4 \n\t"
"psubh $f2, $f2, $f6 \n\t"
"gssdlc1 $f0, 7(%0) \n\t"
"gssdrc1 $f0, 0(%0) \n\t"
"gssdlc1 $f2, 15(%0) \n\t"
"gssdrc1 $f2, 8(%0) \n\t"
"daddi %0, %0, 16 \n\t"
"daddu %1, %1, %3 \n\t"
"daddu %2, %2, %3 \n\t"
"daddi $2, $2, -1 \n\t"
"bgtz $2, 1b \n\t"
::"r"(block),"r"(src1),"r"(src2),"r"(stride)
: "$2","memory"
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment