12c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent/* 22c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * Copyright (C) 2004-2010 NXP Software 32c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * Copyright (C) 2010 The Android Open Source Project 42c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * 52c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 62c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * you may not use this file except in compliance with the License. 72c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * You may obtain a copy of the License at 82c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * 92c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * http://www.apache.org/licenses/LICENSE-2.0 102c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * 112c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * Unless required by applicable law or agreed to in writing, software 122c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 132c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 142c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * See the License for the specific language governing permissions and 152c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent * limitations under the License. 162c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent */ 172c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 182c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent/********************************************************************************** 192c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent INCLUDE FILES 202c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent***********************************************************************************/ 212c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 222c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent#include "VectorArithmetic.h" 232c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 242c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent/********************************************************************************** 252c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent FUNCTION INT32RSHIFTTOINT16_SAT_32X16 262c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent***********************************************************************************/ 272c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 282c87e9c923b0362fabf8c97ff63997542394c428Eric Laurentvoid Int32RShiftToInt16_Sat_32x16(const LVM_INT32 *src, 292c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent LVM_INT16 *dst, 302c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent LVM_INT16 n, 312c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent LVM_INT16 shift ) 322c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent{ 332c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent LVM_INT32 temp; 342c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent LVM_INT16 ii; 352c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 362c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent for (ii = n; ii != 0; ii--) 372c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent { 382c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent temp = *src >> shift; 392c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent src++; 402c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 412c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent if (temp > 0x00007FFF) 422c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent { 432c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent *dst = 0x7FFF; 442c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent } 452c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent else if (temp < -0x00008000) 462c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent { 472c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent *dst = - 0x8000; 482c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent } 492c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent else 502c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent { 512c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent *dst = (LVM_INT16)temp; 522c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent } 532c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 542c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent dst++; 552c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent } 562c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 572c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent return; 582c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent} 592c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent 602c87e9c923b0362fabf8c97ff63997542394c428Eric Laurent/**********************************************************************************/ 61