From: Soft Works <softworkz@hotmail.com> To: "ffmpegdev@gitmailbox.com" <ffmpegdev@gitmailbox.com> Subject: RE: [PATCH] avcodec/vpp_qsv: copy side data from input to output frame Date: Mon, 20 Dec 2021 01:14:27 +0000 Message-ID: <DM8P223MB0365E8C81EBAD8020C2091DDBA7B9@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw) In-Reply-To: <pull.10.ffstaging.FFmpeg.1639962553801.ffmpegagent@gmail.com> > -----Original Message----- > From: ffmpegagent <ffmpegagent@gmail.com> > Sent: Monday, December 20, 2021 2:09 AM > To: softworkz@hotmail.com > Cc: softworkz <softworkz@hotmail.com>; softworkz <softworkz@hotmail.com> > Subject: [PATCH] avcodec/vpp_qsv: copy side data from input to output frame > > From: softworkz <softworkz@hotmail.com> > > Signed-off-by: softworkz <softworkz@hotmail.com> > --- > QSV: Copy side data from input to output frame > > (cherry picked from commit ae556fafe8a0d3b8a1ffb7f640c0abf290424139) > > Published-As: https://github.com/ffstaging/FFmpeg/releases/tag/pr-ffstaging- > 10%2Fsoftworkz%2Fasf_fixes-v1 > Fetch-It-Via: git fetch https://github.com/ffstaging/FFmpeg pr-ffstaging- > 10/softworkz/asf_fixes-v1 > Pull-Request: https://github.com/ffstaging/FFmpeg/pull/10 > > libavfilter/qsvvpp.c | 5 ++++ > libavfilter/vf_overlay_qsv.c | 19 +++++++++--- > libavutil/frame.c | 57 ++++++++++++++++++++---------------- > libavutil/frame.h | 12 ++++++++ > 4 files changed, 64 insertions(+), 29 deletions(-) > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c > index d1218355c7..b291216292 100644 > --- a/libavfilter/qsvvpp.c > +++ b/libavfilter/qsvvpp.c > @@ -849,6 +849,11 @@ int ff_qsvvpp_filter_frame(QSVVPPContext *s, > AVFilterLink *inlink, AVFrame *picr > return AVERROR(EAGAIN); > break; > } > + > + ret = av_frame_copy_side_data(out_frame->frame, in_frame->frame, 0); > + if (ret < 0) > + return ret; > + Test > 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 7e76b39aa9..02518e020c 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) { > + AVFrame *temp; > + > + if (i == 0) > + frame0 = frame; > + else > + 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; > } > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 0912ad9131..b689c8a7c9 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -253,6 +253,36 @@ int av_frame_get_buffer(AVFrame *frame, int align) > return AVERROR(EINVAL); > } > > +int av_frame_copy_side_data(AVFrame* dst, const AVFrame* src, int > force_copy) > +{ > + for (unsigned i = 0; i < src->nb_side_data; i++) { > + const AVFrameSideData *sd_src = src->side_data[i]; > + AVFrameSideData *sd_dst; > + if ( sd_src->type == AV_FRAME_DATA_PANSCAN > + && (src->width != dst->width || src->height != dst->height)) > + continue; > + if (force_copy) { > + sd_dst = av_frame_new_side_data(dst, sd_src->type, > + sd_src->size); > + if (!sd_dst) { > + wipe_side_data(dst); > + return AVERROR(ENOMEM); > + } > + memcpy(sd_dst->data, sd_src->data, sd_src->size); > + } else { > + AVBufferRef *ref = av_buffer_ref(sd_src->buf); > + sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, > ref); > + if (!sd_dst) { > + av_buffer_unref(&ref); > + wipe_side_data(dst); > + return AVERROR(ENOMEM); > + } > + } > + av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); > + } > + return 0; > +} > + > static int frame_copy_props(AVFrame *dst, const AVFrame *src, int > force_copy) > { > int ret, i; > @@ -291,31 +321,8 @@ static int frame_copy_props(AVFrame *dst, const AVFrame > *src, int force_copy) > > av_dict_copy(&dst->metadata, src->metadata, 0); > > - for (i = 0; i < src->nb_side_data; i++) { > - const AVFrameSideData *sd_src = src->side_data[i]; > - AVFrameSideData *sd_dst; > - if ( sd_src->type == AV_FRAME_DATA_PANSCAN > - && (src->width != dst->width || src->height != dst->height)) > - continue; > - if (force_copy) { > - sd_dst = av_frame_new_side_data(dst, sd_src->type, > - sd_src->size); > - if (!sd_dst) { > - wipe_side_data(dst); > - return AVERROR(ENOMEM); > - } > - memcpy(sd_dst->data, sd_src->data, sd_src->size); > - } else { > - AVBufferRef *ref = av_buffer_ref(sd_src->buf); > - sd_dst = av_frame_new_side_data_from_buf(dst, sd_src->type, > ref); > - if (!sd_dst) { > - av_buffer_unref(&ref); > - wipe_side_data(dst); > - return AVERROR(ENOMEM); > - } > - } > - av_dict_copy(&sd_dst->metadata, sd_src->metadata, 0); > - } > + if (ret = av_frame_copy_side_data(dst, src, force_copy) < 0) > + return ret; > > ret = av_buffer_replace(&dst->opaque_ref, src->opaque_ref); > ret |= av_buffer_replace(&dst->private_ref, src->private_ref); > diff --git a/libavutil/frame.h b/libavutil/frame.h > index 3f295f6b9e..61a5110bee 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -822,6 +822,18 @@ int av_frame_copy(AVFrame *dst, const AVFrame *src); > */ > int av_frame_copy_props(AVFrame *dst, const AVFrame *src); > > +/** > + * Copy only side-data from src to dst. > + * > + * @param dst a frame to which the side data should be copied. > + * @param src a frame from which to copy the side data. > + * @param force_copy determines whether to copy the actual data or only just > + * create references to the buffers. > + * > + * @return >= 0 on success, a negative AVERROR on error. > + */ > +int av_frame_copy_side_data(AVFrame* dst, const AVFrame* src, int > force_copy); > + > /** > * Get the buffer reference a given data plane is stored in. > * > > base-commit: 11aa9ca153d4446887ff3ebd26e5a3c243a19d80 > -- > gitgitgadget
next parent reply other threads:[~2021-12-20 1:14 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <pull.10.ffstaging.FFmpeg.1639962553801.ffmpegagent@gmail.com> 2021-12-20 1:14 ` Soft Works [this message] 2021-12-20 1:23 ` Soft Works
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=DM8P223MB0365E8C81EBAD8020C2091DDBA7B9@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \ --to=softworkz@hotmail.com \ --cc=ffmpegdev@gitmailbox.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