From: James Zern <jzern-at-google.com@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2 11/13] lavc/libvpxenc: send frame durations to the encoder
Date: Tue, 9 May 2023 11:17:37 -0700
Message-ID: <CABWgkXLU8rz0q9o+BSxVAUJAz-Er1hNBVFq5wQbsbmkj2PCWAw@mail.gmail.com> (raw)
In-Reply-To: <20230509090933.32380-1-anton@khirnov.net>
On Tue, May 9, 2023 at 2:10 AM Anton Khirnov <anton@khirnov.net> wrote:
>
> Adapt similar code from libaomenc - stop using ticks_per_frame except as
> a last resort.
> ---
> libavcodec/libvpxenc.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
>
lgtm.
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index a20e949842..f70cc87c41 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -1692,6 +1692,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
> const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc;
> vpx_svc_layer_id_t layer_id;
> int layer_id_valid = 0;
> + unsigned long duration = 0;
>
> if (avctx->qmax >= 0 && enccfg->rc_max_quantizer != avctx->qmax) {
> struct vpx_codec_enc_cfg cfg = *enccfg;
> @@ -1820,8 +1821,18 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
> #endif
> }
>
> + if (frame && frame->duration > ULONG_MAX) {
> + av_log(avctx, AV_LOG_WARNING,
> + "Frame duration too large: %"PRId64"\n", frame->duration);
This could fall back to frame rate or ticks, but I imagine this case
would be unlikely in practice unless the timebase was quite large.
> + } else if (frame && frame->duration)
> + duration = frame->duration;
> + else if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
> + duration = av_rescale_q(1, av_inv_q(avctx->framerate), avctx->time_base);
> + else
> + duration = avctx->ticks_per_frame ? avctx->ticks_per_frame : 1;
> +
> res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
> - avctx->ticks_per_frame, flags, ctx->deadline);
> + duration, flags, ctx->deadline);
> if (res != VPX_CODEC_OK) {
> log_encoder_error(avctx, "Error encoding frame");
> return AVERROR_INVALIDDATA;
> @@ -1829,7 +1840,7 @@ static int vpx_encode(AVCodecContext *avctx, AVPacket *pkt,
>
> if (ctx->is_alpha) {
> res = vpx_codec_encode(&ctx->encoder_alpha, rawimg_alpha, timestamp,
> - avctx->ticks_per_frame, flags, ctx->deadline);
> + duration, flags, ctx->deadline);
> if (res != VPX_CODEC_OK) {
> log_encoder_error(avctx, "Error encoding alpha frame");
> return AVERROR_INVALIDDATA;
> --
> 2.39.2
>
_______________________________________________
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:[~2023-05-09 18:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-07 13:32 [FFmpeg-devel] [PATCH 01/13] lavu/frame: extend AVFrame.repeat_pict documentation Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 02/13] fftools/ffmpeg: fix computing video frame duration from repeat_pict Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 03/13] lavc/codec_desc: add a property for codecs that support field coding Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 04/13] lavf: use AV_CODEC_PROP_FIELDS where appropriate Anton Khirnov
2023-05-08 14:12 ` Michael Niedermayer
2023-05-09 8:37 ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2023-05-08 14:15 ` [FFmpeg-devel] [PATCH " Michael Niedermayer
2023-05-09 8:44 ` Anton Khirnov
2023-05-15 18:59 ` Michael Niedermayer
2023-05-15 20:44 ` Anton Khirnov
2023-05-16 17:41 ` Michael Niedermayer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 05/13] lavc/av1*: fix exporting framerate Anton Khirnov
2023-05-10 11:52 ` James Almer
2023-05-14 19:39 ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-05-14 19:50 ` James Almer
2023-05-15 8:22 ` Anton Khirnov
2023-05-15 11:41 ` James Almer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 06/13] lavc/libdav1d: " Anton Khirnov
2023-05-15 8:22 ` [FFmpeg-devel] [PATCH] " Anton Khirnov
2023-05-15 11:47 ` James Almer
2023-05-15 12:22 ` Anton Khirnov
2023-05-15 12:41 ` James Almer
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 07/13] lavc/ratecontrol: use AVCodecContext.framerate when available Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 08/13] lavc/msmpeg4enc: " Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 09/13] libaomenc: " Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 10/13] lavc/libkvazaar, libopenh264enc: drop redundant checks Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 11/13] lavc/libvpxenc: send frame durations to the encoder Anton Khirnov
2023-05-09 1:18 ` James Zern
2023-05-09 9:09 ` [FFmpeg-devel] [PATCH v2 " Anton Khirnov
2023-05-09 18:17 ` James Zern [this message]
2023-05-10 6:34 ` Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 12/13] lavc: deprecate AVCodecContext.ticks_per_frame Anton Khirnov
2023-05-07 13:32 ` [FFmpeg-devel] [PATCH 13/13] fftools/ffmpeg: stop using deprecated ticks_per_frame Anton Khirnov
2023-05-07 16:59 ` [FFmpeg-devel] [PATCH 01/13] lavu/frame: extend AVFrame.repeat_pict documentation Kieran Kunhya
2023-05-07 18:01 ` Anton Khirnov
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=CABWgkXLU8rz0q9o+BSxVAUJAz-Er1hNBVFq5wQbsbmkj2PCWAw@mail.gmail.com \
--to=jzern-at-google.com@ffmpeg.org \
--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