@@ -361,8 +361,11 @@ static int hls_slice_header(HEVCContext *s)
361361 if (IS_IDR (s ))
362362 ff_hevc_clear_refs (s );
363363 }
364+ sh -> no_output_of_prior_pics_flag = 0 ;
364365 if (s -> nal_unit_type >= 16 && s -> nal_unit_type <= 23 )
365366 sh -> no_output_of_prior_pics_flag = get_bits1 (gb );
367+ if (s -> nal_unit_type == NAL_CRA_NUT && s -> last_eos == 1 )
368+ sh -> no_output_of_prior_pics_flag = 1 ;
366369
367370 sh -> pps_id = get_ue_golomb_long (gb );
368371 if (sh -> pps_id >= MAX_PPS_COUNT || !s -> pps_list [sh -> pps_id ]) {
@@ -377,7 +380,13 @@ static int hls_slice_header(HEVCContext *s)
377380 s -> pps = (HEVCPPS * )s -> pps_list [sh -> pps_id ]-> data ;
378381
379382 if (s -> sps != (HEVCSPS * )s -> sps_list [s -> pps -> sps_id ]-> data ) {
383+ const HEVCSPS * last_sps = s -> sps ;
380384 s -> sps = (HEVCSPS * )s -> sps_list [s -> pps -> sps_id ]-> data ;
385+ if (last_sps ) {
386+ if (s -> sps -> width != last_sps -> width || s -> sps -> height != last_sps -> height ||
387+ s -> sps -> temporal_layer [s -> sps -> max_sub_layers - 1 ].max_dec_pic_buffering != last_sps -> temporal_layer [last_sps -> max_sub_layers - 1 ].max_dec_pic_buffering )
388+ sh -> no_output_of_prior_pics_flag = 0 ;
389+ }
381390 ff_hevc_clear_refs (s );
382391 ret = set_sps (s , s -> sps );
383392 if (ret < 0 )
@@ -436,6 +445,7 @@ static int hls_slice_header(HEVCContext *s)
436445 return AVERROR_INVALIDDATA ;
437446 }
438447
448+ sh -> pic_output_flag = 1 ;
439449 if (s -> pps -> output_flag_present_flag )
440450 sh -> pic_output_flag = get_bits1 (gb );
441451
@@ -2589,6 +2599,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
25892599 int i , consumed , ret = 0 ;
25902600
25912601 s -> ref = NULL ;
2602+ s -> last_eos = s -> eos ;
25922603 s -> eos = 0 ;
25932604
25942605 /* split the input packet into NAL units, so we know the upper bound on the
@@ -2945,7 +2956,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx)
29452956 ff_dsputil_init (& s -> dsp , avctx );
29462957
29472958 s -> context_initialized = 1 ;
2948-
2959+ s -> eos = 0 ;
29492960 return 0 ;
29502961
29512962fail :
@@ -3009,6 +3020,7 @@ static int hevc_update_thread_context(AVCodecContext *dst,
30093020 s -> seq_output = s0 -> seq_output ;
30103021 s -> pocTid0 = s0 -> pocTid0 ;
30113022 s -> max_ra = s0 -> max_ra ;
3023+ s -> eos = s0 -> eos ;
30123024
30133025 s -> is_nalff = s0 -> is_nalff ;
30143026 s -> nal_length_size = s0 -> nal_length_size ;
0 commit comments