@@ -347,6 +347,7 @@ x265_close
347347 if (state->lib_initialized )
348348 {
349349 state->api ->encoder_close (state->encoder );
350+ state->api ->cleanup ();
350351 state->lib_initialized = false ;
351352 }
352353
@@ -377,19 +378,19 @@ x265_process
377378 hevc_enc_x265_t * state = (hevc_enc_x265_t *)handle;
378379
379380 x265_nal *p_nal;
380- uint32_t nal ;
381+ uint32_t nal_count = 0 ;
381382
382383 if (state->data ->pending_header && !state->param ->bRepeatHeaders )
383384 {
384385 state->data ->pending_header = false ;
385- if (state->api ->encoder_headers (state->encoder , &p_nal, &nal ) < 0 )
386+ if (state->api ->encoder_headers (state->encoder , &p_nal, &nal_count ) < 0 )
386387 {
387388 state->data ->msg = " Failure generating stream headers." ;
388389 return STATUS_ERROR;
389390 }
390- if (nal )
391+ if (nal_count )
391392 {
392- for (int j = 0 ; j < ( int )nal ; j++)
393+ for (uint32_t j = 0 ; j < nal_count ; j++)
393394 {
394395 nalu_t nalu;
395396 nalu.type = cast_nal_type (p_nal[j].type );
@@ -447,13 +448,13 @@ x265_process
447448 if (true == state->data ->uhd_bd )
448449 input_picture.sliceType = X265_TYPE_B;
449450
450- int num_encoded = state->api ->encoder_encode (state->encoder , &p_nal, &nal , &input_picture, NULL );
451+ int num_encoded = state->api ->encoder_encode (state->encoder , &p_nal, &nal_count , &input_picture, NULL );
451452 if (num_encoded < 0 )
452453 {
453454 state->data ->msg = " encoder_encode() failed." ;
454455 return STATUS_ERROR;
455456 }
456- for (uint32_t j = 0 ; j < nal ; j++)
457+ for (uint32_t j = 0 ; j < nal_count ; j++)
457458 {
458459 nalu_t nalu;
459460 nalu.type = cast_nal_type (p_nal[j].type );
@@ -502,8 +503,8 @@ x265_flush
502503 }
503504
504505 x265_nal *p_nal;
505- uint32_t nal ;
506- int num_encoded = state->api ->encoder_encode (state->encoder , &p_nal, &nal , NULL , NULL );
506+ uint32_t nal_count = 0 ;
507+ int num_encoded = state->api ->encoder_encode (state->encoder , &p_nal, &nal_count , NULL , NULL );
507508
508509 if (num_encoded < 0 )
509510 {
@@ -518,7 +519,7 @@ x265_flush
518519 return STATUS_OK;
519520 }
520521
521- for (uint32_t j = 0 ; j < nal ; j++)
522+ for (uint32_t j = 0 ; j < nal_count ; j++)
522523 {
523524 nalu_t nalu;
524525 nalu.type = cast_nal_type (p_nal[j].type );
0 commit comments