Coverage Report

Created: 2026-04-12 06:50

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
1.11k
{
196
1.11k
    WORD32 size;
197
1.11k
    WORD32 num_luma_samples;
198
1.11k
    WORD32 max_dpb_size;
199
1.11k
    WORD32 num_samples;
200
201
202
1.11k
    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
1.11k
    max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1];
206
207
1.11k
    if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT)
208
1.11k
        max_dpb_size += ps_sps->ai1_sps_max_num_reorder_pics[ps_sps->i1_sps_max_sub_layers - 1];
209
210
1.11k
    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
1.11k
    num_luma_samples = (wd + PAD_WD) * (ht + PAD_HT);
217
218
    /* Account for chroma */
219
1.11k
    if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV444)
220
0
    {
221
0
        num_samples = num_luma_samples * 3;
222
0
    }
223
1.11k
    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
1.11k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
228
1.11k
    {
229
1.11k
        num_samples = num_luma_samples * 3 / 2;
230
1.11k
    }
231
0
    else
232
0
    {
233
0
        num_samples = num_luma_samples;
234
0
    }
235
236
    /* Number of bytes in reference pictures */
237
1.11k
    size = num_samples * max_dpb_size;
238
239
240
1.11k
    return size;
241
1.11k
}
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
2.12k
{
264
2.12k
    WORD32 size;
265
266
2.12k
    WORD32 pic_size;
267
268
2.12k
    WORD32 mv_bank_size;
269
2.12k
    WORD32 num_pu;
270
2.12k
    WORD32 num_ctb;
271
2.12k
    pic_size = num_luma_samples;
272
273
274
2.12k
    num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
275
2.12k
    num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
276
277
2.12k
    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
2.12k
    mv_bank_size += (num_ctb + 1) * sizeof(WORD32);
282
283
    /* Size for pu_map */
284
2.12k
    mv_bank_size += num_pu;
285
286
    /* Size for storing pu_t for each PU */
287
2.12k
    mv_bank_size += num_pu * sizeof(pu_t);
288
289
    /* Size for storing slice_idx for each CTB */
290
2.12k
    mv_bank_size += ALIGN4(num_ctb * sizeof(UWORD16));
291
292
2.12k
    size =  mv_bank_size;
293
2.12k
    return size;
294
2.12k
}
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
1.11k
{
318
319
1.11k
    sps_t *ps_sps = (ps_codec->s_parse.ps_sps_base + ps_codec->i4_sps_id);
320
1.11k
    WORD32 tu_data_size;
321
1.11k
    WORD32 num_ctb;
322
1.11k
    WORD32 num_luma_tu, num_chroma_tu, num_tu;
323
1.11k
    num_ctb = num_luma_samples / (MIN_CTB_SIZE * MIN_CTB_SIZE);
324
325
1.11k
    num_luma_tu = num_luma_samples / (MIN_TU_SIZE * MIN_TU_SIZE);
326
327
1.11k
    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
1.11k
    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
1.11k
    else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
336
1.11k
    {
337
1.11k
        num_chroma_tu = num_luma_tu >> 1;
338
1.11k
    }
339
0
    else
340
0
    {
341
0
        num_chroma_tu = 0;
342
0
    }
343
344
1.11k
    num_tu = num_luma_tu + num_chroma_tu;
345
1.11k
    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
1.11k
    tu_data_size += (num_ctb + 1) * sizeof(WORD32);
350
351
    /* Size for storing tu map */
352
1.11k
    tu_data_size += num_luma_tu * sizeof(UWORD8);
353
354
    /* Size for storing tu_t for each TU */
355
1.11k
    tu_data_size += num_tu * sizeof(tu_t);
356
357
    /* Size for storing number of coded subblocks and scan_idx for each TU */
358
1.11k
    tu_data_size += num_tu * (sizeof(WORD8) + sizeof(WORD8));
359
360
    /* Size for storing coeff data for each TU */
361
1.11k
    tu_data_size += num_tu * sizeof(tu_sblk_coeff_data_t);
362
363
364
1.11k
    return tu_data_size;
365
1.11k
}
366
367
368
WORD32 ihevcd_nctb_cnt(codec_t *ps_codec, sps_t *ps_sps)
369
8.78k
{
370
8.78k
    WORD32 nctb = 1;
371
8.78k
    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
8.78k
    if(ps_sps->i1_log2_ctb_size < 5)
375
333
        nctb = 1;
376
377
8.78k
    return nctb;
378
8.78k
}
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
223k
{
388
389
223k
    tile_t *ps_tile_tmp;
390
223k
    WORD32 i;
391
223k
    WORD32 tile_row, tile_col;
392
393
223k
    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
223k
    tile_row = 0;
403
223k
    tile_col = 0;
404
223k
    ps_tile_tmp = ps_pps->ps_tile;
405
223k
    if(0 == ps_pps->i1_tiles_enabled_flag)
406
129k
    {
407
129k
        *pi4_ctb_tile_x = ctb_x;
408
129k
        *pi4_ctb_tile_y = ctb_y;
409
129k
        *pi4_tile_idx = 0;
410
129k
    }
411
94.7k
    else
412
94.7k
    {
413
183k
        for(i = 0; i < ps_pps->i1_num_tile_columns; i++)
414
183k
        {
415
183k
            WORD16 next_tile_ctb_x;
416
183k
            ps_tile_tmp = ps_pps->ps_tile + i; //* ps_pps->i1_num_tile_rows;
417
183k
            if((ps_pps->i1_num_tile_columns - 1) == i)
418
37.1k
            {
419
37.1k
                next_tile_ctb_x = ps_sps->i2_pic_wd_in_ctb;
420
37.1k
            }
421
145k
            else
422
145k
            {
423
145k
                tile_t *ps_tile_next_tmp;
424
145k
                ps_tile_next_tmp = ps_pps->ps_tile + i + 1;
425
145k
                next_tile_ctb_x = ps_tile_next_tmp->u1_pos_x;
426
145k
            }
427
183k
            if((ctb_x >= ps_tile_tmp->u1_pos_x) && (ctb_x < next_tile_ctb_x))
428
94.7k
            {
429
94.7k
                tile_col = i;
430
94.7k
                break;
431
94.7k
            }
432
183k
        }
433
94.7k
        *pi4_ctb_tile_x = ctb_x - ps_tile_tmp->u1_pos_x;
434
435
196k
        for(i = 0; i < ps_pps->i1_num_tile_rows; i++)
436
196k
        {
437
196k
            WORD16 next_tile_ctb_y;
438
196k
            ps_tile_tmp = ps_pps->ps_tile + i * ps_pps->i1_num_tile_columns;
439
196k
            if((ps_pps->i1_num_tile_rows - 1) == i)
440
30.6k
            {
441
30.6k
                next_tile_ctb_y = ps_sps->i2_pic_ht_in_ctb;
442
30.6k
            }
443
166k
            else
444
166k
            {
445
166k
                tile_t *ps_tile_next_tmp;
446
166k
                ps_tile_next_tmp = ps_pps->ps_tile + ((i + 1) * ps_pps->i1_num_tile_columns);
447
166k
                next_tile_ctb_y = ps_tile_next_tmp->u1_pos_y;
448
166k
            }
449
196k
            if((ctb_y >= ps_tile_tmp->u1_pos_y) && (ctb_y < next_tile_ctb_y))
450
94.7k
            {
451
94.7k
                tile_row = i;
452
94.7k
                break;
453
94.7k
            }
454
455
196k
        }
456
94.7k
        *pi4_ctb_tile_y = ctb_y - ps_tile_tmp->u1_pos_y;
457
94.7k
        *pi4_tile_idx = tile_row * ps_pps->i1_num_tile_columns
458
94.7k
                        + tile_col;
459
94.7k
    }
460
223k
    return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
461
223k
}
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
1.00k
{
486
1.00k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
487
1.00k
    WORD32 i;
488
1.00k
    WORD32 max_dpb_size;
489
1.00k
    sps_t *ps_sps;
490
1.00k
    UWORD8 *pu1_buf;
491
1.00k
    pic_buf_t *ps_pic_buf;
492
1.00k
    WORD32 pic_buf_size_allocated;
493
1.00k
    WORD32 h_samp_factor, v_samp_factor;
494
1.00k
    WORD32 chroma_pixel_strd = 2;
495
496
497
    /* Initialize Pic buffer manager */
498
1.00k
    ps_sps = ps_codec->s_parse.ps_sps;
499
500
1.00k
    h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2;
501
1.00k
    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
1.00k
    max_dpb_size = ps_sps->ai1_sps_max_dec_pic_buffering[ps_sps->i1_sps_max_sub_layers - 1];
505
506
1.00k
    if(ps_codec->e_frm_out_mode != IVD_DECODE_FRAME_OUT)
507
1.00k
        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
1.00k
    max_dpb_size++;
514
515
516
1.00k
    pu1_buf = (UWORD8 *)ps_codec->pu1_ref_pic_buf_base;
517
518
1.00k
    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
1.00k
    if(0 == ps_codec->i4_share_disp_buf)
524
1.00k
    {
525
1.00k
        WORD32 buf_ret;
526
1.00k
        WORD32 luma_samples;
527
1.00k
        WORD32 chroma_samples;
528
1.00k
        pic_buf_size_allocated = ps_codec->i4_total_pic_buf_size;
529
530
1.00k
        luma_samples = (ps_codec->i4_strd) *
531
1.00k
                        (ps_sps->i2_pic_height_in_luma_samples + PAD_HT);
532
533
1.00k
        if(CHROMA_FMT_IDC_MONOCHROME == ps_sps->i1_chroma_format_idc)
534
0
        {
535
0
            chroma_samples = 0;
536
0
        }
537
1.00k
        else
538
1.00k
        {
539
1.00k
            chroma_samples = luma_samples * 2 / (h_samp_factor * v_samp_factor);
540
1.00k
        }
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
10.2k
        for(i = 0; i < max_dpb_size; i++)
547
9.20k
        {
548
9.20k
            pic_buf_size_allocated -= (luma_samples + chroma_samples);
549
550
9.20k
            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
9.20k
            ps_pic_buf->pu1_luma = pu1_buf + ps_codec->i4_strd * PAD_TOP + PAD_LEFT;
557
9.20k
            pu1_buf += luma_samples;
558
559
9.20k
            if(chroma_samples)
560
9.20k
            {
561
9.20k
                ps_pic_buf->pu1_chroma = pu1_buf
562
9.20k
                                + (ps_codec->i4_strd * chroma_pixel_strd / h_samp_factor) * (PAD_TOP / v_samp_factor)
563
9.20k
                                + (PAD_LEFT * chroma_pixel_strd / h_samp_factor);
564
9.20k
                pu1_buf += chroma_samples;
565
9.20k
            }
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
9.20k
            {
575
9.20k
                UWORD8 *pu1_buf;
576
9.20k
                WORD32 strd, wd, ht;
577
9.20k
                WORD32 i;
578
9.20k
                strd = ps_codec->i4_strd;
579
9.20k
                wd = ps_codec->i4_wd;
580
9.20k
                ht = ps_codec->i4_ht;
581
582
9.20k
                pu1_buf = ps_pic_buf->pu1_luma;
583
2.77M
                for(i = 0; i < ht; i++)
584
2.76M
                {
585
2.76M
                    pu1_buf[-1] = 0;
586
2.76M
                    pu1_buf[wd] = 0;
587
2.76M
                    pu1_buf += strd;
588
2.76M
                }
589
9.20k
                pu1_buf = ps_pic_buf->pu1_luma;
590
9.20k
                memset(pu1_buf - strd - 1, 0, wd + 2);
591
592
9.20k
                pu1_buf += strd * ht;
593
9.20k
                memset(pu1_buf - 1, 0, wd + 2);
594
595
9.20k
                if(ps_pic_buf->pu1_chroma)
596
9.20k
                {
597
9.20k
                    pu1_buf = ps_pic_buf->pu1_chroma;
598
9.20k
                    ht /= v_samp_factor;
599
9.20k
                    WORD32 chroma_strd_scale = chroma_pixel_strd / h_samp_factor;
600
1.39M
                    for(i = 0; i < ht; i++)
601
1.38M
                    {
602
1.38M
                        pu1_buf[-1] = 0;
603
1.38M
                        pu1_buf[-2] = 0;
604
1.38M
                        pu1_buf[wd * chroma_strd_scale] = 0;
605
1.38M
                        pu1_buf[wd * chroma_strd_scale + 1] = 0;
606
1.38M
                        pu1_buf += (strd * chroma_strd_scale);
607
1.38M
                    }
608
9.20k
                    pu1_buf = ps_pic_buf->pu1_chroma;
609
9.20k
                    memset(pu1_buf - (strd * chroma_strd_scale) - 2, 0, wd * chroma_strd_scale + 4);
610
611
9.20k
                    pu1_buf += (strd * chroma_strd_scale) * ht;
612
9.20k
                    memset(pu1_buf - 2, 0, wd * chroma_strd_scale + 4);
613
9.20k
                }
614
9.20k
            }
615
616
9.20k
            buf_ret = ihevc_buf_mgr_add((buf_mgr_t *)ps_codec->pv_pic_buf_mgr, ps_pic_buf, i);
617
618
619
9.20k
            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
9.20k
            ps_pic_buf++;
625
9.20k
        }
626
1.00k
    }
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
1.00k
    return ret;
650
1.00k
}
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
1.00k
{
673
1.00k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
674
1.00k
    WORD32 i;
675
1.00k
    WORD32 max_dpb_size;
676
1.00k
    WORD32 mv_bank_size_allocated;
677
1.00k
    WORD32 pic_mv_bank_size;
678
679
1.00k
    sps_t *ps_sps;
680
1.00k
    UWORD8 *pu1_buf;
681
1.00k
    mv_buf_t *ps_mv_buf;
682
683
684
    /* Initialize MV Bank buffer manager */
685
1.00k
    ps_sps = ps_codec->s_parse.ps_sps;
686
687
688
    /* Compute the number of MV Bank buffers needed */
689
1.00k
    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
1.00k
    max_dpb_size++;
696
697
1.00k
    ps_codec->i4_max_dpb_size = max_dpb_size;
698
699
1.00k
    pu1_buf = (UWORD8 *)ps_codec->pv_mv_bank_buf_base;
700
701
1.00k
    ps_mv_buf = (mv_buf_t *)pu1_buf;
702
1.00k
    pu1_buf += max_dpb_size * sizeof(mv_buf_t);
703
1.00k
    ps_codec->ps_mv_buf = ps_mv_buf;
704
1.00k
    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
1.00k
    pic_mv_bank_size = ihevcd_get_pic_mv_bank_size(ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
708
1.00k
                                                   ALIGN64(ps_sps->i2_pic_height_in_luma_samples));
709
710
8.51k
    for(i = 0; i < max_dpb_size; i++)
711
7.51k
    {
712
7.51k
        WORD32 buf_ret;
713
7.51k
        WORD32 num_pu;
714
7.51k
        WORD32 num_ctb;
715
7.51k
        WORD32 pic_size;
716
7.51k
        pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
717
7.51k
                        ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
718
719
720
7.51k
        num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
721
7.51k
        num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
722
723
724
7.51k
        mv_bank_size_allocated -= pic_mv_bank_size;
725
726
7.51k
        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
7.51k
        ps_mv_buf->pu4_pic_pu_idx = (UWORD32 *)pu1_buf;
733
7.51k
        pu1_buf += (num_ctb + 1) * sizeof(WORD32);
734
735
7.51k
        ps_mv_buf->pu1_pic_pu_map = pu1_buf;
736
7.51k
        pu1_buf += num_pu;
737
738
7.51k
        ps_mv_buf->pu1_pic_slice_map = (UWORD16 *)pu1_buf;
739
7.51k
        pu1_buf += ALIGN4(num_ctb * sizeof(UWORD16));
740
741
7.51k
        ps_mv_buf->ps_pic_pu = (pu_t *)pu1_buf;
742
7.51k
        pu1_buf += num_pu * sizeof(pu_t);
743
744
7.51k
        buf_ret = ihevc_buf_mgr_add((buf_mgr_t *)ps_codec->pv_mv_buf_mgr, ps_mv_buf, i);
745
746
7.51k
        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
7.51k
        ps_mv_buf++;
753
754
7.51k
    }
755
1.00k
    return ret;
756
1.00k
}
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
8.94k
{
778
8.94k
    ivd_out_bufdesc_t *ps_out_buffer = ps_codec->ps_out_buffer;
779
8.94k
    UWORD32 au4_min_out_buf_size[IVD_VIDDEC_MAX_IO_BUFFERS];
780
8.94k
    UWORD32 u4_min_num_out_bufs = 0, i;
781
8.94k
    UWORD32 wd, ht;
782
783
8.94k
    if(0 == ps_codec->i4_share_disp_buf)
784
8.94k
    {
785
8.94k
        wd = ps_codec->i4_disp_wd;
786
8.94k
        ht = ps_codec->i4_disp_ht;
787
8.94k
    }
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
8.94k
    if(ps_codec->i4_disp_strd > (WORD32)wd)
795
0
        wd = ps_codec->i4_disp_strd;
796
797
8.94k
    if(ps_codec->e_chroma_fmt == IV_YUV_420P)
798
2.53k
        u4_min_num_out_bufs = MIN_OUT_BUFS_420;
799
6.40k
    else if(ps_codec->e_chroma_fmt == IV_YUV_444P)
800
0
        u4_min_num_out_bufs = MIN_OUT_BUFS_444;
801
6.40k
    else if(ps_codec->e_chroma_fmt == IV_YUV_422P)
802
0
        u4_min_num_out_bufs = MIN_OUT_BUFS_422;
803
6.40k
    else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV)
804
4.24k
                    || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU))
805
3.74k
        u4_min_num_out_bufs = MIN_OUT_BUFS_420SP;
806
2.66k
    else if(ps_codec->e_chroma_fmt == IV_GRAY)
807
2.66k
        u4_min_num_out_bufs = MIN_OUT_BUFS_GRAY;
808
809
8.94k
    if(ps_codec->e_chroma_fmt == IV_YUV_420P)
810
2.53k
    {
811
2.53k
        au4_min_out_buf_size[0] = (wd * ht);
812
2.53k
        au4_min_out_buf_size[1] = (wd * ht) >> 2;
813
2.53k
        au4_min_out_buf_size[2] = (wd * ht) >> 2;
814
2.53k
    }
815
6.40k
    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
6.40k
    else if((ps_codec->e_chroma_fmt == IV_YUV_420SP_UV)
822
4.24k
                    || (ps_codec->e_chroma_fmt == IV_YUV_420SP_VU))
823
3.74k
    {
824
3.74k
        au4_min_out_buf_size[0] = (wd * ht);
825
3.74k
        au4_min_out_buf_size[1] = (wd * ht) >> 1;
826
3.74k
        au4_min_out_buf_size[2] = 0;
827
3.74k
    }
828
2.66k
    else if(ps_codec->e_chroma_fmt == IV_GRAY)
829
2.66k
    {
830
2.66k
        au4_min_out_buf_size[0] = (wd * ht);
831
2.66k
        au4_min_out_buf_size[1] = 0;
832
2.66k
        au4_min_out_buf_size[2] = 0;
833
2.66k
    }
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
8.94k
    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
26.4k
    for (i = 0 ; i < u4_min_num_out_bufs; i++)
848
17.6k
    {
849
17.6k
        if(ps_out_buffer->u4_min_out_buf_size[i] < au4_min_out_buf_size[i])
850
157
        {
851
157
            return (IHEVCD_ERROR_T)IV_FAIL;
852
157
        }
853
17.6k
    }
854
855
8.79k
    return (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
856
8.94k
}
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
8.94k
{
880
8.94k
    IHEVCD_ERROR_T ret = (IHEVCD_ERROR_T)IHEVCD_SUCCESS;
881
8.94k
    mv_buf_t *ps_mv_buf;
882
8.94k
    sps_t *ps_sps;
883
8.94k
    WORD32 num_min_cu;
884
8.94k
    WORD32 cur_pic_buf_id;
885
8.94k
    WORD32 cur_mv_bank_buf_id;
886
8.94k
    pic_buf_t *ps_cur_pic;
887
8.94k
    slice_header_t *ps_slice_hdr;
888
8.94k
    UWORD8 *pu1_cur_pic_luma, *pu1_cur_pic_chroma;
889
8.94k
    WORD32 h_samp_factor, v_samp_factor;
890
8.94k
    WORD32 chroma_pixel_strd = 2;
891
8.94k
    WORD32 i;
892
893
8.94k
    ps_codec->s_parse.i4_error_code = IHEVCD_SUCCESS;
894
8.94k
    ps_sps = ps_codec->s_parse.ps_sps;
895
8.94k
    ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr;
896
897
    /* Memset picture level intra map and transquant bypass map to zero */
898
8.94k
    num_min_cu = ((ps_sps->i2_pic_height_in_luma_samples + 7) / 8) * ((ps_sps->i2_pic_width_in_luma_samples + 63) / 64);
899
8.94k
    memset(ps_codec->s_parse.pu1_pic_intra_flag, 0, num_min_cu);
900
8.94k
    memset(ps_codec->s_parse.pu1_pic_no_loop_filter_flag, 0, num_min_cu);
901
902
8.94k
    h_samp_factor = (CHROMA_FMT_IDC_YUV444 == ps_sps->i1_chroma_format_idc) ? 1 : 2;
903
8.94k
    v_samp_factor = (CHROMA_FMT_IDC_YUV420 == ps_sps->i1_chroma_format_idc) ? 2 : 1;
904
905
8.94k
    if(0 == ps_codec->s_parse.i4_first_pic_init)
906
1.00k
    {
907
1.00k
        ret = ihevcd_mv_buf_mgr_add_bufs(ps_codec);
908
1.00k
        RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
909
910
1.00k
        ret = ihevcd_pic_buf_mgr_add_bufs(ps_codec);
911
1.00k
        RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
912
913
1.00k
        ps_codec->s_parse.i4_first_pic_init = 1;
914
1.00k
    }
915
916
    /* Output buffer check */
917
8.94k
    ret = ihevcd_check_out_buf_size(ps_codec);
918
8.94k
    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
919
920
    /* Initialize all the slice headers' slice addresses to zero */
921
8.79k
    {
922
8.79k
        WORD32 slice_idx;
923
8.79k
        WORD32 slice_start_idx;
924
925
8.79k
        slice_start_idx = ps_codec->i4_slice_error ? 2 : 1;
926
927
2.24M
        for(slice_idx = slice_start_idx; slice_idx < MAX_SLICE_HDR_CNT; slice_idx++)
928
2.24M
        {
929
2.24M
            slice_header_t *ps_slice_hdr_tmp = ps_codec->ps_slice_hdr_base + slice_idx;
930
2.24M
            ps_slice_hdr_tmp->i2_ctb_x = -1;
931
2.24M
            ps_slice_hdr_tmp->i2_ctb_y = -1;
932
933
2.24M
        }
934
8.79k
    }
935
936
    /* Get free MV Bank to hold current picture's motion vector data */
937
8.79k
    {
938
8.79k
        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
8.79k
        if(NULL == ps_mv_buf)
945
6
        {
946
6
            ps_codec->s_parse.i4_error_code = IHEVCD_NO_FREE_MVBANK;
947
6
            ps_codec->i4_error_code = IHEVCD_NO_FREE_MVBANK;
948
6
            return IHEVCD_NO_FREE_MVBANK;
949
6
        }
950
951
8.78k
        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
8.78k
        ps_mv_buf->i4_abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
957
8.78k
    }
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
8.78k
        UWORD8 *pu1_buf;
966
8.78k
        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
8.78k
        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
8.78k
        ps_cur_pic->u4_ts = ps_codec->u4_ts;
981
8.78k
        ps_cur_pic->i4_abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
982
8.78k
        ps_cur_pic->i4_poc_lsb = ps_slice_hdr->i4_pic_order_cnt_lsb;
983
8.78k
        pu1_buf = ps_cur_pic->pu1_luma;
984
8.78k
        pu1_cur_pic_luma = pu1_buf;
985
986
8.78k
        pu1_buf = ps_cur_pic->pu1_chroma;
987
8.78k
        pu1_cur_pic_chroma = pu1_buf;
988
989
8.78k
#ifndef DISABLE_SEI
990
8.78k
        ps_cur_pic->s_sei_params.i1_sei_parameters_present_flag = 0;
991
8.78k
        if(ps_codec->s_parse.s_sei_params.i1_sei_parameters_present_flag)
992
129
        {
993
129
            sei_params_t *ps_sei = &ps_codec->s_parse.s_sei_params;
994
129
            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
129
            ps_sei->i1_sei_parameters_present_flag = 0;
1001
129
            ps_sei->i1_user_data_registered_present_flag = 0;
1002
129
            ps_sei->i1_aud_present_flag = 0;
1003
129
            ps_sei->i1_time_code_present_flag = 0;
1004
129
            ps_sei->i1_buf_period_params_present_flag = 0;
1005
129
            ps_sei->i1_pic_timing_params_present_flag = 0;
1006
129
            ps_sei->i1_recovery_point_params_present_flag = 0;
1007
129
            ps_sei->i1_active_parameter_set = 0;
1008
129
            ps_sei->i4_sei_mastering_disp_colour_vol_params_present_flags = 0;
1009
129
        }
1010
8.78k
#endif
1011
8.78k
    }
1012
1013
8.78k
    if(0 == ps_codec->u4_pic_cnt)
1014
912
    {
1015
912
        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
912
        if(ps_sps->i1_chroma_format_idc != CHROMA_FMT_IDC_MONOCHROME)
1017
912
        {
1018
912
            memset(ps_cur_pic->pu1_chroma,
1019
912
                   128,
1020
912
                   (((ps_sps->i2_pic_width_in_luma_samples + PAD_WD) * (chroma_pixel_strd / h_samp_factor))
1021
912
                                   * ps_sps->i2_pic_height_in_luma_samples / v_samp_factor));
1022
912
        }
1023
912
    }
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
8.78k
    {
1028
8.78k
        pic_buf_t *ps_pic_buf_ref;
1029
8.78k
        mv_buf_t *ps_mv_buf_ref;
1030
8.78k
        WORD32 r_idx;
1031
8.78k
        dpb_mgr_t *ps_dpb_mgr = (dpb_mgr_t *)ps_codec->pv_dpb_mgr;
1032
8.78k
        buf_mgr_t *ps_mv_buf_mgr = (buf_mgr_t *)ps_codec->pv_mv_buf_mgr;
1033
1034
8.78k
        ps_pic_buf_ref = ihevc_dpb_mgr_get_ref_by_nearest_poc(ps_dpb_mgr, ps_slice_hdr->i4_abs_pic_order_cnt);
1035
8.78k
        if(NULL == ps_pic_buf_ref)
1036
2.65k
        {
1037
2.65k
            WORD32 size;
1038
1039
2.65k
            WORD32 num_pu;
1040
2.65k
            WORD32 num_ctb;
1041
2.65k
            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
2.65k
            pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
1046
2.65k
                            ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
1047
1048
2.65k
            num_pu = pic_size / (MIN_PU_SIZE * MIN_PU_SIZE);
1049
2.65k
            num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
1050
1051
2.65k
            memset(ps_mv_buf->ai4_l0_collocated_poc, 0, sizeof(ps_mv_buf->ai4_l0_collocated_poc));
1052
2.65k
            memset(ps_mv_buf->ai1_l0_collocated_poc_lt, 0, sizeof(ps_mv_buf->ai1_l0_collocated_poc_lt));
1053
2.65k
            memset(ps_mv_buf->ai4_l1_collocated_poc, 0, sizeof(ps_mv_buf->ai4_l1_collocated_poc));
1054
2.65k
            memset(ps_mv_buf->ai1_l1_collocated_poc_lt, 0, sizeof(ps_mv_buf->ai1_l1_collocated_poc_lt));
1055
1056
2.65k
            size = (num_ctb + 1) * sizeof(WORD32);
1057
2.65k
            memset(ps_mv_buf->pu4_pic_pu_idx, 0, size);
1058
1059
2.65k
            size = num_pu;
1060
2.65k
            memset(ps_mv_buf->pu1_pic_pu_map, 0, size);
1061
2.65k
            size = ALIGN4(num_ctb * sizeof(UWORD16));
1062
2.65k
            memset(ps_mv_buf->pu1_pic_slice_map, 0, size);
1063
2.65k
            size = num_pu * sizeof(pu_t);
1064
2.65k
            memset(ps_mv_buf->ps_pic_pu, 0, size);
1065
1066
2.65k
            ps_pic_buf_ref = ps_cur_pic;
1067
2.65k
            ps_mv_buf_ref = ps_mv_buf;
1068
2.65k
        }
1069
6.13k
        else
1070
6.13k
        {
1071
6.13k
            ps_mv_buf_ref = ihevcd_mv_mgr_get_poc(ps_mv_buf_mgr, ps_pic_buf_ref->i4_abs_poc);
1072
6.13k
        }
1073
1074
22.1k
        for(r_idx = 0; r_idx < ps_slice_hdr->i1_num_ref_idx_l0_active; r_idx++)
1075
13.3k
        {
1076
13.3k
            if(NULL == ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf)
1077
300
            {
1078
300
                ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1079
300
                ps_slice_hdr->as_ref_pic_list0[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1080
300
            }
1081
13.3k
        }
1082
1083
136k
        for(r_idx = ps_slice_hdr->i1_num_ref_idx_l0_active; r_idx < MAX_DPB_SIZE; r_idx++)
1084
127k
        {
1085
127k
            ps_slice_hdr->as_ref_pic_list0[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1086
127k
            ps_slice_hdr->as_ref_pic_list0[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1087
127k
        }
1088
1089
20.1k
        for(r_idx = 0; r_idx < ps_slice_hdr->i1_num_ref_idx_l1_active; r_idx++)
1090
11.3k
        {
1091
11.3k
            if(NULL == ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf)
1092
307
            {
1093
307
                ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1094
307
                ps_slice_hdr->as_ref_pic_list1[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1095
307
            }
1096
11.3k
        }
1097
1098
137k
        for(r_idx = ps_slice_hdr->i1_num_ref_idx_l1_active; r_idx < MAX_DPB_SIZE; r_idx++)
1099
129k
        {
1100
129k
            ps_slice_hdr->as_ref_pic_list1[r_idx].pv_pic_buf = (void *)ps_pic_buf_ref;
1101
129k
            ps_slice_hdr->as_ref_pic_list1[r_idx].pv_mv_buf = (void *)ps_mv_buf_ref;
1102
129k
        }
1103
8.78k
    }
1104
1105
1106
    /* Reset the jobq to start of the jobq buffer */
1107
8.78k
    ihevcd_jobq_reset((jobq_t *)ps_codec->pv_proc_jobq);
1108
1109
8.78k
    if(ps_codec->i4_threads_active)
1110
8.78k
    {
1111
8.78k
        ps_codec->i4_break_threads = 0;
1112
8.78k
    }
1113
8.78k
    ps_codec->s_parse.i4_pic_pu_idx = 0;
1114
8.78k
    ps_codec->s_parse.i4_pic_tu_idx = 0;
1115
1116
8.78k
    ps_codec->s_parse.pu1_pic_pu_map = ps_mv_buf->pu1_pic_pu_map;
1117
8.78k
    ps_codec->s_parse.ps_pic_pu      = ps_mv_buf->ps_pic_pu;
1118
8.78k
    ps_codec->s_parse.pu4_pic_pu_idx = ps_mv_buf->pu4_pic_pu_idx;
1119
8.78k
    ps_codec->s_parse.pu1_slice_idx = (UWORD16 *)ps_mv_buf->pu1_pic_slice_map;
1120
79.0k
    for(i = 0; i < MAX_PROCESS_THREADS; i++)
1121
70.2k
    {
1122
70.2k
        ps_codec->as_process[i].pu1_slice_idx = (UWORD16 *)ps_mv_buf->pu1_pic_slice_map;
1123
70.2k
    }
1124
8.78k
    ps_codec->s_parse.pu1_pu_map = ps_codec->s_parse.pu1_pic_pu_map;
1125
8.78k
    ps_codec->s_parse.ps_pu = ps_codec->s_parse.ps_pic_pu;
1126
1127
8.78k
    {
1128
8.78k
        UWORD8 *pu1_buf;
1129
8.78k
        WORD32 ctb_luma_min_tu_cnt, ctb_chroma_min_tu_cnt, ctb_min_tu_cnt;
1130
8.78k
        WORD32 pic_size;
1131
8.78k
        WORD32 num_ctb;
1132
1133
8.78k
        pic_size = ALIGN64(ps_sps->i2_pic_width_in_luma_samples) *
1134
8.78k
                        ALIGN64(ps_sps->i2_pic_height_in_luma_samples);
1135
1136
8.78k
        ctb_luma_min_tu_cnt = pic_size / (MIN_TU_SIZE * MIN_TU_SIZE);
1137
1138
8.78k
        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
8.78k
        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
8.78k
        else if(ps_sps->i1_chroma_format_idc == CHROMA_FMT_IDC_YUV420)
1147
8.78k
        {
1148
8.78k
            ctb_chroma_min_tu_cnt = ctb_luma_min_tu_cnt >> 1;
1149
8.78k
        }
1150
0
        else
1151
0
        {
1152
0
            ctb_chroma_min_tu_cnt = 0;
1153
0
        }
1154
1155
8.78k
        ctb_min_tu_cnt = ctb_luma_min_tu_cnt + ctb_chroma_min_tu_cnt;
1156
1157
8.78k
        num_ctb = pic_size / (MIN_CTB_SIZE * MIN_CTB_SIZE);
1158
8.78k
        pu1_buf  = (UWORD8 *)ps_codec->pv_tu_data;
1159
8.78k
        ps_codec->s_parse.pu4_pic_tu_idx = (UWORD32 *)pu1_buf;
1160
8.78k
        pu1_buf += (num_ctb + 1) * sizeof(WORD32);
1161
1162
8.78k
        ps_codec->s_parse.pu1_pic_tu_map = pu1_buf;
1163
8.78k
        pu1_buf += ctb_min_tu_cnt;
1164
1165
8.78k
        ps_codec->s_parse.ps_pic_tu = (tu_t *)pu1_buf;
1166
8.78k
        pu1_buf += ctb_min_tu_cnt * sizeof(tu_t);
1167
1168
8.78k
        ps_codec->s_parse.pv_pic_tu_coeff_data = pu1_buf;
1169
1170
8.78k
        ps_codec->s_parse.pu1_tu_map = ps_codec->s_parse.pu1_pic_tu_map;
1171
8.78k
        ps_codec->s_parse.ps_tu = ps_codec->s_parse.ps_pic_tu;
1172
8.78k
        ps_codec->s_parse.pv_tu_coeff_data = ps_codec->s_parse.pv_pic_tu_coeff_data;
1173
8.78k
    }
1174
1175
8.78k
    ps_codec->s_parse.s_bs_ctxt.ps_pic_pu = ps_codec->s_parse.ps_pic_pu;
1176
8.78k
    ps_codec->s_parse.s_bs_ctxt.pu4_pic_pu_idx = ps_codec->s_parse.pu4_pic_pu_idx;
1177
8.78k
    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
8.78k
    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
8.78k
    {
1186
8.78k
        WORD32 num_ctb;
1187
1188
8.78k
        num_ctb = ps_sps->i4_pic_size_in_ctb;
1189
1190
8.78k
        memset(ps_codec->pu1_parse_map, 0, num_ctb);
1191
1192
8.78k
        memset(ps_codec->pu1_proc_map, 0, num_ctb);
1193
8.78k
    }
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
8.78k
    ps_codec->i4_disp_buf_id = -1;
1201
8.78k
    ps_codec->ps_disp_buf = NULL;
1202
1203
8.78k
    ps_codec->i4_disable_deblk_pic  = 0;
1204
8.78k
    ps_codec->i4_disable_sao_pic    = 0;
1205
8.78k
    ps_codec->i4_fullpel_inter_pred = 0;
1206
8.78k
    ps_codec->i4_mv_frac_mask       = 0x7FFFFFFF;
1207
1208
    /* If degrade is enabled, set the degrade flags appropriately */
1209
8.78k
    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
8.78k
    {
1278
8.78k
        WORD32 i;
1279
79.0k
        for(i = 0; i < MAX_PROCESS_THREADS; i++)
1280
70.2k
        {
1281
70.2k
            ps_codec->as_process[i].pu4_pic_pu_idx = ps_codec->s_parse.pu4_pic_pu_idx;
1282
70.2k
            ps_codec->as_process[i].ps_pic_pu = ps_codec->s_parse.ps_pic_pu;
1283
70.2k
            ps_codec->as_process[i].pu1_pic_pu_map = ps_codec->s_parse.pu1_pic_pu_map;
1284
70.2k
            ps_codec->as_process[i].pu4_pic_tu_idx = ps_codec->s_parse.pu4_pic_tu_idx;
1285
70.2k
            ps_codec->as_process[i].ps_pic_tu = ps_codec->s_parse.ps_pic_tu;
1286
70.2k
            ps_codec->as_process[i].pu1_pic_tu_map = ps_codec->s_parse.pu1_pic_tu_map;
1287
70.2k
            ps_codec->as_process[i].pv_pic_tu_coeff_data = ps_codec->s_parse.pv_pic_tu_coeff_data;
1288
70.2k
            ps_codec->as_process[i].i4_cur_mv_bank_buf_id = cur_mv_bank_buf_id;
1289
70.2k
            ps_codec->as_process[i].s_sao_ctxt.pu1_slice_idx = ps_codec->as_process[i].pu1_slice_idx;
1290
70.2k
            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
70.2k
            ps_codec->as_process[i].pu1_cur_pic_luma = pu1_cur_pic_luma;
1296
70.2k
            ps_codec->as_process[i].pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1297
70.2k
            ps_codec->as_process[i].ps_cur_pic = ps_cur_pic;
1298
70.2k
            ps_codec->as_process[i].i4_cur_pic_buf_id = cur_pic_buf_id;
1299
1300
70.2k
            ps_codec->as_process[i].ps_out_buffer = ps_codec->ps_out_buffer;
1301
70.2k
            if(1 < ps_codec->i4_num_cores)
1302
33.7k
            {
1303
33.7k
                ps_codec->as_process[i].i4_check_parse_status = 1;
1304
33.7k
                ps_codec->as_process[i].i4_check_proc_status = 1;
1305
33.7k
            }
1306
36.5k
            else
1307
36.5k
            {
1308
36.5k
                ps_codec->as_process[i].i4_check_parse_status = 0;
1309
36.5k
                ps_codec->as_process[i].i4_check_proc_status = 0;
1310
36.5k
            }
1311
70.2k
            ps_codec->as_process[i].pu1_pic_intra_flag = ps_codec->s_parse.pu1_pic_intra_flag;
1312
70.2k
            ps_codec->as_process[i].pu1_pic_no_loop_filter_flag = ps_codec->s_parse.pu1_pic_no_loop_filter_flag;
1313
70.2k
            ps_codec->as_process[i].i4_init_done = 0;
1314
1315
70.2k
            ps_codec->as_process[i].s_bs_ctxt.pu4_pic_tu_idx = ps_codec->as_process[i].pu4_pic_tu_idx;
1316
70.2k
            ps_codec->as_process[i].s_bs_ctxt.pu4_pic_pu_idx = ps_codec->as_process[i].pu4_pic_pu_idx;
1317
70.2k
            ps_codec->as_process[i].s_bs_ctxt.ps_pic_pu = ps_codec->as_process[i].ps_pic_pu;
1318
70.2k
            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
70.2k
            ps_codec->as_process[i].s_deblk_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1320
70.2k
            ps_codec->as_process[i].s_deblk_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1321
70.2k
            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
70.2k
            ps_codec->as_process[i].s_sao_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1323
70.2k
            ps_codec->as_process[i].s_sao_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1324
70.2k
            if(i < (ps_codec->i4_num_cores - 1))
1325
8.75k
            {
1326
8.75k
                if (!ps_codec->ai4_process_thread_created[i])
1327
729
                {
1328
729
                    ithread_create(ps_codec->apv_process_thread_handle[i], NULL,
1329
729
                                (void *)ihevcd_process_thread,
1330
729
                                (void *)&ps_codec->as_process[i]);
1331
729
                    ps_codec->ai4_process_thread_created[i] = 1;
1332
729
                }
1333
8.75k
                if(ps_codec->i4_threads_active)
1334
8.75k
                {
1335
8.75k
                    ret = ithread_mutex_lock(ps_codec->apv_proc_start_mutex[i]);
1336
8.75k
                    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
1337
1338
8.75k
                    ps_codec->ai4_process_start[i] = 1;
1339
8.75k
                    ithread_cond_signal(ps_codec->apv_proc_start_condition[i]);
1340
1341
8.75k
                    ret = ithread_mutex_unlock(ps_codec->apv_proc_start_mutex[i]);
1342
8.75k
                    RETURN_IF((ret != (IHEVCD_ERROR_T)IHEVCD_SUCCESS), ret);
1343
8.75k
                }
1344
8.75k
            }
1345
61.5k
            else
1346
61.5k
            {
1347
61.5k
                ps_codec->ai4_process_thread_created[i] = 0;
1348
61.5k
            }
1349
1350
70.2k
        }
1351
8.78k
        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
8.78k
        ps_codec->s_parse.s_deblk_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1364
8.78k
        ps_codec->s_parse.s_deblk_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1365
1366
8.78k
        ps_codec->s_parse.s_sao_ctxt.pu1_cur_pic_luma = pu1_cur_pic_luma;
1367
8.78k
        ps_codec->s_parse.s_sao_ctxt.pu1_cur_pic_chroma = pu1_cur_pic_chroma;
1368
8.78k
    }
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
8.78k
        WORD32 abs_poc;
1380
8.78k
        slice_header_t *ps_slice_hdr;
1381
8.78k
        ps_slice_hdr = ps_codec->s_parse.ps_slice_hdr;
1382
8.78k
        abs_poc = ps_slice_hdr->i4_abs_pic_order_cnt;
1383
8.78k
        ihevc_disp_mgr_add((disp_mgr_t *)ps_codec->pv_disp_buf_mgr,
1384
8.78k
                           ps_codec->as_process[0].i4_cur_pic_buf_id,
1385
8.78k
                           abs_poc,
1386
8.78k
                           ps_codec->as_process[0].ps_cur_pic);
1387
8.78k
    }
1388
8.78k
    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
8.78k
    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
1.31k
       (ps_codec->e_frm_out_mode == IVD_DECODE_FRAME_OUT))
1393
1394
7.47k
    {
1395
7.47k
        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
7.47k
        ps_codec->u4_disp_cnt++;
1397
7.47k
    }
1398
1399
8.78k
    ps_codec->s_fmt_conv.i4_cur_row = 0;
1400
    /* Set number of rows to be processed at a time */
1401
8.78k
    ps_codec->s_fmt_conv.i4_num_rows = 4;
1402
1403
8.78k
    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
8.78k
    ps_codec->i4_pic_present = 1;
1438
1439
8.78k
    return ret;
1440
8.78k
}
1441
1442