@@ -654,26 +654,24 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
654
654
av_packet_unref (d -> pkt );
655
655
} while (1 );
656
656
657
- {
658
- if (d -> avctx -> codec_type == AVMEDIA_TYPE_SUBTITLE ) {
659
- int got_frame = 0 ;
660
- ret = avcodec_decode_subtitle2 (d -> avctx , sub , & got_frame , d -> pkt );
661
- if (ret < 0 ) {
662
- ret = AVERROR (EAGAIN );
663
- } else {
664
- if (got_frame && !d -> pkt -> data ) {
665
- d -> packet_pending = 1 ;
666
- }
667
- ret = got_frame ? 0 : (d -> pkt -> data ? AVERROR (EAGAIN ) : AVERROR_EOF );
668
- }
669
- av_packet_unref (d -> pkt );
657
+ if (d -> avctx -> codec_type == AVMEDIA_TYPE_SUBTITLE ) {
658
+ int got_frame = 0 ;
659
+ ret = avcodec_decode_subtitle2 (d -> avctx , sub , & got_frame , d -> pkt );
660
+ if (ret < 0 ) {
661
+ ret = AVERROR (EAGAIN );
670
662
} else {
671
- if (avcodec_send_packet (d -> avctx , d -> pkt ) == AVERROR (EAGAIN )) {
672
- av_log (d -> avctx , AV_LOG_ERROR , "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n" );
663
+ if (got_frame && !d -> pkt -> data ) {
673
664
d -> packet_pending = 1 ;
674
- } else {
675
- av_packet_unref (d -> pkt );
676
665
}
666
+ ret = got_frame ? 0 : (d -> pkt -> data ? AVERROR (EAGAIN ) : AVERROR_EOF );
667
+ }
668
+ av_packet_unref (d -> pkt );
669
+ } else {
670
+ if (avcodec_send_packet (d -> avctx , d -> pkt ) == AVERROR (EAGAIN )) {
671
+ av_log (d -> avctx , AV_LOG_ERROR , "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n" );
672
+ d -> packet_pending = 1 ;
673
+ } else {
674
+ av_packet_unref (d -> pkt );
677
675
}
678
676
}
679
677
}
@@ -1646,37 +1644,37 @@ static void video_refresh(void *opaque, double *remaining_time)
1646
1644
}
1647
1645
1648
1646
if (is -> subtitle_st ) {
1649
- while (frame_queue_nb_remaining (& is -> subpq ) > 0 ) {
1650
- sp = frame_queue_peek (& is -> subpq );
1651
-
1652
- if (frame_queue_nb_remaining (& is -> subpq ) > 1 )
1653
- sp2 = frame_queue_peek_next (& is -> subpq );
1654
- else
1655
- sp2 = NULL ;
1656
-
1657
- if (sp -> serial != is -> subtitleq .serial
1658
- || (is -> vidclk .pts > (sp -> pts + ((float ) sp -> sub .end_display_time / 1000 )))
1659
- || (sp2 && is -> vidclk .pts > (sp2 -> pts + ((float ) sp2 -> sub .start_display_time / 1000 ))))
1660
- {
1661
- if (sp -> uploaded ) {
1662
- int i ;
1663
- for (i = 0 ; i < sp -> sub .num_rects ; i ++ ) {
1664
- AVSubtitleRect * sub_rect = sp -> sub .rects [i ];
1665
- uint8_t * pixels ;
1666
- int pitch , j ;
1667
-
1668
- if (!SDL_LockTexture (is -> sub_texture , (SDL_Rect * )sub_rect , (void * * )& pixels , & pitch )) {
1669
- for (j = 0 ; j < sub_rect -> h ; j ++ , pixels += pitch )
1670
- memset (pixels , 0 , sub_rect -> w << 2 );
1671
- SDL_UnlockTexture (is -> sub_texture );
1672
- }
1647
+ while (frame_queue_nb_remaining (& is -> subpq ) > 0 ) {
1648
+ sp = frame_queue_peek (& is -> subpq );
1649
+
1650
+ if (frame_queue_nb_remaining (& is -> subpq ) > 1 )
1651
+ sp2 = frame_queue_peek_next (& is -> subpq );
1652
+ else
1653
+ sp2 = NULL ;
1654
+
1655
+ if (sp -> serial != is -> subtitleq .serial
1656
+ || (is -> vidclk .pts > (sp -> pts + ((float ) sp -> sub .end_display_time / 1000 )))
1657
+ || (sp2 && is -> vidclk .pts > (sp2 -> pts + ((float ) sp2 -> sub .start_display_time / 1000 ))))
1658
+ {
1659
+ if (sp -> uploaded ) {
1660
+ int i ;
1661
+ for (i = 0 ; i < sp -> sub .num_rects ; i ++ ) {
1662
+ AVSubtitleRect * sub_rect = sp -> sub .rects [i ];
1663
+ uint8_t * pixels ;
1664
+ int pitch , j ;
1665
+
1666
+ if (!SDL_LockTexture (is -> sub_texture , (SDL_Rect * )sub_rect , (void * * )& pixels , & pitch )) {
1667
+ for (j = 0 ; j < sub_rect -> h ; j ++ , pixels += pitch )
1668
+ memset (pixels , 0 , sub_rect -> w << 2 );
1669
+ SDL_UnlockTexture (is -> sub_texture );
1673
1670
}
1674
1671
}
1675
- frame_queue_next (& is -> subpq );
1676
- } else {
1677
- break ;
1678
1672
}
1673
+ frame_queue_next (& is -> subpq );
1674
+ } else {
1675
+ break ;
1679
1676
}
1677
+ }
1680
1678
}
1681
1679
1682
1680
frame_queue_next (& is -> pictq );
@@ -2968,15 +2966,12 @@ static int read_thread(void *arg)
2968
2966
av_log (NULL , AV_LOG_ERROR ,
2969
2967
"%s: error while seeking\n" , is -> ic -> url );
2970
2968
} else {
2971
- if (is -> audio_stream >= 0 ) {
2969
+ if (is -> audio_stream >= 0 )
2972
2970
packet_queue_flush (& is -> audioq );
2973
- }
2974
- if (is -> subtitle_stream >= 0 ) {
2971
+ if (is -> subtitle_stream >= 0 )
2975
2972
packet_queue_flush (& is -> subtitleq );
2976
- }
2977
- if (is -> video_stream >= 0 ) {
2973
+ if (is -> video_stream >= 0 )
2978
2974
packet_queue_flush (& is -> videoq );
2979
- }
2980
2975
if (is -> seek_flags & AVSEEK_FLAG_BYTE ) {
2981
2976
set_clock (& is -> extclk , NAN , 0 );
2982
2977
} else {
0 commit comments