• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
sad_acc_num_fill_use_free_memtab(sad_acc_handle * pps_sad_acc_handle,itt_memtab_t * ps_memtab,ITT_FUNC_TYPE_E e_func_type)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 {
61     WORD32 i4_mem_tab_idx = 0;
62     sad_acc_t **pps_sad_acc = (sad_acc_t **)pps_sad_acc_handle;
63     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     if(e_func_type == GET_NUM_MEMTAB || e_func_type == FILL_MEMTAB)
68         (*pps_sad_acc) = &s_sad_acc;
69 
70     /*for src rate control state structure*/
71     if(e_func_type != GET_NUM_MEMTAB)
72     {
73         fill_memtab(
74             &ps_memtab[i4_mem_tab_idx], sizeof(sad_acc_t), MEM_TAB_ALIGNMENT, PERSISTENT, DDR);
75         use_or_fill_base(&ps_memtab[0], (void **)pps_sad_acc, e_func_type);
76     }
77     i4_mem_tab_idx++;
78 
79     return (i4_mem_tab_idx);
80 }
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 *****************************************************************************/
init_sad_acc(sad_acc_handle ps_sad_acc_handle)89 void init_sad_acc(sad_acc_handle ps_sad_acc_handle)
90 {
91     sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle;
92     WORD32 i;
93     /* Initialize the array */
94     for(i = 0; i < MAX_PIC_TYPE; i++)
95     {
96         ps_sad_acc->ai4_sad[i] = -1;
97     }
98 }
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 *****************************************************************************/
sad_acc_put_sad(sad_acc_handle ps_sad_acc_handle,WORD32 i4_cur_intra_sad,WORD32 i4_cur_sad,WORD32 i4_cur_pic_type)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 {
114     sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle;
115     ps_sad_acc->ai4_sad[I_PIC] = i4_cur_intra_sad;
116     ps_sad_acc->ai4_sad[i4_cur_pic_type] = i4_cur_sad;
117 }
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 *****************************************************************************/
sad_acc_get_sad(sad_acc_handle ps_sad_acc_handle,WORD32 * pi4_sad)126 void sad_acc_get_sad(sad_acc_handle ps_sad_acc_handle, WORD32 *pi4_sad)
127 {
128     sad_acc_t *ps_sad_acc = (sad_acc_t *)ps_sad_acc_handle;
129     WORD32 i;
130     /* Initialize the array */
131     for(i = 0; i < MAX_PIC_TYPE; i++)
132     {
133         pi4_sad[i] = ps_sad_acc->ai4_sad[i];
134     }
135 }
136