michael@0: // Copyright (c) 2010 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: #include michael@0: #include "yuv_row.h" michael@0: michael@0: namespace mozilla { michael@0: namespace gfx { michael@0: michael@0: // FilterRows combines two rows of the image using linear interpolation. michael@0: // MMX version does 8 pixels at a time. michael@0: void FilterRows_MMX(uint8* ybuf, const uint8* y0_ptr, const uint8* y1_ptr, michael@0: int source_width, int source_y_fraction) { michael@0: __m64 zero = _mm_setzero_si64(); michael@0: __m64 y1_fraction = _mm_set1_pi16(source_y_fraction); michael@0: __m64 y0_fraction = _mm_set1_pi16(256 - source_y_fraction); michael@0: michael@0: const __m64* y0_ptr64 = reinterpret_cast(y0_ptr); michael@0: const __m64* y1_ptr64 = reinterpret_cast(y1_ptr); michael@0: __m64* dest64 = reinterpret_cast<__m64*>(ybuf); michael@0: __m64* end64 = reinterpret_cast<__m64*>(ybuf + source_width); michael@0: michael@0: do { michael@0: __m64 y0 = *y0_ptr64++; michael@0: __m64 y1 = *y1_ptr64++; michael@0: __m64 y2 = _mm_unpackhi_pi8(y0, zero); michael@0: __m64 y3 = _mm_unpackhi_pi8(y1, zero); michael@0: y0 = _mm_unpacklo_pi8(y0, zero); michael@0: y1 = _mm_unpacklo_pi8(y1, zero); michael@0: y0 = _mm_mullo_pi16(y0, y0_fraction); michael@0: y1 = _mm_mullo_pi16(y1, y1_fraction); michael@0: y2 = _mm_mullo_pi16(y2, y0_fraction); michael@0: y3 = _mm_mullo_pi16(y3, y1_fraction); michael@0: y0 = _mm_add_pi16(y0, y1); michael@0: y2 = _mm_add_pi16(y2, y3); michael@0: y0 = _mm_srli_pi16(y0, 8); michael@0: y2 = _mm_srli_pi16(y2, 8); michael@0: y0 = _mm_packs_pu16(y0, y2); michael@0: *dest64++ = y0; michael@0: } while (dest64 < end64); michael@0: } michael@0: michael@0: } michael@0: }