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 <[email protected]>
> AuthorDate: Mon Nov 10 17:23:25 2025 +0100
> Commit:     Tong Wu <[email protected]>
> 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: signature.asc
Description: PGP signature

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to