From patchwork Thu Jun 7 15:29:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Lavrushkin X-Patchwork-Id: 9280 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp352982jad; Thu, 7 Jun 2018 08:29:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFJ4ajMyvPsqRg7MR3prhD3tzYekQw3utGVPwlzi1y+vc7viiRi81cBPmArXoCYKHJKhgj X-Received: by 2002:a5d:42c8:: with SMTP id t8-v6mr2106197wrr.225.1528385398668; Thu, 07 Jun 2018 08:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528385398; cv=none; d=google.com; s=arc-20160816; b=xp01/ps1tR24dfnXBOvUP8P42ldD99xrc+MrKSYVWhKiJTh6vrPKwLolw1HQPxIRtH JNp+EC/tDGK+nyg+RYOLojcs5Nj7yuVnjG+MMxjWR1ZMCgtA21fW9ytOtpURXHZnJ7WH iK5L+zzIsg68Slig9HBfIvIwa1Ul78Ck9BwdFcJ58rXkjnNRQNLSGzXYi783wr4Eq7iv Cb7avdF6Hf+8tqo1sVD7ic/uDfdtiazFOVFE1Yd5KdQR9urtYndgI09d4XZTh5BoVBqg kMLJH6sAN5Yt5koi4v7bn1CBphggMgM856wzrwNF8MUlJO66RdTYJOBs8sWsY0uFPxHZ Up5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=OLRAPau8/roMGGOIFMJneQwsTvOXU9hE6dQiyMKg8d4=; b=b181L7DfUkqtaZzXkO0ti/+EcFX9NFrd7cskVu5iyNXUvwImil+ICllus3Pyt+eeAm mksdeTmCX8+SJ8r84HW992r2tTCzP2yVXiwWbeGmouD7987JQHGjAMP0/IRMtlLQ8U3r yoGIIp10RW5qDbNTEXWvZ/INzfiE7h7prVQGtCxTAlXrvoxRJKbabYgagd0z/0KcaRvm 0vs3cQJozr55rrYxPtaV9ylWgeVwT4aq1yrVUuLhPI45D0K27CekMP3RshnACPbm68zT XZsQg/UfZI80vkTKzWKnz1PYVT9TMRCeF542/fiDls9PX9sXmM7kvBjrkkmEyf6607EG KM8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=hiHUyQep; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s80-v6si1388767wma.38.2018.06.07.08.29.57; Thu, 07 Jun 2018 08:29:58 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=hiHUyQep; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BD2868A743; Thu, 7 Jun 2018 18:29:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl0-f42.google.com (mail-pl0-f42.google.com [209.85.160.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CF44E68A675 for ; Thu, 7 Jun 2018 18:29:02 +0300 (EEST) Received: by mail-pl0-f42.google.com with SMTP id a7-v6so3868982plp.3 for ; Thu, 07 Jun 2018 08:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AaYb7tQlOzSykCeD8ZrJmUVVqGRBwGGPyWquR7B2JGA=; b=hiHUyQepPysCcJXXvVU9get8ADEBTsmLT2UhQCvGuJkGZ6xcqyUEXfTSovU8q4Nsud g1d1GkCmNLJfXlY9CNBWvXu/tzhn/y7zMY3RzimyBDm2ubPJrZrkSgWx3tw2H94TO2wo 709xXbsAnCKFNkbrIF4i803gfVowOuY2nV0tHCRcicNWk2SFJ+8igJ0T/gqyyD+XffMn bvEJGlHDuAJ52wOJ2hGrqsb6OKdNNVRLuoMWrNpUrFsRWl0d5tem+0hmeYRWLmWJEWMe QAIF0Ks+VqJJwAndsLsF1MZ2/vGgFXyqyv4yksblxMrcVZSLUSXofhUQcUOu88SE0sl/ y9HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AaYb7tQlOzSykCeD8ZrJmUVVqGRBwGGPyWquR7B2JGA=; b=T4Aal6PUKavS1KlniBgZjYbAUUlS0HEqHCfX44FGuLihGbG3UmFcOhNAmlagG3belx t+3BE+tzMpmV+KWVJjgrOSi32cFZHGdv6bXSrKw8l3voKGbJs+44MFi80sj8C3ciiXmw bUOfNbgkTKMbasyDvT1slcLnagM5ad9hmHr67SDQOIbKkZKv/8K/0n/A9HtzgtzSF+Xq JCrZEoye6k61yV8lihfVPjvhKwOy7OUKNWTR40I7JoueT4h4K0pcpJ3Ssn3Q/e5vNKme cfHYcEv3/j6kEMVfHJOn9erA1cqJxeIhn2rbLXzCh7Wstd4OiK1VU2UJvJAlTqvGrmmj tRxA== X-Gm-Message-State: APt69E15GUe1GnxOyr1a5LMY625H4+0OnEzPBswbHG87bkFx+pV79lHZ NaCxHJRNrq/s8zx1Bg1bLiAWBt4sMUe6si03/dFjDg== X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr2508594plt.382.1528385388646; Thu, 07 Jun 2018 08:29:48 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:a607:0:0:0:0 with HTTP; Thu, 7 Jun 2018 08:29:47 -0700 (PDT) In-Reply-To: References: <3cf9936c-9995-1ea5-3bab-661eb644becd@gmail.com> <256a62b9-edcc-83cf-6f6d-18308ee68beb@gmail.com> From: Sergey Lavrushkin Date: Thu, 7 Jun 2018 18:29:47 +0300 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [GSOC] [PATCH] TensorFlow backend introduction for DNN module 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: James Almer , Pedro Arthur Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 2018-06-06 17:22 GMT+03:00 Pedro Arthur : > Hi, > > 2018-06-05 20:23 GMT-03:00 Sergey Lavrushkin : > > Here is the patch, that fixes described issues. > When I try to run (video input), when tf is not enabled in configure it > crashes. > > > $ffmpeg -i in.mp4 -vf srcnn=dnn_backend=tensorflow out.mp4 > > ffmpeg version N-91232-g256386fd3e Copyright (c) 2000-2018 the FFmpeg > developers > built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) > configuration: > libavutil 56. 18.102 / 56. 18.102 > libavcodec 58. 19.105 / 58. 19.105 > libavformat 58. 17.100 / 58. 17.100 > libavdevice 58. 4.100 / 58. 4.100 > libavfilter 7. 25.100 / 7. 25.100 > libswscale 5. 2.100 / 5. 2.100 > libswresample 3. 2.100 / 3. 2.100 > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4': > Metadata: > major_brand : isom > minor_version : 512 > compatible_brands: isomiso2mp41 > encoder : Lavf58.17.100 > Duration: 00:06:13.70, start: 0.000000, bitrate: 5912 kb/s > Stream #0:0(und): Video: mpeg4 (Simple Profile) (mp4v / > 0x7634706D), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5777 kb/s, 29.97 > fps, 29.97 tbr, 30k tbn, 30k tbc (default) > Metadata: > handler_name : VideoHandler > Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, > stereo, fltp, 128 kb/s (default) > Metadata: > handler_name : SoundHandler > Stream mapping: > Stream #0:0 -> #0:0 (mpeg4 (native) -> mpeg4 (native)) > Stream #0:1 -> #0:1 (aac (native) -> aac (native)) > Press [q] to stop, [?] for help > free(): invalid pointer > Aborted (core dumped) > > > > When the output is an image, t does not crashes but neither fallback to > native > > > $ffmpeg -i in.jpg -vf srcnn=dnn_backend=tensorflow out.png > > ffmpeg version N-91232-g256386fd3e Copyright (c) 2000-2018 the FFmpeg > developers > built with gcc 7 (Ubuntu 7.3.0-16ubuntu3) > configuration: > libavutil 56. 18.102 / 56. 18.102 > libavcodec 58. 19.105 / 58. 19.105 > libavformat 58. 17.100 / 58. 17.100 > libavdevice 58. 4.100 / 58. 4.100 > libavfilter 7. 25.100 / 7. 25.100 > libswscale 5. 2.100 / 5. 2.100 > libswresample 3. 2.100 / 3. 2.100 > Input #0, image2, from 'in.jpg': > Duration: 00:00:00.04, start: 0.000000, bitrate: 43469 kb/s > Stream #0:0: Video: mjpeg, yuvj444p(pc, bt470bg/unknown/unknown), > 1192x670 [SAR 1:1 DAR 596:335], 25 tbr, 25 tbn, 25 tbc > Stream mapping: > Stream #0:0 -> #0:0 (mjpeg (native) -> png (native)) > Press [q] to stop, [?] for help > [Parsed_srcnn_0 @ 0x557d3ea55980] could not create DNN module for > requested backend > [AVFilterGraph @ 0x557d3ea102c0] Error initializing filter 'srcnn' > with args 'dnn_backend=tensorflow' > Error reinitializing filters! > Failed to inject frame into filter network: Cannot allocate memory > Error while processing the decoded data for stream #0:0 > Conversion failed! > > > I think you could disable the tensorflow option if it is not enable in > configure or fallback to native, either solution is ok for me. I disabled tensorflow option when it is not configured with it. Here is the updated patch. I think, crash occurred due to improper call to av_freep for dnn_module. Here is also the patch, that fixes this bug. From e223a00972ec8b29f557d7ae55d597238abe9004 Mon Sep 17 00:00:00 2001 From: Sergey Lavrushkin Date: Thu, 7 Jun 2018 18:22:22 +0300 Subject: [PATCH 2/2] libavfilter/dnn_interface.c: fix av_freep dnn_module. --- libavfilter/dnn_interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/dnn_interface.c b/libavfilter/dnn_interface.c index ce64fe58f3..87c90526be 100644 --- a/libavfilter/dnn_interface.c +++ b/libavfilter/dnn_interface.c @@ -51,7 +51,7 @@ DNNModule* ff_get_dnn_module(DNNBackendType backend_type) dnn_module->execute_model = &ff_dnn_execute_model_tf; dnn_module->free_model = &ff_dnn_free_model_tf; #else - av_freep(dnn_module); + av_freep(&dnn_module); return NULL; #endif } -- 2.14.1