From: Mark Thompson <sw@jkqxz.net> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH v3 4/6] lavc/vaapi_encode: Extract set output pkt timestamp function Date: Mon, 7 Aug 2023 21:22:39 +0100 Message-ID: <72de5f4d-2110-6d1f-c369-d8e4cd869598@jkqxz.net> (raw) In-Reply-To: <20230803060132.501741-4-fei.w.wang@intel.com> On 03/08/2023 07:01, fei.w.wang-at-intel.com@ffmpeg.org wrote: > From: Fei Wang <fei.w.wang@intel.com> > > Signed-off-by: Fei Wang <fei.w.wang@intel.com> > --- > libavcodec/vaapi_encode.c | 37 ++++++++++++++++++++++++------------- > 1 file changed, 24 insertions(+), 13 deletions(-) > > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c > index 8c9f14df66..c8545cd8db 100644 > --- a/libavcodec/vaapi_encode.c > +++ b/libavcodec/vaapi_encode.c > @@ -650,6 +650,27 @@ fail_at_end: > return err; > } > > +static int vaapi_encode_set_output_timestamp(AVCodecContext *avctx, > + VAAPIEncodePicture *pic, > + AVPacket *pkt) > +{ > + VAAPIEncodeContext *ctx = avctx->priv_data; > + > + if (ctx->output_delay == 0) { > + pkt->dts = pkt->pts; > + } else if (pic->encode_order < ctx->decode_delay) { > + if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff) > + pkt->dts = INT64_MIN; > + else > + pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff; > + } else { > + pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) % > + (3 * ctx->output_delay + ctx->async_depth)]; > + } > + > + return 0; > +} > + > static int vaapi_encode_output(AVCodecContext *avctx, > VAAPIEncodePicture *pic, AVPacket *pkt) > { > @@ -1273,19 +1294,9 @@ int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt) > return err; > } > > - if (ctx->output_delay == 0) { > - pkt->dts = pkt->pts; > - } else if (pic->encode_order < ctx->decode_delay) { > - if (ctx->ts_ring[pic->encode_order] < INT64_MIN + ctx->dts_pts_diff) > - pkt->dts = INT64_MIN; > - else > - pkt->dts = ctx->ts_ring[pic->encode_order] - ctx->dts_pts_diff; > - } else { > - pkt->dts = ctx->ts_ring[(pic->encode_order - ctx->decode_delay) % > - (3 * ctx->output_delay + ctx->async_depth)]; > - } > - av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64" dts %"PRId64".\n", > - pkt->pts, pkt->dts); > + vaapi_encode_set_output_timestamp(avctx, pic, pkt); > + av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64", dts %"PRId64", " > + "size %u bytes.\n", pkt->pts, pkt->dts, pkt->size); Packet size is not unsigned. > > ctx->output_order = pic->encode_order; > vaapi_encode_clear_old(avctx); Seems fair to extract this to its own function, LGTM. Thanks, - Mark _______________________________________________ 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-08-07 20:22 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-03 6:01 [FFmpeg-devel] [PATCH v3 1/6] avcodec/cbs_av1: Add tx mode enum values fei.w.wang-at-intel.com 2023-08-03 6:01 ` [FFmpeg-devel] [PATCH v3 2/6] lavc/av1: Add common code and unit test for level handling fei.w.wang-at-intel.com 2023-08-07 12:40 ` James Almer 2023-08-07 15:45 ` Andreas Rheinhardt 2023-08-03 6:01 ` [FFmpeg-devel] [PATCH v3 3/6] lavc/vaapi_encode: Init pic at the beginning of API fei.w.wang-at-intel.com 2023-08-03 6:01 ` [FFmpeg-devel] [PATCH v3 4/6] lavc/vaapi_encode: Extract set output pkt timestamp function fei.w.wang-at-intel.com 2023-08-07 20:22 ` Mark Thompson [this message] 2023-08-03 6:01 ` [FFmpeg-devel] [PATCH v3 5/6] lavc/vaapi_encode: Separate reference frame into previous/future list fei.w.wang-at-intel.com 2023-08-07 20:28 ` Mark Thompson 2023-08-03 6:01 ` [FFmpeg-devel] [PATCH v3 6/6] lavc/vaapi_encode: Add VAAPI AV1 encoder fei.w.wang-at-intel.com 2023-08-07 21:21 ` Mark Thompson 2023-08-10 2:54 ` Wang, Fei W 2023-08-13 21:43 ` Mark Thompson 2023-08-16 7:54 ` Wang, Fei W 2023-08-16 20:45 ` Mark Thompson 2023-08-15 13:59 ` Dong, Ruijing 2023-08-15 16:49 ` Neal Gompa 2023-08-07 7:51 ` [FFmpeg-devel] [PATCH v3 1/6] avcodec/cbs_av1: Add tx mode enum values Xiang, Haihao
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=72de5f4d-2110-6d1f-c369-d8e4cd869598@jkqxz.net \ --to=sw@jkqxz.net \ --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