From patchwork Mon Jun 10 15:54:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jb X-Patchwork-Id: 13486 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 9FF86449D6E for ; Mon, 10 Jun 2019 18:54:13 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 754B468A708; Mon, 10 Jun 2019 18:54:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F86168A145 for ; Mon, 10 Jun 2019 18:54:07 +0300 (EEST) Received: by mail-wr1-f50.google.com with SMTP id b17so9709536wrq.11 for ; Mon, 10 Jun 2019 08:54:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=fBkVC6RZAkX2OAvAl9WbdC14QIHaSOr2jeP/XmkVWpM=; b=NtWUNGhvURBjaeMxP+4/JeCA39J1CYmWFyuM+VTawmP9b40qkF0objcUjzG+jIP1pG 6oLIfedqXHujF6+YlIjwNrgN8f3zrRzEa1Bb5B/KJsS/c0fbUJi9YuLxOAIGYZ96PFZs pWV11hpgoEcwLFPuVUfzpIWQAyMW2eB8xn3zYzJhZFspfpbKhbPJN8qO0t7XIeEnTAPB KJbHzq25lDuqE7qO40zbcNJ+Vzg108nSf3F08qdcaOxa4DQV30UQ8Ij7wXoDhT+4FwMB ZTnwyG2TJ3fs8z6D4lrq5frd1zdxO2CQ997nAGXEzpRnMgji8lEx9n97VehnY+LBwryb vHcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=fBkVC6RZAkX2OAvAl9WbdC14QIHaSOr2jeP/XmkVWpM=; b=O/kJjKaMqLFvBkX13oahY/QTxKHYnHP5W6Ypm7APY51fiO/slri1JoSyfcfxybKPF7 tAE7WJNVhzhG0rwf/VjgbW85eZLVwaVWyNcJDJusbOqkSGrX9as0JaM9SUn4U17JGZGX jrwS63WuqKXskAMI9BTVrDJn8vWKU8RcpK+xj89ZDAay8Erbaz73kIRh4YR0yjT7ACCl RJPCKHjJlyzbJb0NuOUuNpQMOBFGoos0X/gGvYE0yWzpk+1J6GaaJKpTa67PjA3jhwcH 29kWlSJjYJn3mJ6aE2ABDIbaApnnGg0Y/JqglMa5SNWwDZ35iz48wtLevAQGVvSbS/8Q ipZQ== X-Gm-Message-State: APjAAAXyTHagFPOS844cDWu3taEYvgCzZ2GujzWyqtGrUsF6kDrBJIJp XrxxdFAdf6BanhGk7ikCqU805+kw X-Google-Smtp-Source: APXvYqxSHLNBazFucOuBa6yktoWKbs2WtfVJ+rslEFEzYkvOsXECgJlS2obI3iCCtc5RSaanQhT7og== X-Received: by 2002:adf:db46:: with SMTP id f6mr29704368wrj.330.1560182046886; Mon, 10 Jun 2019 08:54:06 -0700 (PDT) Received: from [192.168.2.104] (p548CEA46.dip0.t-ipconnect.de. [84.140.234.70]) by smtp.gmail.com with ESMTPSA id t198sm15584187wmt.2.2019.06.10.08.54.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jun 2019 08:54:06 -0700 (PDT) To: ffmpeg-devel From: Jonathan Baecker Message-ID: <4eb92524-1a7e-d0d9-4977-328d062fb895@gmail.com> Date: Mon, 10 Jun 2019 17:54:04 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] drawtext: ignore last newline 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" I created this issue on the bugtracker: https://trac.ffmpeg.org/ticket/7948 Here is now a patch for it. drawtext should ignore the very last newline character in text files, because many editor add automatically a newline at the end. But when the filter draws a box behind the text, the box become to big. What do you think about this solution? From 9a4fa45a74c95d1a56a29dafe6c5c727d83c143c Mon Sep 17 00:00:00 2001 From: jonathan Date: Mon, 10 Jun 2019 17:44:03 +0200 Subject: [PATCH] ignore last newline --- libavfilter/vf_drawtext.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 01cd7fa122..e8c33596e9 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1380,8 +1380,10 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, for (i = 0, p = text; *p; i++) { GET_UTF8(code, *p++, continue;); - /* skip the \n in the sequence \r\n */ - if (prev_code == '\r' && code == '\n') + /* skip the \n in the sequence \r\n and ignore last empty line */ + if ((prev_code == '\r' && code == '\n') || + (code == '\n' && i == len - 1) || + (code == '\r' && i == len - 2)) continue; prev_code = code;