From: Michael Niedermayer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Araz Iusubov <Primeadvice@gmail.com>,
Tong Wu <wutong1208@outlook.com>,
Michael Niedermayer <michael@niedermayer.cc>
Subject: [FFmpeg-devel] Re: [FFmpeg-cvslog] [ffmpeg] branch master updated. 92f2f9ea5c avcodec/d3d12va_encode: D3D12 AV1 encoding support
Date: Tue, 2 Dec 2025 03:28:01 +0100
Message-ID: <aS5OscaAsh9xnY-W@neo> (raw)
In-Reply-To: <20251126095910.2B49E68EB72@ffbox0-bg.ffmpeg.org>
[-- Attachment #1.1: Type: text/plain, Size: 3971 bytes --]
Hi
On Wed, Nov 26, 2025 at 11:59:09AM +0200, ffmpeg-git--- via ffmpeg-cvslog wrote:
> The branch, master has been updated
> via 92f2f9ea5c49e94814693861a7e9e47c993fca2e (commit)
> from 81362b319ea7244d8d17110adfa59f10c7e78268 (commit)
>
>
> - Log -----------------------------------------------------------------
> commit 92f2f9ea5c49e94814693861a7e9e47c993fca2e
> Author: Araz Iusubov <Primeadvice@gmail.com>
> AuthorDate: Mon Nov 10 17:23:25 2025 +0100
> Commit: Tong Wu <wutong1208@outlook.com>
> CommitDate: Wed Nov 26 09:58:44 2025 +0000
>
> avcodec/d3d12va_encode: D3D12 AV1 encoding support
>
> Implement AV1 hardware encoding
> using Direct3D 12 Video API (D3D12VA).
>
[...]
> int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt);
> diff --git a/libavcodec/d3d12va_encode_av1.c b/libavcodec/d3d12va_encode_av1.c
> new file mode 100644
> index 0000000000..e7a115a2ee
> --- /dev/null
> +++ b/libavcodec/d3d12va_encode_av1.c
[...]
> +static int d3d12va_encode_av1_get_coded_data(AVCodecContext *avctx,
> + D3D12VAEncodePicture *pic, AVPacket *pkt)
> +{
> + int err = 0;
> + uint8_t *ptr = NULL;
> + uint8_t *mapped_data = NULL;
> + size_t total_size = 0;
> + HRESULT hr = S_OK;
> + size_t av1_pic_hd_size = 0;
> + int tile_group_extra_size = 0;
> + size_t bit_len = 0;
> + D3D12VAEncodeContext *ctx = avctx->priv_data;
> +
> + char pic_hd_data[MAX_PARAM_BUFFER_SIZE] = { 0 };
> +
> + err = d3d12va_encode_av1_get_buffer_size(avctx, pic, &total_size);
> + if (err < 0)
> + goto end;
> +
> + // Update the picture header and calculate the picture header size
> + memset(pic_hd_data, 0, sizeof(pic_hd_data));
> + err = d3d12va_encode_av1_write_picture_header(avctx, pic, pic_hd_data, &av1_pic_hd_size);
> + if (err < 0) {
> + av_log(avctx, AV_LOG_ERROR, "Failed to write picture header: %d.\n", err);
> + return err;
> + }
> + av1_pic_hd_size /= 8;
> + av_log(avctx, AV_LOG_DEBUG, "AV1 picture header size: %zu bytes.\n", av1_pic_hd_size);
> +
> +
> + tile_group_extra_size = (av_log2(total_size) + 7) / 7 + 1; // 1 byte for obu header, rest for tile group LEB128 size
> + av_log(avctx, AV_LOG_DEBUG, "Tile group extra size: %d bytes.\n", tile_group_extra_size);
> +
> + total_size += (pic->header_size + tile_group_extra_size + av1_pic_hd_size);
> + av_log(avctx, AV_LOG_DEBUG, "Output buffer size %"SIZE_SPECIFIER"\n", total_size);
> +
> + hr = ID3D12Resource_Map(pic->output_buffer, 0, NULL, (void **)&mapped_data);
> + if (FAILED(hr)) {
> + err = AVERROR_UNKNOWN;
> + goto end;
> + }
> +
> + err = ff_get_encode_buffer(avctx, pkt, total_size, 0);
> + if (err < 0)
> + goto end;
> + ptr = pkt->data;
> +
> + memcpy(ptr, mapped_data, pic->header_size);
> +
> + ptr += pic->header_size;
> + mapped_data += pic->aligned_header_size;
> + total_size -= pic->header_size;
> +
> + memcpy(ptr, pic_hd_data, av1_pic_hd_size);
> + ptr += av1_pic_hd_size;
> + total_size -= av1_pic_hd_size;
> + av_log(avctx, AV_LOG_DEBUG, "AV1 total_size after write picture header: %d.\n", total_size);
> +
> + total_size -= tile_group_extra_size;
> + err = d3d12va_encode_av1_write_tile_group(avctx, mapped_data, total_size, ptr, &bit_len);
> + if (err < 0) {
> + av_log(avctx, AV_LOG_ERROR, "Failed to write tile group: %d.\n", err);
> + goto end;
> + }
> + assert((total_size + tile_group_extra_size) * 8 == bit_len);
this possibly should be av_assert*
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Observe your enemies, for they first find out your faults. -- Antisthenes
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 163 bytes --]
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
next parent reply other threads:[~2025-12-02 2:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20251126095910.2B49E68EB72@ffbox0-bg.ffmpeg.org>
2025-12-02 2:28 ` Michael Niedermayer via ffmpeg-devel [this message]
2025-12-02 12:07 ` Nicolas George via ffmpeg-devel
2025-12-03 23:13 ` Michael Niedermayer via ffmpeg-devel
[not found] <20251128005559.1126A690194@ffbox0-bg.ffmpeg.org>
2025-12-02 3:36 ` [FFmpeg-devel] Re: [FFmpeg-cvslog] [ffmpeg] branch master updated. 3d96d83a0a avformat/rawdec: set framerate in codec parameters Michael Niedermayer via ffmpeg-devel
2025-12-03 23:32 ` James Almer via ffmpeg-devel
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=aS5OscaAsh9xnY-W@neo \
--to=ffmpeg-devel@ffmpeg.org \
--cc=Primeadvice@gmail.com \
--cc=michael@niedermayer.cc \
--cc=wutong1208@outlook.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