From: "Wang, Fei W" <fei.w.wang-at-intel.com@ffmpeg.org> To: "ffmpeg-devel@ffmpeg.org" <ffmpeg-devel@ffmpeg.org> Cc: "Wang, Fei W" <fei.w.wang@intel.com> Subject: Re: [FFmpeg-devel] [PATCH v1 6/7] lavc/vvc_dec: Add hardware decode API Date: Tue, 2 Apr 2024 06:24:03 +0000 Message-ID: <473c85f564a9b5389d249c3d176fa42d9d296f3d.camel@intel.com> (raw) In-Reply-To: <GV1P250MB073756A29050A0982C39A0958F3B2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> On Thu, 2024-03-28 at 03:04 +0100, Andreas Rheinhardt wrote: > fei.w.wang-at-intel.com@ffmpeg.org: > > From: Fei Wang <fei.w.wang@intel.com> > > > > Signed-off-by: Fei Wang <fei.w.wang@intel.com> > > --- > > libavcodec/vvc/vvc_refs.c | 6 ++++ > > libavcodec/vvc/vvcdec.c | 67 > > +++++++++++++++++++++++++++++++++++---- > > libavcodec/vvc/vvcdec.h | 5 +++ > > 3 files changed, 72 insertions(+), 6 deletions(-) > > > > diff --git a/libavcodec/vvc/vvc_refs.c b/libavcodec/vvc/vvc_refs.c > > index bf70777550..c9f89a5a0a 100644 > > --- a/libavcodec/vvc/vvc_refs.c > > +++ b/libavcodec/vvc/vvc_refs.c > > @@ -25,6 +25,7 @@ > > #include "libavutil/thread.h" > > #include "libavcodec/refstruct.h" > > #include "libavcodec/thread.h" > > +#include "libavcodec/decode.h" > > > > #include "vvc_refs.h" > > > > @@ -56,6 +57,7 @@ void ff_vvc_unref_frame(VVCFrameContext *fc, > > VVCFrame *frame, int flags) > > ff_refstruct_unref(&frame->rpl_tab); > > > > frame->collocated_ref = NULL; > > + ff_refstruct_unref(&frame->hwaccel_picture_private); > > } > > } > > > > @@ -138,6 +140,10 @@ static VVCFrame *alloc_frame(VVCContext *s, > > VVCFrameContext *fc) > > if (!frame->progress) > > goto fail; > > > > + ret = ff_hwaccel_frame_priv_alloc(s->avctx, &frame- > > >hwaccel_picture_private); > > + if (ret < 0) > > + goto fail; > > + > > return frame; > > fail: > > ff_vvc_unref_frame(fc, frame, ~0); > > diff --git a/libavcodec/vvc/vvcdec.c b/libavcodec/vvc/vvcdec.c > > index d5704aca25..f2e269ce76 100644 > > --- a/libavcodec/vvc/vvcdec.c > > +++ b/libavcodec/vvc/vvcdec.c > > @@ -24,6 +24,8 @@ > > #include "libavcodec/decode.h" > > #include "libavcodec/profiles.h" > > #include "libavcodec/refstruct.h" > > +#include "libavcodec/hwconfig.h" > > +#include "libavcodec/hwaccel_internal.h" > > #include "libavutil/cpu.h" > > #include "libavutil/thread.h" > > > > @@ -563,6 +565,8 @@ static int ref_frame(VVCFrame *dst, const > > VVCFrame *src) > > > > ff_refstruct_replace(&dst->rpl_tab, src->rpl_tab); > > ff_refstruct_replace(&dst->rpl, src->rpl); > > + ff_refstruct_replace(&dst->hwaccel_picture_private, > > + src->hwaccel_picture_private); > > dst->nb_rpl_elems = src->nb_rpl_elems; > > > > dst->poc = src->poc; > > @@ -718,17 +722,41 @@ static int slice_start(SliceContext *sc, > > VVCContext *s, VVCFrameContext *fc, > > return 0; > > } > > > > +static enum AVPixelFormat get_format(AVCodecContext *avctx, const > > VVCSPS *sps) > > +{ > > +#define HWACCEL_MAX 0 > > + > > + enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; > > + > > + switch (sps->pix_fmt) { > > + case AV_PIX_FMT_YUV420P: > > + break; > > + case AV_PIX_FMT_YUV420P10: > > + break; > > + } > > + > > + *fmt++ = sps->pix_fmt; > > + *fmt = AV_PIX_FMT_NONE; > > + > > + return ff_get_format(avctx, pix_fmts); > > +} > > + > > static void export_frame_params(VVCContext *s, const > > VVCFrameContext *fc) > > { > > AVCodecContext *c = s->avctx; > > const VVCSPS *sps = fc->ps.sps; > > const VVCPPS *pps = fc->ps.pps; > > > > - c->pix_fmt = sps->pix_fmt; > > - c->coded_width = pps->width; > > - c->coded_height = pps->height; > > - c->width = pps->width - ((pps->r- > > >pps_conf_win_left_offset + pps->r->pps_conf_win_right_offset) << > > sps->hshift[CHROMA]); > > - c->height = pps->height - ((pps->r- > > >pps_conf_win_top_offset + pps->r->pps_conf_win_bottom_offset) << > > sps->vshift[CHROMA]); > > + // Reset HW config if pix_fmt/w/h change. > > + if (s->pix_fmt != sps->pix_fmt || c->coded_width != pps->width > > || c->coded_height != pps->height) { > > + c->coded_width = pps->width; > > + c->coded_height = pps->height; > > + c->pix_fmt = get_format(c, sps); > > + s->pix_fmt = sps->pix_fmt; > > + } > > + > > + c->width = pps->width - ((pps->r->pps_conf_win_left_offset + > > pps->r->pps_conf_win_right_offset) << sps->hshift[CHROMA]); > > + c->height = pps->height - ((pps->r->pps_conf_win_top_offset + > > pps->r->pps_conf_win_bottom_offset) << sps->vshift[CHROMA]); > > } > > > > static int frame_setup(VVCFrameContext *fc, VVCContext *s) > > @@ -771,6 +799,20 @@ static int decode_slice(VVCContext *s, > > VVCFrameContext *fc, const H2645NAL *nal, > > ret = slice_init_entry_points(sc, fc, nal, unit); > > if (ret < 0) > > return ret; > > + > > + if (s->avctx->hwaccel) { > > + if (is_first_slice) { > > + ret = FF_HW_CALL(s->avctx, start_frame, NULL, 0); > > + if (ret < 0) > > + return ret; > > + } > > + > > + ret = FF_HW_CALL(s->avctx, decode_slice, > > + nal->raw_data, nal->raw_size); > > + if (ret < 0) > > + return ret; > > + } > > + > > fc->nb_slices++; > > > > return 0; > > @@ -885,9 +927,20 @@ static int wait_delayed_frame(VVCContext *s, > > AVFrame *output, int *got_output) > > static int submit_frame(VVCContext *s, VVCFrameContext *fc, > > AVFrame *output, int *got_output) > > { > > int ret; > > + > > + if (s->avctx->hwaccel) { > > + if (ret = FF_HW_SIMPLE_CALL(s->avctx, end_frame) < 0) { > > + av_log(s->avctx, AV_LOG_ERROR, > > + "Hardware accelerator failed to decode > > picture\n"); > > + ff_vvc_unref_frame(fc, fc->ref, ~0); > > + return ret; > > + } > > + } else > > + ff_vvc_frame_submit(s, fc); > > + > > s->nb_frames++; > > s->nb_delayed++; > > - ff_vvc_frame_submit(s, fc); > > + > > if (s->nb_delayed >= s->nb_fcs) { > > if ((ret = wait_delayed_frame(s, output, got_output)) < 0) > > return ret; > > @@ -1027,6 +1080,8 @@ static av_cold int > > vvc_decode_init(AVCodecContext *avctx) > > GDR_SET_RECOVERED(s); > > ff_thread_once(&init_static_once, init_default_scale_m); > > > > + s->pix_fmt = AV_PIX_FMT_NONE; > > + > > return 0; > > } > > > > diff --git a/libavcodec/vvc/vvcdec.h b/libavcodec/vvc/vvcdec.h > > index aa3d715524..009d57424e 100644 > > --- a/libavcodec/vvc/vvcdec.h > > +++ b/libavcodec/vvc/vvcdec.h > > @@ -78,6 +78,9 @@ typedef struct VVCFrame { > > * A combination of VVC_FRAME_FLAG_* > > */ > > uint8_t flags; > > + > > + AVBufferRef *hwaccel_priv_buf; > > Seems unused (hwaccel_picture_private uses RefStruct nowadays; no > other > decoder uses the AVBuffer API for this any more). Thanks, will fix in next version. Fei > > > + void *hwaccel_picture_private; ///< hardware accelerator > > private data > > } VVCFrame; > > > > typedef struct SliceContext { > > @@ -224,6 +227,8 @@ typedef struct VVCContext { > > > > uint64_t nb_frames; ///< processed frames > > int nb_delayed; ///< delayed frames > > + > > + enum AVPixelFormat pix_fmt; ///< pix format of current frame > > } VVCContext ; > > > > #endif /* AVCODEC_VVC_VVCDEC_H */ > > _______________________________________________ > 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". _______________________________________________ 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".
next prev parent reply other threads:[~2024-04-02 6:24 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-28 1:26 [FFmpeg-devel] [PATCH v1 1/7] lavc/vaapi_dec: Create VA parameters dynamically fei.w.wang-at-intel.com 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 2/7] lavc/vvc_refs: Move definition of VVC_FRAME_FLAG* to h header fei.w.wang-at-intel.com 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 3/7] lavc/cbs_h266: Add SliceTopLeftTileIdx to H266RawPPS fei.w.wang-at-intel.com 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 4/7] lavc/cbs_h266: Add NumSlicesInTile " fei.w.wang-at-intel.com 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 5/7] lavc/vvc_ps: Add alf raw syntax into VVCALF fei.w.wang-at-intel.com 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 6/7] lavc/vvc_dec: Add hardware decode API fei.w.wang-at-intel.com 2024-03-28 2:04 ` Andreas Rheinhardt 2024-04-02 6:24 ` Wang, Fei W [this message] 2024-03-28 1:26 ` [FFmpeg-devel] [PATCH v1 7/7] lavc/vaapi_dec: Add VVC decoder fei.w.wang-at-intel.com 2024-04-02 12:48 ` Nuo Mi 2024-04-03 3:31 ` Wang, Fei W 2024-04-06 5:03 ` Nuo Mi 2024-04-01 19:52 ` [FFmpeg-devel] [PATCH v1 1/7] lavc/vaapi_dec: Create VA parameters dynamically Mark Thompson 2024-04-02 6:16 ` Wang, Fei W
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=473c85f564a9b5389d249c3d176fa42d9d296f3d.camel@intel.com \ --to=fei.w.wang-at-intel.com@ffmpeg.org \ --cc=fei.w.wang@intel.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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