Without resetting it, if there was a previous set of varstreams with subtitles, it would subtract from all the streams, leading to chaos and segfaults when trying to access for example stream -1.
Unified · Split
| @@ -2441,7 +2441,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) · 2440 unmodified lines | |||
| 2441 | int is_ref_pkt = 1; | 2441 | int is_ref_pkt = 1; |
| 2442 | int ret = 0, can_split = 1, i, j; | 2442 | int ret = 0, can_split = 1, i, j; |
| 2443 | int stream_index = 0; | 2443 | int stream_index = 0; |
| 2444 | int subtitle_streams = 0; | ||
| 2445 | int range_length = 0; | 2444 | int range_length = 0; |
| 2446 | const char *proto = NULL; | 2445 | const char *proto = NULL; |
| 2447 | int use_temp_file = 0; | 2446 | int use_temp_file = 0; |
| @@ -2449,6 +2448,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) · 1 unmodified line | |||
| 2449 | char *old_filename = NULL; | 2448 | char *old_filename = NULL; |
| 2450 | 2449 | ||
| 2451 | for (i = 0; i < hls->nb_varstreams; i++) { | 2450 | for (i = 0; i < hls->nb_varstreams; i++) { |
| 2451 | int subtitle_streams = 0; | ||
| 2452 | vs = &hls->var_streams[i]; | 2452 | vs = &hls->var_streams[i]; |
| 2453 | for (j = 0; j < vs->nb_streams; j++) { | 2453 | for (j = 0; j < vs->nb_streams; j++) { |
| 2454 | if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { | 2454 | if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { |