Coverage Report

Created: 2025-07-09 06:20

/src/libhevc/encoder/sqrt_interp.c
Line
Count
Source (jump to first uncovered line)
1
/******************************************************************************
2
 *
3
 * Copyright (C) 2018 The Android Open Source Project
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at:
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 *****************************************************************************
18
 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19
*/
20
/*!
21
******************************************************************************
22
* \file squrt_interp.c
23
*
24
* \brief
25
*    This file contain square root interpolate function
26
*
27
* \date
28
*
29
* \author
30
*    ittiam
31
*
32
******************************************************************************
33
*/
34
/*****************************************************************************/
35
/* File Includes                                                             */
36
/*****************************************************************************/
37
/* System include files */
38
#include <stdio.h>
39
#include <stdlib.h>
40
41
/* User include files */
42
#include "ia_type_def.h"
43
#include "defs.h"
44
/* #include "constants.h" */
45
#include "ia_basic_ops32.h"
46
/* #include "ia_basic_ops16.h" */
47
#include "ia_basic_ops40.h"
48
#include "sqrt_interp.h"
49
/* #include "ia_enhaacplus_enc_basicops.h" */
50
#include "common_rom.h"
51
52
WORD32 sqrtFix_interpolate(WORD32 num, WORD *q, const WORD32 *sqrt_tab)
53
90.7k
{
54
90.7k
    WORD32 index, answer, temp, delta, step_size;
55
90.7k
    WORD q_temp = *q;
56
90.7k
    WORD k;
57
58
90.7k
    if(num == 0)
59
0
        return 0;
60
61
90.7k
    k = norm32(num);
62
90.7k
    temp = shr32(shl32(num, k), 21);
63
90.7k
    q_temp += k;
64
90.7k
    index = temp & 0x1FF; /* Leave leading 1 */
65
90.7k
    {
66
90.7k
        delta = shl32((shl32(num, k) - shl32(temp, 21)), 10);
67
90.7k
        step_size = sub32(sqrt_tab[index + 1], sqrt_tab[index]);
68
90.7k
        step_size = mult32_shl_sat(step_size, delta); /* Q:Q_SQRT_TAB + 21 + 10 - 31 */
69
90.7k
        answer = add32(sqrt_tab[index], step_size);
70
90.7k
    }
71
90.7k
    if(q_temp & 1)
72
44.8k
    {
73
44.8k
        q_temp -= 1;
74
44.8k
        answer = mult32_shl_sat(answer, INV_SQRT_2_Q31);
75
44.8k
    }
76
77
90.7k
    q_temp = q_temp >> 1;
78
90.7k
    q_temp += (Q_SQRT_TAB);
79
90.7k
    *q = q_temp;
80
81
90.7k
    answer >>= 1;
82
90.7k
    *q -= 1;
83
84
90.7k
    return answer;
85
90.7k
}
86
87
WORD32 sqrtFix(WORD32 num, WORD *q, const WORD32 *sqrt_tab)
88
0
{
89
0
    WORD32 index, answer, temp;
90
0
    WORD k;
91
0
    WORD q_temp = *q;
92
93
0
    if(num == 0)
94
0
        return 0;
95
96
0
    k = norm32(num);
97
0
    temp = shr32(shl32(num, k), 21);
98
0
    q_temp += k;
99
0
    index = temp & 0x1FF; /* Leave leading 1 */
100
0
    answer = sqrt_tab[index];
101
0
    if(q_temp & 1)
102
0
    {
103
0
        q_temp -= 1;
104
0
        answer = mult32x16in32_shl(answer, INV_SQRT_2_Q15);
105
0
    }
106
0
    q_temp = q_temp >> 1;
107
0
    q_temp += Q_SQRT_TAB;
108
0
    *q = q_temp;
109
0
    return answer;
110
0
}
111
112
#ifdef ITT_C6678
113
#pragma CODE_SECTION(sqrtFix_interpolate, "itt_varq_l1pram");
114
#pragma CODE_SECTION(sqrtFix, "itt_varq_l1pram");
115
#endif