/src/libavc/encoder/svc/isvce_fmt_conv.c
Line | Count | Source |
1 | | /****************************************************************************** |
2 | | * |
3 | | * Copyright (C) 2022 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 | | ******************************************************************************* |
23 | | * @file |
24 | | * isvce_fmt_conv.c |
25 | | * |
26 | | * @brief |
27 | | * Contains functions for format conversion or frame copy of output buffer |
28 | | * |
29 | | * @author |
30 | | * ittiam |
31 | | * |
32 | | * @par List of Functions: |
33 | | * - isvce_fmt_conv() |
34 | | * |
35 | | * @remarks |
36 | | * None |
37 | | * |
38 | | ******************************************************************************* |
39 | | */ |
40 | | #include "ih264_typedefs.h" |
41 | | #include "ih264_macros.h" |
42 | | /* Dependencies of ih264_buf_mgr.h */ |
43 | | /* Dependencies of ih264_list.h */ |
44 | | #include "ih264_error.h" |
45 | | /* Dependencies of ih264_common_tables.h */ |
46 | | #include "ih264_defs.h" |
47 | | #include "ih264_structs.h" |
48 | | #include "ih264_buf_mgr.h" |
49 | | #include "ih264_common_tables.h" |
50 | | #include "ih264_list.h" |
51 | | #include "ih264_platform_macros.h" |
52 | | #include "ih264_trans_data.h" |
53 | | #include "ih264_size_defs.h" |
54 | | /* Dependencies of ih264e_cabac_structs.h */ |
55 | | #include "ih264_cabac_tables.h" |
56 | | /* Dependencies of ime_structs.h */ |
57 | | #include "ime_defs.h" |
58 | | #include "ime_distortion_metrics.h" |
59 | | /* Dependencies of ih264e_structs.h */ |
60 | | #include "iv2.h" |
61 | | #include "ive2.h" |
62 | | #include "ih264_defs.h" |
63 | | #include "ih264_deblk_edge_filters.h" |
64 | | #include "ih264_inter_pred_filters.h" |
65 | | #include "ih264_structs.h" |
66 | | #include "ih264_trans_quant_itrans_iquant.h" |
67 | | /* Dependencies of ih264e_bitstream.h */ |
68 | | #include "ih264e_error.h" |
69 | | #include "ih264e_bitstream.h" |
70 | | #include "ih264e_cabac_structs.h" |
71 | | #include "irc_cntrl_param.h" |
72 | | #include "irc_frame_info_collector.h" |
73 | | #include "ime_statistics.h" |
74 | | #include "ime_structs.h" |
75 | | /* Dependencies of 'ih264e_utils.h' */ |
76 | | #include "ih264e_defs.h" |
77 | | #include "ih264e_structs.h" |
78 | | #include "ih264e_fmt_conv.h" |
79 | | #include "isvce_structs.h" |
80 | | |
81 | | IH264E_ERROR_T isvce_fmt_conv(isvce_codec_t *ps_codec, svc_au_buf_t *ps_pic, UWORD8 *pu1_y_dst, |
82 | | UWORD8 *pu1_u_dst, UWORD8 *pu1_v_dst, UWORD32 u4_dst_y_strd, |
83 | | UWORD32 u4_dst_uv_strd, WORD32 cur_row, WORD32 num_rows) |
84 | 1.87k | { |
85 | 1.87k | IH264E_ERROR_T ret = IH264E_SUCCESS; |
86 | 1.87k | UWORD8 *pu1_y_src, *pu1_uv_src; |
87 | 1.87k | UWORD8 *pu1_y_dst_tmp, *pu1_uv_dst_tmp; |
88 | 1.87k | UWORD8 *pu1_u_dst_tmp, *pu1_v_dst_tmp; |
89 | 1.87k | WORD32 is_u_first; |
90 | 1.87k | UWORD8 *pu1_luma; |
91 | 1.87k | UWORD8 *pu1_chroma; |
92 | 1.87k | WORD32 wd; |
93 | | |
94 | 1.87k | WORD32 src_y_strd; |
95 | 1.87k | WORD32 src_uv_strd; |
96 | | |
97 | 1.87k | WORD32 layer_id = ps_pic->u1_num_spatial_layers - 1; |
98 | | |
99 | 1.87k | if(0 == num_rows) |
100 | 0 | { |
101 | 0 | return ret; |
102 | 0 | } |
103 | | |
104 | 1.87k | pu1_luma = ps_pic->ps_layer_yuv_buf_props[layer_id].as_component_bufs[0].pv_data; |
105 | 1.87k | pu1_chroma = ps_pic->ps_layer_yuv_buf_props[layer_id].as_component_bufs[1].pv_data; |
106 | | |
107 | 1.87k | src_y_strd = ps_pic->ps_layer_yuv_buf_props[layer_id].as_component_bufs[0].i4_data_stride; |
108 | 1.87k | src_uv_strd = ps_pic->ps_layer_yuv_buf_props[layer_id].as_component_bufs[1].i4_data_stride; |
109 | | |
110 | 1.87k | wd = ps_codec->s_cfg.u4_disp_wd; |
111 | 1.87k | is_u_first = (IV_YUV_420SP_UV == ps_codec->e_codec_color_format) ? 1 : 0; |
112 | | |
113 | | /* In case of 420P output luma copy is disabled for shared mode */ |
114 | 1.87k | { |
115 | 1.87k | pu1_y_src = pu1_luma + cur_row * src_y_strd; |
116 | 1.87k | pu1_uv_src = pu1_chroma + (cur_row / 2) * src_uv_strd; |
117 | | |
118 | 1.87k | pu1_y_dst_tmp = pu1_y_dst + cur_row * u4_dst_y_strd; |
119 | 1.87k | pu1_uv_dst_tmp = pu1_u_dst + (cur_row / 2) * u4_dst_uv_strd; |
120 | 1.87k | pu1_u_dst_tmp = pu1_u_dst + (cur_row / 2) * u4_dst_uv_strd; |
121 | 1.87k | pu1_v_dst_tmp = pu1_v_dst + (cur_row / 2) * u4_dst_uv_strd; |
122 | | |
123 | | /* If the call is non-blocking and there are no rows to be copied then |
124 | | * return */ |
125 | | /* In non-shared mode, reference buffers are in 420SP UV format, |
126 | | * if output also is in 420SP_UV, then just copy |
127 | | * if output is in 420SP_VU then swap UV values |
128 | | */ |
129 | 1.87k | if((IV_YUV_420SP_UV == ps_codec->s_cfg.e_recon_color_fmt) || |
130 | 1.87k | (IV_YUV_420SP_VU == ps_codec->s_cfg.e_recon_color_fmt)) |
131 | 0 | { |
132 | 0 | ih264e_fmt_conv_420sp_to_420sp(pu1_y_src, pu1_uv_src, pu1_y_dst_tmp, pu1_uv_dst_tmp, wd, |
133 | 0 | num_rows, ps_codec->i4_rec_strd, ps_codec->i4_rec_strd, |
134 | 0 | u4_dst_y_strd, u4_dst_uv_strd); |
135 | 0 | } |
136 | 1.87k | else if(IV_YUV_420P == ps_codec->s_cfg.e_recon_color_fmt) |
137 | 1.87k | { |
138 | 1.87k | ih264e_fmt_conv_420sp_to_420p(pu1_y_src, pu1_uv_src, pu1_y_dst_tmp, pu1_u_dst_tmp, |
139 | 1.87k | pu1_v_dst_tmp, wd, num_rows, ps_codec->i4_rec_strd, |
140 | 1.87k | ps_codec->i4_rec_strd, u4_dst_y_strd, u4_dst_uv_strd, |
141 | 1.87k | is_u_first, 0); |
142 | 1.87k | } |
143 | 1.87k | } |
144 | 1.87k | return (ret); |
145 | 1.87k | } |