From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <ffmpeg-devel-bounces@ffmpeg.org> Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 2FDD44C7A7 for <ffmpegdev@gitmailbox.com>; Wed, 9 Apr 2025 11:11:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7C8B768B3B5; Wed, 9 Apr 2025 14:11:02 +0300 (EEST) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7C3EA687CA3 for <ffmpeg-devel@ffmpeg.org>; Wed, 9 Apr 2025 14:10:55 +0300 (EEST) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id D137A2819121C for <ffmpeg-devel@ffmpeg.org>; Wed, 09 Apr 2025 13:10:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1744197054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ov4j7B56ppUbkaBG/n7YAARo0ZhlIdScizeQfEd4JKI=; b=FyzHPOskIS680KLf0qvyHnArHbHkzP4vL9IeLtf23/kRFXW71h3MtIDbuc9VJDgGiYa86B XO+q04awPMOrFgBrqWz+Gh7mLsOVcnCeIXZiXl70L9lxyueLWX41uFRuAyelnZFO3ixpZm zH6Wrx8jNIrYNWHEY/5grupaqMXdIb8MtLg9rV3k7XAom2KXl5C0Te5lJsfkm9FWmK72Yg EFlkKqD+K8w9C0+ZUzhSouK4S0Yh1usvktsKq9Us7Sb/Lu70SdiVs8zmsgA8b75B1ok1QD kgQCOoKp0MFr5PlBLtyl114XtG6XVSjY2DLPXevcX5vuV/eA8PcR+Oi185HBRQ== Message-ID: <1a991e00-7944-4b20-bfd3-6be08c7715cf@rothenpieler.org> Date: Wed, 9 Apr 2025 13:11:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250408-nvdec-vc1-fix-v2-1-f9edc32f5d92@gmail.com> Content-Language: en-US, de-DE From: Timo Rothenpieler <timo@rothenpieler.org> In-Reply-To: <20250408-nvdec-vc1-fix-v2-1-f9edc32f5d92@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH v2] nvdec/vc1: add marker insertion logic X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org> List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe> List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel> List-Post: <mailto:ffmpeg-devel@ffmpeg.org> List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help> List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>, <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe> Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org> Archived-At: <https://master.gitmailbox.com/ffmpegdev/1a991e00-7944-4b20-bfd3-6be08c7715cf@rothenpieler.org/> List-Archive: <https://master.gitmailbox.com/ffmpegdev/> List-Post: <mailto:ffmpegdev@gitmailbox.com> On 08/04/2025 22:50, averne wrote: > This mirrors existing code in d3dxx and dxva hwaccels > > --- > Changes since v1: use the codec-specific handler > for wmv3. > > Insert the relevant marker into the bitstream on > slice submission. > This is analogous to the logic found in DXVA and > D3D hwaccels. > > Fixes decoding of various VC-1 streams, eg.: > https://drive.google.com/file/d/1WJyiRhcdU4FHTW3sVMitS7UdrZM1NBy-/view?usp=sharing > > This was investigated using my nvdec tracing tool: > https://github.com/averne/NvdecTrace > > Signed-off-by: averne <averne381@gmail.com> > --- > libavcodec/nvdec_vc1.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 44 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/nvdec_vc1.c b/libavcodec/nvdec_vc1.c > index fbfba1ecb43421573ef8fea1e37a2425c272edc9..a88327833df55054a42e7ced8cdd4c99fa6b6584 100644 > --- a/libavcodec/nvdec_vc1.c > +++ b/libavcodec/nvdec_vc1.c > @@ -22,6 +22,7 @@ > > #include "config_components.h" > > +#include "libavutil/mem.h" > #include "avcodec.h" > #include "hwaccel_internal.h" > #include "internal.h" > @@ -107,6 +108,48 @@ static int nvdec_vc1_start_frame(AVCodecContext *avctx, const uint8_t *buffer, u > return 0; > } > > +static int nvdec_vc1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > + uint32_t size) > +{ > + NVDECContext *ctx = avctx->internal->hwaccel_priv_data; > + const VC1Context *v = avctx->priv_data; > + uint32_t marker; > + int marker_size; > + void *tmp; > + > + if (ctx->bitstream_len) > + marker = VC1_CODE_SLICE; > + else if (v->profile == PROFILE_ADVANCED && v->fcm == ILACE_FIELD && v->second_field) > + marker = VC1_CODE_FIELD; > + else > + marker = VC1_CODE_FRAME; > + > + /* Only insert the marker if not already present in the bitstream */ > + marker_size = (size >= sizeof(marker) && AV_RB32(buffer) != marker) ? sizeof(marker) : 0; > + > + tmp = av_fast_realloc(ctx->bitstream_internal, &ctx->bitstream_allocated, > + ctx->bitstream_len + size + marker_size); > + if (!tmp) > + return AVERROR(ENOMEM); > + ctx->bitstream = ctx->bitstream_internal = tmp; > + > + tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, > + (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); > + if (!tmp) > + return AVERROR(ENOMEM); > + ctx->slice_offsets = tmp; > + > + if (marker_size) > + AV_WB32(ctx->bitstream_internal + ctx->bitstream_len, marker); > + > + memcpy(ctx->bitstream_internal + ctx->bitstream_len + marker_size, buffer, size); > + ctx->slice_offsets[ctx->nb_slices] = ctx->bitstream_len ; > + ctx->bitstream_len += size + marker_size; > + ctx->nb_slices++; > + > + return 0; > +} > + > static int nvdec_vc1_frame_params(AVCodecContext *avctx, > AVBufferRef *hw_frames_ctx) > { > @@ -121,7 +164,7 @@ const FFHWAccel ff_vc1_nvdec_hwaccel = { > .p.pix_fmt = AV_PIX_FMT_CUDA, > .start_frame = nvdec_vc1_start_frame, > .end_frame = ff_nvdec_simple_end_frame, > - .decode_slice = ff_nvdec_simple_decode_slice, > + .decode_slice = nvdec_vc1_decode_slice, > .frame_params = nvdec_vc1_frame_params, > .init = ff_nvdec_decode_init, > .uninit = ff_nvdec_decode_uninit, > > --- > base-commit: f76195ff656d6bea68feee783160652e2b3e3d60 > change-id: 20250408-nvdec-vc1-fix-7fb117513851 > > Best regards, I'll give this a test later and apply if everything works fine. _______________________________________________ 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".