1/******************************************************************************
2*
3* Copyright (C) 2012 Ittiam Systems Pvt Ltd, Bangalore
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/**
19 *******************************************************************************
20 * @file
21 *  ihevcd_itrans_recon_dc.c
22 *
23 * @brief
24 *  Contains functions for DC inverse transform and reconstruction
25 *
26 * @author
27 *  Ittiam
28 *
29 * @par List of Functions:
30 * - ihevcd_itrans_recon_dc_luma()
31 * - ihevcd_itrans_recon_dc_chroma()
32 *
33 * @remarks
34 *  None
35 *
36 *******************************************************************************
37 */
38/*****************************************************************************/
39/* File Includes                                                             */
40/*****************************************************************************/
41#include <stdio.h>
42#include <stddef.h>
43#include <stdlib.h>
44#include <string.h>
45
46#include "ihevc_typedefs.h"
47#include "iv.h"
48#include "ivd.h"
49#include "ihevcd_cxa.h"
50
51#include "ihevc_defs.h"
52#include "ihevc_debug.h"
53#include "ihevc_structs.h"
54#include "ihevc_cabac_tables.h"
55#include "ihevc_macros.h"
56#include "ihevc_platform_macros.h"
57
58#include "ihevcd_defs.h"
59#include "ihevcd_function_selector.h"
60#include "ihevcd_structs.h"
61#include "ihevcd_error.h"
62#include "ihevcd_bitstream.h"
63#include "ihevc_common_tables.h"
64
65/* Intra pred includes */
66#include "ihevc_intra_pred.h"
67
68/* Inverse transform common module includes */
69#include "ihevc_trans_tables.h"
70#include "ihevc_trans_macros.h"
71#include "ihevc_itrans_recon.h"
72#include "ihevc_recon.h"
73#include "ihevc_chroma_itrans_recon.h"
74#include "ihevc_chroma_recon.h"
75
76/* Decoder includes */
77#include "ihevcd_common_tables.h"
78#include "ihevcd_iquant_itrans_recon_ctb.h"
79#include "ihevcd_debug.h"
80#include "ihevcd_profile.h"
81#include "ihevcd_statistics.h"
82#include "ihevcd_itrans_recon_dc.h"
83
84
85
86void ihevcd_itrans_recon_dc_luma(UWORD8 *pu1_pred,
87                                 UWORD8 *pu1_dst,
88                                 WORD32 pred_strd,
89                                 WORD32 dst_strd,
90                                 WORD32 log2_trans_size,
91                                 WORD16 i2_coeff_value)
92{
93    WORD32 row, col;
94    WORD32 add, shift;
95    WORD32 dc_value, quant_out;
96    WORD32 trans_size;
97
98    trans_size = (1 << log2_trans_size);
99
100    quant_out = i2_coeff_value;
101
102    shift = IT_SHIFT_STAGE_1;
103    add = 1 << (shift - 1);
104    dc_value = CLIP_S16((quant_out * 64 + add) >> shift);
105    shift = IT_SHIFT_STAGE_2;
106    add = 1 << (shift - 1);
107    dc_value = CLIP_S16((dc_value * 64 + add) >> shift);
108
109    for(row = 0; row < trans_size; row++)
110        for(col = 0; col < trans_size; col++)
111            pu1_dst[row * dst_strd + col] = CLIP_U8((pu1_pred[row * pred_strd + col] + dc_value));
112
113}
114
115
116void ihevcd_itrans_recon_dc_chroma(UWORD8 *pu1_pred,
117                                   UWORD8 *pu1_dst,
118                                   WORD32 pred_strd,
119                                   WORD32 dst_strd,
120                                   WORD32 log2_trans_size,
121                                   WORD16 i2_coeff_value)
122{
123    WORD32 row, col;
124    WORD32 add, shift;
125    WORD32 dc_value, quant_out;
126    WORD32 trans_size;
127
128
129    trans_size = (1 << log2_trans_size);
130
131    quant_out = i2_coeff_value;
132
133    shift = IT_SHIFT_STAGE_1;
134    add = 1 << (shift - 1);
135    dc_value = CLIP_S16((quant_out * 64 + add) >> shift);
136    shift = IT_SHIFT_STAGE_2;
137    add = 1 << (shift - 1);
138    dc_value = CLIP_S16((dc_value * 64 + add) >> shift);
139
140    for(row = 0; row < trans_size; row++)
141        for(col = 0; col < trans_size; col++)
142            pu1_dst[row * dst_strd + (col << 1)] = CLIP_U8((pu1_pred[row * pred_strd + (col << 1)] + dc_value));
143
144}
145
146
147