From: green-hand-shandong
<[email protected]>
This series adds hardware video acceleration for Huawei Ascend NPUs
(Atlas 300I-Duo / Ascend 310P, and other DVPP-equipped Ascend SoCs)
through the open-source CANN runtime (libascendcl), enabled with
--enable-libascendcl.
What is included
----------------
Decoders (VDEC): h264_ascend, hevc_ascend (10-bit streams decode to
NV12; the 10-bit semi-planar output path is rejected by current
310P firmware, so those fall back to 8-bit output with a documented
log). JPEG: jpeg_ascend decoder (JPEGD) and encoder (JPEGE).
Encoders (VENC): h264_ascend, hevc_ascend with cbr/vbr/avbr/fixqp
rate control and a zero_copy mode for ASCEND hardware frame input.
Filters (VPC): scale_ascend, crop_ascend, pad_ascend, overlay_ascend.
Infrastructure: AV_PIX_FMT_ASCEND, AV_HWDEVICE_TYPE_ASCEND and
libavutil/hwcontext_ascend.c with a DVPP buffer pool and
hwdownload/hwupload. device_id=-1 (default) auto-picks the first
usable device via the runtime.
Why this patchset
-----------------
Huawei ships the same hardware interface through MindX (mxVision), but
their FFmpeg extension (MediaCodeV2 in mindsdk-referenceapps) is
unmaintained and limited to a decode-resize-encode chain; nothing has
ever been posted to ffmpeg-devel for these devices. This series brings
the support into the mainline codec/filter/hwcontext abstractions so
any existing FFmpeg user can use Ascend NPUs with standard CLI syntax.
Testing
-------
All done on Atlas 300I-Duo (2x Ascend 310P3), CANN 9.1.0, aarch64,
against this tree:
- Decode matrix (10 cases): H264/H265 ES+MP4, odd sizes, 4K, 10-bit,
seeks - all PASS; hw decode output MD5-identical to software decode
- Transcode 1080p->720p full-hardware (decode->scale->encode):
748/750 frames, 113 fps after the hwdownload bulk-copy fix, 4 Mbps
CBR output verified
- zero_copy vs staged: 55 vs 46 fps on 720p->360p
- JPEG round trip: encode->decode PSNR 51.8 dB at qfactor 90
- Overlay: position and chroma verified against software overlay
- 3x loop long-run (2243 frames): stable, no DVPP memory growth
- 2 and 4 concurrent processes on one device: complete outputs
Known limitations (documented in code comments)
-----------------------------------------------
- 310P VPC does not implement rotate/flip (HI_ERR_VPC_NOT_SUPPORT);
no transpose_ascend is proposed
- 310P JPEGD emits chroma as a luma replica for 4:2:0 sources; the
decoder detects this and neutral-grays the chroma with a clear
warning, so output is a clean grayscale image rather than garbage
- 310P PNGD crashes in png_get_image_info (driver defect); png_ascend
is NOT included
- Some VPC ops require per-thread context binding; handled in each
filter's thread paths
Maintenance
-----------
I have the hardware on hand and will maintain these files.
Feedback on the overall shape (especially hwcontext_ascend and the
zero_copy contract in ascendenc) is welcome before I rework anything
larger.
green-hand-shandong
green-hand-shandong (16):
avcodec/ascenddec: add Ascend NPU (CANN DVPP) H.264/H.265 hardware
decoder
avcodec/ascenddec: single-pass frame copy and finer get_frame polling
avcodec/ascenddec: 10-bit decode support (P010 output)
avutil/hwcontext_ascend: Ascend NPU hardware frame support
avcodec/ascendenc: Ascend NPU (CANN DVPP) H.264/H.265 hardware encoder
avfilter/vf_scale_ascend: Ascend NPU VPC hardware scaling filter
avcodec/ascenddec: tolerate flush reset failure and resume after EOS
avcodec/ascendjpeg: neutral-gray chroma degradation for JPEGD
avfilter/vf_crop_ascend, vf_pad_ascend: Ascend NPU VPC crop and
letterbox
avfilter/ascend: propagate frame_rate across hw filters
avcodec/ascendenc: map VENC stream pts back to the original frame pts
avfilter/vf_overlay_ascend: Ascend NPU VPC hardware overlay filter
avcodec/ascendenc: zero_copy mode for ASCEND hw frame input
avcodec/ascend: device_id=-1 auto-picks the first usable device
avutil/hwcontext_ascend: bulk plane copy in transfer_data_from
avcodec/ascendjpege: JPEG hardware encoder via CANN JPEGE
configure | 24 +
libavcodec/Makefile | 7 +
libavcodec/allcodecs.c | 7 +
libavcodec/ascenddec.c | 811 ++++++++++++++++++++++++++++++++
libavcodec/ascendenc.c | 660 ++++++++++++++++++++++++++
libavcodec/ascendjpeg.c | 568 ++++++++++++++++++++++
libavcodec/ascendjpege.c | 390 +++++++++++++++
libavfilter/Makefile | 7 +-
libavfilter/allfilters.c | 5 +
libavfilter/vf_crop_ascend.c | 318 +++++++++++++
libavfilter/vf_overlay_ascend.c | 431 +++++++++++++++++
libavfilter/vf_pad_ascend.c | 343 ++++++++++++++
libavfilter/vf_scale_ascend.c | 281 +++++++++++
libavutil/Makefile | 2 +
libavutil/hwcontext.c | 4 +
libavutil/hwcontext.h | 2 +
libavutil/hwcontext_ascend.c | 441 +++++++++++++++++
libavutil/hwcontext_ascend.h | 64 +++
libavutil/hwcontext_internal.h | 1 +
libavutil/pixdesc.c | 4 +
libavutil/pixfmt.h | 7 +
21 files changed, 4376 insertions(+), 1 deletion(-)
create mode 100644 libavcodec/ascenddec.c
create mode 100644 libavcodec/ascendenc.c
create mode 100644 libavcodec/ascendjpeg.c
create mode 100644 libavcodec/ascendjpege.c
create mode 100644 libavfilter/vf_crop_ascend.c
create mode 100644 libavfilter/vf_overlay_ascend.c
create mode 100644 libavfilter/vf_pad_ascend.c
create mode 100644 libavfilter/vf_scale_ascend.c
create mode 100644 libavutil/hwcontext_ascend.c
create mode 100644 libavutil/hwcontext_ascend.h
--
2.25.1
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]