/src/libhevc/encoder/rc_sad_acc.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 rc_sad_acc.c |
23 | | * |
24 | | * \brief |
25 | | * This file contain sad accumulator related functions |
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 <string.h> |
40 | | |
41 | | /* User include files */ |
42 | | #include "ittiam_datatypes.h" |
43 | | #include "mem_req_and_acq.h" |
44 | | #include "rc_common.h" |
45 | | #include "rc_cntrl_param.h" |
46 | | #include "var_q_operator.h" |
47 | | #include "trace_support.h" |
48 | | #include "rc_sad_acc.h" |
49 | | |
50 | | /* State structure for sad accumulator */ |
51 | | typedef struct |
52 | | { |
53 | | WORD32 ai4_sad[MAX_PIC_TYPE]; |
54 | | |
55 | | } sad_acc_t; |
56 | | |
57 | | #if NON_STEADSTATE_CODE |
58 | | WORD32 sad_acc_num_fill_use_free_memtab( |
59 | | sad_acc_handle *pps_sad_acc_handle, itt_memtab_t *ps_memtab, ITT_FUNC_TYPE_E e_func_type) |
60 | 0 | { |
61 | 0 | WORD32 i4_mem_tab_idx = 0; |
62 | 0 | sad_acc_t **pps_sad_acc = (sad_acc_t **)pps_sad_acc_handle; |
63 | 0 | static sad_acc_t s_sad_acc; |
64 | | |
65 | | /* Hack for al alloc, during which we dont have any state memory. |
66 | | Dereferencing can cause issues */ |
67 | 0 | if(e_func_type == GET_NUM_MEMTAB || e_func_type == FILL_MEMTAB) |
68 | 0 | (*pps_sad_acc) = &s_sad_acc; |
69 | | |
70 | | /*for src rate control state structure*/ |
71 | 0 | if(e_func_type != GET_NUM_MEMTAB) |
72 | 0 | { |
73 | 0 | fill_memtab( |
74 | 0 | &ps_memtab[i4_mem_tab_idx], sizeof(sad_acc_t), MEM_TAB_ALIGNMENT, PERSISTENT, DDR); |
75 | 0 | use_or_fill_base(&ps_memtab[0], (void **)pps_sad_acc, e_func_type); |
76 | 0 | } |
77 | 0 | i4_mem_tab_idx++; |
78 | |
|
79 | 0 | return (i4_mem_tab_idx); |
80 | 0 | } |
81 | | /****************************************************************************** |
82 | | Function Name : init_sad_acc |
83 | | Description : |
84 | | Arguments : ps_sad_acc_handle |
85 | | Return Values : void |
86 | | Revision History: |
87 | | Creation |
88 | | *****************************************************************************/ |
89 | | void init_sad_acc(sad_acc_handle ps_sad_acc_handle) |
90 | 0 | { |
91 | 0 | sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle; |
92 | 0 | WORD32 i; |
93 | | /* Initialize the array */ |
94 | 0 | for(i = 0; i < MAX_PIC_TYPE; i++) |
95 | 0 | { |
96 | 0 | ps_sad_acc->ai4_sad[i] = -1; |
97 | 0 | } |
98 | 0 | } |
99 | | #endif /* #if NON_STEADSTATE_CODE */ |
100 | | /****************************************************************************** |
101 | | Function Name : sad_acc_put_sad |
102 | | Description : |
103 | | Arguments : ps_sad_acc_handle |
104 | | Return Values : void |
105 | | Revision History: |
106 | | Creation |
107 | | *****************************************************************************/ |
108 | | void sad_acc_put_sad( |
109 | | sad_acc_handle ps_sad_acc_handle, |
110 | | WORD32 i4_cur_intra_sad, |
111 | | WORD32 i4_cur_sad, |
112 | | WORD32 i4_cur_pic_type) |
113 | 0 | { |
114 | 0 | sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle; |
115 | 0 | ps_sad_acc->ai4_sad[I_PIC] = i4_cur_intra_sad; |
116 | 0 | ps_sad_acc->ai4_sad[i4_cur_pic_type] = i4_cur_sad; |
117 | 0 | } |
118 | | /****************************************************************************** |
119 | | Function Name : sad_acc_get_sad |
120 | | Description : |
121 | | Arguments : ps_sad_acc_handle |
122 | | Return Values : void |
123 | | Revision History: |
124 | | Creation |
125 | | *****************************************************************************/ |
126 | | void sad_acc_get_sad(sad_acc_handle ps_sad_acc_handle, WORD32 *pi4_sad) |
127 | 0 | { |
128 | 0 | sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle; |
129 | 0 | WORD32 i; |
130 | | /* Initialize the array */ |
131 | 0 | for(i = 0; i < MAX_PIC_TYPE; i++) |
132 | 0 | { |
133 | 0 | pi4_sad[i] = ps_sad_acc->ai4_sad[i]; |
134 | 0 | } |
135 | 0 | } |