Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Neal Gompa <ngompa13@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: fei.w.wang@intel.com
Subject: Re: [FFmpeg-devel] [PATCH v5 5/8] lavc/vaapi_encode: Extract set output pkt property function
Date: Tue, 19 Sep 2023 20:44:23 -0400
Message-ID: <CAEg-Je98pAAOGPWRiT7fyhfncnsYWfxj6ykjPgwrrLNKzxiwuw@mail.gmail.com> (raw)
In-Reply-To: <20230911075232.797886-5-fei.w.wang@intel.com>

On Mon, Sep 11, 2023 at 3:53 AM <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 | 65 +++++++++++++++++++++++----------------
>  1 file changed, 38 insertions(+), 27 deletions(-)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index 5ae63c9f25..46762342eb 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -650,6 +650,41 @@ fail_at_end:
>      return err;
>  }
>
> +static int vaapi_encode_set_output_property(AVCodecContext *avctx,
> +                                            VAAPIEncodePicture *pic,
> +                                            AVPacket *pkt)
> +{
> +    VAAPIEncodeContext *ctx = avctx->priv_data;
> +
> +    if (pic->type == PICTURE_TYPE_IDR)
> +        pkt->flags |= AV_PKT_FLAG_KEY;
> +
> +    pkt->pts = pic->pts;
> +    pkt->duration = pic->duration;
> +
> +    // for no-delay encoders this is handled in generic codec
> +    if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY &&
> +        avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
> +        pkt->opaque     = pic->opaque;
> +        pkt->opaque_ref = pic->opaque_ref;
> +        pic->opaque_ref = NULL;
> +    }
> +
> +    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)
>  {
> @@ -691,12 +726,6 @@ static int vaapi_encode_output(AVCodecContext *avctx,
>          ptr += buf->size;
>      }
>
> -    if (pic->type == PICTURE_TYPE_IDR)
> -        pkt->flags |= AV_PKT_FLAG_KEY;
> -
> -    pkt->pts = pic->pts;
> -    pkt->duration = pic->duration;
> -
>      vas = vaUnmapBuffer(ctx->hwctx->display, pic->output_buffer);
>      if (vas != VA_STATUS_SUCCESS) {
>          av_log(avctx, AV_LOG_ERROR, "Failed to unmap output buffers: "
> @@ -705,14 +734,6 @@ static int vaapi_encode_output(AVCodecContext *avctx,
>          goto fail;
>      }
>
> -    // for no-delay encoders this is handled in generic codec
> -    if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY &&
> -        avctx->flags & AV_CODEC_FLAG_COPY_OPAQUE) {
> -        pkt->opaque     = pic->opaque;
> -        pkt->opaque_ref = pic->opaque_ref;
> -        pic->opaque_ref = NULL;
> -    }
> -
>      av_buffer_unref(&pic->output_buffer_ref);
>      pic->output_buffer = VA_INVALID_ID;
>
> @@ -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_property(avctx, pic, pkt);
> +    av_log(avctx, AV_LOG_DEBUG, "Output packet: pts %"PRId64", dts %"PRId64", "
> +           "size %d bytes.\n", pkt->pts, pkt->dts, pkt->size);
>
>      ctx->output_order = pic->encode_order;
>      vaapi_encode_clear_old(avctx);
> --
> 2.25.1
>

LGTM.

Reviewed-by: Neal Gompa <ngompa13@gmail.com>



-- 
真実はいつも一つ!/ Always, there's only one truth!
_______________________________________________
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".

  reply	other threads:[~2023-09-20  0:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11  7:52 [FFmpeg-devel] [PATCH v5 1/8] avcodec/cbs_av1: Add tx mode enum values fei.w.wang-at-intel.com
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 2/8] cbs: Make tracing more general fei.w.wang-at-intel.com
2023-09-20  0:41   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 3/8] avcodec/cbs_av1: Allow specifying obu size byte length fei.w.wang-at-intel.com
2023-09-20  0:41   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 4/8] lavc/vaapi_encode: Init pic at the beginning of API fei.w.wang-at-intel.com
2023-09-20  0:43   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 5/8] lavc/vaapi_encode: Extract set output pkt property function fei.w.wang-at-intel.com
2023-09-20  0:44   ` Neal Gompa [this message]
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 6/8] lavc/vaapi_encode: Separate reference frame into previous/future list fei.w.wang-at-intel.com
2023-09-20  0:45   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 7/8] lavc/vaapi_encode: Add VAAPI AV1 encoder fei.w.wang-at-intel.com
2023-09-20  0:46   ` Neal Gompa
2023-09-11  7:52 ` [FFmpeg-devel] [PATCH v5 8/8] lavc/av1: Add unit test for level handling fei.w.wang-at-intel.com
2023-09-20  0:47   ` Neal Gompa
2023-09-20  0:40 ` [FFmpeg-devel] [PATCH v5 1/8] avcodec/cbs_av1: Add tx mode enum values Neal Gompa
2023-09-20  0:42   ` Neal Gompa
2023-09-20  2:21   ` Xiang, Haihao
2023-09-22  5:33     ` 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=CAEg-Je98pAAOGPWRiT7fyhfncnsYWfxj6ykjPgwrrLNKzxiwuw@mail.gmail.com \
    --to=ngompa13@gmail.com \
    --cc=fei.w.wang@intel.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