yading@10: /* yading@10: * VC-1 and WMV3 - DSP functions MMX-optimized yading@10: * Copyright (c) 2007 Christophe GISQUET yading@10: * yading@10: * Permission is hereby granted, free of charge, to any person yading@10: * obtaining a copy of this software and associated documentation yading@10: * files (the "Software"), to deal in the Software without yading@10: * restriction, including without limitation the rights to use, yading@10: * copy, modify, merge, publish, distribute, sublicense, and/or sell yading@10: * copies of the Software, and to permit persons to whom the yading@10: * Software is furnished to do so, subject to the following yading@10: * conditions: yading@10: * yading@10: * The above copyright notice and this permission notice shall be yading@10: * included in all copies or substantial portions of the Software. yading@10: * yading@10: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, yading@10: * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES yading@10: * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND yading@10: * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT yading@10: * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, yading@10: * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING yading@10: * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR yading@10: * OTHER DEALINGS IN THE SOFTWARE. yading@10: */ yading@10: yading@10: #include "libavutil/cpu.h" yading@10: #include "libavutil/x86/cpu.h" yading@10: #include "libavcodec/vc1dsp.h" yading@10: #include "dsputil_mmx.h" yading@10: #include "vc1dsp.h" yading@10: #include "config.h" yading@10: yading@10: #define LOOP_FILTER(EXT) \ yading@10: void ff_vc1_v_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ yading@10: void ff_vc1_h_loop_filter4_ ## EXT(uint8_t *src, int stride, int pq); \ yading@10: void ff_vc1_v_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \ yading@10: void ff_vc1_h_loop_filter8_ ## EXT(uint8_t *src, int stride, int pq); \ yading@10: \ yading@10: static void vc1_v_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \ yading@10: { \ yading@10: ff_vc1_v_loop_filter8_ ## EXT(src, stride, pq); \ yading@10: ff_vc1_v_loop_filter8_ ## EXT(src+8, stride, pq); \ yading@10: } \ yading@10: \ yading@10: static void vc1_h_loop_filter16_ ## EXT(uint8_t *src, int stride, int pq) \ yading@10: { \ yading@10: ff_vc1_h_loop_filter8_ ## EXT(src, stride, pq); \ yading@10: ff_vc1_h_loop_filter8_ ## EXT(src+8*stride, stride, pq); \ yading@10: } yading@10: yading@10: #if HAVE_YASM yading@10: LOOP_FILTER(mmxext) yading@10: LOOP_FILTER(sse2) yading@10: LOOP_FILTER(ssse3) yading@10: yading@10: void ff_vc1_h_loop_filter8_sse4(uint8_t *src, int stride, int pq); yading@10: yading@10: static void vc1_h_loop_filter16_sse4(uint8_t *src, int stride, int pq) yading@10: { yading@10: ff_vc1_h_loop_filter8_sse4(src, stride, pq); yading@10: ff_vc1_h_loop_filter8_sse4(src+8*stride, stride, pq); yading@10: } yading@10: yading@10: static void avg_vc1_mspel_mc00_mmxext(uint8_t *dst, const uint8_t *src, yading@10: ptrdiff_t stride, int rnd) yading@10: { yading@10: ff_avg_pixels8_mmxext(dst, src, stride, 8); yading@10: } yading@10: #endif /* HAVE_YASM */ yading@10: yading@10: void ff_put_vc1_chroma_mc8_nornd_mmx (uint8_t *dst, uint8_t *src, yading@10: int stride, int h, int x, int y); yading@10: void ff_avg_vc1_chroma_mc8_nornd_mmxext(uint8_t *dst, uint8_t *src, yading@10: int stride, int h, int x, int y); yading@10: void ff_avg_vc1_chroma_mc8_nornd_3dnow(uint8_t *dst, uint8_t *src, yading@10: int stride, int h, int x, int y); yading@10: void ff_put_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src, yading@10: int stride, int h, int x, int y); yading@10: void ff_avg_vc1_chroma_mc8_nornd_ssse3(uint8_t *dst, uint8_t *src, yading@10: int stride, int h, int x, int y); yading@10: yading@10: yading@10: av_cold void ff_vc1dsp_init_x86(VC1DSPContext *dsp) yading@10: { yading@10: int mm_flags = av_get_cpu_flags(); yading@10: yading@10: if (INLINE_MMX(mm_flags)) yading@10: ff_vc1dsp_init_mmx(dsp); yading@10: yading@10: if (INLINE_MMXEXT(mm_flags)) yading@10: ff_vc1dsp_init_mmxext(dsp); yading@10: yading@10: #define ASSIGN_LF(EXT) \ yading@10: dsp->vc1_v_loop_filter4 = ff_vc1_v_loop_filter4_ ## EXT; \ yading@10: dsp->vc1_h_loop_filter4 = ff_vc1_h_loop_filter4_ ## EXT; \ yading@10: dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_ ## EXT; \ yading@10: dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_ ## EXT; \ yading@10: dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_ ## EXT; \ yading@10: dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_ ## EXT yading@10: yading@10: #if HAVE_YASM yading@10: if (mm_flags & AV_CPU_FLAG_MMX) { yading@10: dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_mmx; yading@10: } yading@10: yading@10: if (mm_flags & AV_CPU_FLAG_MMXEXT) { yading@10: ASSIGN_LF(mmxext); yading@10: dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_mmxext; yading@10: yading@10: dsp->avg_vc1_mspel_pixels_tab[0] = avg_vc1_mspel_mc00_mmxext; yading@10: } else if (mm_flags & AV_CPU_FLAG_3DNOW) { yading@10: dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_3dnow; yading@10: } yading@10: yading@10: if (mm_flags & AV_CPU_FLAG_SSE2) { yading@10: dsp->vc1_v_loop_filter8 = ff_vc1_v_loop_filter8_sse2; yading@10: dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse2; yading@10: dsp->vc1_v_loop_filter16 = vc1_v_loop_filter16_sse2; yading@10: dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse2; yading@10: } yading@10: if (mm_flags & AV_CPU_FLAG_SSSE3) { yading@10: ASSIGN_LF(ssse3); yading@10: dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = ff_put_vc1_chroma_mc8_nornd_ssse3; yading@10: dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = ff_avg_vc1_chroma_mc8_nornd_ssse3; yading@10: } yading@10: if (mm_flags & AV_CPU_FLAG_SSE4) { yading@10: dsp->vc1_h_loop_filter8 = ff_vc1_h_loop_filter8_sse4; yading@10: dsp->vc1_h_loop_filter16 = vc1_h_loop_filter16_sse4; yading@10: } yading@10: #endif /* HAVE_YASM */ yading@10: }