From patchwork Thu Apr 19 17:18:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 8505 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp971131jad; Thu, 19 Apr 2018 11:09:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+FnGuNcscoFk4+WtPJqwlHZWjI1yiHjAXDYMwHg3xtfPjedKRmKEOJFurQT3/8fELOZVVY X-Received: by 10.28.175.140 with SMTP id y134mr5591555wme.139.1524161388355; Thu, 19 Apr 2018 11:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524161388; cv=none; d=google.com; s=arc-20160816; b=AySLn0FY4NeG6tmULmR6kuxm3A6BXFYI231Krc87ZVuIwIiPzkrd7NpNxkaaP2x9Ku E/4nGj3xf6LcoFPNNdrSgJtwba2ILmfWwvnAK/5PAxLhnqZk7dLiajHH5cdAM2o+FZBY OvxkRiqnmj2TQUxRfYkZkXhLhYhCTN/vVqGUdVYAqAmEVsWOoMqUmRyvbu1QkfdzJ8Vq QB/evP9h6W8P6mupybh0rNXVFegUU5XwFZHAP8rn24SFMCayHFY2nDtqQwO5aAKIENwg mYwGELgbE2Xq9tg29XU0FS1vbYfHZtYSiWgq0CVSPau0k/ZzTdW1nxUqgEuqUELHWhZn mHVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:user-agent :in-reply-to:mime-version:references:message-id:to:from:date :delivered-to:arc-authentication-results; bh=1383A+DFENSOMww3ft+MT3MWIDpOOfpHXoyljukWkgg=; b=OjFpd1GxQtlH5XX4FsuS4iN4wjAmCNrHf0pWkw7Xeln4SY9BzZkRaG7YXexgePFI4i SYKsOw6sVbByNPSx9te00kDg5+cGnqI40QTIh8JQEJwUV2ni5sQMY5jmcgRA3nGyQ0Lc UOMT5mBknR6HfljLfESCVcxAsh9n9G1ZcO3aq0gah1TFgZIKsP4n+jFwmnM/8+H5+7rI aKdO3lxGpkroqAkzSAhvMmQrzgO/WM8FfCZRrb53Ai5rgqNI5SeapA9RDTsIxKqzHhod HSyEqbTFOyFBJvOUztKUWiX3aC4d2/yBhgnrZlQxSOVRLJ6Ei/+HDOwiVejHDQVoG9k+ cGFg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id p35-v6si3408243wrc.89.2018.04.19.11.09.47; Thu, 19 Apr 2018 11:09:48 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E26EE689C88; Thu, 19 Apr 2018 21:09:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from slow1-d.mail.gandi.net (mslow2.mail.gandi.net [217.70.178.242]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 84C54689B63 for ; Thu, 19 Apr 2018 21:09:12 +0300 (EEST) Received: from relay6-d.mail.gandi.net (unknown [217.70.183.198]) by slow1-d.mail.gandi.net (Postfix) with ESMTP id 539FA3A89D3 for ; Thu, 19 Apr 2018 19:18:33 +0200 (CEST) X-Originating-IP: 213.47.41.20 Received: from localhost (213-47-41-20.cable.dynamic.surfer.at [213.47.41.20]) (Authenticated sender: michael@niedermayer.cc) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A9D2EC0008 for ; Thu, 19 Apr 2018 19:18:26 +0200 (CEST) Date: Thu, 19 Apr 2018 19:18:24 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20180419171824.GL20131@michaelspb> References: <20180412223455.GN20131@michaelspb> <20180415191917.GG20131@michaelspb> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [FFmpeg-devel] GSOC 2018 qualification task. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On Wed, Apr 18, 2018 at 02:45:36PM +0530, ANURAG SINGH IIT BHU wrote: > Hello Sir, > > I have implemented the suggested changes, now the filter does not break > builds, also now it works for all inputs and You are still removing the Copyright statments from the filter you copy the newly added code has 960 lines only 56 of these lines are not in vf_drawtext.c diff -wbu libavfilter/vf_drawtext.c libavfilter/vf_hellosubs.c |diffstat vf_hellosubs.c | 677 ++++----------------------------------------------------- 1 file changed, 56 insertions(+), 621 deletions(-) wc libavfilter/vf_hellosubs.c 960 3333 32438 libavfilter/vf_hellosubs.c From these 56 some are changes of the filter name and context name The remaining changes are reviewed below, I attempted to format this so the code is readable. - * drawtext filter, based on the original vhook/drawtext.c - * filter by Gustavo Sverzut Barbieri + * Libfreetype subtitles burning filter. + * @see{http://www.matroska.org/technical/specs/subtitles/ssa.html} The SSA link has nothing to do with the code based on drawtext @@ -207,3 +181,2 @@ - {"text", "set text", OFFSET(text), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, - {"textfile", "set text file", OFFSET(textfile), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, FLAGS}, - {"fontcolor", "set foreground color", OFFSET(fontcolor.rgba), AV_OPT_TYPE_COLOR, {.str="black"}, CHAR_MIN, CHAR_MAX, FLAGS}, + {"text", "set text", OFFSET(text), AV_OPT_TYPE_STRING, {.str="Hello world"}, CHAR_MIN, CHAR_MAX, FLAGS}, + {"fontcolor", "set foreground color", OFFSET(fontcolor.rgba), AV_OPT_TYPE_COLOR, {.str="white"}, CHAR_MIN, CHAR_MAX, FLAGS}, @@ -217,5 +185,3 @@ - {"fontsize", "set font size", OFFSET(fontsize_expr), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX , FLAGS}, - {"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS}, - {"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX, FLAGS}, - {"shadowx", "set shadow x offset", OFFSET(shadowx), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX , FLAGS}, - {"shadowy", "set shadow y offset", OFFSET(shadowy), AV_OPT_TYPE_INT, {.i64=0}, INT_MIN, INT_MAX , FLAGS}, + {"fontsize", "set font size", OFFSET(fontsize_expr), AV_OPT_TYPE_STRING, {.str="h/20"}, CHAR_MIN, CHAR_MAX , FLAGS}, + {"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="w/2.7"}, CHAR_MIN, CHAR_MAX, FLAGS}, + {"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="h/1.3"}, CHAR_MIN, CHAR_MAX, FLAGS}, ... +static int generatehellosub(AVFilterContext *ctx, AVBPrint *bp) { DrawTextContext *s = ctx->priv; double pts = s->var_values[VAR_T]; int64_t ms = llrint(pts * 1000); + if (ms < 0) + ms = -ms; + av_bprintf(bp, "Hello world %d:%02d",(int)(ms / (60 * 1000)),(int)(ms / 1000) % 60); return 0; } The use of float/double can cause rounding diffferences between platforms and is especially as the filters input is neverf float/double not needed if (s->fix_bounds) { /* calculate footprint of text effects */ - int boxoffset = s->draw_box ? FFMAX(s->boxborderw, 0) : 0; - int borderoffset = s->borderw ? FFMAX(s->borderw, 0) : 0; - int offsetleft = FFMAX3(boxoffset, borderoffset, - (s->shadowx < 0 ? FFABS(s->shadowx) : 0)); - int offsettop = FFMAX3(boxoffset, borderoffset, - (s->shadowy < 0 ? FFABS(s->shadowy) : 0)); - - int offsetright = FFMAX3(boxoffset, borderoffset, - (s->shadowx > 0 ? s->shadowx : 0)); - int offsetbottom = FFMAX3(boxoffset, borderoffset, - (s->shadowy > 0 ? s->shadowy : 0)); + int offsetleft = FFMAX3(0,0,0); + + int offsettop = FFMAX3(0, 0,0); This can be simplified further @@ -1515 +951 @@ - .description = NULL_IF_CONFIG_SMALL("Draw text on top of video frames using libfreetype library."), + .description = NULL_IF_CONFIG_SMALL("Writes hello world time on top of video frames using libfreetype library."), > > ffplay -f lavfi -i testsrc -vf hellosubs > > works. > > Sir I think passing the text using metadata to drawtext filter would not be > an efficient way in terms of time as drawtext filter calls a number of > functions which are not needed by the hellosubs filter, functions like > expand_text(), expand_func() etc, i.e drawtext filter is of 1525 lines > where as hellosubs is more than 1/3 rd times less in lines. and sir for > realtime subtitles I think we should emphasise more on reducing the time > taken by the filter to remove lag. I think there are several misunderstandings here. The code you submit is 960 lines of code but only about 56 lines are not already in the codebase. Its not an option to duplicate code like this if its intended to be pushed into FFmpeg git. It also doesnt make the code faster. Using metadata as i suggested would have solved this problem. It was indeed not my first suggestion to solve this. The first was to implent AV_MEDIA_TYPE_SUBTITLE in avfilter (this would have been the best). For synchronization of actual subtitles (not just hello world ones) it will/would be needed to do proper synchronization. With AV_MEDIA_TYPE_SUBTITLE that would come naturally from the timestamps of the frames. Either way, this last patch was submitted after the deadline. So it doesnt affect your qualification task either way. Thanks [...] --- libavfilter/vf_drawtext.c 2018-04-17 14:20:30.340366781 +0200 +++ libavfilter/vf_hellosubs.c 2018-04-19 17:51:48.371572589 +0200 @@ -1,8 +1,4 @@ /* - * Copyright (c) 2011 Stefano Sabatini - * Copyright (c) 2010 S.N. Hemanth Meenakshisundaram - * Copyright (c) 2003 Gustavo Sverzut Barbieri - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or