diff mbox series

[FFmpeg-devel,2/2] avcodec/vpp_qsv: Copy side data from input to output frame

Message ID 43eb3257afeb4d93bac31fe593e6edffb2a09e50.1666652664.git.ffmpegagent@gmail.com
State New
Headers show
Series QSV Overlay Filter: Copy side data from input to output frame | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished

Commit Message

Aman Karmani Oct. 24, 2022, 11:04 p.m. UTC
From: softworkz <softworkz@hotmail.com>

Signed-off-by: softworkz <softworkz@hotmail.com>
---
 libavfilter/qsvvpp.c         |  6 ++++++
 libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
 2 files changed, 21 insertions(+), 4 deletions(-)

Comments

Xiang, Haihao Nov. 1, 2022, 4:58 a.m. UTC | #1
On Mon, 2022-10-24 at 23:04 +0000, softworkz wrote:
> From: softworkz <softworkz@hotmail.com>
> 
> Signed-off-by: softworkz <softworkz@hotmail.com>
> ---
>  libavfilter/qsvvpp.c         |  6 ++++++
>  libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
>  2 files changed, 21 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> index 8428ee89ab..ae9766d12f 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -880,6 +880,12 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink
> *inlink, AVFrame *picr
>                  return AVERROR(EAGAIN);
>              break;
>          }
> +
> +        av_frame_remove_all_side_data(out_frame->frame);
> +        ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame, 0);
> +        if (ret < 0)
> +            return ret;
> +
>          out_frame->frame->pts = av_rescale_q(out_frame-
> >surface.Data.TimeStamp,
>                                               default_tb, outlink->time_base);
>  
> diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
> index d947a1faa1..04fd284b92 100644
> --- a/libavfilter/vf_overlay_qsv.c
> +++ b/libavfilter/vf_overlay_qsv.c
> @@ -231,13 +231,24 @@ static int process_frame(FFFrameSync *fs)
>  {
>      AVFilterContext  *ctx = fs->parent;
>      QSVOverlayContext  *s = fs->opaque;
> +    AVFrame       *frame0 = NULL;
>      AVFrame        *frame = NULL;
> -    int               ret = 0, i;
> +    int               ret = 0;
>  
> -    for (i = 0; i < ctx->nb_inputs; i++) {
> +    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
>          ret = ff_framesync_get_frame(fs, i, &frame, 0);
> -        if (ret == 0)
> -            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
> +
> +        if (ret == 0) {
> +            if (i == 0)
> +                frame0 = frame;
> +            else {
> +                av_frame_remove_all_side_data(frame);
> +                ret = av_frame_copy_side_data(frame, frame0, 0);
> +            }
> +
> +            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv, ctx-
> >inputs[i], frame);
> +        }
> +
>          if (ret < 0 && ret != AVERROR(EAGAIN))
>              break;
>      }

Patchset LGTM, I'll push this patchset if no more comment or objection. 

Thanks
Haihao
Zhao Zhili Nov. 1, 2022, 9:17 a.m. UTC | #2
> On Nov 1, 2022, at 12:58, Xiang, Haihao <haihao.xiang-at-intel.com@ffmpeg.org> wrote:
> 
> On Mon, 2022-10-24 at 23:04 +0000, softworkz wrote:
>> From: softworkz <softworkz@hotmail.com>
>> 
>> Signed-off-by: softworkz <softworkz@hotmail.com>
>> ---
>> libavfilter/qsvvpp.c         |  6 ++++++
>> libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
>> 2 files changed, 21 insertions(+), 4 deletions(-)
>> 
>> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
>> index 8428ee89ab..ae9766d12f 100644
>> --- a/libavfilter/qsvvpp.c
>> +++ b/libavfilter/qsvvpp.c
>> @@ -880,6 +880,12 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink
>> *inlink, AVFrame *picr
>>                 return AVERROR(EAGAIN);
>>             break;
>>         }
>> +
>> +        av_frame_remove_all_side_data(out_frame->frame);
>> +        ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame, 0);
>> +        if (ret < 0)
>> +            return ret;
>> +
>>         out_frame->frame->pts = av_rescale_q(out_frame-
>>> surface.Data.TimeStamp,
>>                                              default_tb, outlink->time_base);
>> 
>> diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
>> index d947a1faa1..04fd284b92 100644
>> --- a/libavfilter/vf_overlay_qsv.c
>> +++ b/libavfilter/vf_overlay_qsv.c
>> @@ -231,13 +231,24 @@ static int process_frame(FFFrameSync *fs)
>> {
>>     AVFilterContext  *ctx = fs->parent;
>>     QSVOverlayContext  *s = fs->opaque;
>> +    AVFrame       *frame0 = NULL;
>>     AVFrame        *frame = NULL;
>> -    int               ret = 0, i;
>> +    int               ret = 0;
>> 
>> -    for (i = 0; i < ctx->nb_inputs; i++) {
>> +    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
>>         ret = ff_framesync_get_frame(fs, i, &frame, 0);
>> -        if (ret == 0)
>> -            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
>> +
>> +        if (ret == 0) {
>> +            if (i == 0)
>> +                frame0 = frame;
>> +            else {
>> +                av_frame_remove_all_side_data(frame);
>> +                ret = av_frame_copy_side_data(frame, frame0, 0);
>> +            }
>> +
>> +            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv, ctx-
>>> inputs[i], frame);
>> +        }
>> +
>>         if (ret < 0 && ret != AVERROR(EAGAIN))
>>             break;
>>     }
> 
> Patchset LGTM, I'll push this patchset if no more comment or objection. 

avcodec/vpp_qsv: Copy side data from input to output frame
^^^^^^^

avcodec -> avfilter

> 
> 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".
Andreas Rheinhardt Nov. 2, 2022, 4:23 a.m. UTC | #3
Xiang, Haihao:
> On Mon, 2022-10-24 at 23:04 +0000, softworkz wrote:
>> From: softworkz <softworkz@hotmail.com>
>>
>> Signed-off-by: softworkz <softworkz@hotmail.com>
>> ---
>>  libavfilter/qsvvpp.c         |  6 ++++++
>>  libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
>>  2 files changed, 21 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
>> index 8428ee89ab..ae9766d12f 100644
>> --- a/libavfilter/qsvvpp.c
>> +++ b/libavfilter/qsvvpp.c
>> @@ -880,6 +880,12 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink
>> *inlink, AVFrame *picr
>>                  return AVERROR(EAGAIN);
>>              break;
>>          }
>> +
>> +        av_frame_remove_all_side_data(out_frame->frame);
>> +        ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame, 0);
>> +        if (ret < 0)
>> +            return ret;
>> +
>>          out_frame->frame->pts = av_rescale_q(out_frame-
>>> surface.Data.TimeStamp,
>>                                               default_tb, outlink->time_base);
>>  
>> diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
>> index d947a1faa1..04fd284b92 100644
>> --- a/libavfilter/vf_overlay_qsv.c
>> +++ b/libavfilter/vf_overlay_qsv.c
>> @@ -231,13 +231,24 @@ static int process_frame(FFFrameSync *fs)
>>  {
>>      AVFilterContext  *ctx = fs->parent;
>>      QSVOverlayContext  *s = fs->opaque;
>> +    AVFrame       *frame0 = NULL;
>>      AVFrame        *frame = NULL;
>> -    int               ret = 0, i;
>> +    int               ret = 0;
>>  
>> -    for (i = 0; i < ctx->nb_inputs; i++) {
>> +    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
>>          ret = ff_framesync_get_frame(fs, i, &frame, 0);
>> -        if (ret == 0)
>> -            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
>> +
>> +        if (ret == 0) {
>> +            if (i == 0)
>> +                frame0 = frame;
>> +            else {
>> +                av_frame_remove_all_side_data(frame);
>> +                ret = av_frame_copy_side_data(frame, frame0, 0);
>> +            }
>> +
>> +            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv, ctx-
>>> inputs[i], frame);
>> +        }
>> +
>>          if (ret < 0 && ret != AVERROR(EAGAIN))
>>              break;
>>      }
> 
> Patchset LGTM, I'll push this patchset if no more comment or objection. 
> 

Can you wait a few days on this? I'd like to take a look at #1.

- Andreas
Xiang, Haihao Nov. 2, 2022, 6:05 a.m. UTC | #4
On Wed, 2022-11-02 at 05:23 +0100, Andreas Rheinhardt wrote:
> Xiang, Haihao:
> > On Mon, 2022-10-24 at 23:04 +0000, softworkz wrote:
> > > From: softworkz <softworkz@hotmail.com>
> > > 
> > > Signed-off-by: softworkz <softworkz@hotmail.com>
> > > ---
> > >  libavfilter/qsvvpp.c         |  6 ++++++
> > >  libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
> > >  2 files changed, 21 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> > > index 8428ee89ab..ae9766d12f 100644
> > > --- a/libavfilter/qsvvpp.c
> > > +++ b/libavfilter/qsvvpp.c
> > > @@ -880,6 +880,12 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s,
> > > AVFilterLink
> > > *inlink, AVFrame *picr
> > >                  return AVERROR(EAGAIN);
> > >              break;
> > >          }
> > > +
> > > +        av_frame_remove_all_side_data(out_frame->frame);
> > > +        ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame,
> > > 0);
> > > +        if (ret < 0)
> > > +            return ret;
> > > +
> > >          out_frame->frame->pts = av_rescale_q(out_frame-
> > > > surface.Data.TimeStamp,
> > >                                               default_tb, outlink-
> > > >time_base);
> > >  
> > > diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
> > > index d947a1faa1..04fd284b92 100644
> > > --- a/libavfilter/vf_overlay_qsv.c
> > > +++ b/libavfilter/vf_overlay_qsv.c
> > > @@ -231,13 +231,24 @@ static int process_frame(FFFrameSync *fs)
> > >  {
> > >      AVFilterContext  *ctx = fs->parent;
> > >      QSVOverlayContext  *s = fs->opaque;
> > > +    AVFrame       *frame0 = NULL;
> > >      AVFrame        *frame = NULL;
> > > -    int               ret = 0, i;
> > > +    int               ret = 0;
> > >  
> > > -    for (i = 0; i < ctx->nb_inputs; i++) {
> > > +    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
> > >          ret = ff_framesync_get_frame(fs, i, &frame, 0);
> > > -        if (ret == 0)
> > > -            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
> > > +
> > > +        if (ret == 0) {
> > > +            if (i == 0)
> > > +                frame0 = frame;
> > > +            else {
> > > +                av_frame_remove_all_side_data(frame);
> > > +                ret = av_frame_copy_side_data(frame, frame0, 0);
> > > +            }
> > > +
> > > +            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv, ctx-
> > > > inputs[i], frame);
> > > +        }
> > > +
> > >          if (ret < 0 && ret != AVERROR(EAGAIN))
> > >              break;
> > >      }
> > 
> > Patchset LGTM, I'll push this patchset if no more comment or objection. 
> > 
> 
> Can you wait a few days on this? I'd like to take a look at #1.

Sure ofc, I can wait until no more comments about this patchset. 

Thanks
Haihao
Soft Works Nov. 2, 2022, 10:44 p.m. UTC | #5
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> "zhilizhao(???)"
> Sent: Tuesday, November 1, 2022 10:18 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/vpp_qsv: Copy side
> data from input to output frame
> 
> 
> 
> > On Nov 1, 2022, at 12:58, Xiang, Haihao <haihao.xiang-at-
> intel.com@ffmpeg.org> wrote:
> >
> > On Mon, 2022-10-24 at 23:04 +0000, softworkz wrote:
> >> From: softworkz <softworkz@hotmail.com>
> >>
> >> Signed-off-by: softworkz <softworkz@hotmail.com>
> >> ---
> >> libavfilter/qsvvpp.c         |  6 ++++++
> >> libavfilter/vf_overlay_qsv.c | 19 +++++++++++++++----
> >> 2 files changed, 21 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
> >> index 8428ee89ab..ae9766d12f 100644
> >> --- a/libavfilter/qsvvpp.c
> >> +++ b/libavfilter/qsvvpp.c
> >> @@ -880,6 +880,12 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s,
> AVFilterLink
> >> *inlink, AVFrame *picr
> >>                 return AVERROR(EAGAIN);
> >>             break;
> >>         }
> >> +
> >> +        av_frame_remove_all_side_data(out_frame->frame);
> >> +        ret = av_frame_copy_side_data(out_frame->frame, in_frame-
> >frame, 0);
> >> +        if (ret < 0)
> >> +            return ret;
> >> +
> >>         out_frame->frame->pts = av_rescale_q(out_frame-
> >>> surface.Data.TimeStamp,
> >>                                              default_tb, outlink-
> >time_base);
> >>
> >> diff --git a/libavfilter/vf_overlay_qsv.c
> b/libavfilter/vf_overlay_qsv.c
> >> index d947a1faa1..04fd284b92 100644
> >> --- a/libavfilter/vf_overlay_qsv.c
> >> +++ b/libavfilter/vf_overlay_qsv.c
> >> @@ -231,13 +231,24 @@ static int process_frame(FFFrameSync *fs)
> >> {
> >>     AVFilterContext  *ctx = fs->parent;
> >>     QSVOverlayContext  *s = fs->opaque;
> >> +    AVFrame       *frame0 = NULL;
> >>     AVFrame        *frame = NULL;
> >> -    int               ret = 0, i;
> >> +    int               ret = 0;
> >>
> >> -    for (i = 0; i < ctx->nb_inputs; i++) {
> >> +    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
> >>         ret = ff_framesync_get_frame(fs, i, &frame, 0);
> >> -        if (ret == 0)
> >> -            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i],
> frame);
> >> +
> >> +        if (ret == 0) {
> >> +            if (i == 0)
> >> +                frame0 = frame;
> >> +            else {
> >> +                av_frame_remove_all_side_data(frame);
> >> +                ret = av_frame_copy_side_data(frame, frame0, 0);
> >> +            }
> >> +
> >> +            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv,
> ctx-
> >>> inputs[i], frame);
> >> +        }
> >> +
> >>         if (ret < 0 && ret != AVERROR(EAGAIN))
> >>             break;
> >>     }
> >
> > Patchset LGTM, I'll push this patchset if no more comment or
> objection.
> 
> avcodec/vpp_qsv: Copy side data from input to output frame
> ^^^^^^^
> 
> avcodec -> avfilter
> 

Good catch!

Thank you,
sw
diff mbox series

Patch

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8428ee89ab..ae9766d12f 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -880,6 +880,12 @@  int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr
                 return AVERROR(EAGAIN);
             break;
         }
+
+        av_frame_remove_all_side_data(out_frame->frame);
+        ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame, 0);
+        if (ret < 0)
+            return ret;
+
         out_frame->frame->pts = av_rescale_q(out_frame->surface.Data.TimeStamp,
                                              default_tb, outlink->time_base);
 
diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c
index d947a1faa1..04fd284b92 100644
--- a/libavfilter/vf_overlay_qsv.c
+++ b/libavfilter/vf_overlay_qsv.c
@@ -231,13 +231,24 @@  static int process_frame(FFFrameSync *fs)
 {
     AVFilterContext  *ctx = fs->parent;
     QSVOverlayContext  *s = fs->opaque;
+    AVFrame       *frame0 = NULL;
     AVFrame        *frame = NULL;
-    int               ret = 0, i;
+    int               ret = 0;
 
-    for (i = 0; i < ctx->nb_inputs; i++) {
+    for (unsigned i = 0; i < ctx->nb_inputs; i++) {
         ret = ff_framesync_get_frame(fs, i, &frame, 0);
-        if (ret == 0)
-            ret = ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
+
+        if (ret == 0) {
+            if (i == 0)
+                frame0 = frame;
+            else {
+                av_frame_remove_all_side_data(frame);
+                ret = av_frame_copy_side_data(frame, frame0, 0);
+            }
+
+            ret = ret < 0 ? ret : ff_qsvvpp_filter_frame(s->qsv, ctx->inputs[i], frame);
+        }
+
         if (ret < 0 && ret != AVERROR(EAGAIN))
             break;
     }