Coverage Report

Created: 2025-07-23 06:18

/src/libavc/decoder/svc/isvcd_thread_parse_decode.c
Line
Count
Source (jump to first uncovered line)
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
 * @file
23
 *  isvcd_thread_parse_decode.c
24
 *
25
 * @brief
26
 *  Contains routines that for multi-thread decoder
27
 *
28
 * @author
29
 *  Kishore
30
 *
31
 * @remarks
32
 *  None
33
 *
34
 *******************************************************************************
35
 */
36
37
#include <string.h>
38
#include "ih264d_error_handler.h"
39
#include "ih264d_debug.h"
40
#include "ithread.h"
41
#include "ih264d_defs.h"
42
#include "ih264d_debug.h"
43
#include "ih264d_tables.h"
44
#include "isvcd_structs.h"
45
#include "ih264d_defs.h"
46
#include "ih264d_mb_utils.h"
47
#include "ih264d_thread_parse_decode.h"
48
#include "ih264d_inter_pred.h"
49
#include "ih264d_process_pslice.h"
50
#include "isvcd_process_epslice.h"
51
#include "ih264d_process_intra_mb.h"
52
#include "ih264d_deblocking.h"
53
#include "ih264d_format_conv.h"
54
#include "isvcd_thread_parse_decode.h"
55
56
/*****************************************************************************/
57
/*                                                                           */
58
/*  Function Name : isvcd_decode_recon_tfr_nmb_thread                        */
59
/*                                                                           */
60
/*  Description   :                                                          */
61
/*                :                                                          */
62
/*                :                                                          */
63
/*  Inputs        :                                                          */
64
/*  Processing    :Only for Target Layer processing                          */
65
/*                                                                           */
66
/*  Outputs       :                                                          */
67
/*  Returns       : None                                                     */
68
/*                                                                           */
69
/*  Revision History:                                                        */
70
/*                                                                           */
71
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
72
/*                      ITTIAM                                               */
73
/*****************************************************************************/
74
WORD32 isvcd_decode_recon_tfr_nmb_thread(svc_dec_lyr_struct_t *ps_svc_lyr_dec, UWORD8 u1_num_mbs,
75
                                         UWORD8 u1_num_mbs_next, UWORD8 u1_end_of_row)
76
186k
{
77
186k
    WORD32 i, j;
78
186k
    dec_mb_info_t *ps_cur_mb_info;
79
186k
    dec_svc_mb_info_t *ps_svc_cur_mb_info;
80
186k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
81
186k
    const UWORD32 u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
82
186k
    UWORD32 u1_slice_type, u1_B;
83
186k
    WORD32 u1_skip_th;
84
186k
    UWORD32 u1_ipcm_th;
85
186k
    UWORD32 u4_cond;
86
186k
    UWORD16 u2_slice_num, u2_cur_dec_mb_num;
87
186k
    UWORD32 u4_mb_num;
88
186k
    WORD32 nop_cnt = 8 * 128;
89
186k
    UWORD16 *pu2_res_luma_csbp;
90
186k
    WORD32 ret;
91
186k
    u1_slice_type = ps_dec->ps_decode_cur_slice->slice_type;
92
93
186k
    u1_B = (u1_slice_type == B_SLICE);
94
186k
    u1_skip_th = ((u1_slice_type != I_SLICE) ? (u1_B ? B_8x8 : PRED_8x8R0) : -1);
95
186k
    u1_ipcm_th = ((u1_slice_type != I_SLICE) ? (u1_B ? 23 : 5) : 0);
96
186k
    u2_cur_dec_mb_num = ps_dec->cur_dec_mb_num;
97
98
199k
    while(1)
99
199k
    {
100
199k
        UWORD32 u4_max_mb =
101
199k
            (UWORD32) (ps_dec->i2_dec_thread_mb_y + (1 << u1_mbaff)) * ps_dec->u2_frm_wd_in_mbs - 1;
102
199k
        u4_mb_num = u2_cur_dec_mb_num;
103
        /*introducing 1 MB delay*/
104
199k
        u4_mb_num = MIN(u4_mb_num + u1_num_mbs + 1, u4_max_mb);
105
106
199k
        CHECK_MB_MAP_BYTE(u4_mb_num, ps_dec->pu1_dec_mb_map, u4_cond);
107
199k
        if(u4_cond)
108
186k
        {
109
186k
            break;
110
186k
        }
111
13.0k
        else
112
13.0k
        {
113
13.0k
            if(nop_cnt > 0)
114
10.7k
            {
115
10.7k
                nop_cnt -= 128;
116
10.7k
                NOP(128);
117
10.7k
            }
118
2.31k
            else
119
2.31k
            {
120
2.31k
                if(ps_dec->u4_output_present && (2 == ps_dec->u4_num_cores) &&
121
2.31k
                   (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))
122
1.61k
                {
123
1.61k
                    ps_dec->u4_fmt_conv_num_rows =
124
1.61k
                        MIN(FMT_CONV_NUM_ROWS,
125
1.61k
                            (ps_dec->s_disp_frame_info.u4_y_ht - ps_dec->u4_fmt_conv_cur_row));
126
1.61k
                    ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), ps_dec->u4_fmt_conv_cur_row,
127
1.61k
                                          ps_dec->u4_fmt_conv_num_rows);
128
1.61k
                    ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;
129
1.61k
                }
130
699
                else
131
699
                {
132
699
                    nop_cnt = 8 * 128;
133
699
                    ithread_yield();
134
699
                }
135
2.31k
                if(1 == ps_svc_lyr_dec->u1_error_in_cur_frame)
136
250
                {
137
250
                    return NOT_OK;
138
250
                }
139
2.31k
            }
140
13.0k
        }
141
199k
    }
142
143
    /* N Mb MC Loop */
144
796k
    for(i = 0; i < u1_num_mbs; i++)
145
618k
    {
146
618k
        u4_mb_num = u2_cur_dec_mb_num;
147
618k
        GET_SLICE_NUM_MAP(ps_dec->pu2_slice_num_map, u2_cur_dec_mb_num, u2_slice_num);
148
149
618k
        if(u2_slice_num != ps_dec->u2_cur_slice_num_dec_thread)
150
7.21k
        {
151
7.21k
            ps_dec->u4_cur_slice_decode_done = 1;
152
7.21k
            break;
153
7.21k
        }
154
155
610k
        ps_cur_mb_info = &ps_dec->ps_frm_mb_info[u2_cur_dec_mb_num];
156
157
610k
        ps_dec->u4_dma_buf_idx = 0;
158
610k
        ps_dec->u4_pred_info_idx = 0;
159
160
        /*Pointer assignment for Residual NNZ */
161
610k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
162
610k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
163
164
610k
        if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
165
131k
        {
166
131k
            WORD32 pred_cnt = 0;
167
131k
            pred_info_pkd_t *ps_pred_pkd;
168
131k
            UWORD32 u4_pred_info_pkd_idx;
169
170
131k
            u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
171
172
401k
            while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
173
269k
            {
174
269k
                ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
175
176
269k
                ps_dec->p_form_mb_part_info_thread(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
177
269k
                                                   ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
178
269k
                                                   ps_cur_mb_info);
179
180
269k
                u4_pred_info_pkd_idx++;
181
269k
                pred_cnt++;
182
269k
            }
183
131k
            ps_dec->p_mc_dec_thread(ps_dec, ps_cur_mb_info);
184
131k
        }
185
479k
        else if(ps_cur_mb_info->u1_mb_type == MB_SKIP)
186
400k
        {
187
400k
            WORD32 pred_cnt = 0;
188
400k
            pred_info_pkd_t *ps_pred_pkd;
189
400k
            UWORD32 u4_pred_info_pkd_idx;
190
191
400k
            u4_pred_info_pkd_idx = ps_cur_mb_info->u4_pred_info_pkd_idx;
192
193
831k
            while(pred_cnt < ps_cur_mb_info->u1_num_pred_parts)
194
430k
            {
195
430k
                ps_pred_pkd = ps_dec->ps_pred_pkd + u4_pred_info_pkd_idx;
196
197
430k
                ps_dec->p_form_mb_part_info_thread(ps_pred_pkd, ps_dec, ps_cur_mb_info->u2_mbx,
198
430k
                                                   ps_cur_mb_info->u2_mby, (i >> u1_mbaff),
199
430k
                                                   ps_cur_mb_info);
200
201
430k
                u4_pred_info_pkd_idx++;
202
430k
                pred_cnt++;
203
430k
            }
204
            /* Decode MB skip */
205
400k
            ps_dec->p_mc_dec_thread(ps_dec, ps_cur_mb_info);
206
207
400k
            *pu2_res_luma_csbp = 0;
208
400k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
209
400k
                ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
210
400k
                (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
211
400k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_mb_mode = SVC_INTER_MB;
212
400k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_tx_size =
213
400k
                ps_cur_mb_info->u1_tran_form8x8;
214
400k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u2_luma_nnz = 0;
215
400k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->u1_chroma_nnz = 0;
216
400k
        }
217
218
610k
        u2_cur_dec_mb_num++;
219
610k
    }
220
221
    /* N Mb IQ IT RECON  Loop */
222
796k
    for(j = 0; j < i; j++)
223
610k
    {
224
610k
        ps_cur_mb_info = &ps_dec->ps_frm_mb_info[ps_dec->cur_dec_mb_num];
225
610k
        ps_svc_cur_mb_info = &ps_svc_lyr_dec->ps_svc_frm_mb_info[ps_dec->cur_dec_mb_num];
226
227
610k
        if(NULL == ps_cur_mb_info->ps_curmb)
228
0
        {
229
0
            return NOT_OK;
230
0
        }
231
232
        /*Pointer assignment for Residual NNZ */
233
610k
        pu2_res_luma_csbp = ps_svc_lyr_dec->pu2_frm_res_luma_csbp + ps_cur_mb_info->u2_mbx;
234
610k
        pu2_res_luma_csbp += ps_cur_mb_info->u2_mby * ps_svc_lyr_dec->i4_frm_res_luma_csbp_stride;
235
236
610k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb =
237
610k
            ps_svc_lyr_dec->ps_inter_lyr_mb_prms_frm_start + ps_cur_mb_info->u2_mbx +
238
610k
            (ps_svc_lyr_dec->u2_inter_lyr_mb_prms_stride * (ps_cur_mb_info->u2_mby));
239
240
610k
        ps_svc_lyr_dec->ps_inter_lyr_mb_prms_cur_mb->i1_slice_id = (WORD8) ps_dec->u2_cur_slice_num;
241
242
610k
        if((ps_dec->u4_num_cores == 2) || !ps_dec->i1_recon_in_thread3_flag)
243
610k
        {
244
610k
            if(ps_cur_mb_info->u1_mb_type <= u1_skip_th)
245
131k
            {
246
131k
                {
247
                    /* inter intra pred generation */
248
131k
                    if(SVCD_FALSE == ps_svc_lyr_dec->u1_dyadic_flag)
249
92.4k
                    {
250
92.4k
                        ret = isvcd_process_ii_mb(ps_svc_lyr_dec, ps_cur_mb_info,
251
92.4k
                                                  ps_svc_cur_mb_info, j);
252
92.4k
                        if(ret != OK) return ret;
253
92.4k
                    }
254
131k
                    if(0 == ps_svc_cur_mb_info->u1_residual_prediction_flag)
255
26.2k
                    {
256
                        /* IT + Recon */
257
26.2k
                        ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
258
26.2k
                        isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 0);
259
26.2k
                        *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
260
26.2k
                    }
261
105k
                    else
262
105k
                    {
263
                        /* IT + Residual + Recon */
264
105k
                        ret = isvcd_process_inter_mb_rsd_pred_target_lyr(
265
105k
                            ps_svc_lyr_dec, ps_cur_mb_info, j, 0, pu2_res_luma_csbp);
266
105k
                        if(ret != OK) return ret;
267
105k
                    }
268
131k
                }
269
131k
            }
270
271
479k
            else if((ps_cur_mb_info->u1_mb_type != MB_SKIP) &&
272
479k
                    (ps_cur_mb_info->u1_mb_type != MB_INFER))
273
16.6k
            {
274
16.6k
                if((u1_ipcm_th + 25) != ps_cur_mb_info->u1_mb_type)
275
16.4k
                {
276
16.4k
                    ps_cur_mb_info->u1_mb_type -= (u1_skip_th + 1);
277
16.4k
                    ih264d_process_intra_mb(ps_dec, ps_cur_mb_info, j);
278
16.4k
                    isvcd_update_intra_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
279
16.4k
                }
280
140
                else
281
140
                {
282
140
                    isvcd_update_ipcm_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
283
140
                }
284
16.6k
                *pu2_res_luma_csbp = 0;
285
16.6k
            }
286
462k
            else if(ps_cur_mb_info->u1_mb_type == MB_INFER)
287
61.5k
            {
288
                /* inter layer intra prediction : intra upsample, IQ, IT ,deblock */
289
61.5k
                {
290
                    /* Intra resample for IBL mode */
291
61.5k
                    ret = isvcd_process_ibl_mb(ps_svc_lyr_dec, ps_cur_mb_info, j, 0);
292
61.5k
                    if(ret != OK) return ret;
293
                    /* Pass intra resample as pred to Recon generation */
294
61.5k
                    ih264d_process_inter_mb(ps_dec, ps_cur_mb_info, j);
295
61.5k
                    isvcd_update_inter_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info, 1);
296
61.5k
                    *pu2_res_luma_csbp = ps_cur_mb_info->u2_luma_csbp;
297
61.5k
                }
298
61.5k
                ps_dec->pi1_left_pred_mode[0] = DC;
299
61.5k
                ps_dec->pi1_left_pred_mode[1] = DC;
300
61.5k
                ps_dec->pi1_left_pred_mode[2] = DC;
301
61.5k
                ps_dec->pi1_left_pred_mode[3] = DC;
302
303
61.5k
                ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[0] = DC;
304
61.5k
                ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[1] = DC;
305
61.5k
                ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[2] = DC;
306
61.5k
                ps_cur_mb_info->ps_curmb->pi1_intrapredmodes[3] = DC;
307
308
61.5k
                isvcd_update_ibl_mb_inter_layer_info(ps_svc_lyr_dec, ps_cur_mb_info);
309
61.5k
            }
310
311
610k
            if(ps_dec->u4_use_intrapred_line_copy == 1)
312
610k
                ih264d_copy_intra_pred_line(ps_dec, ps_cur_mb_info, j);
313
610k
        }
314
315
610k
        DATA_SYNC();
316
317
610k
        u4_mb_num = ps_cur_mb_info->u2_mbx + ps_dec->u2_frm_wd_in_mbs * ps_cur_mb_info->u2_mby;
318
610k
        UPDATE_MB_MAP_MBNUM_BYTE(ps_dec->pu1_recon_mb_map, u4_mb_num);
319
610k
        ps_dec->cur_dec_mb_num++;
320
610k
    }
321
322
    /*N MB deblocking*/
323
186k
    if(ps_dec->u4_nmb_deblk == 1)
324
0
    {
325
0
        UWORD32 u4_wd_y, u4_wd_uv;
326
0
        tfr_ctxt_t *ps_tfr_cxt = &(ps_dec->s_tran_addrecon);
327
0
        UWORD8 u1_field_pic_flag = ps_dec->ps_cur_slice->u1_field_pic_flag;
328
0
        const WORD32 i4_cb_qp_idx_ofst = ps_dec->ps_cur_pps->i1_chroma_qp_index_offset;
329
0
        const WORD32 i4_cr_qp_idx_ofst = ps_dec->ps_cur_pps->i1_second_chroma_qp_index_offset;
330
331
0
        u4_wd_y = ps_dec->u2_frm_wd_y << u1_field_pic_flag;
332
0
        u4_wd_uv = ps_dec->u2_frm_wd_uv << u1_field_pic_flag;
333
334
0
        ps_cur_mb_info = &ps_dec->ps_frm_mb_info[ps_dec->u4_cur_deblk_mb_num];
335
336
0
        ps_dec->u4_deblk_mb_x = ps_cur_mb_info->u2_mbx;
337
0
        ps_dec->u4_deblk_mb_y = ps_cur_mb_info->u2_mby;
338
339
0
        for(j = 0; j < i; j++)
340
0
        {
341
0
            ih264d_deblock_mb_nonmbaff(ps_dec, ps_tfr_cxt, i4_cb_qp_idx_ofst, i4_cr_qp_idx_ofst,
342
0
                                       u4_wd_y, u4_wd_uv);
343
0
        }
344
0
    }
345
346
    /*handle the last mb in picture case*/
347
186k
    if(ps_dec->cur_dec_mb_num > ps_dec->ps_cur_sps->u4_max_mb_addr)
348
19.0k
        ps_dec->u4_cur_slice_decode_done = 1;
349
350
186k
    if(i != u1_num_mbs)
351
7.21k
    {
352
7.21k
        u1_end_of_row = 0;
353
        /*Number of MB's left in row*/
354
7.21k
        u1_num_mbs_next = u1_num_mbs_next + ((u1_num_mbs - i) >> u1_mbaff);
355
7.21k
    }
356
357
186k
    ih264d_decode_tfr_nmb(ps_dec, (i), u1_num_mbs_next, u1_end_of_row);
358
359
186k
    return OK;
360
186k
}
361
362
/*****************************************************************************/
363
/*                                                                           */
364
/*  Function Name : isvcd_decode_slice_thread                                */
365
/*                                                                           */
366
/*  Description   :                                                          */
367
/*                :                                                          */
368
/*                :                                                          */
369
/*  Inputs        :                                                          */
370
/*  Processing    :                                                          */
371
/*                                                                           */
372
/*  Outputs       :                                                          */
373
/*  Returns       : 0 on success                                             */
374
/*                                                                           */
375
/*  Revision History:                                                        */
376
/*                                                                           */
377
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
378
/*                      ITTIAM                                               */
379
/*****************************************************************************/
380
WORD32 isvcd_decode_slice_thread(svc_dec_lyr_struct_t *ps_svc_lyr_dec)
381
27.6k
{
382
27.6k
    UWORD8 u1_num_mbs_next, u1_num_mbsleft, u1_end_of_row = 0;
383
27.6k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
384
27.6k
    const UWORD32 i2_pic_wdin_mbs = ps_dec->u2_frm_wd_in_mbs;
385
27.6k
    UWORD8 u1_mbaff, u1_num_mbs;
386
387
27.6k
    UWORD16 u2_first_mb_in_slice;
388
27.6k
    UWORD16 i16_mb_x, i16_mb_y;
389
27.6k
    UWORD8 u1_field_pic;
390
27.6k
    UWORD32 u4_frame_stride, x_offset, y_offset;
391
27.6k
    WORD32 ret;
392
27.6k
    tfr_ctxt_t *ps_trns_addr;
393
394
    /*check for mb map of first mb in slice to ensure slice header is parsed*/
395
73.6k
    while(1)
396
73.6k
    {
397
73.6k
        UWORD32 u4_mb_num = ps_dec->cur_dec_mb_num;
398
73.6k
        UWORD32 u4_cond = 0;
399
73.6k
        WORD32 nop_cnt = 8 * 128;
400
73.6k
        CHECK_MB_MAP_BYTE(u4_mb_num, ps_dec->pu1_dec_mb_map, u4_cond);
401
73.6k
        if(u4_cond)
402
26.4k
        {
403
26.4k
            break;
404
26.4k
        }
405
47.1k
        else
406
47.1k
        {
407
47.1k
            if(nop_cnt > 0)
408
47.1k
            {
409
47.1k
                nop_cnt -= 128;
410
47.1k
                NOP(128);
411
47.1k
            }
412
0
            else if(ps_dec->u4_output_present && (2 == ps_dec->u4_num_cores) &&
413
0
                    (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))
414
0
            {
415
0
                ps_dec->u4_fmt_conv_num_rows =
416
0
                    MIN(FMT_CONV_NUM_ROWS,
417
0
                        (ps_dec->s_disp_frame_info.u4_y_ht - ps_dec->u4_fmt_conv_cur_row));
418
0
                ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), ps_dec->u4_fmt_conv_cur_row,
419
0
                                      ps_dec->u4_fmt_conv_num_rows);
420
0
                ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;
421
0
            }
422
0
            else
423
0
            {
424
0
                nop_cnt = 8 * 128;
425
0
                ithread_yield();
426
0
            }
427
47.1k
            if(1 == ps_svc_lyr_dec->u1_error_in_cur_frame)
428
1.16k
            {
429
1.16k
                return NOT_OK;
430
1.16k
            }
431
46.0k
            DEBUG_THREADS_PRINTF(
432
46.0k
                "waiting for mb mapcur_dec_mb_num = %d,ps_dec->u2_cur_mb_addr  = "
433
46.0k
                "%d\n",
434
46.0k
                u2_cur_dec_mb_num, ps_dec->u2_cur_mb_addr);
435
46.0k
        }
436
73.6k
    }
437
438
26.4k
    u1_mbaff = ps_dec->ps_cur_slice->u1_mbaff_frame_flag;
439
26.4k
    u2_first_mb_in_slice = ps_dec->ps_decode_cur_slice->u4_first_mb_in_slice;
440
26.4k
    i16_mb_x = MOD(u2_first_mb_in_slice, i2_pic_wdin_mbs);
441
26.4k
    i16_mb_y = DIV(u2_first_mb_in_slice, i2_pic_wdin_mbs);
442
26.4k
    i16_mb_y <<= u1_mbaff;
443
26.4k
    ps_dec->i2_dec_thread_mb_y = i16_mb_y;
444
26.4k
    ps_dec->cur_dec_mb_num = u2_first_mb_in_slice << u1_mbaff;
445
446
26.4k
    if((ps_dec->u4_num_cores == 2) || !ps_dec->i1_recon_in_thread3_flag)
447
26.4k
    {
448
26.4k
        ps_dec->pv_proc_tu_coeff_data =
449
26.4k
            (void *) ps_dec->ps_decode_cur_slice->pv_tu_coeff_data_start;
450
26.4k
    }
451
452
    // recalculate recon pointers
453
26.4k
    u1_field_pic = ps_dec->ps_cur_slice->u1_field_pic_flag;
454
26.4k
    u4_frame_stride = ps_dec->u2_frm_wd_y << u1_field_pic;
455
26.4k
    x_offset = i16_mb_x << 4;
456
26.4k
    y_offset = (i16_mb_y * u4_frame_stride) << 4;
457
458
26.4k
    ps_trns_addr = &(ps_dec->s_tran_addrecon);
459
460
26.4k
    ps_trns_addr->pu1_dest_y = ps_dec->s_cur_pic.pu1_buf1 + x_offset + y_offset;
461
462
26.4k
    u4_frame_stride = ps_dec->u2_frm_wd_uv << u1_field_pic;
463
26.4k
    x_offset >>= 1;
464
26.4k
    y_offset = (i16_mb_y * u4_frame_stride) << 3;
465
26.4k
    x_offset *= YUV420SP_FACTOR;
466
467
26.4k
    ps_trns_addr->pu1_dest_u = ps_dec->s_cur_pic.pu1_buf2 + x_offset + y_offset;
468
26.4k
    ps_trns_addr->pu1_dest_v = ps_dec->s_cur_pic.pu1_buf3 + x_offset + y_offset;
469
470
26.4k
    ps_trns_addr->pu1_mb_y = ps_trns_addr->pu1_dest_y;
471
26.4k
    ps_trns_addr->pu1_mb_u = ps_trns_addr->pu1_dest_u;
472
26.4k
    ps_trns_addr->pu1_mb_v = ps_trns_addr->pu1_dest_v;
473
474
    /* Initialise MC and formMbPartInfo fn ptrs one time based on profile_idc */
475
26.4k
    {
476
26.4k
        ps_dec->p_mc_dec_thread = ih264d_motion_compensate_bp;
477
26.4k
        ps_dec->p_form_mb_part_info_thread = ih264d_form_mb_part_info_bp;
478
26.4k
    }
479
26.4k
    {
480
26.4k
        UWORD8 uc_nofield_nombaff;
481
26.4k
        uc_nofield_nombaff = ((ps_dec->ps_cur_slice->u1_field_pic_flag == 0) &&
482
26.4k
                              (ps_dec->ps_cur_slice->u1_mbaff_frame_flag == 0) &&
483
26.4k
                              (ps_dec->ps_decode_cur_slice->slice_type != B_SLICE) &&
484
26.4k
                              (ps_dec->ps_cur_pps->u1_wted_pred_flag == 0));
485
486
26.4k
        if(uc_nofield_nombaff == 0)
487
7.67k
        {
488
7.67k
            ps_dec->p_mc_dec_thread = ih264d_motion_compensate_mp;
489
7.67k
            ps_dec->p_form_mb_part_info_thread = ih264d_form_mb_part_info_mp;
490
7.67k
        }
491
26.4k
    }
492
493
26.4k
    ps_dec->u4_cur_slice_decode_done = 0;
494
495
212k
    while(ps_dec->u4_cur_slice_decode_done != 1)
496
186k
    {
497
186k
        u1_num_mbsleft = ((i2_pic_wdin_mbs - i16_mb_x) << u1_mbaff);
498
499
186k
        if(u1_num_mbsleft <= ps_dec->u4_recon_mb_grp)
500
186k
        {
501
186k
            u1_num_mbs = u1_num_mbsleft;
502
503
            /*Indicate number of mb's left in a row*/
504
186k
            u1_num_mbs_next = 0;
505
186k
            u1_end_of_row = 1;
506
186k
            i16_mb_x = 0;
507
186k
        }
508
0
        else
509
0
        {
510
0
            u1_num_mbs = ps_dec->u4_recon_mb_grp;
511
512
            /*Indicate number of mb's left in a row*/
513
0
            u1_num_mbs_next = i2_pic_wdin_mbs - i16_mb_x - (ps_dec->u4_recon_mb_grp >> u1_mbaff);
514
0
            i16_mb_x += (u1_num_mbs >> u1_mbaff);
515
0
            u1_end_of_row = 0;
516
0
        }
517
186k
        if(ps_svc_lyr_dec->u1_layer_identifier == TARGET_LAYER)
518
186k
        {
519
186k
            ret = isvcd_decode_recon_tfr_nmb_thread(ps_svc_lyr_dec, u1_num_mbs, u1_num_mbs_next,
520
186k
                                                    u1_end_of_row);
521
186k
        }
522
186k
        if(ret != OK) return ret;
523
186k
    }
524
26.2k
    return OK;
525
26.4k
}
526
527
/*****************************************************************************/
528
/*                                                                           */
529
/*  Function Name : isvcd_decode_picture_thread                              */
530
/*                                                                           */
531
/*  Description   :                                                          */
532
/*                :                                                          */
533
/*                :                                                          */
534
/*  Inputs        :                                                          */
535
/*  Processing    :                                                          */
536
/*                                                                           */
537
/*  Outputs       :                                                          */
538
/*  Returns       : None                                                     */
539
/*                                                                           */
540
/*  Revision History:                                                        */
541
/*                                                                           */
542
/*         DD MM YYYY   Author(s)       Changes (Describe the changes made)  */
543
/*                      ITTIAM                                               */
544
/*****************************************************************************/
545
void isvcd_decode_picture_thread(svc_dec_lyr_struct_t *ps_svc_lyr_dec)
546
20.4k
{
547
20.4k
    dec_struct_t *ps_dec = &ps_svc_lyr_dec->s_dec;
548
20.4k
    WORD32 ret;
549
20.4k
    ithread_set_name("isvcd_decode_picture_thread");
550
20.4k
    while(1)
551
20.4k
    {
552
#ifdef KEEP_THREADS_ACTIVE
553
        ret = ithread_mutex_lock(ps_dec->apv_proc_start_mutex[0]);
554
        if(OK != ret) break;
555
556
        while(ps_dec->ai4_process_start[0] != PROC_START)
557
        {
558
            ithread_cond_wait(ps_dec->apv_proc_start_condition[0], ps_dec->apv_proc_start_mutex[0]);
559
        }
560
        ps_dec->ai4_process_start[0] = PROC_IN_PROGRESS;
561
562
        ret = ithread_mutex_unlock(ps_dec->apv_proc_start_mutex[0]);
563
        if(OK != ret || ps_dec->i4_break_threads == 1) break;
564
#endif
565
27.6k
        while(1)
566
27.6k
        {
567
            /*Complete all writes before processing next slice*/
568
569
27.6k
            DEBUG_THREADS_PRINTF(" Entering decode slice svc ext\n");
570
571
27.6k
            ret = isvcd_decode_slice_thread(ps_svc_lyr_dec);
572
27.6k
            if(OK != ret) break;
573
26.2k
            DEBUG_THREADS_PRINTF(" Exit  isvcd_decode_slice_thread\n");
574
575
26.2k
            if(ps_dec->cur_dec_mb_num > ps_dec->ps_cur_sps->u4_max_mb_addr)
576
19.0k
            {
577
                /*Last slice in frame*/
578
19.0k
                break;
579
19.0k
            }
580
7.21k
            else
581
7.21k
            {
582
7.21k
                ps_dec->ps_decode_cur_slice++;
583
7.21k
                ps_dec->u2_cur_slice_num_dec_thread++;
584
7.21k
            }
585
26.2k
        }
586
20.4k
        if(ps_dec->u4_output_present && (2 == ps_dec->u4_num_cores) &&
587
20.4k
           (ps_dec->u4_fmt_conv_cur_row < ps_dec->s_disp_frame_info.u4_y_ht))
588
8.21k
        {
589
8.21k
            ps_dec->u4_fmt_conv_num_rows =
590
8.21k
                (ps_dec->s_disp_frame_info.u4_y_ht - ps_dec->u4_fmt_conv_cur_row);
591
8.21k
            ih264d_format_convert(ps_dec, &(ps_dec->s_disp_op), ps_dec->u4_fmt_conv_cur_row,
592
8.21k
                                  ps_dec->u4_fmt_conv_num_rows);
593
8.21k
            ps_dec->u4_fmt_conv_cur_row += ps_dec->u4_fmt_conv_num_rows;
594
8.21k
        }
595
#ifdef KEEP_THREADS_ACTIVE
596
        ret = ithread_mutex_lock(ps_dec->apv_proc_done_mutex[0]);
597
        if(OK != ret) break;
598
599
        ps_dec->ai4_process_done[0] = PROC_DONE;
600
        ithread_cond_signal(ps_dec->apv_proc_done_condition[0]);
601
602
        ret = ithread_mutex_unlock(ps_dec->apv_proc_done_mutex[0]);
603
        if(OK != ret) break;
604
#else
605
20.4k
        break;
606
20.4k
#endif
607
20.4k
    }
608
20.4k
}