Skip to content

Commit b2b115e

Browse files
srujan874harishdm
authored andcommitted
libhevc: move encoder SEI related code under a macro
Bug: 338446610 Test: ./hevcenc Change-Id: I76fa9371aac6ef5fca3723425e0010cf1f13db1f
1 parent dc22533 commit b2b115e

21 files changed

Lines changed: 135 additions & 18 deletions

Android.bp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ cc_library_static {
447447
host_supported: true,
448448
cflags: [
449449
"-DENABLE_MAIN_REXT_PROFILE",
450+
"-DDISABLE_SEI",
450451
"-fPIC",
451452
"-O3",
452453
"-Wall",
@@ -810,6 +811,7 @@ cc_test {
810811
host_supported: true,
811812
cflags: [
812813
"-DARM",
814+
"-DDISABLE_SEI",
813815
"-fPIC",
814816
"-Wall",
815817
"-Werror",

common/ihevc_structs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#define _IHEVC_STRUCTS_H_
4040

4141

42+
#ifndef DISABLE_SEI
4243
/**
4344
* Buffering Period SEI parameters Info
4445
*/
@@ -519,6 +520,7 @@ typedef struct
519520
time_code_t s_time_code;
520521
} sei_params_t;
521522

523+
#endif
522524

523525
/**
524526
* Sub-layer HRD parameters Info
@@ -952,7 +954,9 @@ typedef struct
952954
// See IV_FLD_TYPE_T for all field types
953955
UWORD32 e4_fld_type;
954956

957+
#ifndef DISABLE_SEI
955958
sei_params_t s_sei_params;
959+
#endif
956960

957961
WORD32 i4_vui_present;
958962

encoder/ihevce_api.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@
7676
/* Maximum number of processor groups supported */
7777
#define MAX_NUMBER_PROC_GRPS 4
7878

79+
#ifndef DISABLE_SEI
7980
/** @brief maximum length of CC User Data in a single frame */
8081
#define MAX_SEI_PAYLOAD_PER_TLV (0x200)
8182

8283
#define MAX_NUMBER_OF_SEI_PAYLOAD (10)
84+
#endif
8385

8486
#define IHEVCE_COMMANDS_TAG_MASK (0x0000FFFF)
8587

@@ -179,8 +181,10 @@ typedef enum
179181
IHEVCE_SYNCH_API_END_TAG = 0xFFFF,
180182
IHEVCE_SYNCH_API_FLUSH_TAG = 0x21,
181183
IHEVCE_SYNCH_API_FORCE_IDR_TAG = 0x22,
184+
#ifndef DISABLE_SEI
182185
IHEVCE_SYNCH_API_REG_KEYFRAME_SEI_TAG = 0x23,
183186
IHEVCE_SYNCH_API_REG_ALLFRAME_SEI_TAG = 0x24,
187+
#endif
184188
IHEVCE_SYNCH_API_SET_RES_TAG = 0x25
185189
} IHEVCE_SYNCH_API_COMMAND_TAG_T;
186190

@@ -192,7 +196,9 @@ typedef enum
192196
IHEVCE_SYNCH_ERR_NO_PADDING = IHEVCE_SYNCH_ERROR_START + 0x14,
193197
IHEVCE_SYNCH_ERR_WRONG_LENGTH = IHEVCE_SYNCH_ERROR_START + 0x15,
194198
IHEVCE_SYNCH_ERR_FREQ_FORCE_IDR_RECEIVED = IHEVCE_SYNCH_ERROR_START + 0x16,
199+
#ifndef DISABLE_SEI
195200
IHEVCE_SYNCH_ERR_TOO_MANY_SEI_MSG = IHEVCE_SYNCH_ERROR_START + 0x17,
201+
#endif
196202
IHEVCE_SYNCH_ERR_SET_RES_NOT_SUPPORTED = IHEVCE_SYNCH_ERROR_START + 0x18
197203
} IHEVCE_SYNCH_ERROR_TAG_T;
198204

@@ -437,6 +443,7 @@ typedef struct
437443
/** Enable VUI output 1: enable 0 : disable */
438444
WORD32 i4_vui_enable;
439445

446+
#ifndef DISABLE_SEI
440447
/** Enable specific SEI messages in the stream
441448
* 1: enable 0 : disable
442449
*/
@@ -466,6 +473,7 @@ typedef struct
466473
* 1: enable 0 : disable
467474
*/
468475
WORD32 i4_sei_mastering_disp_colour_vol_flags;
476+
#endif
469477

470478
/**
471479
* Array to store the display_primaries_x values
@@ -497,6 +505,7 @@ typedef struct
497505
*/
498506
UWORD32 u4_min_display_mastering_luminance;
499507

508+
#ifndef DISABLE_SEI
500509
/**
501510
* Enable Content Level Light Info
502511
*/
@@ -516,6 +525,7 @@ typedef struct
516525
* 3 : Checksum, 2 : CRC, 1 : MD5, 0 : disable
517526
*/
518527
WORD32 i4_decoded_pic_hash_sei_flag;
528+
#endif
519529

520530
/** Enable specific AUD messages in the stream
521531
* 1: enable 0 : disable

encoder/ihevce_enc_structs.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,8 +1589,10 @@ typedef struct
15891589
/** Buffer pointer for CTB level information in pre intra pass*/
15901590
ihevce_ed_ctb_l1_t *ps_ed_ctb_l1;
15911591

1592+
#ifndef DISABLE_SEI
15921593
/** vps parameters activated by current slice */
15931594
sei_params_t s_sei;
1595+
#endif
15941596

15951597
/** nal_type for the slice to be encoded */
15961598
WORD32 i4_slice_nal_type;
@@ -1826,13 +1828,15 @@ typedef struct
18261828
ULWORD64 i8_frame_inter_cost;
18271829
} s_pic_level_acc_info_t;
18281830

1831+
#ifndef DISABLE_SEI
18291832
typedef struct
18301833
{
18311834
UWORD32 u4_target_bit_rate_sei_entropy;
18321835
UWORD32 u4_buffer_size_sei_entropy;
18331836
UWORD32 u4_dbf_entropy;
18341837

18351838
} s_pic_level_sei_info_t;
1839+
#endif
18361840
/**
18371841
******************************************************************************
18381842
* @brief ME pass and Main enocde pass shared variables and buffers
@@ -1912,12 +1916,14 @@ typedef struct
19121916

19131917
} me_enc_rdopt_ctxt_t;
19141918

1919+
#ifndef DISABLE_SEI
19151920
typedef struct
19161921
{
19171922
UWORD32 u4_payload_type;
19181923
UWORD32 u4_payload_length;
19191924
UWORD8 *pu1_sei_payload;
19201925
} sei_payload_t;
1926+
#endif
19211927

19221928
typedef struct
19231929
{
@@ -1954,8 +1960,10 @@ typedef struct
19541960
/** vps parameters activated by current slice */
19551961
vps_t *ps_vps;
19561962

1963+
#ifndef DISABLE_SEI
19571964
/** vps parameters activated by current slice */
19581965
sei_params_t s_sei;
1966+
#endif
19591967

19601968
/* Flag to indicate if AUD NAL is present */
19611969
WORD8 i1_aud_present_flag;
@@ -2019,9 +2027,11 @@ typedef struct
20192027

20202028
WORD32 i4_is_end_of_idr_gop;
20212029

2030+
#ifndef DISABLE_SEI
20222031
sei_payload_t as_sei_payload[MAX_NUMBER_OF_SEI_PAYLOAD];
20232032

20242033
UWORD32 u4_num_sei_payload;
2034+
#endif
20252035
/* Flag used only in mres single output case to flush out one res and start with next */
20262036
WORD32 i4_out_flush_flag;
20272037

encoder/ihevce_encode_header_sei_vui.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ WORD32 ihevce_generate_vui(bitstrm_t *ps_bitstrm, sps_t *ps_sps, vui_t s_vui)
595595
return return_status;
596596
}
597597

598+
#ifndef DISABLE_SEI
598599
/**
599600
******************************************************************************
600601
*
@@ -2470,6 +2471,7 @@ WORD32 ihevce_populate_hash_sei(
24702471

24712472
return IHEVCE_SUCCESS;
24722473
}
2474+
#endif
24732475

24742476
/**
24752477
******************************************************************************

encoder/ihevce_encode_header_sei_vui.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
/* Function Macros */
4141
/*****************************************************************************/
4242

43+
#ifndef DISABLE_SEI
4344
/**
4445
******************************************************************************
4546
* @brief Macro to calculate the CRC for a bit index
@@ -93,17 +94,6 @@ typedef enum
9394
/* Extern Function Declarations */
9495
/*****************************************************************************/
9596

96-
WORD32 ihevce_generate_sub_layer_hrd_params(
97-
bitstrm_t *ps_bitstrm,
98-
sub_lyr_hrd_params_t *ps_sub_lyr_hrd_params,
99-
hrd_params_t *ps_hrd_params,
100-
WORD32 cpb_cnt_minus1);
101-
102-
WORD32
103-
ihevce_generate_hrd_params(bitstrm_t *ps_bitstrm, hrd_params_t *ps_hrd_params, sps_t *ps_sps);
104-
105-
WORD32 ihevce_generate_vui(bitstrm_t *ps_bitstrm, sps_t *ps_sps, vui_t s_vui);
106-
10797
WORD32 ihevce_put_buf_period_sei_params(
10898
buf_period_sei_params_t *ps_bp_sei, vui_t *ps_vui_params, bitstrm_t *ps_bitstrm);
10999

@@ -163,6 +153,18 @@ WORD32 ihevce_populate_hash_sei(
163153
WORD32 uv_strd,
164154
WORD32 i4_frame_pos_x,
165155
WORD32 i4_frame_pos_y);
156+
#endif
157+
158+
WORD32 ihevce_generate_sub_layer_hrd_params(
159+
bitstrm_t *ps_bitstrm,
160+
sub_lyr_hrd_params_t *ps_sub_lyr_hrd_params,
161+
hrd_params_t *ps_hrd_params,
162+
WORD32 cpb_cnt_minus1);
163+
164+
WORD32
165+
ihevce_generate_hrd_params(bitstrm_t *ps_bitstrm, hrd_params_t *ps_hrd_params, sps_t *ps_sps);
166+
167+
WORD32 ihevce_generate_vui(bitstrm_t *ps_bitstrm, sps_t *ps_sps, vui_t s_vui);
166168

167169
WORD32 ihevce_populate_vui(
168170
vui_t *ps_vui,

encoder/ihevce_entropy_cod.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
282282

283283
PROFILE_START(
284284
&ps_hle_ctxt->profile_entropy[ps_enc_ctxt->i4_resolution_id][i4_bitrate_instance_num]);
285+
#ifndef DISABLE_SEI
285286
/* Content Light Level Information */
286287
{
287288
ps_curr_inp->s_sei.i1_sei_cll_enable =
@@ -291,6 +292,7 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
291292
ps_curr_inp->s_sei.s_cll_info_sei_params.u2_sei_avg_cll =
292293
ps_enc_ctxt->ps_stat_prms->s_out_strm_prms.u2_sei_avg_cll;
293294
}
295+
#endif
294296
if((NULL != ps_curr_out) && (NULL != ps_curr_inp))
295297

296298
{
@@ -370,6 +372,7 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
370372

371373
if(1 == ps_curr_inp->i4_frm_proc_valid_flag)
372374
{
375+
#ifndef DISABLE_SEI
373376
/* --- Init of buffering period and pic timing SEI related params ----*/
374377
{
375378
UWORD32 i4_dbf, i4_buffersize, i4_trgt_bit_rate;
@@ -414,10 +417,12 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
414417
ps_curr_inp->ps_sps->ai1_sps_max_num_reorder_pics[0] +
415418
ps_curr_inp->i4_display_num - u4_encode_frm_num;
416419
}
420+
#endif
417421
/* call the core entropy coding entry point function */
418422
entropy_error = ihevce_entropy_encode_frame(
419423
pv_entropy_hdl, ps_curr_out, ps_curr_inp, ps_curr_out->i4_bitstream_buf_size);
420424

425+
#ifndef DISABLE_SEI
421426
/* ----------------- Derivation of u4_au_cpb_removal_delay_minus1 --------------------------------*/
422427
if(ps_curr_inp->s_sei.i1_buf_period_params_present_flag)
423428
{
@@ -438,6 +443,7 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
438443
u4_au_cpb_removal_delay_minus1 = (u4_au_cpb_removal_delay_minus1 + 1) &
439444
u4_max_cpb_removal_delay_val;
440445
}
446+
#endif
441447
/* Debug prints for entropy error */
442448
if(entropy_error)
443449
{
@@ -449,13 +455,20 @@ WORD32 ihevce_ent_coding_thrd(void *pv_frm_proc_thrd_ctxt)
449455
/* acquire mutex lock for rate control calls */
450456
osal_mutex_lock(ps_enc_ctxt->pv_rc_mutex_lock_hdl);
451457

458+
UWORD32 removal_delay_minus1;
459+
#ifndef DISABLE_SEI
460+
removal_delay_minus1 =
461+
ps_curr_inp->s_sei.s_pic_timing_sei_params.u4_au_cpb_removal_delay_minus1;
462+
#else
463+
removal_delay_minus1 = 0;
464+
#endif
452465
/* get frame rate/bit rate/max buffer size */
453466
ihevce_vbv_compliance_frame_level_update(
454467
ps_enc_ctxt->s_module_ctxt.apv_rc_ctxt[i4_bitrate_instance_num],
455468
(ps_curr_out->i4_bytes_generated << 3),
456469
i4_resolution_id,
457470
i4_bitrate_instance_num,
458-
ps_curr_inp->s_sei.s_pic_timing_sei_params.u4_au_cpb_removal_delay_minus1);
471+
removal_delay_minus1);
459472
/* release mutex lock after rate control calls */
460473
osal_mutex_unlock(ps_enc_ctxt->pv_rc_mutex_lock_hdl);
461474
}

encoder/ihevce_entropy_interface.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ WORD32 ihevce_entropy_encode_frame(
322322
vps_t *ps_vps = ps_curr_inp->ps_vps;
323323
sps_t *ps_sps = ps_curr_inp->ps_sps;
324324
pps_t *ps_pps = ps_curr_inp->ps_pps;
325+
#ifndef DISABLE_SEI
325326
sei_params_t *ps_sei = &ps_curr_inp->s_sei;
327+
#endif
326328
ihevce_tile_params_t *ps_tile_params_base;
327329
WORD32 out_buf_size = i4_out_buf_size;
328330

@@ -355,7 +357,9 @@ WORD32 ihevce_entropy_encode_frame(
355357
ps_entropy_ctxt->ps_vps = ps_vps;
356358
ps_entropy_ctxt->ps_sps = ps_sps;
357359
ps_entropy_ctxt->ps_pps = ps_pps;
360+
#ifndef DISABLE_SEI
358361
ps_entropy_ctxt->ps_sei = ps_sei;
362+
#endif
359363
ps_entropy_ctxt->ps_slice_hdr = &ps_curr_inp->s_slice_hdr;
360364
ps_entropy_ctxt->i4_is_cu_cbf_zero = 1;
361365

@@ -413,6 +417,7 @@ WORD32 ihevce_entropy_encode_frame(
413417
ret |= ihevce_generate_pps(ps_bitstrm, ps_entropy_ctxt->ps_pps);
414418
}
415419

420+
#ifndef DISABLE_SEI
416421
/* generate sei */
417422
if(1 == ps_entropy_ctxt->ps_sei->i1_sei_parameters_present_flag)
418423
{
@@ -435,6 +440,7 @@ WORD32 ihevce_entropy_encode_frame(
435440
&ps_curr_inp->as_sei_payload[0]);
436441
}
437442
}
443+
#endif
438444

439445
/*PIC INFO: Populate slice header bits */
440446
ps_entropy_ctxt->ps_pic_level_info->u8_bits_estimated_slice_header +=
@@ -674,6 +680,7 @@ WORD32 ihevce_entropy_encode_frame(
674680
}
675681
}
676682

683+
#ifndef DISABLE_SEI
677684
/* generate suffix sei */
678685
if(1 == ps_entropy_ctxt->ps_sei->i1_sei_parameters_present_flag)
679686
{
@@ -693,6 +700,7 @@ WORD32 ihevce_entropy_encode_frame(
693700
/* Updating bytes generated */
694701
ps_curr_out->i4_bytes_generated += ps_bitstrm->u4_strm_buf_offset;
695702
}
703+
#endif
696704

697705
/* generate end of sequence nal */
698706
if((1 == ps_curr_inp->i1_eos_present_flag) && (ps_curr_inp->i4_is_end_of_idr_gop == 1))

encoder/ihevce_entropy_structs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,10 @@ typedef struct entropy_context
213213
/** pointer to current pps parameters */
214214
pps_t *ps_pps;
215215

216+
#ifndef DISABLE_SEI
216217
/** pointer to current sei parameters */
217218
sei_params_t *ps_sei;
219+
#endif
218220

219221
/** pointer to current slice header parameters */
220222
slice_header_t *ps_slice_hdr;

0 commit comments

Comments
 (0)