From patchwork Fri Apr 9 10:34:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Liu X-Patchwork-Id: 26823 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4CA4C4495CE for ; Fri, 9 Apr 2021 13:35:18 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 19DAE68A5D3; Fri, 9 Apr 2021 13:35:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbgau1.qq.com (smtpbgau1.qq.com [54.206.16.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 880FA689E47 for ; Fri, 9 Apr 2021 13:35:10 +0300 (EEST) X-QQ-mid: bizesmtp4t1617964467ts5xkunc3 Received: from localhost (unknown [103.107.216.230]) by esmtp6.qq.com (ESMTP) with id ; Fri, 09 Apr 2021 18:34:26 +0800 (CST) X-QQ-SSF: 01100000002000Z0Z000B00A0020000 X-QQ-FEAT: BBZ6qreST04t9xRBR/i+H2cP7mG6UigSXgw50cuyOd1cKltqkIYfKyYqTRDSM 67fuidBqvXXI61UyTTt0sDqNBSYL+ewwp/HNErR4rE16tcfWqBSw2z5Nyi4Jr5HBhgYSUfD VJApAi83La2uvRtZX/tW9oAGqPqxflDv0x/6tWDqDBxa2NxROxUJ2ZDB52Wn8E1OZQJDofY vRpER1LwL7HqPJ10WnBl8pB9bJ7XvQea55i7B51DcnMAelpyALKj5alQ6EYVzNBbbdSy7d9 GICTOmAOn7Yh5qRfJJAHNjAO/T8HQIXKDMxVjmqPbeTSfh/IUVVtVuWBE= X-QQ-GoodBg: 0 X-QQ-CSender: lq@chinaffmpeg.org From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Apr 2021 18:34:24 +0800 Message-Id: <20210409103424.55429-1-liuqi05@kuaishou.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign5 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_cuda: check ctx->hwctx->internal null pointer X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Steven Liu because it will cannot get ctx->hwctx->internal value when get ctx->hwctx->internal->cuda_dl value. so should check if internal is null. before patch: liuqi@chinaffmpeg:~/multimedia/build$ ./ffmpeg_g -hwaccel_device 0 -hwaccel cuda -pix_fmt nv12 -s 1920x1080 -i output.yuv -hwaccel_device 0 -hwaccel cuda -pix_fmt nv12 -s 800x480 -i output_small.yuv -filter_complex "[0:v]hwupload_cuda[a];[1:v]hwupload_cuda[b];[a][b]overlay_cuda=x=0:y=0[o];[o]hwdownload[o1]" -map "[o1]" -pix_fmt nv12 -y -t 1 xxx.yuv ffmpeg version N-101879-g13bf797ced Copyright (c) 2000-2021 the FFmpeg developers built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04) configuration: --cc='ccache cc' --enable-libx264 --enable-libx265 --enable-libopus --enable-libwebp --enable-libvpx --enable-ffnvcodec --enable-vaapi --enable-opengl --enable-nonfree --enable-gpl --enable-libfdk-aac --enable-libfreetype --enable-cuda --enable-libnpp --enable-cuda-nvcc --enable-cuda-llvm libavutil 56. 72.100 / 56. 72.100 libavcodec 58.135.100 / 58.135.100 libavformat 58. 78.100 / 58. 78.100 libavdevice 58. 14.100 / 58. 14.100 libavfilter 7.111.100 / 7.111.100 libswscale 5. 10.100 / 5. 10.100 libswresample 3. 10.100 / 3. 10.100 libpostproc 55. 10.100 / 55. 10.100 [rawvideo @ 0x5584b7a9e4c0] Estimating duration from bitrate, this may be inaccurate Input #0, rawvideo, from 'output.yuv': Duration: 00:01:54.64, start: 0.000000, bitrate: 622080 kb/s Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 1920x1080, 622080 kb/s, 25 tbr, 25 tbn, 25 tbc [rawvideo @ 0x5584b7aa30c0] Estimating duration from bitrate, this may be inaccurate Input #1, rawvideo, from 'output_small.yuv': Duration: 00:04:07.16, start: 0.000000, bitrate: 115200 kb/s Stream #1:0: Video: rawvideo (NV12 / 0x3231564E), nv12, 800x480, 115200 kb/s, 25 tbr, 25 tbn, 25 tbc Stream mapping: Stream #0:0 (rawvideo) -> hwupload_cuda Stream #1:0 (rawvideo) -> hwupload_cuda hwdownload -> Stream #0:0 (rawvideo) Press [q] to stop, [?] for help Output #0, rawvideo, to 'xxx.yuv': Metadata: encoder : Lavf58.78.100 Stream #0:0: Video: rawvideo (NV12 / 0x3231564E), nv12(progressive), 1920x1080, q=2-31, 622080 kb/s, 25 fps, 25 tbn (default) Metadata: encoder : Lavc58.135.100 rawvideo frame= 25 fps=0.0 q=-0.0 Lsize= 75938kB time=00:00:01.00 bitrate=622080.0kbits/s speed=6.11x video:75938kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000% Segmentation fault (core dumped) This patch can fix the Segmentation fault problem. Signed-off-by: Steven Liu --- libavfilter/vf_overlay_cuda.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index f6ee43e929..4d8617475f 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -249,7 +249,7 @@ static av_cold void overlay_cuda_uninit(AVFilterContext *avctx) ff_framesync_uninit(&ctx->fs); - if (ctx->hwctx && ctx->cu_module) { + if (ctx->hwctx && ctx->cu_module && ctx->hwctx->internal) { CUcontext dummy; CudaFunctions *cu = ctx->hwctx->internal->cuda_dl; CHECK_CU(cu->cuCtxPushCurrent(ctx->cu_ctx));