Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index
@ 2024-01-11  6:31 tong1.wu-at-intel.com
  2024-01-11  6:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/d3d12va_mpeg2|vc1: remove the unused macros tong1.wu-at-intel.com
  2024-01-17  6:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index Xiang, Haihao
  0 siblings, 2 replies; 4+ messages in thread
From: tong1.wu-at-intel.com @ 2024-01-11  6:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Tong Wu

From: Tong Wu <tong1.wu@intel.com>

Fixes #10759.

It can happen in H.264, MPEG2, VC1 that the current frame resource
memory is already in ref_resource. For example, for a interlaced frame,
the same curr memory is passed twice. For the second time it could possibly
reference itself. When this happens the curr is already given an index and
in ref_resources. When the reference frame index is required, we should check
the existance in the ref_resources first before assigning a new index for it.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
---
 libavcodec/d3d12va_decode.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
index c5c599675e..a6f40236d1 100644
--- a/libavcodec/d3d12va_decode.c
+++ b/libavcodec/d3d12va_decode.c
@@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext *avctx,
     if (!res)
         goto fail;
 
-    if (!curr) {
-        for (i = 0; i < ctx->max_num_ref; i++) {
-            if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
-                ctx->used_mask |= 1 << i;
-                return i;
-            }
+    for (i = 0; i < ctx->max_num_ref; i++) {
+        if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
+            ctx->used_mask |= 1 << i;
+            return i;
         }
-    } else {
+    }
+
+    if (curr) {
         for (i = 0; i < ctx->max_num_ref; i++) {
             if (!((ctx->used_mask >> i) & 0x1)) {
                 ctx->ref_resources[i] = res;
-- 
2.41.0.windows.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] avcodec/d3d12va_mpeg2|vc1: remove the unused macros
  2024-01-11  6:31 [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index tong1.wu-at-intel.com
@ 2024-01-11  6:31 ` tong1.wu-at-intel.com
  2024-01-17  6:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index Xiang, Haihao
  1 sibling, 0 replies; 4+ messages in thread
From: tong1.wu-at-intel.com @ 2024-01-11  6:31 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Tong Wu

From: Tong Wu <tong1.wu@intel.com>

These macros are no longer used. Remove them.

Signed-off-by: Tong Wu <tong1.wu@intel.com>
---
 libavcodec/d3d12va_mpeg2.c | 4 ----
 libavcodec/d3d12va_vc1.c   | 4 ----
 2 files changed, 8 deletions(-)

diff --git a/libavcodec/d3d12va_mpeg2.c b/libavcodec/d3d12va_mpeg2.c
index b964f8d2ff..936af5f86a 100644
--- a/libavcodec/d3d12va_mpeg2.c
+++ b/libavcodec/d3d12va_mpeg2.c
@@ -31,10 +31,6 @@
 #define MAX_SLICES  1024
 #define INVALID_REF 0xffff
 
-#define REF_RESOURCE(index) if (index != INVALID_REF) { \
-    ctx->ref_resources[index] = frames_hwctx->texture_infos[index].texture; \
-}
-
 typedef struct D3D12DecodePictureContext {
     DXVA_PictureParameters  pp;
     DXVA_QmatrixData        qm;
diff --git a/libavcodec/d3d12va_vc1.c b/libavcodec/d3d12va_vc1.c
index 3d15abd1f1..4b89a65bb0 100644
--- a/libavcodec/d3d12va_vc1.c
+++ b/libavcodec/d3d12va_vc1.c
@@ -33,10 +33,6 @@
 #define MAX_SLICES  1024
 #define INVALID_REF 0xffff
 
-#define REF_RESOURCE(index) if (index != INVALID_REF) { \
-    ctx->ref_resources[index] = frames_hwctx->texture_infos[index].texture; \
-}
-
 typedef struct D3D12DecodePictureContext {
     DXVA_PictureParameters pp;
     unsigned               slice_count;
-- 
2.41.0.windows.1

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index
  2024-01-11  6:31 [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index tong1.wu-at-intel.com
  2024-01-11  6:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/d3d12va_mpeg2|vc1: remove the unused macros tong1.wu-at-intel.com
@ 2024-01-17  6:23 ` Xiang, Haihao
  2024-01-24  7:14   ` Xiang, Haihao
  1 sibling, 1 reply; 4+ messages in thread
From: Xiang, Haihao @ 2024-01-17  6:23 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu, Tong1

On Do, 2024-01-11 at 14:31 +0800, tong1.wu-at-intel.com@ffmpeg.org wrote:
> From: Tong Wu <tong1.wu@intel.com>
> 
> Fixes #10759.
> 
> It can happen in H.264, MPEG2, VC1 that the current frame resource
> memory is already in ref_resource. For example, for a interlaced frame,
> the same curr memory is passed twice. For the second time it could possibly
> reference itself. When this happens the curr is already given an index and
> in ref_resources. When the reference frame index is required, we should check
> the existance in the ref_resources first before assigning a new index for it.
> 
> Signed-off-by: Tong Wu <tong1.wu@intel.com>
> ---
>  libavcodec/d3d12va_decode.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
> index c5c599675e..a6f40236d1 100644
> --- a/libavcodec/d3d12va_decode.c
> +++ b/libavcodec/d3d12va_decode.c
> @@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const AVCodecContext
> *avctx,
>      if (!res)
>          goto fail;
>  
> -    if (!curr) {
> -        for (i = 0; i < ctx->max_num_ref; i++) {
> -            if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> -                ctx->used_mask |= 1 << i;
> -                return i;
> -            }
> +    for (i = 0; i < ctx->max_num_ref; i++) {
> +        if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> +            ctx->used_mask |= 1 << i;
> +            return i;
>          }
> -    } else {
> +    }
> +
> +    if (curr) {
>          for (i = 0; i < ctx->max_num_ref; i++) {
>              if (!((ctx->used_mask >> i) & 0x1)) {
>                  ctx->ref_resources[i] = res;

Patchset LGTM, 

BRs
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index
  2024-01-17  6:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index Xiang, Haihao
@ 2024-01-24  7:14   ` Xiang, Haihao
  0 siblings, 0 replies; 4+ messages in thread
From: Xiang, Haihao @ 2024-01-24  7:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu, Tong1

On Wo, 2024-01-17 at 06:23 +0000, Xiang, Haihao wrote:
> On Do, 2024-01-11 at 14:31 +0800, tong1.wu-at-intel.com@ffmpeg.org wrote:
> > From: Tong Wu <tong1.wu@intel.com>
> > 
> > Fixes #10759.
> > 
> > It can happen in H.264, MPEG2, VC1 that the current frame resource
> > memory is already in ref_resource. For example, for a interlaced frame,
> > the same curr memory is passed twice. For the second time it could possibly
> > reference itself. When this happens the curr is already given an index and
> > in ref_resources. When the reference frame index is required, we should
> > check
> > the existance in the ref_resources first before assigning a new index for
> > it.
> > 
> > Signed-off-by: Tong Wu <tong1.wu@intel.com>
> > ---
> >  libavcodec/d3d12va_decode.c | 14 +++++++-------
> >  1 file changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/libavcodec/d3d12va_decode.c b/libavcodec/d3d12va_decode.c
> > index c5c599675e..a6f40236d1 100644
> > --- a/libavcodec/d3d12va_decode.c
> > +++ b/libavcodec/d3d12va_decode.c
> > @@ -62,14 +62,14 @@ unsigned ff_d3d12va_get_surface_index(const
> > AVCodecContext
> > *avctx,
> >      if (!res)
> >          goto fail;
> >  
> > -    if (!curr) {
> > -        for (i = 0; i < ctx->max_num_ref; i++) {
> > -            if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> > -                ctx->used_mask |= 1 << i;
> > -                return i;
> > -            }
> > +    for (i = 0; i < ctx->max_num_ref; i++) {
> > +        if (ctx->ref_resources[i] && res == ctx->ref_resources[i]) {
> > +            ctx->used_mask |= 1 << i;
> > +            return i;
> >          }
> > -    } else {
> > +    }
> > +
> > +    if (curr) {
> >          for (i = 0; i < ctx->max_num_ref; i++) {
> >              if (!((ctx->used_mask >> i) & 0x1)) {
> >                  ctx->ref_resources[i] = res;
> 
> Patchset LGTM, 
> 
Will apply,

- 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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-24  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-11  6:31 [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index tong1.wu-at-intel.com
2024-01-11  6:31 ` [FFmpeg-devel] [PATCH 2/2] avcodec/d3d12va_mpeg2|vc1: remove the unused macros tong1.wu-at-intel.com
2024-01-17  6:23 ` [FFmpeg-devel] [PATCH 1/2] avcodec/d3d12va_decode: check existance before assigning a new index Xiang, Haihao
2024-01-24  7:14   ` Xiang, Haihao

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