avformat/hevc: Check num_long_term_ref_pics_sps to avoid potentially long loops