Coverage Report

Created: 2026-05-30 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libhevc/decoder/ihevcd_utils.c
Line
Count
Source
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_utils.c
22
*
23
* @brief
24
*  Contains miscellaneous utility functions such as init() etc
25
*
26
* @author
27
*  Harish
28
*
29
* @par List of Functions:
30
*
31
* @remarks
32
*  None
33
*
34
*******************************************************************************
35
*/
36
/*****************************************************************************/
37
/* File Includes                                                             */
38
/*****************************************************************************/
39
#include <stdio.h>
40
#include <stddef.h>
41
#include <stdlib.h>
42
#include <string.h>
43
#include <assert.h>
44
45
#include "ihevc_typedefs.h"
46
#include "iv.h"
47
#include "ivd.h"
48
#include "ihevcd_cxa.h"
49
#include "ithread.h"
50
51
#include "ihevc_defs.h"
52
#include "ihevc_debug.h"
53
#include "ihevc_defs.h"
54
#include "ihevc_error.h"
55
#include "ihevc_structs.h"
56
#include "ihevc_buf_mgr.h"
57
#include "ihevc_dpb_mgr.h"
58
#include "ihevc_macros.h"
59
#include "ihevc_platform_macros.h"
60
61
#include "ihevc_common_tables.h"
62
#include "ihevc_buf_mgr.h"
63
#include "ihevc_disp_mgr.h"
64
#include "ihevc_cabac_tables.h"
65
66
#include "ihevcd_defs.h"
67
68
#include "ihevcd_function_selector.h"
69
#include "ihevcd_structs.h"
70
#include "ihevcd_error.h"
71
#include "ihevcd_nal.h"
72
#include "ihevcd_bitstream.h"
73
#include "ihevcd_utils.h"
74
#include "ihevcd_trace.h"
75
#include "ihevcd_process_slice.h"
76
#include "ihevcd_job_queue.h"
77
#define MAX_DPB_PIC_BUF 6
78
79
/* Function declarations */
80
mv_buf_t* ihevcd_mv_mgr_get_poc(buf_mgr_t *ps_mv_buf_mgr, UWORD32 abs_poc);
81
82
/**
83
*******************************************************************************
84
*
85
* @brief
86
*  Used to get level index for a given level
87
*
88
* @par Description:
89
*  Converts from level_idc (which is multiplied by 30) to an index that can be
90
*  used as a lookup. Also used to ignore invalid levels like 2.2 , 3.2 etc
91
*
92
* @param[in] level
93
*  Level of the stream
94
*
95
* @returns  Level index for a given level
96
*
97
* @remarks
98
*
99
*
100
*******************************************************************************
101
*/
102
WORD32 ihevcd_get_lvl_idx(WORD32 level)
103
0
{
104
0
    WORD32 lvl_idx = 0;
105
106
0
    if(level < IHEVC_LEVEL_20)
107
0
    {
108
0
        lvl_idx = 0;
109
0
    }
110
0
    else if(level >= IHEVC_LEVEL_20 && level < IHEVC_LEVEL_21)
111
0
    {
112
0
        lvl_idx = 1;
113
0
    }
114
0
    else if(level >= IHEVC_LEVEL_21 && level < IHEVC_LEVEL_30)
115
0
    {
116
0
        lvl_idx = 2;
117
0
    }
118
0
    else if(level >= IHEVC_LEVEL_30 && level < IHEVC_LEVEL_31)
119
0
    {
120
0
        lvl_idx = 3;
121
0
    }
122
0
    else if(level >= IHEVC_LEVEL_31 && level < IHEVC_LEVEL_40)
123
0
    {
124
0
        lvl_idx = 4;
125
0
    }
126
0
    else if(level >= IHEVC_LEVEL_40 && level < IHEVC_LEVEL_41)
127
0
    {
128
0
        lvl_idx = 5;
129
0
    }
130
0
    else if(level >= IHEVC_LEVEL_41 && level < IHEVC_LEVEL_50)
131
0
    {
132
0
        lvl_idx = 6;
133
0
    }
134
0
    else if(level >= IHEVC_LEVEL_50 && level < IHEVC_LEVEL_51)
135
0
    {
136
0
        lvl_idx = 7;
137
0
    }
138
0
    else if(level >= IHEVC_LEVEL_51 && level < IHEVC_LEVEL_52)
139
0
    {
140
0
        lvl_idx = 8;
141
0
    }
142
0
    else if(level >= IHEVC_LEVEL_52 && level < IHEVC_LEVEL_60)
143
0
    {
144
0
        lvl_idx = 9;
145
0
    }
146
0
    else if(level >= IHEVC_LEVEL_60 && level < IHEVC_LEVEL_61)
147
0
    {
148
0
        lvl_idx = 10;
149
0
    }
150
0
    else if(level >= IHEVC_LEVEL_61 && level < IHEVC_LEVEL_62)
151
0
    {
152
0
        lvl_idx = 11;
153
0
    }
154
0
    else if(level >= IHEVC_LEVEL_62)
155
0
    {
156
0
        lvl_idx = 12;
157
0
    }
158
159
0
    return (lvl_idx);
160
0
}
161
162
/**
163
*******************************************************************************
164
*
165
* @brief
166
*  Used to get reference picture buffer size for a given level and
167
*  and padding used
168
*
169
* @par Description:
170
*  Used to get reference picture buffer size for a given level and padding used
171
*  Each picture is padded on all four sides
172
*
173
* @param[in] pic_size
174
*  Mumber of luma samples (Width * Height)
175
*
176
* @param[in] level
177
*  Level
178
*
179
* @param[in] horz_pad
180
*  Total padding used in horizontal direction
181
*
182
* @param[in] vert_pad
183
*  Total padding used in vertical direction
184
*
185
* @returns  Total picture buffer size
186
*
187
* @remarks
188
*
189
*
190
*******************************************************************************
191
*/
192
WORD32 ihevcd_get_total_pic_buf_size(codec_t *ps_codec,
193
                                     WORD32 wd,
194
                                     WORD32 ht)
195
8.39k
{
196
8.39k
    WORD32 size;
197
8.39k
    WORD32 num_luma_samples;
198
8.39k
    WORD32 max_dpb_size;
199
8.39k
    WORD32 num_samples;
200
201
202
8.39k
    sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id);
203
204
    /* Get maximum number of buffers for the current picture size */
205
8.39k
    max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1];
206
207
8.39k
    if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT)
208
8.39k
        max_dpb_size += ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1];
209
210
8.39k
    max_dpb_size++;
211
    /* Allocation is required for
212
     * (Wd + horz_pad) * (Ht + vert_pad) * (2 * max_dpb_size + 1)
213
     */
214
215
    /* Account for padding area */
216
8.39k
    num_luma_samples = (wd + PAD_WD) * (ht + PAD_HT);
217
218
    /* Account for chroma */
219
8.39k
    if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444)
220
0
    {
221
0
        num_samples = num_luma_samples * 3;
222
0
    }
223
8.39k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422)
224
0
    {
225
0
        num_samples = num_luma_samples * 2;
226
0
    }
227
8.39k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
228
8.39k
    {
229
8.39k
        num_samples = num_luma_samples * 3 / 2;
230
8.39k
    }
231
0
    else
232
0
    {
233
0
        num_samples = num_luma_samples;
234
0
    }
235
236
    /* Number of bytes in reference pictures */
237
8.39k
    size = num_samples * max_dpb_size;
238
239
240
8.39k
    return size;
241
8.39k
}
242
/**
243
*******************************************************************************
244
*
245
* @brief
246
*  Used to get MV bank size for a given number of luma samples
247
*
248
* @par Description:
249
*  For given number of luma samples  one MV bank size is computed
250
*  Each MV bank includes pu_map and pu_t for all the min PUs(4x4) in a picture
251
*
252
* @param[in] num_luma_samples
253
*  Max number of luma pixels in the frame
254
*
255
* @returns  Total MV Bank size
256
*
257
* @remarks
258
*
259
*
260
*******************************************************************************
261
*/
262
WORD32 ihevcd_get_pic_mv_bank_size(WORD32 num_luma_samples)
263
15.1k
{
264
15.1k
    WORD32 size;
265
266
15.1k
    WORD32 pic_size;
267
268
15.1k
    WORD32 mv_bank_size;
269
15.1k
    WORD32 num_pu;
270
15.1k
    WORD32 num_ctb;
271
15.1k
    pic_size = num_luma_samples;
272
273
274
15.1k
    num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
275
15.1k
    num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
276
277
15.1k
    mv_bank_size = 0;
278
279
    /* Size for storing pu_t start index each CTB */
280
    /* One extra entry is needed to compute number of PUs in the last CTB */
281
15.1k
    mv_bank_size += (num_ctb + 1) * sizeof(WORD32);
282
283
    /* Size for pu_map */
284
15.1k
    mv_bank_size += num_pu;
285
286
    /* Size for storing pu_t for each PU */
287
15.1k
    mv_bank_size += num_pu * sizeof(pu_t);
288
289
    /* Size for storing slice_idx for each CTB */
290
15.1k
    mv_bank_size += ALIGN4(num_ctb * sizeof(UWORD16));
291
292
15.1k
    size =  mv_bank_size;
293
15.1k
    return size;
294
15.1k
}
295
/**
296
*******************************************************************************
297
*
298
* @brief
299
*  Used to get TU data size for a given number luma samples
300
*
301
* @par Description:
302
*  For a given number of luma samples TU data size is computed
303
*  Each TU data includes tu_map and tu_t and coeff data for all
304
*  the min TUs(4x4) in given CTB
305
*
306
* @param[in] num_luma_samples
307
*  Number of 64 x 64 CTBs for which TU data has to be allocated.
308
*
309
* @returns  Total TU data size
310
*
311
* @remarks Assumption is num_luma_samples will be at least
312
* 64 x 64 to handle CTB of size 64 x 64. Can be frame size as well
313
*
314
*******************************************************************************
315
*/
316
WORD32 ihevcd_get_tu_data_size(codec_t *ps_codec, WORD32 num_luma_samples)
317
8.39k
{
318
319
8.39k
    sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id);
320
8.39k
    WORD32 tu_data_size;
321
8.39k
    WORD32 num_ctb;
322
8.39k
    WORD32 num_luma_tu, num_chroma_tu, num_tu;
323
8.39k
    num_ctb = num_luma_samples / (MIN_CTB_SIZE * MIN_CTB_SIZE);
324
325
8.39k
    num_luma_tu = num_luma_samples / (MIN_TU_SIZE * MIN_TU_SIZE);
326
327
8.39k
    if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444)
328
0
    {
329
0
        num_chroma_tu = num_luma_tu << 1;
330
0
    }
331
8.39k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422)
332
0
    {
333
0
        num_chroma_tu = num_luma_tu;
334
0
    }
335
8.39k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
336
8.39k
    {
337
8.39k
        num_chroma_tu = num_luma_tu >> 1;
338
8.39k
    }
339
0
    else
340
0
    {
341
0
        num_chroma_tu = 0;
342
0
    }
343
344
8.39k
    num_tu = num_luma_tu + num_chroma_tu;
345
8.39k
    tu_data_size = 0;
346
347
    /* Size for storing tu_t start index each CTB */
348
    /* One extra entry is needed to compute number of TUs in the last CTB */
349
8.39k
    tu_data_size += (num_ctb + 1) * sizeof(WORD32);
350
351
    /* Size for storing tu map */
352
8.39k
    tu_data_size += num_luma_tu * sizeof(UWORD8);
353
354
    /* Size for storing tu_t for each TU */
355
8.39k
    tu_data_size += num_tu * sizeof(tu_t);
356
357
    /* Size for storing number of coded subblocks and scan_idx for each TU */
358
8.39k
    tu_data_size += num_tu * (sizeof(WORD8) + sizeof(WORD8));
359
360
    /* Size for storing coeff data for each TU */
361
8.39k
    tu_data_size += num_tu * sizeof(tu_sblk_coeff_data_t);
362
363
364
8.39k
    return tu_data_size;
365
8.39k
}
366
367
368
WORD32 ihevcd_nctb_cnt(codec_t *ps_codec, sps_t *ps_sps)
369
31.2k
{
370
31.2k
    WORD32 nctb = 1;
371
31.2k
    UNUSED(ps_codec);
372
    //TODO: Currently set to 1
373
    /* If CTB size is less than 32 x 32 then set nCTB as 4 */
374
31.2k
    if(ps_sps->i1_log2_ctb_size < 5)
375
3.24k
        nctb = 1;
376
377
31.2k
    return nctb;
378
31.2k
}
379
380
IHEVCD_ERROR_T ihevcd_get_tile_pos(pps_t *ps_pps,
381
                                   sps_t *ps_sps,
382
                                   WORD32 ctb_x,
383
                                   WORD32 ctb_y,
384
                                   WORD32 *pi4_ctb_tile_x,
385
                                   WORD32 *pi4_ctb_tile_y,
386
                                   WORD32 *pi4_tile_idx)
387
899k
{
388
389
899k
    tile_t *ps_tile_tmp;
390
899k
    WORD32 i;
391
899k
    WORD32 tile_row, tile_col;
392
393
899k
    if(ctb_x < 0 || ctb_y < 0)
394
0
    {
395
0
        *pi4_ctb_tile_x = 0;
396
0
        *pi4_ctb_tile_y = 0;
397
0
        *pi4_tile_idx = 0;
398
399
0
        return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
400
0
    }
401
402
899k
    tile_row = 0;
403
899k
    tile_col = 0;
404
899k
    ps_tile_tmp = ps_pps->ps_tile;
405
899k
    if(0 == ps_pps->i1_tiles_enabled_flag)
406
526k
    {
407
526k
        *pi4_ctb_tile_x = ctb_x;
408
526k
        *pi4_ctb_tile_y = ctb_y;
409
526k
        *pi4_tile_idx = 0;
410
526k
    }
411
372k
    else
412
372k
    {
413
1.23M
        for(i = 0; i < ps_pps->i1_num_tile_columns; i++)
414
1.23M
        {
415
1.23M
            WORD16 next_tile_ctb_x;
416
1.23M
            ps_tile_tmp = ps_pps->ps_tile + i; //* ps_pps->i1_num_tile_rows;
417
1.23M
            if((ps_pps->i1_num_tile_columns - 1) == i)
418
131k
            {
419
131k
                next_tile_ctb_x = ps_sps->i2_pic_wd_in_ctb;
420
131k
            }
421
1.10M
            else
422
1.10M
            {
423
1.10M
                tile_t *ps_tile_next_tmp;
424
1.10M
                ps_tile_next_tmp = ps_pps->ps_tile + i + 1;
425
1.10M
                next_tile_ctb_x = ps_tile_next_tmp->u1_pos_x;
426
1.10M
            }
427
1.23M
            if((ctb_x >= ps_tile_tmp->u1_pos_x) && (ctb_x < next_tile_ctb_x))
428
372k
            {
429
372k
                tile_col = i;
430
372k
                break;
431
372k
            }
432
1.23M
        }
433
372k
        *pi4_ctb_tile_x = ctb_x - ps_tile_tmp->u1_pos_x;
434
435
1.23M
        for(i = 0; i < ps_pps->i1_num_tile_rows; i++)
436
1.23M
        {
437
1.23M
            WORD16 next_tile_ctb_y;
438
1.23M
            ps_tile_tmp = ps_pps->ps_tile + i * ps_pps->i1_num_tile_columns;
439
1.23M
            if((ps_pps->i1_num_tile_rows - 1) == i)
440
240k
            {
441
240k
                next_tile_ctb_y = ps_sps->i2_pic_ht_in_ctb;
442
240k
            }
443
994k
            else
444
994k
            {
445
994k
                tile_t *ps_tile_next_tmp;
446
994k
                ps_tile_next_tmp = ps_pps->ps_tile + ((i + 1) * ps_pps->i1_num_tile_columns);
447
994k
                next_tile_ctb_y = ps_tile_next_tmp->u1_pos_y;
448
994k
            }
449
1.23M
            if((ctb_y >= ps_tile_tmp->u1_pos_y) && (ctb_y < next_tile_ctb_y))
450
372k
            {
451
372k
                tile_row = i;
452
372k
                break;
453
372k
            }
454
455
1.23M
        }
456
372k
        *pi4_ctb_tile_y = ctb_y - ps_tile_tmp->u1_pos_y;
457
372k
        *pi4_tile_idx = tile_row * ps_pps->i1_num_tile_columns
458
372k
                        + tile_col;
459
372k
    }
460
899k
    return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
461
899k
}
462
/**
463
*******************************************************************************
464
*
465
* @brief
466
*  Function to initialize ps_pic_buf structs add pic buffers to
467
*  buffer manager in case of non-shared mode
468
*
469
* @par Description:
470
*  Function to initialize ps_pic_buf structs add pic buffers to
471
*  buffer manager in case of non-shared mode
472
*  To be called once per stream or for every reset
473
*
474
* @param[in] ps_codec
475
*  Pointer to codec context
476
*
477
* @returns  Error from IHEVCD_ERROR_T
478
*
479
* @remarks
480
*
481
*
482
*******************************************************************************
483
*/
484
IHEVCD_ERROR_T ihevcd_pic_buf_mgr_add_bufs(codec_t *ps_codec)
485
6.76k
{
486
6.76k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
487
6.76k
    WORD32 i;
488
6.76k
    WORD32 max_dpb_size;
489
6.76k
    sps_t *ps_sps;
490
6.76k
    UWORD8 *pu1_buf;
491
6.76k
    pic_buf_t *ps_pic_buf;
492
6.76k
    WORD32 pic_buf_size_allocated;
493
6.76k
    WORD32 h_samp_factor, v_samp_factor;
494
6.76k
    WORD32 chroma_pixel_strd = 2;
495
496
497
    /* Initialize Pic buffer manager */
498
6.76k
    ps_sps = ps_codec->s_parse.ps_sps;
499
500
6.76k
    h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2;
501
6.76k
    v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1;
502
503
    /* Compute the number of Pic buffers needed */
504
6.76k
    max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1];
505
506
6.76k
    if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT)
507
6.76k
        max_dpb_size += ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1];
508
509
    /* Allocate one extra picture to handle current frame
510
     * In case of asynchronous parsing and processing, number of buffers should increase here
511
     * based on when parsing and processing threads are synchronized
512
     */
513
6.76k
    max_dpb_size++;
514
515
516
6.76k
    pu1_buf = (UWORD8 *)ps_codec->pu1_ref_pic_buf_base;
517
518
6.76k
    ps_pic_buf = (pic_buf_t *)ps_codec->ps_pic_buf;
519
520
    /* In case of non-shared mode, add picture buffers to buffer manager
521
     * In case of shared mode buffers are added in the run-time
522
     */
523
6.76k
    if(0 == ps_codec->i4_share_disp_buf)
524
6.76k
    {
525
6.76k
        WORD32 buf_ret;
526
6.76k
        WORD32 luma_samples;
527
6.76k
        WORD32 chroma_samples;
528
6.76k
        pic_buf_size_allocated = ps_codec->i4_total_pic_buf_size;
529
530
6.76k
        luma_samples = (ps_codec->i4_strd) *
531
6.76k
                        (ps_sps->i2_pic_height_in_luma_samples + PAD_HT);
532
533
6.76k
        if(CHROMA_FMT_IDC_MONOCHROME == ps_sps->i1_chroma_format_idc)
534
0
        {
535
0
            chroma_samples = 0;
536
0
        }
537
6.76k
        else
538
6.76k
        {
539
6.76k
            chroma_samples = luma_samples * 2 / (h_samp_factor * v_samp_factor);
540
6.76k
        }
541
542
        /* Try to add as many buffers as possible since memory is already allocated */
543
        /* If the number of buffers that can be added is less than max_num_bufs
544
         * return with an error.
545
         */
546
47.3k
        for(i = 0; i < max_dpb_size; i++)
547
40.6k
        {
548
40.6k
            pic_buf_size_allocated -= (luma_samples + chroma_samples);
549
550
40.6k
            if(pic_buf_size_allocated < 0)
551
0
            {
552
0
                ps_codec->s_parse.i4_error_code = IHEVCD_INSUFFICIENT_MEM_PICBUF;
553
0
                return IHEVCD_INSUFFICIENT_MEM_PICBUF;
554
0
            }
555
556
40.6k
            ps_pic_buf->pu1_luma = pu1_buf + ps_codec->i4_strd * PAD_TOP + PAD_LEFT;
557
40.6k
            pu1_buf += luma_samples;
558
559
40.6k
            if(chroma_samples)
560
40.6k
            {
561
40.6k
                ps_pic_buf->pu1_chroma = pu1_buf
562
40.6k
                                + (ps_codec->i4_strd * chroma_pixel_strd / h_samp_factor) * (PAD_TOP / v_samp_factor)
563
40.6k
                                + (PAD_LEFT * chroma_pixel_strd / h_samp_factor);
564
40.6k
                pu1_buf += chroma_samples;
565
40.6k
            }
566
0
            else
567
0
            {
568
0
                ps_pic_buf->pu1_chroma = NULL;
569
0
            }
570
571
            /* Pad boundary pixels (one pixel on all sides) */
572
            /* This ensures SAO does not read uninitialized pixels */
573
            /* Note these are not used in actual processing */
574
40.6k
            {
575
40.6k
                UWORD8 *pu1_buf;
576
40.6k
                WORD32 strd, wd, ht;
577
40.6k
                WORD32 i;
578
40.6k
                strd = ps_codec->i4_strd;
579
40.6k
                wd = ps_codec->i4_wd;
580
40.6k
                ht = ps_codec->i4_ht;
581
582
40.6k
                pu1_buf = ps_pic_buf->pu1_luma;
583
15.1M
                for(i = 0; i < ht; i++)
584
15.1M
                {
585
15.1M
                    pu1_buf[-1] = 0;
586
15.1M
                    pu1_buf[wd] = 0;
587
15.1M
                    pu1_buf += strd;
588
15.1M
                }
589
40.6k
                pu1_buf = ps_pic_buf->pu1_luma;
590
40.6k
                memset(pu1_buf - strd - 1, 0, wd + 2);
591
592
40.6k
                pu1_buf += strd * ht;
593
40.6k
                memset(pu1_buf - 1, 0, wd + 2);
594
595
40.6k
                if(ps_pic_buf->pu1_chroma)
596
40.6k
                {
597
40.6k
                    pu1_buf = ps_pic_buf->pu1_chroma;
598
40.6k
                    ht /= v_samp_factor;
599
40.6k
                    WORD32 chroma_strd_scale = chroma_pixel_strd / h_samp_factor;
600
7.60M
                    for(i = 0; i < ht; i++)
601
7.56M
                    {
602
7.56M
                        pu1_buf[-1] = 0;
603
7.56M
                        pu1_buf[-2] = 0;
604
7.56M
                        pu1_buf[wd * chroma_strd_scale] = 0;
605
7.56M
                        pu1_buf[wd * chroma_strd_scale + 1] = 0;
606
7.56M
                        pu1_buf += (strd * chroma_strd_scale);
607
7.56M
                    }
608
40.6k
                    pu1_buf = ps_pic_buf->pu1_chroma;
609
40.6k
                    memset(pu1_buf - (strd * chroma_strd_scale) - 2, 0, wd * chroma_strd_scale + 4);
610
611
40.6k
                    pu1_buf += (strd * chroma_strd_scale) * ht;
612
40.6k
                    memset(pu1_buf - 2, 0, wd * chroma_strd_scale + 4);
613
40.6k
                }
614
40.6k
            }
615
616
40.6k
            buf_ret = ihevc_buf_mgr_add((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, ps_pic_buf, i);
617
618
619
40.6k
            if(0 != buf_ret)
620
0
            {
621
0
                ps_codec->s_parse.i4_error_code = IHEVCD_BUF_MGR_ERROR;
622
0
                return IHEVCD_BUF_MGR_ERROR;
623
0
            }
624
40.6k
            ps_pic_buf++;
625
40.6k
        }
626
6.76k
    }
627
0
    else
628
0
    {
629
        /* In case of shared mode, buffers are added without adjusting for padding.
630
           Update luma and chroma pointers here to account for padding as per stride.
631
           In some cases stride might not be available when set_display_frame is called.
632
           Hence updated luma and chroma pointers here */
633
634
0
        for(i = 0; i < BUF_MGR_MAX_CNT; i++)
635
0
        {
636
0
            ps_pic_buf = ihevc_buf_mgr_get_buf((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, i);
637
0
            if((NULL == ps_pic_buf) ||
638
0
               (NULL == ps_pic_buf->pu1_luma) ||
639
0
               (NULL == ps_pic_buf->pu1_chroma))
640
0
            {
641
0
                break;
642
0
            }
643
0
            ps_pic_buf->pu1_luma += ps_codec->i4_strd * PAD_TOP + PAD_LEFT;
644
0
            ps_pic_buf->pu1_chroma += (ps_codec->i4_strd * chroma_pixel_strd / h_samp_factor) * (PAD_TOP / v_samp_factor)
645
0
                            + (PAD_LEFT * chroma_pixel_strd / h_samp_factor);
646
0
        }
647
0
    }
648
649
6.76k
    return ret;
650
6.76k
}
651
/**
652
*******************************************************************************
653
*
654
* @brief
655
*  Function to add buffers to MV Bank buffer manager
656
*
657
* @par Description:
658
*  Function to add buffers to MV Bank buffer manager
659
*  To be called once per stream or for every reset
660
*
661
* @param[in] ps_codec
662
*  Pointer to codec context
663
*
664
* @returns  Error from IHEVCD_ERROR_T
665
*
666
* @remarks
667
*
668
*
669
*******************************************************************************
670
*/
671
IHEVCD_ERROR_T ihevcd_mv_buf_mgr_add_bufs(codec_t *ps_codec)
672
6.76k
{
673
6.76k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
674
6.76k
    WORD32 i;
675
6.76k
    WORD32 max_dpb_size;
676
6.76k
    WORD32 mv_bank_size_allocated;
677
6.76k
    WORD32 pic_mv_bank_size;
678
679
6.76k
    sps_t *ps_sps;
680
6.76k
    UWORD8 *pu1_buf;
681
6.76k
    mv_buf_t *ps_mv_buf;
682
683
684
    /* Initialize MV Bank buffer manager */
685
6.76k
    ps_sps = ps_codec->s_parse.ps_sps;
686
687
688
    /* Compute the number of MV Bank buffers needed */
689
6.76k
    max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1];
690
691
    /* Allocate one extra MV Bank to handle current frame
692
     * In case of asynchronous parsing and processing, number of buffers should increase here
693
     * based on when parsing and processing threads are synchronized
694
     */
695
6.76k
    max_dpb_size++;
696
697
6.76k
    ps_codec->i4_max_dpb_size = max_dpb_size;
698
699
6.76k
    pu1_buf = (UWORD8 *)ps_codec->pv_mv_bank_buf_base;
700
701
6.76k
    ps_mv_buf = (mv_buf_t *)pu1_buf;
702
6.76k
    pu1_buf += max_dpb_size * sizeof(mv_buf_t);
703
6.76k
    ps_codec->ps_mv_buf = ps_mv_buf;
704
6.76k
    mv_bank_size_allocated = ps_codec->i4_total_mv_bank_size - max_dpb_size  * sizeof(mv_buf_t);
705
706
    /* Compute MV bank size per picture */
707
6.76k
    pic_mv_bank_size = ihevcd_get_pic_mv_bank_size(ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
708
6.76k
                                                   ALIGN64(ps_sps->i2_pic_height_in_luma_samples));
709
710
44.1k
    for(i = 0; i < max_dpb_size; i++)
711
37.3k
    {
712
37.3k
        WORD32 buf_ret;
713
37.3k
        WORD32 num_pu;
714
37.3k
        WORD32 num_ctb;
715
37.3k
        WORD32 pic_size;
716
37.3k
        pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
717
37.3k
                        ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
718
719
720
37.3k
        num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
721
37.3k
        num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
722
723
724
37.3k
        mv_bank_size_allocated -= pic_mv_bank_size;
725
726
37.3k
        if(mv_bank_size_allocated < 0)
727
0
        {
728
0
            ps_codec->s_parse.i4_error_code = IHEVCD_INSUFFICIENT_MEM_MVBANK;
729
0
            return IHEVCD_INSUFFICIENT_MEM_MVBANK;
730
0
        }
731
732
37.3k
        ps_mv_buf->pu4_pic_pu_idx = (UWORD32 *)pu1_buf;
733
37.3k
        pu1_buf += (num_ctb + 1) * sizeof(WORD32);
734
735
37.3k
        ps_mv_buf->pu1_pic_pu_map = pu1_buf;
736
37.3k
        pu1_buf += num_pu;
737
738
37.3k
        ps_mv_buf->pu1_pic_slice_map = (UWORD16 *)pu1_buf;
739
37.3k
        pu1_buf += ALIGN4(num_ctb * sizeof(UWORD16));
740
741
37.3k
        ps_mv_buf->ps_pic_pu = (pu_t *)pu1_buf;
742
37.3k
        pu1_buf += num_pu * sizeof(pu_t);
743
744
37.3k
        buf_ret = ihevc_buf_mgr_add((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, ps_mv_buf, i);
745
746
37.3k
        if(0 != buf_ret)
747
0
        {
748
0
            ps_codec->s_parse.i4_error_code = IHEVCD_BUF_MGR_ERROR;
749
0
            return IHEVCD_BUF_MGR_ERROR;
750
0
        }
751
752
37.3k
        ps_mv_buf++;
753
754
37.3k
    }
755
6.76k
    return ret;
756
6.76k
}
757
/**
758
*******************************************************************************
759
*
760
* @brief
761
*  Output buffer check
762
*
763
* @par Description:
764
*  Check for the number of buffers and buffer sizes of output buffer
765
*
766
* @param[in] ps_codec
767
*  Pointer to codec context
768
*
769
* @returns  Error from IHEVCD_ERROR_T
770
*
771
* @remarks
772
*
773
*
774
*******************************************************************************
775
*/
776
IHEVCD_ERROR_T ihevcd_check_out_buf_size(codec_t *ps_codec)
777
32.2k
{
778
32.2k
    ivd_out_bufdesc_t *ps_out_buffer = ps_codec->ps_out_buffer;
779
32.2k
    UWORD32 au4_min_out_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
780
32.2k
    UWORD32 u4_min_num_out_bufs = 0, i;
781
32.2k
    UWORD32 wd, ht;
782
783
32.2k
    if(0 == ps_codec->i4_share_disp_buf)
784
32.2k
    {
785
32.2k
        wd = ps_codec->i4_disp_wd;
786
32.2k
        ht = ps_codec->i4_disp_ht;
787
32.2k
    }
788
0
    else
789
0
    {
790
        /* In case of shared mode, do not check validity of ps_codec->ps_out_buffer */
791
0
        return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
792
0
    }
793
794
32.2k
    if(ps_codec->i4_disp_strd > (WORD32)wd)
795
0
        wd = ps_codec->i4_disp_strd;
796
797
32.2k
    if(ps_codec->e_chroma_fmt == IV_YUV_420P)
798
10.8k
        u4_min_num_out_bufs = MIN_OUT_BUFS_420;
799
21.4k
    else if(ps_codec->e_chroma_fmt == IV_YUV_444P)
800
0
        u4_min_num_out_bufs = MIN_OUT_BUFS_444;
801
21.4k
    else if(ps_codec->e_chroma_fmt == IV_YUV_422P)
802
0
        u4_min_num_out_bufs = MIN_OUT_BUFS_422;
803
21.4k
    else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV)
804
9.53k
                    || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU))
805
15.8k
        u4_min_num_out_bufs = MIN_OUT_BUFS_420SP;
806
5.56k
    else if(ps_codec->e_chroma_fmt == IV_GRAY)
807
5.56k
        u4_min_num_out_bufs = MIN_OUT_BUFS_GRAY;
808
809
32.2k
    if(ps_codec->e_chroma_fmt == IV_YUV_420P)
810
10.8k
    {
811
10.8k
        au4_min_out_buf_size[0] = (wd * ht);
812
10.8k
        au4_min_out_buf_size[1] = (wd * ht) >> 2;
813
10.8k
        au4_min_out_buf_size[2] = (wd * ht) >> 2;
814
10.8k
    }
815
21.4k
    else if(ps_codec->e_chroma_fmt == IV_YUV_444P)
816
0
    {
817
0
        au4_min_out_buf_size[0] = (wd * ht);
818
0
        au4_min_out_buf_size[1] = (wd * ht);
819
0
        au4_min_out_buf_size[2] = (wd * ht);
820
0
    }
821
21.4k
    else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV)
822
9.53k
                    || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU))
823
15.8k
    {
824
15.8k
        au4_min_out_buf_size[0] = (wd * ht);
825
15.8k
        au4_min_out_buf_size[1] = (wd * ht) >> 1;
826
15.8k
        au4_min_out_buf_size[2] = 0;
827
15.8k
    }
828
5.56k
    else if(ps_codec->e_chroma_fmt == IV_GRAY)
829
5.56k
    {
830
5.56k
        au4_min_out_buf_size[0] = (wd * ht);
831
5.56k
        au4_min_out_buf_size[1] = 0;
832
5.56k
        au4_min_out_buf_size[2] = 0;
833
5.56k
    }
834
0
    else if(ps_codec->e_chroma_fmt == IV_YUV_422P)
835
0
    {
836
0
        au4_min_out_buf_size[0] = (wd * ht);
837
0
        au4_min_out_buf_size[1] = (wd * ht) >> 1;
838
0
        au4_min_out_buf_size[2] = (wd * ht) >> 1;
839
0
    }
840
841
842
32.2k
    if(ps_out_buffer->u4_num_bufs < u4_min_num_out_bufs)
843
0
    {
844
0
        return (IHEVCD_ERROR_T)IV_FAIL;
845
0
    }
846
847
100k
    for (i = 0 ; i < u4_min_num_out_bufs; i++)
848
69.2k
    {
849
69.2k
        if(ps_out_buffer->u4_min_out_buf_size[i] < au4_min_out_buf_size[i])
850
545
        {
851
545
            return (IHEVCD_ERROR_T)IV_FAIL;
852
545
        }
853
69.2k
    }
854
855
31.7k
    return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
856
32.2k
}
857
858
/**
859
*******************************************************************************
860
*
861
* @brief
862
*  Picture level initializations required during parsing
863
*
864
* @par Description:
865
*  Initialize picture level context variables during parsing Initialize mv
866
* bank buffer manager in the first init call
867
*
868
* @param[in] ps_codec
869
*  Pointer to codec context
870
*
871
* @returns  Error from IHEVCD_ERROR_T
872
*
873
* @remarks
874
*
875
*
876
*******************************************************************************
877
*/
878
IHEVCD_ERROR_T ihevcd_parse_pic_init(codec_t *ps_codec)
879
32.2k
{
880
32.2k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
881
32.2k
    mv_buf_t *ps_mv_buf;
882
32.2k
    sps_t *ps_sps;
883
32.2k
    WORD32 num_min_cu;
884
32.2k
    WORD32 cur_pic_buf_id;
885
32.2k
    WORD32 cur_mv_bank_buf_id;
886
32.2k
    pic_buf_t *ps_cur_pic;
887
32.2k
    slice_header_t *ps_slice_hdr;
888
32.2k
    UWORD8 *pu1_cur_pic_luma, *pu1_cur_pic_chroma;
889
32.2k
    WORD32 h_samp_factor, v_samp_factor;
890
32.2k
    WORD32 chroma_pixel_strd = 2;
891
32.2k
    WORD32 i;
892
893
32.2k
    ps_codec->s_parse.i4_error_code = IHEVCD_SUCCESS;
894
32.2k
    ps_sps = ps_codec->s_parse.ps_sps;
895
32.2k
    ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr;
896
897
    /* Memset picture level intra map and transquant bypass map to zero */
898
32.2k
    num_min_cu = ((ps_sps->i2_pic_height_in_luma_samples + 7) / 8) * ((ps_sps->i2_pic_width_in_luma_samples + 63) / 64);
899
32.2k
    memset(ps_codec->s_parse.pu1_pic_intra_flag, 0, num_min_cu);
900
32.2k
    memset(ps_codec->s_parse.pu1_pic_no_loop_filter_flag, 0, num_min_cu);
901
902
32.2k
    h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2;
903
32.2k
    v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1;
904
905
32.2k
    if(0 == ps_codec->s_parse.i4_first_pic_init)
906
6.76k
    {
907
6.76k
        ret = ihevcd_mv_buf_mgr_add_bufs(ps_codec);
908
6.76k
        RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
909
910
6.76k
        ret = ihevcd_pic_buf_mgr_add_bufs(ps_codec);
911
6.76k
        RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
912
913
6.76k
        ps_codec->s_parse.i4_first_pic_init = 1;
914
6.76k
    }
915
916
    /* Output buffer check */
917
32.2k
    ret = ihevcd_check_out_buf_size(ps_codec);
918
32.2k
    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
919
920
    /* Initialize all the slice headers' slice addresses to zero */
921
31.7k
    {
922
31.7k
        WORD32 slice_idx;
923
31.7k
        WORD32 slice_start_idx;
924
925
31.7k
        slice_start_idx = ps_codec->i4_slice_error ? 2 : 1;
926
927
8.11M
        for(slice_idx = slice_start_idx; slice_idx < MAX_SLICE_HDR_CNT; slice_idx++)
928
8.08M
        {
929
8.08M
            slice_header_t *ps_slice_hdr_tmp = ps_codec->ps_slice_hdr_base + slice_idx;
930
8.08M
            ps_slice_hdr_tmp->i2_ctb_x = -1;
931
8.08M
            ps_slice_hdr_tmp->i2_ctb_y = -1;
932
933
8.08M
        }
934
31.7k
    }
935
936
    /* Get free MV Bank to hold current picture's motion vector data */
937
31.7k
    {
938
31.7k
        ps_mv_buf = (mv_buf_t *)ihevc_buf_mgr_get_next_free((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, &cur_mv_bank_buf_id);
939
940
        /* If there are no free buffers then return with an error code.
941
         * If the buffer is to be freed by another thread , change the
942
         * following to call thread yield and wait for buffer to be freed
943
         */
944
31.7k
        if(NULL == ps_mv_buf)
945
445
        {
946
445
            ps_codec->s_parse.i4_error_code = IHEVCD_NO_FREE_MVBANK;
947
445
            ps_codec->i4_error_code = IHEVCD_NO_FREE_MVBANK;
948
445
            return IHEVCD_NO_FREE_MVBANK;
949
445
        }
950
951
31.2k
        ps_codec->s_parse.ps_cur_mv_buf = ps_mv_buf;
952
        /* Set current ABS poc to ps_mv_buf, so that while freeing a reference buffer
953
         * corresponding mv buffer can be found by looping through ps_codec->ps_mv_buf array
954
         * and getting a buffer id to free
955
         */
956
31.2k
        ps_mv_buf->i4_abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
957
31.2k
    }
958
959
    /* Get free picture buffer to hold current picture recon data */
960
    /* TODO: For asynchronous api the following initializations related to picture
961
     * buffer should be moved to processing side
962
     */
963
0
    {
964
965
31.2k
        UWORD8 *pu1_buf;
966
31.2k
        ps_cur_pic = (pic_buf_t *)ihevc_buf_mgr_get_next_free((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, &cur_pic_buf_id);
967
968
        /* If there are no free buffers then return with an error code.
969
         * TODO: If the buffer is to be freed by another thread , change the
970
         * following to call thread yield and wait for buffer to be freed
971
         */
972
31.2k
        if(NULL == ps_cur_pic)
973
0
        {
974
0
            ps_codec->s_parse.i4_error_code = IHEVCD_NO_FREE_PICBUF;
975
0
            ps_codec->i4_error_code = IHEVCD_NO_FREE_PICBUF;
976
0
            return IHEVCD_NO_FREE_PICBUF;
977
0
        }
978
979
        /* Store input timestamp sent with input buffer */
980
31.2k
        ps_cur_pic->u4_ts = ps_codec->u4_ts;
981
31.2k
        ps_cur_pic->i4_abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
982
31.2k
        ps_cur_pic->i4_poc_lsb = ps_slice_hdr->i4_pic_order_cnt_lsb;
983
31.2k
        pu1_buf = ps_cur_pic->pu1_luma;
984
31.2k
        pu1_cur_pic_luma = pu1_buf;
985
986
31.2k
        pu1_buf = ps_cur_pic->pu1_chroma;
987
31.2k
        pu1_cur_pic_chroma = pu1_buf;
988
989
31.2k
#ifndef DISABLE_SEI
990
31.2k
        ps_cur_pic->s_sei_params.i1_sei_parameters_present_flag = 0;
991
31.2k
        if(ps_codec->s_parse.s_sei_params.i1_sei_parameters_present_flag)
992
686
        {
993
686
            sei_params_t *ps_sei = &ps_codec->s_parse.s_sei_params;
994
686
            ps_cur_pic->s_sei_params = ps_codec->s_parse.s_sei_params;
995
996
            /* Once sei_params is copied to pic_buf,
997
             * mark sei_params in s_parse as not present,
998
             * this ensures that future frames do not use this data again.
999
             */
1000
686
            ps_sei->i1_sei_parameters_present_flag = 0;
1001
686
            ps_sei->i1_user_data_registered_present_flag = 0;
1002
686
            ps_sei->i1_aud_present_flag = 0;
1003
686
            ps_sei->i1_time_code_present_flag = 0;
1004
686
            ps_sei->i1_buf_period_params_present_flag = 0;
1005
686
            ps_sei->i1_pic_timing_params_present_flag = 0;
1006
686
            ps_sei->i1_recovery_point_params_present_flag = 0;
1007
686
            ps_sei->i1_active_parameter_set = 0;
1008
686
            ps_sei->i4_sei_mastering_disp_colour_vol_params_present_flags = 0;
1009
686
        }
1010
31.2k
#endif
1011
31.2k
    }
1012
1013
31.2k
    if(0 == ps_codec->u4_pic_cnt)
1014
6.31k
    {
1015
6.31k
        memset(ps_cur_pic->pu1_luma, 128, (ps_sps->i2_pic_width_in_luma_samples + PAD_WD) * ps_sps->i2_pic_height_in_luma_samples);
1016
6.31k
        if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME)
1017
6.31k
        {
1018
6.31k
            memset(ps_cur_pic->pu1_chroma,
1019
6.31k
                   128,
1020
6.31k
                   (((ps_sps->i2_pic_width_in_luma_samples + PAD_WD) * (chroma_pixel_strd / h_samp_factor))
1021
6.31k
                                   * ps_sps->i2_pic_height_in_luma_samples / v_samp_factor));
1022
6.31k
        }
1023
6.31k
    }
1024
1025
    /* Fill the remaining entries of the reference lists with the nearest POC
1026
     * This is done to handle cases where there is a corruption in the reference index */
1027
31.2k
    {
1028
31.2k
        pic_buf_t *ps_pic_buf_ref;
1029
31.2k
        mv_buf_t *ps_mv_buf_ref;
1030
31.2k
        WORD32 r_idx;
1031
31.2k
        dpb_mgr_t *ps_dpb_mgr = (dpb_mgr_t *)ps_codec->pv_dpb_mgr;
1032
31.2k
        buf_mgr_t *ps_mv_buf_mgr = (buf_mgr_t *)ps_codec->pv_mv_buf_mgr;
1033
1034
31.2k
        ps_pic_buf_ref = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ps_slice_hdr->i4_abs_pic_order_cnt);
1035
31.2k
        if(NULL == ps_pic_buf_ref)
1036
21.6k
        {
1037
21.6k
            WORD32 size;
1038
1039
21.6k
            WORD32 num_pu;
1040
21.6k
            WORD32 num_ctb;
1041
21.6k
            WORD32 pic_size;
1042
            /* In case current mv buffer itself is being used as reference mv buffer for colocated
1043
             * calculations, then memset all the buffers to zero.
1044
             */
1045
21.6k
            pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
1046
21.6k
                            ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
1047
1048
21.6k
            num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
1049
21.6k
            num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
1050
1051
21.6k
            memset(ps_mv_buf->ai4_l0_collocated_poc, 0, sizeof(ps_mv_buf->ai4_l0_collocated_poc));
1052
21.6k
            memset(ps_mv_buf->ai1_l0_collocated_poc_lt, 0, sizeof(ps_mv_buf->ai1_l0_collocated_poc_lt));
1053
21.6k
            memset(ps_mv_buf->ai4_l1_collocated_poc, 0, sizeof(ps_mv_buf->ai4_l1_collocated_poc));
1054
21.6k
            memset(ps_mv_buf->ai1_l1_collocated_poc_lt, 0, sizeof(ps_mv_buf->ai1_l1_collocated_poc_lt));
1055
1056
21.6k
            size = (num_ctb + 1) * sizeof(WORD32);
1057
21.6k
            memset(ps_mv_buf->pu4_pic_pu_idx, 0, size);
1058
1059
21.6k
            size = num_pu;
1060
21.6k
            memset(ps_mv_buf->pu1_pic_pu_map, 0, size);
1061
21.6k
            size = ALIGN4(num_ctb * sizeof(UWORD16));
1062
21.6k
            memset(ps_mv_buf->pu1_pic_slice_map, 0, size);
1063
21.6k
            size = num_pu * sizeof(pu_t);
1064
21.6k
            memset(ps_mv_buf->ps_pic_pu, 0, size);
1065
1066
21.6k
            ps_pic_buf_ref = ps_cur_pic;
1067
21.6k
            ps_mv_buf_ref = ps_mv_buf;
1068
21.6k
        }
1069
9.63k
        else
1070
9.63k
        {
1071
9.63k
            ps_mv_buf_ref = ihevcd_mv_mgr_get_poc(ps_mv_buf_mgr, ps_pic_buf_ref->i4_abs_poc);
1072
9.63k
        }
1073
1074
57.4k
        for(r_idx = 0; r_idx < ps_slice_hdr->i1_num_ref_idx_l0_active; r_idx++)
1075
26.2k
        {
1076
26.2k
            if(NULL == ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf)
1077
4.41k
            {
1078
4.41k
                ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1079
4.41k
                ps_slice_hdr->as_ref_pic_list0[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1080
4.41k
            }
1081
26.2k
        }
1082
1083
505k
        for(r_idx = ps_slice_hdr->i1_num_ref_idx_l0_active; r_idx < MAX_DPB_SIZE; r_idx++)
1084
473k
        {
1085
473k
            ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1086
473k
            ps_slice_hdr->as_ref_pic_list0[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1087
473k
        }
1088
1089
52.4k
        for(r_idx = 0; r_idx < ps_slice_hdr->i1_num_ref_idx_l1_active; r_idx++)
1090
21.2k
        {
1091
21.2k
            if(NULL == ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf)
1092
3.94k
            {
1093
3.94k
                ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1094
3.94k
                ps_slice_hdr->as_ref_pic_list1[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1095
3.94k
            }
1096
21.2k
        }
1097
1098
510k
        for(r_idx = ps_slice_hdr->i1_num_ref_idx_l1_active; r_idx < MAX_DPB_SIZE; r_idx++)
1099
478k
        {
1100
478k
            ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1101
478k
            ps_slice_hdr->as_ref_pic_list1[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1102
478k
        }
1103
31.2k
    }
1104
1105
1106
    /* Reset the jobq to start of the jobq buffer */
1107
31.2k
    ihevcd_jobq_reset((jobq_t *)ps_codec->pv_proc_jobq);
1108
1109
31.2k
    if(ps_codec->i4_threads_active)
1110
31.2k
    {
1111
31.2k
        ps_codec->i4_break_threads = 0;
1112
31.2k
    }
1113
31.2k
    ps_codec->s_parse.i4_pic_pu_idx = 0;
1114
31.2k
    ps_codec->s_parse.i4_pic_tu_idx = 0;
1115
1116
31.2k
    ps_codec->s_parse.pu1_pic_pu_map = ps_mv_buf->pu1_pic_pu_map;
1117
31.2k
    ps_codec->s_parse.ps_pic_pu      = ps_mv_buf->ps_pic_pu;
1118
31.2k
    ps_codec->s_parse.pu4_pic_pu_idx = ps_mv_buf->pu4_pic_pu_idx;
1119
31.2k
    ps_codec->s_parse.pu1_slice_idx = (UWORD16 *)ps_mv_buf->pu1_pic_slice_map;
1120
281k
    for(i = 0; i < MAX_PROCESS_THREADS; i++)
1121
250k
    {
1122
250k
        ps_codec->as_process[i].pu1_slice_idx = (UWORD16 *)ps_mv_buf->pu1_pic_slice_map;
1123
250k
    }
1124
31.2k
    ps_codec->s_parse.pu1_pu_map = ps_codec->s_parse.pu1_pic_pu_map;
1125
31.2k
    ps_codec->s_parse.ps_pu = ps_codec->s_parse.ps_pic_pu;
1126
1127
31.2k
    {
1128
31.2k
        UWORD8 *pu1_buf;
1129
31.2k
        WORD32 ctb_luma_min_tu_cnt, ctb_chroma_min_tu_cnt, ctb_min_tu_cnt;
1130
31.2k
        WORD32 pic_size;
1131
31.2k
        WORD32 num_ctb;
1132
1133
31.2k
        pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
1134
31.2k
                        ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
1135
1136
31.2k
        ctb_luma_min_tu_cnt = pic_size / (MIN_TU_SIZE * MIN_TU_SIZE);
1137
1138
31.2k
        if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444)
1139
0
        {
1140
0
            ctb_chroma_min_tu_cnt = ctb_luma_min_tu_cnt << 1;
1141
0
        }
1142
31.2k
        else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV422)
1143
0
        {
1144
0
            ctb_chroma_min_tu_cnt = ctb_luma_min_tu_cnt;
1145
0
        }
1146
31.2k
        else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
1147
31.2k
        {
1148
31.2k
            ctb_chroma_min_tu_cnt = ctb_luma_min_tu_cnt >> 1;
1149
31.2k
        }
1150
0
        else
1151
0
        {
1152
0
            ctb_chroma_min_tu_cnt = 0;
1153
0
        }
1154
1155
31.2k
        ctb_min_tu_cnt = ctb_luma_min_tu_cnt + ctb_chroma_min_tu_cnt;
1156
1157
31.2k
        num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
1158
31.2k
        pu1_buf  = (UWORD8 *)ps_codec->pv_tu_data;
1159
31.2k
        ps_codec->s_parse.pu4_pic_tu_idx = (UWORD32 *)pu1_buf;
1160
31.2k
        pu1_buf += (num_ctb + 1) * sizeof(WORD32);
1161
1162
31.2k
        ps_codec->s_parse.pu1_pic_tu_map = pu1_buf;
1163
31.2k
        pu1_buf += ctb_min_tu_cnt;
1164
1165
31.2k
        ps_codec->s_parse.ps_pic_tu = (tu_t *)pu1_buf;
1166
31.2k
        pu1_buf += ctb_min_tu_cnt * sizeof(tu_t);
1167
1168
31.2k
        ps_codec->s_parse.pv_pic_tu_coeff_data = pu1_buf;
1169
1170
31.2k
        ps_codec->s_parse.pu1_tu_map = ps_codec->s_parse.pu1_pic_tu_map;
1171
31.2k
        ps_codec->s_parse.ps_tu = ps_codec->s_parse.ps_pic_tu;
1172
31.2k
        ps_codec->s_parse.pv_tu_coeff_data = ps_codec->s_parse.pv_pic_tu_coeff_data;
1173
31.2k
    }
1174
1175
31.2k
    ps_codec->s_parse.s_bs_ctxt.ps_pic_pu = ps_codec->s_parse.ps_pic_pu;
1176
31.2k
    ps_codec->s_parse.s_bs_ctxt.pu4_pic_pu_idx = ps_codec->s_parse.pu4_pic_pu_idx;
1177
31.2k
    ps_codec->s_parse.s_bs_ctxt.pu4_pic_tu_idx = ps_codec->s_parse.pu4_pic_tu_idx;
1178
1179
1180
    /* Set number of CTBs to be processed simultaneously */
1181
31.2k
    ps_codec->i4_proc_nctb = ihevcd_nctb_cnt(ps_codec, ps_sps);
1182
1183
    /* Memset Parse Map and process map at the start of frame */
1184
    //TODO: In case of asynchronous API proc_map can not be set to zero here
1185
31.2k
    {
1186
31.2k
        WORD32 num_ctb;
1187
1188
31.2k
        num_ctb = ps_sps->i4_pic_size_in_ctb;
1189
1190
31.2k
        memset(ps_codec->pu1_parse_map, 0, num_ctb);
1191
1192
31.2k
        memset(ps_codec->pu1_proc_map, 0, num_ctb);
1193
31.2k
    }
1194
1195
1196
1197
    /* Initialize disp buf id to -1, this will be updated at the end of frame if there is
1198
     * buffer to be displayed
1199
     */
1200
31.2k
    ps_codec->i4_disp_buf_id = -1;
1201
31.2k
    ps_codec->ps_disp_buf = NULL;
1202
1203
31.2k
    ps_codec->i4_disable_deblk_pic  = 0;
1204
31.2k
    ps_codec->i4_disable_sao_pic    = 0;
1205
31.2k
    ps_codec->i4_fullpel_inter_pred = 0;
1206
31.2k
    ps_codec->i4_mv_frac_mask       = 0x7FFFFFFF;
1207
1208
    /* If degrade is enabled, set the degrade flags appropriately */
1209
31.2k
    if(ps_codec->i4_degrade_type && ps_codec->i4_degrade_pics)
1210
0
    {
1211
0
        WORD32 degrade_pic;
1212
0
        ps_codec->i4_degrade_pic_cnt++;
1213
0
        degrade_pic = 0;
1214
1215
        /* If degrade is to be done in all frames, then do not check further */
1216
0
        switch(ps_codec->i4_degrade_pics)
1217
0
        {
1218
0
            case 4:
1219
0
            {
1220
0
                degrade_pic = 1;
1221
0
                break;
1222
0
            }
1223
0
            case 3:
1224
0
            {
1225
0
                if(ps_slice_hdr->i1_slice_type != ISLICE)
1226
0
                    degrade_pic = 1;
1227
1228
0
                break;
1229
0
            }
1230
0
            case 2:
1231
0
            {
1232
1233
                /* If pic count hits non-degrade interval or it is an islice, then do not degrade */
1234
0
                if((ps_slice_hdr->i1_slice_type != ISLICE) &&
1235
0
                   (ps_codec->i4_degrade_pic_cnt != ps_codec->i4_nondegrade_interval))
1236
0
                    degrade_pic = 1;
1237
1238
0
                break;
1239
0
            }
1240
0
            case 1:
1241
0
            {
1242
                /* Check if the current picture is non-ref */
1243
0
                if((ps_slice_hdr->i1_nal_unit_type < NAL_BLA_W_LP) &&
1244
0
                   (ps_slice_hdr->i1_nal_unit_type % 2 == 0))
1245
0
                {
1246
0
                    degrade_pic = 1;
1247
0
                }
1248
0
                break;
1249
0
            }
1250
1251
1252
0
        }
1253
0
        if(degrade_pic)
1254
0
        {
1255
0
            if(ps_codec->i4_degrade_type & 0x1)
1256
0
                ps_codec->i4_disable_sao_pic = 1;
1257
1258
0
            if(ps_codec->i4_degrade_type & 0x2)
1259
0
                ps_codec->i4_disable_deblk_pic = 1;
1260
1261
            /* MC degrading is done only for non-ref pictures */
1262
0
            if((ps_slice_hdr->i1_nal_unit_type < NAL_BLA_W_LP) &&
1263
0
               (ps_slice_hdr->i1_nal_unit_type % 2 == 0))
1264
0
            {
1265
0
                if(ps_codec->i4_degrade_type & 0x4)
1266
0
                    ps_codec->i4_mv_frac_mask = 0;
1267
1268
0
                if(ps_codec->i4_degrade_type & 0x8)
1269
0
                    ps_codec->i4_mv_frac_mask = 0;
1270
0
            }
1271
0
        }
1272
0
        else
1273
0
            ps_codec->i4_degrade_pic_cnt = 0;
1274
0
    }
1275
1276
1277
31.2k
    {
1278
31.2k
        WORD32 i;
1279
281k
        for(i = 0; i < MAX_PROCESS_THREADS; i++)
1280
250k
        {
1281
250k
            ps_codec->as_process[i].pu4_pic_pu_idx = ps_codec->s_parse.pu4_pic_pu_idx;
1282
250k
            ps_codec->as_process[i].ps_pic_pu = ps_codec->s_parse.ps_pic_pu;
1283
250k
            ps_codec->as_process[i].pu1_pic_pu_map = ps_codec->s_parse.pu1_pic_pu_map;
1284
250k
            ps_codec->as_process[i].pu4_pic_tu_idx = ps_codec->s_parse.pu4_pic_tu_idx;
1285
250k
            ps_codec->as_process[i].ps_pic_tu = ps_codec->s_parse.ps_pic_tu;
1286
250k
            ps_codec->as_process[i].pu1_pic_tu_map = ps_codec->s_parse.pu1_pic_tu_map;
1287
250k
            ps_codec->as_process[i].pv_pic_tu_coeff_data = ps_codec->s_parse.pv_pic_tu_coeff_data;
1288
250k
            ps_codec->as_process[i].i4_cur_mv_bank_buf_id = cur_mv_bank_buf_id;
1289
250k
            ps_codec->as_process[i].s_sao_ctxt.pu1_slice_idx = ps_codec->as_process[i].pu1_slice_idx;
1290
250k
            ps_codec->as_process[i].s_sao_ctxt.pu1_tile_idx = ps_codec->as_process[i].pu1_tile_idx;
1291
1292
            /* TODO: For asynchronous api the following initializations related to picture
1293
             * buffer should be moved to processing side
1294
             */
1295
250k
            ps_codec->as_process[i].pu1_cur_pic_luma = pu1_cur_pic_luma;
1296
250k
            ps_codec->as_process[i].pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1297
250k
            ps_codec->as_process[i].ps_cur_pic = ps_cur_pic;
1298
250k
            ps_codec->as_process[i].i4_cur_pic_buf_id = cur_pic_buf_id;
1299
1300
250k
            ps_codec->as_process[i].ps_out_buffer = ps_codec->ps_out_buffer;
1301
250k
            if(1 < ps_codec->i4_num_cores)
1302
149k
            {
1303
149k
                ps_codec->as_process[i].i4_check_parse_status = 1;
1304
149k
                ps_codec->as_process[i].i4_check_proc_status = 1;
1305
149k
            }
1306
100k
            else
1307
100k
            {
1308
100k
                ps_codec->as_process[i].i4_check_parse_status = 0;
1309
100k
                ps_codec->as_process[i].i4_check_proc_status = 0;
1310
100k
            }
1311
250k
            ps_codec->as_process[i].pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag;
1312
250k
            ps_codec->as_process[i].pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag;
1313
250k
            ps_codec->as_process[i].i4_init_done = 0;
1314
1315
250k
            ps_codec->as_process[i].s_bs_ctxt.pu4_pic_tu_idx = ps_codec->as_process[i].pu4_pic_tu_idx;
1316
250k
            ps_codec->as_process[i].s_bs_ctxt.pu4_pic_pu_idx = ps_codec->as_process[i].pu4_pic_pu_idx;
1317
250k
            ps_codec->as_process[i].s_bs_ctxt.ps_pic_pu = ps_codec->as_process[i].ps_pic_pu;
1318
250k
            ps_codec->as_process[i].s_deblk_ctxt.pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag;
1319
250k
            ps_codec->as_process[i].s_deblk_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1320
250k
            ps_codec->as_process[i].s_deblk_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1321
250k
            ps_codec->as_process[i].s_sao_ctxt.pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag;
1322
250k
            ps_codec->as_process[i].s_sao_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1323
250k
            ps_codec->as_process[i].s_sao_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1324
250k
            if(i < (ps_codec->i4_num_cores - 1))
1325
39.9k
            {
1326
39.9k
                if (!ps_codec->ai4_process_thread_created[i])
1327
6.86k
                {
1328
6.86k
                    ithread_create(ps_codec->apv_process_thread_handle[i], NULL,
1329
6.86k
                                (void *)ihevcd_process_thread,
1330
6.86k
                                (void *)&ps_codec->as_process[i]);
1331
6.86k
                    ps_codec->ai4_process_thread_created[i] = 1;
1332
6.86k
                }
1333
39.9k
                if(ps_codec->i4_threads_active)
1334
39.9k
                {
1335
39.9k
                    ret = ithread_mutex_lock(ps_codec->apv_proc_start_mutex[i]);
1336
39.9k
                    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
1337
1338
39.9k
                    ps_codec->ai4_process_start[i] = 1;
1339
39.9k
                    ithread_cond_signal(ps_codec->apv_proc_start_condition[i]);
1340
1341
39.9k
                    ret = ithread_mutex_unlock(ps_codec->apv_proc_start_mutex[i]);
1342
39.9k
                    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
1343
39.9k
                }
1344
39.9k
            }
1345
210k
            else
1346
210k
            {
1347
210k
                ps_codec->ai4_process_thread_created[i] = 0;
1348
210k
            }
1349
1350
250k
        }
1351
31.2k
        if(ps_codec->u1_enable_cu_info)
1352
0
        {
1353
0
            ps_codec->as_buf_id_info_map[cur_pic_buf_id].pu1_qp_map =
1354
0
                ps_codec->pu1_qp_map_base + (cur_pic_buf_id * ps_codec->u4_num_8x8_blks);
1355
0
            ps_codec->as_buf_id_info_map[cur_pic_buf_id].pu1_cu_type_map =
1356
0
                ps_codec->pu1_cu_type_map_base + (cur_pic_buf_id * ps_codec->u4_num_8x8_blks);
1357
0
            memset(ps_codec->as_buf_id_info_map[cur_pic_buf_id].pu1_qp_map,
1358
0
                0, ps_codec->u4_num_8x8_blks);
1359
0
            memset(ps_codec->as_buf_id_info_map[cur_pic_buf_id].pu1_qp_map,
1360
0
                0, ps_codec->u4_num_8x8_blks);
1361
0
        }
1362
1363
31.2k
        ps_codec->s_parse.s_deblk_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1364
31.2k
        ps_codec->s_parse.s_deblk_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1365
1366
31.2k
        ps_codec->s_parse.s_sao_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1367
31.2k
        ps_codec->s_parse.s_sao_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1368
31.2k
    }
1369
    /* Since any input bitstream buffer that contains slice data will be sent to output(even in
1370
     * case of error, this buffer is added to display queue and next buffer in the display queue
1371
     * will be returned as the display buffer.
1372
     * Note: If format conversion (or frame copy) is used and is scheduled
1373
     * in a different thread then it has to check if the processing for the current row is complete before
1374
     * it copies/converts a given row. In case of low delay or in case of B pictures, current frame being decoded has to be
1375
     * returned, which requires a status check to ensure that the current row is reconstructed before copying.
1376
     */
1377
    /* Add current picture to display manager */
1378
0
    {
1379
31.2k
        WORD32 abs_poc;
1380
31.2k
        slice_header_t *ps_slice_hdr;
1381
31.2k
        ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr;
1382
31.2k
        abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
1383
31.2k
        ihevc_disp_mgr_add((disp_mgr_t *)ps_codec->pv_disp_buf_mgr,
1384
31.2k
                           ps_codec->as_process[0].i4_cur_pic_buf_id,
1385
31.2k
                           abs_poc,
1386
31.2k
                           ps_codec->as_process[0].ps_cur_pic);
1387
31.2k
    }
1388
31.2k
    ps_codec->ps_disp_buf = NULL;
1389
    /* Get picture to be displayed if number of pictures decoded is more than max allowed reorder */
1390
    /* Since the current will be decoded, check is fore >= instead of > */
1391
31.2k
    if(((WORD32)(ps_codec->u4_pic_cnt - ps_codec->u4_disp_cnt) >= ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1]) ||
1392
2.26k
       (ps_codec->e_frm_out_mode == IVD_DECODE_FRAME_OUT))
1393
1394
28.9k
    {
1395
28.9k
        ps_codec->ps_disp_buf = (pic_buf_t *)ihevc_disp_mgr_get((disp_mgr_t *)ps_codec->pv_disp_buf_mgr, &ps_codec->i4_disp_buf_id);
1396
28.9k
        ps_codec->u4_disp_cnt++;
1397
28.9k
    }
1398
1399
31.2k
    ps_codec->s_fmt_conv.i4_cur_row = 0;
1400
    /* Set number of rows to be processed at a time */
1401
31.2k
    ps_codec->s_fmt_conv.i4_num_rows = 4;
1402
1403
31.2k
    if(ps_codec->u4_enable_fmt_conv_ahead && (ps_codec->i4_num_cores > 1))
1404
0
    {
1405
0
        process_ctxt_t *ps_proc;
1406
1407
        /* i4_num_cores - 1 contexts are currently being used by other threads */
1408
0
        ps_proc = &ps_codec->as_process[ps_codec->i4_num_cores - 1];
1409
1410
        /* If the frame being decoded and displayed are different, schedule format conversion jobs
1411
         * this will keep the proc threads busy and lets parse thread decode few CTBs ahead
1412
         * If the frame being decoded and displayed are same, then format conversion is scheduled later.
1413
         */
1414
0
        if((ps_codec->ps_disp_buf) && (ps_codec->i4_disp_buf_id != ps_proc->i4_cur_pic_buf_id) &&
1415
0
           ((0 == ps_codec->i4_share_disp_buf) || (IV_YUV_420P == ps_codec->e_chroma_fmt)))
1416
0
        {
1417
1418
0
            for(i = 0; i < ps_sps->i2_pic_ht_in_ctb; i++)
1419
0
            {
1420
0
                proc_job_t s_job;
1421
0
                IHEVCD_ERROR_T ret;
1422
0
                s_job.i4_cmd = CMD_FMTCONV;
1423
0
                s_job.i2_ctb_cnt = 0;
1424
0
                s_job.i2_ctb_x = 0;
1425
0
                s_job.i2_ctb_y = i;
1426
0
                s_job.i2_slice_idx = 0;
1427
0
                s_job.i4_tu_coeff_data_ofst = 0;
1428
0
                ret = ihevcd_jobq_queue((jobq_t *)ps_codec->s_parse.pv_proc_jobq,
1429
0
                                        &s_job, sizeof(proc_job_t), 1);
1430
0
                if(ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS)
1431
0
                    return ret;
1432
0
            }
1433
0
        }
1434
0
    }
1435
1436
    /* If parse_pic_init is called, then slice data is present in the input bitstrea stream */
1437
31.2k
    ps_codec->i4_pic_present = 1;
1438
1439
31.2k
    return ret;
1440
31.2k
}
1441
1442