Skip to content

Commit 9edec92

Browse files
committed
fftools/ffplay: reindent and some minor cosmetics
Signed-off-by: Marton Balint <[email protected]>
1 parent 36d6714 commit 9edec92

File tree

1 file changed

+45
-50
lines changed

1 file changed

+45
-50
lines changed

fftools/ffplay.c

+45-50
Original file line numberDiff line numberDiff line change
@@ -654,26 +654,24 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) {
654654
av_packet_unref(d->pkt);
655655
} while (1);
656656

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);
670662
} 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) {
673664
d->packet_pending = 1;
674-
} else {
675-
av_packet_unref(d->pkt);
676665
}
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);
677675
}
678676
}
679677
}
@@ -1646,37 +1644,37 @@ static void video_refresh(void *opaque, double *remaining_time)
16461644
}
16471645

16481646
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);
16731670
}
16741671
}
1675-
frame_queue_next(&is->subpq);
1676-
} else {
1677-
break;
16781672
}
1673+
frame_queue_next(&is->subpq);
1674+
} else {
1675+
break;
16791676
}
1677+
}
16801678
}
16811679

16821680
frame_queue_next(&is->pictq);
@@ -2968,15 +2966,12 @@ static int read_thread(void *arg)
29682966
av_log(NULL, AV_LOG_ERROR,
29692967
"%s: error while seeking\n", is->ic->url);
29702968
} else {
2971-
if (is->audio_stream >= 0) {
2969+
if (is->audio_stream >= 0)
29722970
packet_queue_flush(&is->audioq);
2973-
}
2974-
if (is->subtitle_stream >= 0) {
2971+
if (is->subtitle_stream >= 0)
29752972
packet_queue_flush(&is->subtitleq);
2976-
}
2977-
if (is->video_stream >= 0) {
2973+
if (is->video_stream >= 0)
29782974
packet_queue_flush(&is->videoq);
2979-
}
29802975
if (is->seek_flags & AVSEEK_FLAG_BYTE) {
29812976
set_clock(&is->extclk, NAN, 0);
29822977
} else {

0 commit comments

Comments
 (0)