From patchwork Sun Feb 7 21:06:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 25490 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D99DB44A84D for ; Sun, 7 Feb 2021 23:06:55 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCF9B689A8D; Sun, 7 Feb 2021 23:06:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DFB74689ADA for ; Sun, 7 Feb 2021 23:06:48 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id C9E98E4D8E; Sun, 7 Feb 2021 22:06:48 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FjRiJ7YemL0h; Sun, 7 Feb 2021 22:06:47 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 09F2CE4F4E; Sun, 7 Feb 2021 22:06:47 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Feb 2021 22:06:34 +0100 Message-Id: <20210207210634.16494-4-cus@passwd.hu> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210207210634.16494-1-cus@passwd.hu> References: <20210207210634.16494-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] fftools/ffplay: reindent and some minor cosmetics X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- fftools/ffplay.c | 95 +++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 50 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index eab156c47a..b9a30cdb11 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -654,26 +654,24 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { av_packet_unref(d->pkt); } while (1); - { - if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { - int got_frame = 0; - ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, d->pkt); - if (ret < 0) { - ret = AVERROR(EAGAIN); - } else { - if (got_frame && !d->pkt->data) { - d->packet_pending = 1; - } - ret = got_frame ? 0 : (d->pkt->data ? AVERROR(EAGAIN) : AVERROR_EOF); - } - av_packet_unref(d->pkt); + if (d->avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) { + int got_frame = 0; + ret = avcodec_decode_subtitle2(d->avctx, sub, &got_frame, d->pkt); + if (ret < 0) { + ret = AVERROR(EAGAIN); } else { - if (avcodec_send_packet(d->avctx, d->pkt) == AVERROR(EAGAIN)) { - av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n"); + if (got_frame && !d->pkt->data) { d->packet_pending = 1; - } else { - av_packet_unref(d->pkt); } + ret = got_frame ? 0 : (d->pkt->data ? AVERROR(EAGAIN) : AVERROR_EOF); + } + av_packet_unref(d->pkt); + } else { + if (avcodec_send_packet(d->avctx, d->pkt) == AVERROR(EAGAIN)) { + av_log(d->avctx, AV_LOG_ERROR, "Receive_frame and send_packet both returned EAGAIN, which is an API violation.\n"); + d->packet_pending = 1; + } else { + av_packet_unref(d->pkt); } } } @@ -1646,37 +1644,37 @@ retry: } if (is->subtitle_st) { - while (frame_queue_nb_remaining(&is->subpq) > 0) { - sp = frame_queue_peek(&is->subpq); - - if (frame_queue_nb_remaining(&is->subpq) > 1) - sp2 = frame_queue_peek_next(&is->subpq); - else - sp2 = NULL; - - if (sp->serial != is->subtitleq.serial - || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) - || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) - { - if (sp->uploaded) { - int i; - for (i = 0; i < sp->sub.num_rects; i++) { - AVSubtitleRect *sub_rect = sp->sub.rects[i]; - uint8_t *pixels; - int pitch, j; - - if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) { - for (j = 0; j < sub_rect->h; j++, pixels += pitch) - memset(pixels, 0, sub_rect->w << 2); - SDL_UnlockTexture(is->sub_texture); - } + while (frame_queue_nb_remaining(&is->subpq) > 0) { + sp = frame_queue_peek(&is->subpq); + + if (frame_queue_nb_remaining(&is->subpq) > 1) + sp2 = frame_queue_peek_next(&is->subpq); + else + sp2 = NULL; + + if (sp->serial != is->subtitleq.serial + || (is->vidclk.pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) + || (sp2 && is->vidclk.pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) + { + if (sp->uploaded) { + int i; + for (i = 0; i < sp->sub.num_rects; i++) { + AVSubtitleRect *sub_rect = sp->sub.rects[i]; + uint8_t *pixels; + int pitch, j; + + if (!SDL_LockTexture(is->sub_texture, (SDL_Rect *)sub_rect, (void **)&pixels, &pitch)) { + for (j = 0; j < sub_rect->h; j++, pixels += pitch) + memset(pixels, 0, sub_rect->w << 2); + SDL_UnlockTexture(is->sub_texture); } } - frame_queue_next(&is->subpq); - } else { - break; } + frame_queue_next(&is->subpq); + } else { + break; } + } } frame_queue_next(&is->pictq); @@ -2968,15 +2966,12 @@ static int read_thread(void *arg) av_log(NULL, AV_LOG_ERROR, "%s: error while seeking\n", is->ic->url); } else { - if (is->audio_stream >= 0) { + if (is->audio_stream >= 0) packet_queue_flush(&is->audioq); - } - if (is->subtitle_stream >= 0) { + if (is->subtitle_stream >= 0) packet_queue_flush(&is->subtitleq); - } - if (is->video_stream >= 0) { + if (is->video_stream >= 0) packet_queue_flush(&is->videoq); - } if (is->seek_flags & AVSEEK_FLAG_BYTE) { set_clock(&is->extclk, NAN, 0); } else {