1c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org/* 2c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * 4c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * Use of this source code is governed by a BSD-style license 5c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * that can be found in the LICENSE file in the root of the source 6c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * tree. An additional intellectual property rights grant can be found 7c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * in the file PATENTS. All contributing project authors may 8c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * be found in the AUTHORS file in the root of the source tree. 9c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org */ 10c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org 11c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org 12c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org/* 13c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * This file contains implementations of the functions 14c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org * WebRtcSpl_ScaleAndAddVectorsWithRound_mips() 15c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org */ 16c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org 17c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org#include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" 18c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org 19c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.orgint WebRtcSpl_ScaleAndAddVectorsWithRound_mips(const int16_t* in_vector1, 20c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t in_vector1_scale, 21c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org const int16_t* in_vector2, 22c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t in_vector2_scale, 23c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int right_shifts, 24c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t* out_vector, 25c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int length) { 26c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t r0 = 0, r1 = 0; 27c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t *in1 = (int16_t*)in_vector1; 28c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t *in2 = (int16_t*)in_vector2; 29c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int16_t *out = out_vector; 30c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org int i = 0, value32 = 0; 31c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org 32c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org if (in_vector1 == NULL || in_vector2 == NULL || out_vector == NULL || 33c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org length <= 0 || right_shifts < 0) { 34c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org return -1; 35c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org } 36c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org for (i = 0; i < length; i++) { 37c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org __asm __volatile ( 38c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "lh %[r0], 0(%[in1]) \n\t" 39c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "lh %[r1], 0(%[in2]) \n\t" 40c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "mult %[r0], %[in_vector1_scale] \n\t" 41c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "madd %[r1], %[in_vector2_scale] \n\t" 42c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "extrv_r.w %[value32], $ac0, %[right_shifts] \n\t" 43c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "addiu %[in1], %[in1], 2 \n\t" 44c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "addiu %[in2], %[in2], 2 \n\t" 45c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "sh %[value32], 0(%[out]) \n\t" 46c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org "addiu %[out], %[out], 2 \n\t" 47c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org : [value32] "=&r" (value32), [out] "+r" (out), [in1] "+r" (in1), 48c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org [in2] "+r" (in2), [r0] "=&r" (r0), [r1] "=&r" (r1) 49c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org : [in_vector1_scale] "r" (in_vector1_scale), 50c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org [in_vector2_scale] "r" (in_vector2_scale), 51c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org [right_shifts] "r" (right_shifts) 52c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org : "hi", "lo", "memory" 53c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org ); 54c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org } 55c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org return 0; 56c61a170086121bb18950bc478c9fc71175d32db8andrew@webrtc.org} 57