diff mbox

[FFmpeg-devel,2/2] dxva2: get the slice number directly from the surface in D3D11VA

Message ID 20161201141008.472-2-robux4@videolabs.io
State Superseded
Headers show

Commit Message

Stève Lhomme Dec. 1, 2016, 2:10 p.m. UTC
No need to loop through the known surfaces, we'll use it anyway.

The loop is only done for DXVA2
---
 libavcodec/dxva2.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Hendrik Leppkes Dec. 1, 2016, 2:43 p.m. UTC | #1
On Thu, Dec 1, 2016 at 3:13 PM, Stève Lhomme <robux4@videolabs.io> wrote:
> I think I should update the minor version number as I need to rely on
> this behaviour change in VLC, the surface array will be empty.
>
> Should I also change the headers so that they don't require the output
> surface to be pre-allocated ?

How does this end up being a behavior change? The commit doesn't make
it sound like it would change anything but simplify the code.
Please document the changed behavior in the commit message, then.

- Hendrik
Steve Lhomme Dec. 1, 2016, 3:50 p.m. UTC | #2
On Thu, Dec 1, 2016 at 3:43 PM, Hendrik Leppkes <h.leppkes@gmail.com> wrote:
> On Thu, Dec 1, 2016 at 3:13 PM, Stève Lhomme <robux4@videolabs.io> wrote:
>> I think I should update the minor version number as I need to rely on
>> this behaviour change in VLC, the surface array will be empty.
>>
>> Should I also change the headers so that they don't require the output
>> surface to be pre-allocated ?
>
> How does this end up being a behavior change? The commit doesn't make
> it sound like it would change anything but simplify the code.

Before this change the d3d11va.surface and d3d11va.surface_count could
not be NULL/0 respectively. They had to be filled. But with this
change it's not necessary anymore. We may even drop them in the
future.

I should investigate if the same thing is possible with D3D9 surfaces.

> Please document the changed behavior in the commit message, then.

OK

> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
diff mbox

Patch

diff --git a/libavcodec/dxva2.c b/libavcodec/dxva2.c
index a64b1b5..459e267 100644
--- a/libavcodec/dxva2.c
+++ b/libavcodec/dxva2.c
@@ -41,20 +41,20 @@  unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
     void *surface = ff_dxva2_get_surface(frame);
     unsigned i;
 
-    for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
 #if CONFIG_D3D11VA
-        if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD && ctx->d3d11va.surface[i] == surface)
-        {
-            D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
-            ID3D11VideoDecoderOutputView_GetDesc(ctx->d3d11va.surface[i], &viewDesc);
-            return viewDesc.Texture2D.ArraySlice;
-        }
+    if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD)
+    {
+        D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
+        ID3D11VideoDecoderOutputView_GetDesc((ID3D11VideoDecoderOutputView*) surface, &viewDesc);
+        return viewDesc.Texture2D.ArraySlice;
+    }
 #endif
 #if CONFIG_DXVA2
+    for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
         if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface)
             return i;
-#endif
     }
+#endif
 
     assert(0);
     return 0;