- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
dsputil_iwmmxt.c
资源名称:tcpmp.rar [点击查看]
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:8k
源码类别:
Windows CE
开发平台:
C/C++
- /*
- * iWMMXt optimized DSP utils
- * Copyright (c) 2004 AGAWA Koji
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #include "../dsputil.h"
- #define DEF(x, y) x ## _no_rnd_ ## y ##_iwmmxt
- #define SET_RND(regd) __asm__ __volatile__ ("mov r12, #1 nt tbcsth " #regd ", r12":::"r12");
- #define WAVG2B "wavg2b"
- #include "dsputil_iwmmxt_rnd.h"
- #undef DEF
- #undef SET_RND
- #undef WAVG2B
- #define DEF(x, y) x ## _ ## y ##_iwmmxt
- #define SET_RND(regd) __asm__ __volatile__ ("mov r12, #2 nt tbcsth " #regd ", r12":::"r12");
- #define WAVG2B "wavg2br"
- #include "dsputil_iwmmxt_rnd.h"
- #undef DEF
- #undef SET_RND
- #undef WAVG2BR
- // need scheduling
- #define OP(AVG)
- asm volatile (
- /* alignment */
- "and r12, %[pixels], #7 nt"
- "bic %[pixels], %[pixels], #7 nt"
- "tmcr wcgr1, r12 nt"
- "wldrd wr0, [%[pixels]] nt"
- "wldrd wr1, [%[pixels], #8] nt"
- "add %[pixels], %[pixels], %[line_size] nt"
- "walignr1 wr4, wr0, wr1 nt"
- "1: nt"
- "wldrd wr2, [%[pixels]] nt"
- "wldrd wr3, [%[pixels], #8] nt"
- "add %[pixels], %[pixels], %[line_size] nt"
- "pld [%[pixels]] nt"
- "walignr1 wr5, wr2, wr3 nt"
- AVG " wr6, wr4, wr5 nt"
- "wstrd wr6, [%[block]] nt"
- "add %[block], %[block], %[line_size] nt"
- "wldrd wr0, [%[pixels]] nt"
- "wldrd wr1, [%[pixels], #8] nt"
- "add %[pixels], %[pixels], %[line_size] nt"
- "walignr1 wr4, wr0, wr1 nt"
- "pld [%[pixels]] nt"
- AVG " wr6, wr4, wr5 nt"
- "wstrd wr6, [%[block]] nt"
- "add %[block], %[block], %[line_size] nt"
- "subs %[h], %[h], #2 nt"
- "bne 1b nt"
- : [block]"+r"(block), [pixels]"+r"(pixels), [h]"+r"(h)
- : [line_size]"r"(line_size)
- : "memory", "r12");
- void put_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
- {
- OP("wavg2br");
- }
- void put_no_rnd_pixels8_y2_iwmmxt(uint8_t *block, const uint8_t *pixels, const int line_size, int h)
- {
- OP("wavg2b");
- }
- #undef OP
- void add_pixels_clamped_iwmmxt(const DCTELEM *block, uint8_t *pixels, int line_size)
- {
- uint8_t *pixels2 = pixels + line_size;
- __asm__ __volatile__ (
- "mov r12, #4 nt"
- "1: nt"
- "pld [%[pixels], %[line_size2]] nt"
- "pld [%[pixels2], %[line_size2]] nt"
- "wldrd wr4, [%[pixels]] nt"
- "wldrd wr5, [%[pixels2]] nt"
- "pld [%[block], #32] nt"
- "wunpckelub wr6, wr4 nt"
- "wldrd wr0, [%[block]] nt"
- "wunpckehub wr7, wr4 nt"
- "wldrd wr1, [%[block], #8] nt"
- "wunpckelub wr8, wr5 nt"
- "wldrd wr2, [%[block], #16] nt"
- "wunpckehub wr9, wr5 nt"
- "wldrd wr3, [%[block], #24] nt"
- "add %[block], %[block], #32 nt"
- "waddhss wr10, wr0, wr6 nt"
- "waddhss wr11, wr1, wr7 nt"
- "waddhss wr12, wr2, wr8 nt"
- "waddhss wr13, wr3, wr9 nt"
- "wpackhus wr14, wr10, wr11 nt"
- "wpackhus wr15, wr12, wr13 nt"
- "wstrd wr14, [%[pixels]] nt"
- "add %[pixels], %[pixels], %[line_size2] nt"
- "subs r12, r12, #1 nt"
- "wstrd wr15, [%[pixels2]] nt"
- "add %[pixels2], %[pixels2], %[line_size2] nt"
- "bne 1b nt"
- : [block]"+r"(block), [pixels]"+r"(pixels), [pixels2]"+r"(pixels2)
- : [line_size2]"r"(line_size << 1)
- : "cc", "memory", "r12");
- }
- static void nop(uint8_t *block, const uint8_t *pixels, int line_size, int h)
- {
- return;
- }
- int mm_flags; /* multimedia extension flags */
- int mm_support(void)
- {
- return 0; /* TODO, implement proper detection */
- }
- void dsputil_init_iwmmxt(DSPContext* c, AVCodecContext *avctx)
- {
- mm_flags = mm_support();
- if (avctx->dsp_mask) {
- if (avctx->dsp_mask & FF_MM_FORCE)
- mm_flags |= (avctx->dsp_mask & 0xffff);
- else
- mm_flags &= ~(avctx->dsp_mask & 0xffff);
- }
- if (!(mm_flags & MM_IWMMXT)) return;
- c->add_pixels_clamped = add_pixels_clamped_iwmmxt;
- c->put_pixels_tab[0][0] = put_pixels16_iwmmxt;
- c->put_pixels_tab[0][1] = put_pixels16_x2_iwmmxt;
- c->put_pixels_tab[0][2] = put_pixels16_y2_iwmmxt;
- c->put_pixels_tab[0][3] = put_pixels16_xy2_iwmmxt;
- c->put_no_rnd_pixels_tab[0][0] = put_pixels16_iwmmxt;
- c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_iwmmxt;
- c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_iwmmxt;
- c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_iwmmxt;
- c->put_pixels_tab[1][0] = put_pixels8_iwmmxt;
- c->put_pixels_tab[1][1] = put_pixels8_x2_iwmmxt;
- c->put_pixels_tab[1][2] = put_pixels8_y2_iwmmxt;
- c->put_pixels_tab[1][3] = put_pixels8_xy2_iwmmxt;
- c->put_no_rnd_pixels_tab[1][0] = put_pixels8_iwmmxt;
- c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_iwmmxt;
- c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_iwmmxt;
- c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_iwmmxt;
- c->avg_pixels_tab[0][0] = avg_pixels16_iwmmxt;
- c->avg_pixels_tab[0][1] = avg_pixels16_x2_iwmmxt;
- c->avg_pixels_tab[0][2] = avg_pixels16_y2_iwmmxt;
- c->avg_pixels_tab[0][3] = avg_pixels16_xy2_iwmmxt;
- c->avg_no_rnd_pixels_tab[0][0] = avg_pixels16_iwmmxt;
- c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_iwmmxt;
- c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_iwmmxt;
- c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_iwmmxt;
- c->avg_pixels_tab[1][0] = avg_pixels8_iwmmxt;
- c->avg_pixels_tab[1][1] = avg_pixels8_x2_iwmmxt;
- c->avg_pixels_tab[1][2] = avg_pixels8_y2_iwmmxt;
- c->avg_pixels_tab[1][3] = avg_pixels8_xy2_iwmmxt;
- c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_iwmmxt;
- c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_iwmmxt;
- c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_iwmmxt;
- c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_iwmmxt;
- }