Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org>
Cc: "nowrep@gmail.com" <nowrep@gmail.com>
Subject: Re: [FFmpeg-devel] [PATCH v2] lavc/vaapi_h264: Fix merging fields in DPB with missing references
Date: Mon, 27 May 2024 07:39:45 +0000
Message-ID: <2d89d993db4862fa7475ae6337b9a29b2a588e32.camel@intel.com> (raw)
In-Reply-To: <20240508154213.24388-2-nowrep@gmail.com>

On Wo, 2024-05-08 at 17:41 +0200, David Rosca wrote:
> If there are missing references, h264 decode does error concealment
> by copying previous refs which means there will be duplicated surfaces.
> Check long_ref and frame_idx in addition to surface when looking for
> the other field to avoid trying to merge with wrong picture.
> Also allow to merge with multiple pictures in case there are duplicates
> of the other field.
> ---
> v2: Check long_ref/frame_idx + multiple merge
> 
>  libavcodec/vaapi_h264.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
> index b47531ce1c..398e92568c 100644
> --- a/libavcodec/vaapi_h264.c
> +++ b/libavcodec/vaapi_h264.c
> @@ -93,14 +93,19 @@ typedef struct DPB {
>   */
>  static int dpb_add(DPB *dpb, const H264Picture *pic)
>  {
> -    int i;
> +    int i, pic_frame_idx, merged = 0;
>  
>      if (dpb->size >= dpb->max_size)
>          return -1;
>  
> +    pic_frame_idx = pic->long_ref ? pic->pic_id : pic->frame_num;
> +
>      for (i = 0; i < dpb->size; i++) {
>          VAPictureH264 * const va_pic = &dpb->va_pics[i];
> -        if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f)) {
> +        int va_pic_long_ref = !!(va_pic->flags &
> VA_PICTURE_H264_LONG_TERM_REFERENCE);
> +        if (va_pic->picture_id == ff_vaapi_get_surface_id(pic->f) &&
> +            va_pic_long_ref == pic->long_ref &&
> +            va_pic->frame_idx == pic_frame_idx) {
>              VAPictureH264 temp_va_pic;
>              fill_vaapi_pic(&temp_va_pic, pic, 0);
>  
> @@ -112,11 +117,14 @@ static int dpb_add(DPB *dpb, const H264Picture *pic)
>                  } else {
>                      va_pic->BottomFieldOrderCnt =
> temp_va_pic.BottomFieldOrderCnt;
>                  }
> +                merged = 1;
>              }
> -            return 0;
>          }
>      }
>  
> +    if (merged)
> +        return 0;
> +
>      fill_vaapi_pic(&dpb->va_pics[dpb->size++], pic, 0);
>      return 0;
>  }

LGTM, will apply

Thanks
Haihao


_______________________________________________
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:[~2024-05-27  7:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 15:41 David Rosca
2024-05-27  7:39 ` Xiang, Haihao [this message]

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=2d89d993db4862fa7475ae6337b9a29b2a588e32.camel@intel.com \
    --to=haihao.xiang-at-intel.com@ffmpeg.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=nowrep@gmail.com \
    /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