From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EAB04401A2 for ; Sun, 4 Dec 2022 21:53:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ECA9368BBFD; Sun, 4 Dec 2022 23:53:16 +0200 (EET) Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F41AE68BBF1 for ; Sun, 4 Dec 2022 23:53:10 +0200 (EET) Received: by mail-ot1-f51.google.com with SMTP id a7-20020a056830008700b0066c82848060so6219878oto.4 for ; Sun, 04 Dec 2022 13:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DZ0LjEDInEf2SIWEnbbM+ue20c9eQM9Fn/FeWWN1g74=; b=Jw5SXL+UjAzVQqaX4vHN4G5kmOlqVsiiKtouck2xCJ7EYacNickexqArQjRVZcIdiq maR1IMT+tq8TXdzIiA+31qC0501fQsj7kyj3i0lc2qAuX5OvqSRBTrl9LoBM7OE5a+u4 gmzcN8WL+3Epwdg1ex9QL4Nt2633N+bIzEplciL6NOtk0XlcaQnfWyxZQmNFHEPEyGiA asO2sDxI+cx8OaloQ54NRCBbqi4/K+hy9Y0HCKuE67704FYnO9TWMhXHU2wT/du3QBuI sofxdy8onZ57EQzuMxuxm+mJj9gKoLZ1NBoE1bI0gSPxUqtlr+7ob6A/EV4fo5drf4b4 9lhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DZ0LjEDInEf2SIWEnbbM+ue20c9eQM9Fn/FeWWN1g74=; b=qnDMu4tZpmLVs9rSNC3VQW88G4jw//LjZ+gko0Ssp/MfSyWBf2yQJTWorXEwWud7s2 QiPrgNRMN619Hwg5wa5DkiBqZVxo0fN0VS6kzhuECkHQ4sfOHNltqDml66Uac2zNM9zd w7Ew+dUUg2KxPlU1GeTU6cTmhtpglmSbeLxtF6qCANkcSptmF+0nUM5FtHaNy84UXI5l 0Yej96cH6aopumauJKWZZwEw1O5JX/sj0BQVWmfqhQChbpL4IxicOPd+b4KsDbG4KId9 apS6PpyEry7PS1A8MjAywfEe+Pl5Q/3rTWBen1T0gbDs0abz/mQ+i20G34gPIdIYyCAb KrhA== X-Gm-Message-State: ANoB5pk7ciTgfgjeS43uMFVBVKEH90Rm5qe09lTz7eHnzOCq2HbnKghw EouaTHpZhN1P122t0+RPYwI+sFjPYyA= X-Google-Smtp-Source: AA0mqf7eNRJdoFfvaPQoJSZ0cwXgt84FLA45U4Su0MPwkRyrsjCLAQhkhIfPsdgHw3MS73RXnVS+vQ== X-Received: by 2002:a05:6830:799:b0:66e:7535:a120 with SMTP id w25-20020a056830079900b0066e7535a120mr8722663ots.249.1670190788857; Sun, 04 Dec 2022 13:53:08 -0800 (PST) Received: from localhost.localdomain ([181.85.72.69]) by smtp.gmail.com with ESMTPSA id s16-20020a056830439000b0066c7733be43sm6823100otv.30.2022.12.04.13.53.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Dec 2022 13:53:08 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Dec 2022 18:52:27 -0300 Message-Id: <20221204215227.4186-5-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204215227.4186-1-jamrial@gmail.com> References: <20221204215227.4186-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded frame was skipped X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: This ensures the video stream duration is not lost after decoding. Signed-off-by: James Almer --- libavcodec/h263dec.c | 13 +++++++++++++ libavcodec/mpegvideo.h | 1 + 2 files changed, 14 insertions(+) diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c index ac7a8521e5..0a2d7487a8 100644 --- a/libavcodec/h263dec.c +++ b/libavcodec/h263dec.c @@ -430,6 +430,18 @@ int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, return ret; s->next_picture_ptr = NULL; + *got_frame = 1; + } else if (s->skipped_last_frame && s->current_picture_ptr) { + /* Output the last picture we decoded again if the stream ended with + * an NVOP */ + if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) + return ret; + /* Copy props from the last input packet. Otherwise, props from the last + * returned picture would be reused */ + if ((ret = ff_decode_frame_props(avctx, pict)) < 0) + return ret; + s->current_picture_ptr = NULL; + *got_frame = 1; } @@ -500,6 +512,7 @@ retry: s->extradata_parsed = 1; } ret = ff_mpeg4_decode_picture_header(avctx->priv_data, &s->gb, 0, 0); + s->skipped_last_frame = (ret == FRAME_SKIPPED); } else if (CONFIG_H263I_DECODER && s->codec_id == AV_CODEC_ID_H263I) { ret = ff_intel_h263_decode_picture_header(s); } else if (CONFIG_FLV_DECODER && s->h263_flv) { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 6440b906b1..42275953b9 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -175,6 +175,7 @@ typedef struct MpegEncContext { Picture *last_picture_ptr; ///< pointer to the previous picture. Picture *next_picture_ptr; ///< pointer to the next picture (for bidir pred) Picture *current_picture_ptr; ///< pointer to the current picture + int skipped_last_frame; int last_dc[3]; ///< last DC values for MPEG-1 int16_t *dc_val_base; int16_t *dc_val[3]; ///< used for MPEG-4 DC prediction, all 3 arrays must be continuous -- 2.38.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".