From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 5/5] avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded frame was skipped
Date: Tue, 6 Dec 2022 10:17:18 +0100
Message-ID: <GV1P250MB0737F2EB218D18543D0115B58F1B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <20221204215227.4186-5-jamrial@gmail.com>
James Almer:
> This ensures the video stream duration is not lost after decoding.
>
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
> 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
Can you give an example where this matters? And what does the spec say
about this? Is "output the last frame again" really the appropriate
response upon encountering a NVOP?
- Andreas
_______________________________________________
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".
next prev parent reply other threads:[~2022-12-06 9:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-04 21:52 [FFmpeg-devel] [PATCH 1/5] avcodec/binkaudio: clear pts when returning more than one frame per input packet James Almer
2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 2/5] Revert "avcodec/decode: use a packet list to store packet properties" James Almer
2022-12-05 21:26 ` Michael Niedermayer
2022-12-06 0:03 ` [FFmpeg-devel] [PATCH 2/6] avcodec/wmadec: clear pts when returning a frame during flush James Almer
2022-12-06 8:27 ` Paul B Mahol
2022-12-06 11:42 ` James Almer
2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 3/5] avcodec/decode: don't set last_pkt_props->size James Almer
2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 4/5] avcodec/pthread_frame.c: keep the last_pkt_props from worker threads in sync with the user context James Almer
2022-12-04 21:52 ` [FFmpeg-devel] [PATCH 5/5] avcodec/mpeg4videodec: duplicate the last decoded frame when the last coded frame was skipped James Almer
2022-12-06 9:17 ` Andreas Rheinhardt [this message]
2022-12-06 11:21 ` James Almer
2022-12-12 11:37 ` James Almer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=GV1P250MB0737F2EB218D18543D0115B58F1B9@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git