diff mbox

[FFmpeg-devel,2/4] dxva2: use a single macro to test if the DXVA context is valid

Message ID 20170104133644.6720-3-robux4@gmail.com
State Superseded
Headers show

Commit Message

Steve Lhomme Jan. 4, 2017, 1:36 p.m. UTC
---
 libavcodec/dxva2_h264.c     | 4 +---
 libavcodec/dxva2_hevc.c     | 4 +---
 libavcodec/dxva2_internal.h | 5 +++++
 libavcodec/dxva2_mpeg2.c    | 4 +---
 libavcodec/dxva2_vc1.c      | 4 +---
 libavcodec/dxva2_vp9.c      | 4 +---
 6 files changed, 10 insertions(+), 15 deletions(-)

Comments

Steve Lhomme Jan. 10, 2017, 10:18 a.m. UTC | #1
This was not rejected and has been merged in libav.
3/4 and 4/4 seem to be valid too and pending on both sides. I just
need to send an update of 4/4 as the libavcodec version has changed.

On Wed, Jan 4, 2017 at 2:36 PM, Steve Lhomme <robux4@gmail.com> wrote:
> ---
>  libavcodec/dxva2_h264.c     | 4 +---
>  libavcodec/dxva2_hevc.c     | 4 +---
>  libavcodec/dxva2_internal.h | 5 +++++
>  libavcodec/dxva2_mpeg2.c    | 4 +---
>  libavcodec/dxva2_vc1.c      | 4 +---
>  libavcodec/dxva2_vp9.c      | 4 +---
>  6 files changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
> index 82a772d..59fa5e3 100644
> --- a/libavcodec/dxva2_h264.c
> +++ b/libavcodec/dxva2_h264.c
> @@ -450,9 +450,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
>      AVDXVAContext *ctx = avctx->hwaccel_context;
>      struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private;
>
> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>          return -1;
>      assert(ctx_pic);
>
> diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
> index 5a312ea..981c888 100644
> --- a/libavcodec/dxva2_hevc.c
> +++ b/libavcodec/dxva2_hevc.c
> @@ -364,9 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
>      AVDXVAContext *ctx = avctx->hwaccel_context;
>      struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
>
> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>          return -1;
>      av_assert0(ctx_pic);
>
> diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
> index c962810..e5322ef 100644
> --- a/libavcodec/dxva2_internal.h
> +++ b/libavcodec/dxva2_internal.h
> @@ -76,6 +76,9 @@ typedef union {
>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (DXVA_CONTEXT_DECODER(avctx, ctx) && \
> +                                                 DXVA_CONTEXT_CFG(avctx, ctx) && \
> +                                                 DXVA_CONTEXT_COUNT(avctx, ctx))
>  #elif CONFIG_DXVA2
>  #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->dxva2.workaround)
>  #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->dxva2.surface_count)
> @@ -85,6 +88,7 @@ typedef union {
>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->dxva2.cfg->ConfigBitstreamRaw)
>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
>  #elif CONFIG_D3D11VA
>  #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->d3d11va.workaround)
>  #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->d3d11va.surface_count)
> @@ -94,6 +98,7 @@ typedef union {
>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->d3d11va.cfg->ConfigBitstreamRaw)
>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
>  #endif
>
>  unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
> diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
> index c2f0b58..14ac48f 100644
> --- a/libavcodec/dxva2_mpeg2.c
> +++ b/libavcodec/dxva2_mpeg2.c
> @@ -262,9 +262,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
>      struct dxva2_picture_context *ctx_pic =
>          s->current_picture_ptr->hwaccel_picture_private;
>
> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>          return -1;
>      assert(ctx_pic);
>
> diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
> index 36bf1ba..cc97d7b 100644
> --- a/libavcodec/dxva2_vc1.c
> +++ b/libavcodec/dxva2_vc1.c
> @@ -317,9 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
>      AVDXVAContext *ctx = avctx->hwaccel_context;
>      struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
>
> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>          return -1;
>      assert(ctx_pic);
>
> diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c
> index 0c4996c..d53b327 100644
> --- a/libavcodec/dxva2_vp9.c
> +++ b/libavcodec/dxva2_vp9.c
> @@ -261,9 +261,7 @@ static int dxva2_vp9_start_frame(AVCodecContext *avctx,
>      AVDXVAContext *ctx = avctx->hwaccel_context;
>      struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
>
> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>          return -1;
>      av_assert0(ctx_pic);
>
> --
> 2.10.2
>
Steve Lhomme Jan. 13, 2017, 8:52 a.m. UTC | #2
For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
merged in libav.

On Tue, Jan 10, 2017 at 11:18 AM, Steve Lhomme <robux4@gmail.com> wrote:
> This was not rejected and has been merged in libav.
> 3/4 and 4/4 seem to be valid too and pending on both sides. I just
> need to send an update of 4/4 as the libavcodec version has changed.
>
> On Wed, Jan 4, 2017 at 2:36 PM, Steve Lhomme <robux4@gmail.com> wrote:
>> ---
>>  libavcodec/dxva2_h264.c     | 4 +---
>>  libavcodec/dxva2_hevc.c     | 4 +---
>>  libavcodec/dxva2_internal.h | 5 +++++
>>  libavcodec/dxva2_mpeg2.c    | 4 +---
>>  libavcodec/dxva2_vc1.c      | 4 +---
>>  libavcodec/dxva2_vp9.c      | 4 +---
>>  6 files changed, 10 insertions(+), 15 deletions(-)
>>
>> diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
>> index 82a772d..59fa5e3 100644
>> --- a/libavcodec/dxva2_h264.c
>> +++ b/libavcodec/dxva2_h264.c
>> @@ -450,9 +450,7 @@ static int dxva2_h264_start_frame(AVCodecContext *avctx,
>>      AVDXVAContext *ctx = avctx->hwaccel_context;
>>      struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private;
>>
>> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
>> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>>          return -1;
>>      assert(ctx_pic);
>>
>> diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
>> index 5a312ea..981c888 100644
>> --- a/libavcodec/dxva2_hevc.c
>> +++ b/libavcodec/dxva2_hevc.c
>> @@ -364,9 +364,7 @@ static int dxva2_hevc_start_frame(AVCodecContext *avctx,
>>      AVDXVAContext *ctx = avctx->hwaccel_context;
>>      struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
>>
>> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
>> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>>          return -1;
>>      av_assert0(ctx_pic);
>>
>> diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
>> index c962810..e5322ef 100644
>> --- a/libavcodec/dxva2_internal.h
>> +++ b/libavcodec/dxva2_internal.h
>> @@ -76,6 +76,9 @@ typedef union {
>>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
>>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
>>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
>> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (DXVA_CONTEXT_DECODER(avctx, ctx) && \
>> +                                                 DXVA_CONTEXT_CFG(avctx, ctx) && \
>> +                                                 DXVA_CONTEXT_COUNT(avctx, ctx))
>>  #elif CONFIG_DXVA2
>>  #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->dxva2.workaround)
>>  #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->dxva2.surface_count)
>> @@ -85,6 +88,7 @@ typedef union {
>>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->dxva2.cfg->ConfigBitstreamRaw)
>>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
>>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
>> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
>>  #elif CONFIG_D3D11VA
>>  #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->d3d11va.workaround)
>>  #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->d3d11va.surface_count)
>> @@ -94,6 +98,7 @@ typedef union {
>>  #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->d3d11va.cfg->ConfigBitstreamRaw)
>>  #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
>>  #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
>> +#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
>>  #endif
>>
>>  unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
>> diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
>> index c2f0b58..14ac48f 100644
>> --- a/libavcodec/dxva2_mpeg2.c
>> +++ b/libavcodec/dxva2_mpeg2.c
>> @@ -262,9 +262,7 @@ static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
>>      struct dxva2_picture_context *ctx_pic =
>>          s->current_picture_ptr->hwaccel_picture_private;
>>
>> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
>> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>>          return -1;
>>      assert(ctx_pic);
>>
>> diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
>> index 36bf1ba..cc97d7b 100644
>> --- a/libavcodec/dxva2_vc1.c
>> +++ b/libavcodec/dxva2_vc1.c
>> @@ -317,9 +317,7 @@ static int dxva2_vc1_start_frame(AVCodecContext *avctx,
>>      AVDXVAContext *ctx = avctx->hwaccel_context;
>>      struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
>>
>> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
>> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>>          return -1;
>>      assert(ctx_pic);
>>
>> diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c
>> index 0c4996c..d53b327 100644
>> --- a/libavcodec/dxva2_vp9.c
>> +++ b/libavcodec/dxva2_vp9.c
>> @@ -261,9 +261,7 @@ static int dxva2_vp9_start_frame(AVCodecContext *avctx,
>>      AVDXVAContext *ctx = avctx->hwaccel_context;
>>      struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
>>
>> -    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
>> -        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
>> +    if (!DXVA_CONTEXT_VALID(avctx, ctx))
>>          return -1;
>>      av_assert0(ctx_pic);
>>
>> --
>> 2.10.2
>>
wm4 Jan. 13, 2017, 9:47 a.m. UTC | #3
On Fri, 13 Jan 2017 09:52:18 +0100
Steve Lhomme <robux4@gmail.com> wrote:

> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
> merged in libav.

So how do we handle this. Do we wait until the merges catch up, or do
you want to push your patches to ffmpeg's git immediately?
Stève Lhomme Jan. 13, 2017, 10:40 a.m. UTC | #4
On Fri, Jan 13, 2017 at 10:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
> On Fri, 13 Jan 2017 09:52:18 +0100

> Steve Lhomme <robux4@gmail.com> wrote:

>

>> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now

>> merged in libav.

>

> So how do we handle this. Do we wait until the merges catch up, or do

> you want to push your patches to ffmpeg's git immediately?


Not sure what you mean. What merge are you talking about ?
These 3 patches can live on their own, regardless of what is being
done with d3d11va in hwcontext and ffmpeg.
I can send again 4/4 as the version number needs to be updated.

> _______________________________________________

> ffmpeg-devel mailing list

> ffmpeg-devel@ffmpeg.org

> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Michael Niedermayer Jan. 13, 2017, 12:01 p.m. UTC | #5
On Fri, Jan 13, 2017 at 10:40:23AM +0000, Stève Lhomme wrote:
> On Fri, Jan 13, 2017 at 10:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
> > On Fri, 13 Jan 2017 09:52:18 +0100
> > Steve Lhomme <robux4@gmail.com> wrote:
> >
> >> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
> >> merged in libav.
> >
> > So how do we handle this. Do we wait until the merges catch up, or do
> > you want to push your patches to ffmpeg's git immediately?
> 
> Not sure what you mean. What merge are you talking about ?
> These 3 patches can live on their own, regardless of what is being
> done with d3d11va in hwcontext and ffmpeg.
> I can send again 4/4 as the version number needs to be updated.

when resending you may want to add a patch to add yourself to the
MAINTAINERs file, maybe for d3d11va or any other part you want

[...]
Michael Niedermayer Jan. 13, 2017, 12:04 p.m. UTC | #6
On Fri, Jan 13, 2017 at 01:01:14PM +0100, Michael Niedermayer wrote:
> On Fri, Jan 13, 2017 at 10:40:23AM +0000, Stève Lhomme wrote:
> > On Fri, Jan 13, 2017 at 10:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
> > > On Fri, 13 Jan 2017 09:52:18 +0100
> > > Steve Lhomme <robux4@gmail.com> wrote:
> > >
> > >> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
> > >> merged in libav.
> > >
> > > So how do we handle this. Do we wait until the merges catch up, or do
> > > you want to push your patches to ffmpeg's git immediately?
> > 
> > Not sure what you mean. What merge are you talking about ?
> > These 3 patches can live on their own, regardless of what is being
> > done with d3d11va in hwcontext and ffmpeg.
> > I can send again 4/4 as the version number needs to be updated.
> 
> when resending you may want to add a patch to add yourself to the
> MAINTAINERs file, maybe for d3d11va or any other part you want

to clarify, i think you should have write access to git and the
list of people havig write access should match the list of people in
MAINTAINERs

[...]
Steve Lhomme Jan. 13, 2017, 1:02 p.m. UTC | #7
On Fri, Jan 13, 2017 at 1:04 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
> On Fri, Jan 13, 2017 at 01:01:14PM +0100, Michael Niedermayer wrote:
>> On Fri, Jan 13, 2017 at 10:40:23AM +0000, Stève Lhomme wrote:
>> > On Fri, Jan 13, 2017 at 10:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
>> > > On Fri, 13 Jan 2017 09:52:18 +0100
>> > > Steve Lhomme <robux4@gmail.com> wrote:
>> > >
>> > >> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
>> > >> merged in libav.
>> > >
>> > > So how do we handle this. Do we wait until the merges catch up, or do
>> > > you want to push your patches to ffmpeg's git immediately?
>> >
>> > Not sure what you mean. What merge are you talking about ?
>> > These 3 patches can live on their own, regardless of what is being
>> > done with d3d11va in hwcontext and ffmpeg.
>> > I can send again 4/4 as the version number needs to be updated.
>>
>> when resending you may want to add a patch to add yourself to the
>> MAINTAINERs file, maybe for d3d11va or any other part you want
>
> to clarify, i think you should have write access to git and the

OK, How does commit work ? login/pass via HTTP ? ssh key ?

> list of people havig write access should match the list of people in
> MAINTAINERs

I've sent the updated patches and added myself for DXVA2 and D3D11VA stuff.

> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> During times of universal deceit, telling the truth becomes a
> revolutionary act. -- George Orwell
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Michael Niedermayer Jan. 13, 2017, 4:32 p.m. UTC | #8
On Fri, Jan 13, 2017 at 02:02:29PM +0100, Steve Lhomme wrote:
> On Fri, Jan 13, 2017 at 1:04 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
> > On Fri, Jan 13, 2017 at 01:01:14PM +0100, Michael Niedermayer wrote:
> >> On Fri, Jan 13, 2017 at 10:40:23AM +0000, Stève Lhomme wrote:
> >> > On Fri, Jan 13, 2017 at 10:47 AM, wm4 <nfxjfg@googlemail.com> wrote:
> >> > > On Fri, 13 Jan 2017 09:52:18 +0100
> >> > > Steve Lhomme <robux4@gmail.com> wrote:
> >> > >
> >> > >> For the record all 3 remaining patches (2/4, 3/4 and 4/4) are now
> >> > >> merged in libav.
> >> > >
> >> > > So how do we handle this. Do we wait until the merges catch up, or do
> >> > > you want to push your patches to ffmpeg's git immediately?
> >> >
> >> > Not sure what you mean. What merge are you talking about ?
> >> > These 3 patches can live on their own, regardless of what is being
> >> > done with d3d11va in hwcontext and ffmpeg.
> >> > I can send again 4/4 as the version number needs to be updated.
> >>
> >> when resending you may want to add a patch to add yourself to the
> >> MAINTAINERs file, maybe for d3d11va or any other part you want
> >
> > to clarify, i think you should have write access to git and the
> 
> OK, How does commit work ? login/pass via HTTP ? ssh key ?

ssh key

[...]
diff mbox

Patch

diff --git a/libavcodec/dxva2_h264.c b/libavcodec/dxva2_h264.c
index 82a772d..59fa5e3 100644
--- a/libavcodec/dxva2_h264.c
+++ b/libavcodec/dxva2_h264.c
@@ -450,9 +450,7 @@  static int dxva2_h264_start_frame(AVCodecContext *avctx,
     AVDXVAContext *ctx = avctx->hwaccel_context;
     struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private;
 
-    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+    if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
     assert(ctx_pic);
 
diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c
index 5a312ea..981c888 100644
--- a/libavcodec/dxva2_hevc.c
+++ b/libavcodec/dxva2_hevc.c
@@ -364,9 +364,7 @@  static int dxva2_hevc_start_frame(AVCodecContext *avctx,
     AVDXVAContext *ctx = avctx->hwaccel_context;
     struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
 
-    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+    if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
     av_assert0(ctx_pic);
 
diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index c962810..e5322ef 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -76,6 +76,9 @@  typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigIntraResidUnsigned : ctx->dxva2.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ? ctx->d3d11va.cfg->ConfigResidDiffAccelerator : ctx->dxva2.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)          (DXVA_CONTEXT_DECODER(avctx, ctx) && \
+                                                 DXVA_CONTEXT_CFG(avctx, ctx) && \
+                                                 DXVA_CONTEXT_COUNT(avctx, ctx))
 #elif CONFIG_DXVA2
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->dxva2.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->dxva2.surface_count)
@@ -85,6 +88,7 @@  typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->dxva2.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->dxva2.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->dxva2.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->dxva2.decoder && ctx->dxva2.cfg && ctx->dxva2.surface_count)
 #elif CONFIG_D3D11VA
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx)     (ctx->d3d11va.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)          (ctx->d3d11va.surface_count)
@@ -94,6 +98,7 @@  typedef union {
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ctx->d3d11va.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ctx->d3d11va.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ctx->d3d11va.cfg->ConfigResidDiffAccelerator)
+#define DXVA_CONTEXT_VALID(avctx, ctx)          (ctx->d3d11va.decoder && ctx->d3d11va.cfg && ctx->d3d11va.surface_count)
 #endif
 
 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
diff --git a/libavcodec/dxva2_mpeg2.c b/libavcodec/dxva2_mpeg2.c
index c2f0b58..14ac48f 100644
--- a/libavcodec/dxva2_mpeg2.c
+++ b/libavcodec/dxva2_mpeg2.c
@@ -262,9 +262,7 @@  static int dxva2_mpeg2_start_frame(AVCodecContext *avctx,
     struct dxva2_picture_context *ctx_pic =
         s->current_picture_ptr->hwaccel_picture_private;
 
-    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+    if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
     assert(ctx_pic);
 
diff --git a/libavcodec/dxva2_vc1.c b/libavcodec/dxva2_vc1.c
index 36bf1ba..cc97d7b 100644
--- a/libavcodec/dxva2_vc1.c
+++ b/libavcodec/dxva2_vc1.c
@@ -317,9 +317,7 @@  static int dxva2_vc1_start_frame(AVCodecContext *avctx,
     AVDXVAContext *ctx = avctx->hwaccel_context;
     struct dxva2_picture_context *ctx_pic = v->s.current_picture_ptr->hwaccel_picture_private;
 
-    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+    if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
     assert(ctx_pic);
 
diff --git a/libavcodec/dxva2_vp9.c b/libavcodec/dxva2_vp9.c
index 0c4996c..d53b327 100644
--- a/libavcodec/dxva2_vp9.c
+++ b/libavcodec/dxva2_vp9.c
@@ -261,9 +261,7 @@  static int dxva2_vp9_start_frame(AVCodecContext *avctx,
     AVDXVAContext *ctx = avctx->hwaccel_context;
     struct vp9_dxva2_picture_context *ctx_pic = h->frames[CUR_FRAME].hwaccel_picture_private;
 
-    if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_CFG(avctx, ctx) == NULL ||
-        DXVA_CONTEXT_COUNT(avctx, ctx) <= 0)
+    if (!DXVA_CONTEXT_VALID(avctx, ctx))
         return -1;
     av_assert0(ctx_pic);