From patchwork Tue May 3 16:13:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35566 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496126pzb; Tue, 3 May 2022 09:14:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr9V0A86jo8UZm7w/09ZKuBmGdBoUN77pJy1fxLABOP3PlIkyXpXeTwHUNRi2ir5is49HC X-Received: by 2002:a17:907:6090:b0:6e8:abda:8933 with SMTP id ht16-20020a170907609000b006e8abda8933mr16616350ejc.46.1651594439796; Tue, 03 May 2022 09:13:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594439; cv=none; d=google.com; s=arc-20160816; b=EwJlOfGyD3PgHW6O3jtYvQwGqm0AO9de5stmtGb1b+K+f9pbtDMnNz7OEuhKkwV+aN 4XpYp2WIOsjlktnTOQU30sESaXoCn9PSiFeVU3Cy7ByfLyWRbQHxxgcdHTWIF0nwURw5 AoeyfJPqTJWh8C61MUG8klileGRn9GYq+Ac6AFs5jJ09pS1vyWe72ODfBvwZkgxdJN0S KYGFbkDz7yGeANba7jzbMt0P25yLdvjwO8+/Dc1ubhPb+GfntOE9sgLX+RDby2N2zb+r zz8aGHm+9zSqFmwoVAmcKqJgCyWXehUzJJUWfnYB8yIE7Q10UL6BzLz5lTegL/vIyj+i OlVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=PGjlCPgi8e7Vc5sYDPVjUMhNUptyUKqKuJEypaensBQ=; b=r/WJsI4gzYDL4J4l2VBk8odi6wGxf/8qA89QR89lKjtYzU6x4+UJU9joT5vSK63QTq jzWnrBvmNNO/9gRytjz3zJ6Y+KpKDNS5E1MZtbe1xVoHzb9Kgt4N1tTW3BZ1mszcWYjT YPJqrwOEKzwwqVsQrdpZlazx5r6F1oa+YyJSR6OccUNdQbCAk02xE3IihpL3UlwJkgRZ tP3PdrzLkEw6SM04ZfCOfkA81MZOZYS7eJPu2E71a23cEzjk3Ku3AjmfF2Fw0/sYPymy q1F3BiE2liixJIc2IjlqrxNXdGqyofrwTRj7xMNAvr2UiWYBSjJ9CCuBQjFZ8Td4+KBA 04MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Jzq1buNb; 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 du8-20020a17090772c800b006f45fa75d7esi4411391ejc.894.2022.05.03.09.13.59; Tue, 03 May 2022 09:13:59 -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=20210112 header.b=Jzq1buNb; 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 EAE7D68B379; Tue, 3 May 2022 19:13:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 91DFE680725 for ; Tue, 3 May 2022 19:13:48 +0300 (EEST) Received: by mail-qk1-f176.google.com with SMTP id s4so14144421qkh.0 for ; Tue, 03 May 2022 09:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HrxyjLR/H2MyzNj8ERRPZO+zGKPI9lN7b2Pbm4gX3Yw=; b=Jzq1buNbsBOU3ue1vBep7OgOqUxF2l74WZ02NPCxBEBbajFwUScpOh4KMLWFk8YDjI jC0JtqfTPcEQVrZiC0N8CIhSC3dAU1K8+QVkeqeKiONV00Xztm7hm57gAO3PjxmUiQ86 vsLkdbsiy2ZCYczhWghK6cP3pdHkCBTCnsOjow+woNm9Lyfio9nUSzY2vUU3PyrVbhjO KkWzu0TsheLBijanaLMbCyPPbggHC8DAhkWq5DJdVVncF8edAWp2cGto1T5vIuPorUxs gnx5caYaVgTpaXQRCHXydqOA9qGWy7s32JGfW8gxYP5uuRORmVwLk+2sOatq8QKN+K8N Y3mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HrxyjLR/H2MyzNj8ERRPZO+zGKPI9lN7b2Pbm4gX3Yw=; b=Vykq5hisHLpnxKc3NyELyB4jlSn6bO0AuCmlP+CiDz27utc/jHgXrTLR9vvU9DPZC/ jk9dwkMpj9S7w8hy9b7vuOVtdb5aae4/XuDe5hjl0AFCkfrlAuN8siUqQmQ7sxdePPkU Vevd2DOXaYYHyJqeTT/rLJcJ+GoT1F6lti6eacPiLfv3PCFwOx85nmU+vdxTVvhhk1JH UoUYrlwlNr5cITVe//aCrMDmOyUpZ2aEqYzRNXyb+c++i3Ui/reBmOsuOy7zU5ahcH4a KbIdDMxIcOMP1aAlF/KdM4K+3uHh6yo9AinLpl6ZYzZabgcbHBahxyMQft4hUdjzJU81 HMgA== X-Gm-Message-State: AOAM533zfojFhENNpKyT1wc63RDwYU/d0vnCpwCURvbz9DfwIJgJDRmz dnQzkwQivM5CAJr51MTzAKawOQx05tfS X-Received: by 2002:a37:b147:0:b0:69f:9b0c:2cb1 with SMTP id a68-20020a37b147000000b0069f9b0c2cb1mr12803688qkf.546.1651594426894; Tue, 03 May 2022 09:13:46 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:46 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:17 -0400 Message-Id: <20220503161328.842587-2-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/12] Implemented text to bitmap subtitles! X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Vy5T3w+vhV4q --- fftools/ffmpeg.c | 47 ++++++++++++++- libavfilter/vf_subtitles.c | 117 +++++++++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a85ed18b08..53717d3ebb 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2325,6 +2325,45 @@ fail: return err < 0 ? err : ret; } +void render_avsub_ass(InputStream *, AVSubtitle *); + +static void print_subtitle(AVSubtitle sub) +{ + printf("sub.format: %u\n", sub.format); + printf("sub.start_display_time: %u\n", sub.start_display_time); + printf("sub.end_display_time: %u\n", sub.end_display_time); + printf("sub.num_rects: %u\n", sub.num_rects); + printf("sub.pts: %ld\n", sub.pts); + for (int i = 0; i < sub.num_rects; i++) + { + printf("sub.rects[%d]->type: %d\n", i, sub.rects[i]->type); + printf("sub.rects[%d]->nb_colors: %d\n", i, sub.rects[i]->nb_colors); + printf("sub.rects[%d]->(x,y,w,h): (%d,%d,%d,%d)\n", i, sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h); + printf("sub.rects[%d]->linesize: [%d,%d,%d,%d]\n", i, sub.rects[i]->linesize[0], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1]); + switch (sub.rects[i]->type) + { + case SUBTITLE_TEXT: + printf("sub.rects[%d]->text: %s\n", i, sub.rects[i]->text); + break; + case SUBTITLE_ASS: + printf("sub.rects[%d]->ass: %s\n", i, sub.rects[i]->ass); + break; + case SUBTITLE_BITMAP: + for (int c = 0; c < sub.rects[i]->nb_colors; c++) + printf("color %d: [%u,%u,%u,%u]\n", c, + sub.rects[i]->data[1][c * 4 + 0], + sub.rects[i]->data[1][c * 4 + 1], + sub.rects[i]->data[1][c * 4 + 2], + sub.rects[i]->data[1][c * 4 + 3]); + for (int y = 0; y < sub.rects[i]->h; y++, printf("\n")) + for (int x = 0; x < sub.rects[i]->w; x++) + printf("%d", sub.rects[i]->data[0][y * sub.rects[i]->w + x]); + break; + } + } + printf("\n"); +} + static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, int *decode_failed) { @@ -2383,6 +2422,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, goto out; ist->frames_decoded++; + + render_avsub_ass(ist, &subtitle); for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -3213,11 +3254,15 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); if (output_descriptor) output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - if (input_props && output_props && input_props != output_props) { + /*if (input_props && output_props && input_props != output_props) { snprintf(error, error_len, "Subtitle encoding currently only possible from text to text " "or bitmap to bitmap"); return AVERROR_INVALIDDATA; + }*/ + if (input_props == AV_CODEC_PROP_BITMAP_SUB && output_props == AV_CODEC_PROP_TEXT_SUB) { + snprintf(error, error_len, "Subtitle encoding from bitmap to text currently not possible"); + return AVERROR_INVALIDDATA; } } diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 82e140e986..f751786033 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -181,6 +181,24 @@ static void overlay_ass_image(AssContext *ass, AVFrame *picref, } } +static void print_ass_image(const ASS_Image *image) +{ + int index = 0; + for (; image != NULL; image = image->next, index++) + { + printf("index: %d\n", index); + printf("image->(dst_x,dst_y): (%d,%d)\n", image->dst_x, image->dst_y); + printf("image->(w,h): (%d,%d)\n", image->w, image->h); + printf("image->stride: %d\n", image->stride); + printf("image->type: %d\n", image->type); + printf("image->color: [%u,%u,%u,%u]\n", AR(image->color), AG(image->color), AB(image->color), AA(image->color)); + for (int y = 0; y < image->h; y++, printf("\n")) + for (int x = 0; x < image->w; x++) + printf("%02X", image->bitmap[y * image->stride + x]); + printf("\n"); + } +} + static int filter_frame(AVFilterLink *inlink, AVFrame *picref) { AVFilterContext *ctx = inlink->dst; @@ -199,6 +217,105 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) return ff_filter_frame(outlink, picref); } +#include "../fftools/ffmpeg.h" +#include "libavcodec/avcodec.h" +#include "../libavcodec/ass_split.h" + +#define ALPHA_THRESHOLD 0b10000000 + +void render_avsub_ass(InputStream *, AVSubtitle *); +void render_avsub_ass(InputStream *ist, AVSubtitle *sub) +{ + ASS_Library *library = ass_library_init(); + ass_set_extract_fonts(library, 1); + ASS_Renderer *renderer = ass_renderer_init(library); + int w = 1920, h = 1080; + ass_set_frame_size(renderer, w, h); + ass_set_pixel_aspect(renderer, 1); + ass_set_storage_size(renderer, w, h); + ass_set_shaper(renderer, 0); + ass_set_fonts(renderer, NULL, NULL, 1, NULL, 1); + + for (int r = 0; r < sub->num_rects; r++) + { + AVSubtitleRect *rect = sub->rects[r]; + if (rect->data[0]) continue; + + ASSSplitContext *ass_context = ff_ass_split((char *)ist->dec_ctx->subtitle_header); + ASSDialog *dialog = ff_ass_split_dialog(ass_context, rect->ass); + + ASS_Track *track = ass_read_memory(library, (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); + track->n_events = track->max_events = 1; + track->events = (ASS_Event *)malloc(sizeof(ASS_Event)); + track->events[0].Start = sub->start_display_time + sub->pts / (AV_TIME_BASE / 1000); + track->events[0].Duration = sub->end_display_time - sub->start_display_time; + track->events[0].Effect = strdup(dialog->effect); + track->events[0].Layer = dialog->layer; + track->events[0].MarginL = dialog->margin_l; + track->events[0].MarginR = dialog->margin_r; + track->events[0].MarginV = dialog->margin_v; + track->events[0].Name = strdup(dialog->name); + track->events[0].Text = strdup(dialog->text); + track->events[0].ReadOrder = dialog->readorder; + track->events[0].Style = 0; + for (int style = 0; style < track->n_styles; style++) + if (!strcmp(track->styles[style].Name, dialog->style)) + track->events[0].Style = style; + track->events[0].render_priv = NULL; + ff_ass_free_dialog(&dialog); + ff_ass_split_free(ass_context); + + int change; + ASS_Image *image = ass_render_frame(renderer, track, track->events[0].Start + 1, &change); // Don't have to free it for some reason + printf("image: %p\n", image); + + rect->x = image->dst_x; rect->w = 0; + rect->y = image->dst_y; rect->h = 0; + rect->nb_colors = 1; // Transparent background counts as a color + for (ASS_Image *img = image; img != NULL; img = img->next) + { + // Set image bounds to encompass all images + if (img->dst_x < rect->x) rect->x = img->dst_x; + if (img->dst_y < rect->y) rect->y = img->dst_y; + if (img->dst_x + img->w > rect->x + rect->w) + rect->w = img->dst_x + img->w - rect->x; + if (img->dst_y + img->h > rect->y + rect->h) + rect->h = img->dst_y + img->h - rect->y; + rect->nb_colors++; + } + rect->linesize[0] = rect->w; + rect->data[0] = (uint8_t *)malloc(rect->w * rect->h * sizeof(uint8_t)); + rect->data[1] = (uint8_t *)malloc(4 * rect->nb_colors * sizeof(uint8_t)); + memset(rect->data[0], 0, rect->w * rect->h); // Set all to transparent + memset(rect->data[1], 0, 4); // Set transparent color + memset(&rect->linesize[1], 0, 3 * sizeof(int)); + rect->data[2] = rect->data[3] = NULL; + for (int color = 1; image != NULL; image = image->next, color++) + { + // Set color + rect->data[1][4 * color + 0] = AR(image->color); + rect->data[1][4 * color + 1] = AG(image->color); + rect->data[1][4 * color + 2] = AB(image->color); + rect->data[1][4 * color + 3] = AA(image->color); + // Set pixels + for (int y = 0; y < image->h; y++) + for (int x = 0; x < image->w; x++) + if (image->bitmap[y * image->stride + x] >= ALPHA_THRESHOLD) + { + int x_rect = image->dst_x + x - rect->x; + int y_rect = image->dst_y + y - rect->y; + rect->data[0][y_rect * rect->w + x_rect] = color; + } + } + rect->type = SUBTITLE_BITMAP; + + ass_free_track(track); + } + + ass_renderer_done(renderer); + ass_library_done(library); +} + static const AVFilterPad ass_inputs[] = { { .name = "default", From patchwork Tue May 3 16:13:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35567 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496254pzb; Tue, 3 May 2022 09:14:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKyJSKCrQeUuBuxeZfZsbIFgydPjRkassjM43mHHqFi2Ebx2uevOE4hgqAkrb7I8+KbDnN X-Received: by 2002:a05:6402:2710:b0:427:d087:b with SMTP id y16-20020a056402271000b00427d087000bmr8419499edd.11.1651594451118; Tue, 03 May 2022 09:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594451; cv=none; d=google.com; s=arc-20160816; b=O3WyS11ECyR8BNh5FJqL4ZFid3qUkBKOnIXjEfRpKoRtQyM+Y0kFTc8AzUFKKoffBz 2E7jq7MznBWPAHSfCwlDDv5Kkc/MV4+Wbg+iZIw0Ykuy6jPctHnW8gjCH/Ab8JzNU/vJ mVjsRPiC5IcSVRXVHp27yKBoF3n7olFT7+0C/fjLokvt5COUJLpzCdE0p/Y9SMzBf+sJ TcaW9DLA7Qt1FEYFtsu36PxkH8W/up8cWlMIVbpTOhPPy78yN5HMgnm3udrOZ3H0gWTO zkl5nfCRFJVlAo00BHG1F4sSDMmHKCKBaNDZBZMGbuAMKSiMrpYjQWzwfHduAR8NL0tW lj8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=3V0TNRlPtGJBFmsHjSKhDa12liJYcv9Vwp+rGrmw1iM=; b=qN3XhUd1FZSl21qvfc1QK2LJ6phAOEw96eI30UP2k5bLqm6+1s1XLViUXPrTSO1b6B 1zNyE4nKFgMXiKrpNqOM0VUWqRcYwKr7fxTSxPhf8MXnQU8ZsiW8TzDXBuJP59umtlDo +cdvqCJEcr+5oMvd4VHtAgjs5do6CC1rrTsJDpdMn4OuNxWrLElWURFi/26plKgV53a9 5wzL7pnUd/2y4ubh2gVsVo7PBkAj7mLSMwtp3hHzWDzabERL9tgRpFrooSiLjTdOfMrH Sy/ee4KH+lJw9ZDGv0NL+PMAyPcP+3KKK4eOj7UpVxaiPOvCJZBWxuFJwGG37EXXF8lI uaew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Sq0D8TFY; 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 q22-20020a170906389600b006f39d4eb670si14927073ejd.966.2022.05.03.09.14.10; Tue, 03 May 2022 09:14:11 -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=20210112 header.b=Sq0D8TFY; 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 194CB68B38C; Tue, 3 May 2022 19:13:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18E0968B37A for ; Tue, 3 May 2022 19:13:51 +0300 (EEST) Received: by mail-qk1-f173.google.com with SMTP id e128so14106973qkd.7 for ; Tue, 03 May 2022 09:13:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o3oBhOtsQLpEU5KT3KHYlSGTxv6Gdy8Z9odcZowbEgQ=; b=Sq0D8TFY3d/32XBsqy40xaf4lw7Bkw7hIPY8NP5hMaXa7WqpXzskKp4rdr7HeF7UO5 KLLOPJ2MUUS/6buLpcd3b9YtqUR6J+CBHv5wSFSdbdKOc+U3FQxqhHCLaXhHuDL0D0bm u7vFADN9HKiI9PjApKpWKpMHDRs0RMbn/h9jhIkzFefJ7z0I+cyeC8b/6MKo0moV4KBF op5Q3m/DsDusJ1QknnSaSGx38QOcouvqMsomf7UQ2PjW2NCED4FZOfMBdtSgTKYZl3+l /Tf7Paa3zsDwtlVKUnrllgADGEFebU+RxoY0YcYvSJna+vwjkeI5tY+dQjrkkDXY1CMY TQgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o3oBhOtsQLpEU5KT3KHYlSGTxv6Gdy8Z9odcZowbEgQ=; b=DlmUuxnKTygt3Xtg4tbf9tqpf/DKSukZAUzxVrCwSHDfAUBncZmkJPJEWYDE7HcMeW l0WnFeHlx2YgoqAh+Ey0GFzWAIjZju6xBVOFBJkWXJZnX6n1jqq+tjdHGUTuZy8ZixVI 7Q/GT7GB2WXhB/yNZIYNnsFMi6EuY0Esf7NR0Y3uiELHG5DQmLQR0txFWLPdXQr/ge4P bhhslS5cSwdUsRDrmdoZX+JNOsrcgpmEdYPWIvid1cjGmZgz6a522F/cXuoE72hK2Mig +RVnOcxdUNEd6r8YKaePItXiwiydkG8wK8wyKl4nWWo33ICeTDiVYRT5mL1oLY7LFCmq o0Kw== X-Gm-Message-State: AOAM531PubAIApTXmUUc/B6CvNp5asfFGNQMZ+LrQO1trWCOEr5IC0MF b3vHi59Mc/3lZleMNP9Rljj3g+pcjp4d X-Received: by 2002:a05:620a:448f:b0:69f:e9a2:9403 with SMTP id x15-20020a05620a448f00b0069fe9a29403mr6516268qkp.122.1651594429371; Tue, 03 May 2022 09:13:49 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:48 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:18 -0400 Message-Id: <20220503161328.842587-3-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/12] Render only when necessary X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jHO6mZ09DRuP --- fftools/ffmpeg.c | 12 ++++++++++-- libavfilter/vf_subtitles.c | 1 - 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 53717d3ebb..dea2aec2ce 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2422,9 +2422,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, goto out; ist->frames_decoded++; - - render_avsub_ass(ist, &subtitle); + int rendered = 0; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -2432,6 +2431,15 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) continue; + if (avcodec_descriptor_get(ost->enc_ctx->codec_id)->props & AV_CODEC_PROP_BITMAP_SUB) + if (avcodec_descriptor_get(ist->dec_ctx->codec_id)->props & AV_CODEC_PROP_TEXT_SUB) + if (!rendered) { + render_avsub_ass(ist, &subtitle); + for (int r = 0; r < subtitle.num_rects; r++) + subtitle.rects[r]->type = SUBTITLE_BITMAP; + rendered = 1; + } + do_subtitle_out(output_files[ost->file_index], ost, &subtitle); } diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index f751786033..16f9c3fff6 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -307,7 +307,6 @@ void render_avsub_ass(InputStream *ist, AVSubtitle *sub) rect->data[0][y_rect * rect->w + x_rect] = color; } } - rect->type = SUBTITLE_BITMAP; ass_free_track(track); } From patchwork Tue May 3 16:13:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35568 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496370pzb; Tue, 3 May 2022 09:14:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzexD5IKtRuc80m+EHKHWXC4ebkWt8LJimuiVNU1D8TZwBV83QG670krfMEurABZg8ZEW06 X-Received: by 2002:a17:906:1186:b0:6f3:e700:75be with SMTP id n6-20020a170906118600b006f3e70075bemr16357304eja.350.1651594462383; Tue, 03 May 2022 09:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594462; cv=none; d=google.com; s=arc-20160816; b=qAnUyGqLoqe6l5xLx4Cxq/lnPuYFseci7dPyTqiNV/jCeMS8Zt/B+Eicv+Vdj3pR2O YWeJrtwMC1azHNuo8693SnOaLgsq9/I8yG2OhcLIBFx+Z3n5F2pXKalSvU/nhVMrb2Io 8Iiuj4Brx9yRssMqMRJf/v2RMXGCuB1jVjL6lMZ+CQwxkmG9ihPgTK320xgOrtZ2ZGkY 7VssygRVJQGhJTy/kVFb9GL4sTNrMG3Bo+8I1h9j236zOXjSgIepIs8EW4S5OrdtdwDK a9Hj8YCBqpXe9JXwwUlJOOYj4EYkH+LVvjiJv5YVgH+rlheRIzgz4nfmay+Sdv2g78wo eT3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=OPHNS2LQzv9oSuHldj9wEn37ZXVr0IHvblqOR99zUh8=; b=XMEZgD9Lod4AWp1n7K8UbBvHY+nrAUfC/d/UknV+/t4t5A031ej2WTDMLsmbzis4Is lseC+1pFu7w8cpztSajCoK4gSMq9VgK/Kl2gHX36ZTm51hhY4a2Q7f7WNQgBL1wjLihN zEz/O3JGmz64+W01ds8OnYryTB7/+TH8tQOqqc37zpvaPus6ZQ031bcaSZmtNRm1rMSt vLmaaMg6gfSXWJGHnPe3lepQTSCeeLq0rHuiA0Ns4Tq3DQyD/u0gmuvk3pDgNsgF7NvX L5+2aOnRmExA+LcxjKEfd5+AbbwgXyPkrHhPVaidXmaXHKp7eNXKzlFHx/XO2jJAUoKa xTVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="A3aP/9lG"; 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 e16-20020a170906315000b006df76385f31si13922317eje.977.2022.05.03.09.14.21; Tue, 03 May 2022 09:14:22 -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=20210112 header.b="A3aP/9lG"; 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 5488E68B3A0; Tue, 3 May 2022 19:13:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F2E168B394 for ; Tue, 3 May 2022 19:13:52 +0300 (EEST) Received: by mail-qt1-f177.google.com with SMTP id hh4so13875590qtb.10 for ; Tue, 03 May 2022 09:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6PFjBMPY0LcWDjHW8ANF6N3ro/90ICiz03wEyR5aF18=; b=A3aP/9lGl9jEp0Dvmjizmouz3xemj4XT7CHOAnNtPEvgirUn/Pos5Y2oAD40htw7c7 6ZaVygfS144VKxiCLcNsrWOrcpd01RzBEiEQsiSrEF/Hf3PbvtKGXXoH/3CxNkOBEDG2 9zx1W7u+gH+2FYgNsJmFxr0eBq6V5xxb1ceFc7B6fm9ouFRMbJZDpdSChJ+VxWIIILsV 4Fs/m6gOVHFkeGYS/F4PsjvNAv56MXBJaeWZVRieA5EuuA6IgFGymxVxhXvPLRpx8RVU d9+5hl68JYv/nWTHAxFffC8XzLwmZjQqqgdieskT+tLzb/EwJaDfc0/me0/QDS+J04mt MSgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6PFjBMPY0LcWDjHW8ANF6N3ro/90ICiz03wEyR5aF18=; b=njOUGgxAgGvodC65PJAIafkb+EeyAPkn4UAMCwikF571TccgQcAxsn9bgOhvQWGvGx aN/pKTvAZJKgclUvgMxC54oD91xb1kPMfH6efuriAohVxdyvX+TnlcMu5CbJpcIPAZWE oY9gjPU2U3P6zQ+ZZwLnSxdNv1ZH+cUMl/TOC+2LzHgzU2eKqZUT9odtjz0zaIXPQ1H4 1KT1Bbisi1OvsTLgJWlVlKfMPDkKG/KaNd23hctwVotqWfx7op5o66VOW2lz8C+1vuc5 uh0TOVLsyjWOqrUVdklqy5CKev9LahX1XvezPKOvY5sM1Y7SJExCDPc7fitgJ3KgPSOb Klnw== X-Gm-Message-State: AOAM533SJLrEEStus42Z9dWyX2HY3B/YtkDGVxmlAtUb8TeY9fTppYh/ bf9HNYL9UGsAcw/NGw51uHsqqeeCarmU X-Received: by 2002:a05:622a:164b:b0:2f3:8701:2859 with SMTP id y11-20020a05622a164b00b002f387012859mr15306703qtj.33.1651594430993; Tue, 03 May 2022 09:13:50 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:50 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:19 -0400 Message-Id: <20220503161328.842587-4-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/12] Retreive width and height from video stream! X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PanC9i2FKjrd --- fftools/ffmpeg.c | 29 ++++++++++++++++++++++++++--- libavfilter/vf_subtitles.c | 9 ++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index dea2aec2ce..a74800bb68 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2325,7 +2325,7 @@ fail: return err < 0 ? err : ret; } -void render_avsub_ass(InputStream *, AVSubtitle *); +void render_avsub_ass(InputStream *, AVSubtitle *, int, int); static void print_subtitle(AVSubtitle sub) { @@ -2423,7 +2423,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, ist->frames_decoded++; - int rendered = 0; + int rendered = 0; // Variable for text to bitmap support for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -2431,10 +2431,33 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) continue; + // Support text to bitmap if (avcodec_descriptor_get(ost->enc_ctx->codec_id)->props & AV_CODEC_PROP_BITMAP_SUB) if (avcodec_descriptor_get(ist->dec_ctx->codec_id)->props & AV_CODEC_PROP_TEXT_SUB) if (!rendered) { - render_avsub_ass(ist, &subtitle); + // Try to get a height and width from a video + int width = 0, height = 0; + // Try output streams + for (int j = 0; j < nb_output_streams; j++) + if (output_streams[j]->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + { + width = output_streams[j]->enc_ctx->width; + height = output_streams[j]->enc_ctx->height; + break; + } + if (width == 0) + // Try input streams + for (int j = 0; j < nb_input_streams; j++) + if (input_streams[j]->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + { + width = input_streams[j]->dec_ctx->width; + height = input_streams[j]->dec_ctx->height; + break; + } + if (width == 0) { + // TODO Error: Cannot render without a video stream + } + render_avsub_ass(ist, &subtitle, width, height); for (int r = 0; r < subtitle.num_rects; r++) subtitle.rects[r]->type = SUBTITLE_BITMAP; rendered = 1; diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 16f9c3fff6..7226911f6c 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -223,16 +223,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) #define ALPHA_THRESHOLD 0b10000000 -void render_avsub_ass(InputStream *, AVSubtitle *); -void render_avsub_ass(InputStream *ist, AVSubtitle *sub) +void render_avsub_ass(InputStream *, AVSubtitle *, int, int); +void render_avsub_ass(InputStream *ist, AVSubtitle *sub, int frame_width, int frame_height) { ASS_Library *library = ass_library_init(); ass_set_extract_fonts(library, 1); ASS_Renderer *renderer = ass_renderer_init(library); - int w = 1920, h = 1080; - ass_set_frame_size(renderer, w, h); + ass_set_frame_size(renderer, frame_width, frame_height); ass_set_pixel_aspect(renderer, 1); - ass_set_storage_size(renderer, w, h); + ass_set_storage_size(renderer, frame_width, frame_height); ass_set_shaper(renderer, 0); ass_set_fonts(renderer, NULL, NULL, 1, NULL, 1); From patchwork Tue May 3 16:13:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35573 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496882pzb; Tue, 3 May 2022 09:15:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9llrDZzs1xsVmAChw9zaQX7pAxdFKVXESjq++MCUz0V3OrPqGxrGwRsC5+eBpktmD+iBi X-Received: by 2002:a17:907:6e8b:b0:6f4:7147:a6ac with SMTP id sh11-20020a1709076e8b00b006f47147a6acmr6560261ejc.187.1651594521392; Tue, 03 May 2022 09:15:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594521; cv=none; d=google.com; s=arc-20160816; b=PxZ0FjNJ4QGYwB88N8HlyzSv96EobF1zLdQlhHge6Kl+zlqW2iQyFzOCaEUIE5yUT7 dflpy1pXx1YEk+8PwX65Cik3x/PsbjhATwevOzugF6HjWLK7dU0IVq7ACQtwt8GQ8lJd Avqd09lo/KqmVk6Tbw0EjFzdNVP3qBLKR/DZLbbDUOThd7SM2FJ8vUmNiJIRh50GSBtB J4ldxcrSYOVhZRCSwgi/jBWhqRcbWrrTEo1oNbwSH9Vweomo0PuJAfIFm4WLxTiKXRAG qxBDucmiGKigLyxssBF5zszU0muA7eOHErRXbUGjd+t+KQFAVvFvQzfnzWCgjjdUVX8H uKsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Xwp5jCHGwGPQjgHi+lTOaWwjiDLeZIlzkwfd8ebXG64=; b=Tz2dIk/yizD8WPOZgae0DgPQdzO0o10lO0Ed4ptarqw2VQFnmAnpXKdADTRwqmievt 7oDHzEp404oaj1NmOJcBODo843QunBWpKwcsnnCOnUIMvSrpLvZPfsKwA1h5i+QfRyQ/ +J+S7Lc3cSthkM4XXOEIxVi31iEWIddLageXb8xkUIb6ztRF6jMAPVU8rE10TgxGA/S0 5G0dFCzAgjVPa4S+jNDWUHR19keXUda2BhszfetUMLkh3Ms1GQtF3NVW599eNtxeTr6n vYOsY6X7xZZm2FR2IKX8ExX5N31d4YRY7ApTvcjkx0evjp7PtIVJED9a0x3XXO6FvsTu +fVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=LNHzAfPa; 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 v24-20020a50a458000000b00420c32eec37si13174844edb.119.2022.05.03.09.15.20; Tue, 03 May 2022 09:15:21 -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=20210112 header.b=LNHzAfPa; 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 3C09C68B3A7; Tue, 3 May 2022 19:14:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E17768B3AB for ; Tue, 3 May 2022 19:13:55 +0300 (EEST) Received: by mail-qt1-f169.google.com with SMTP id fu47so13874224qtb.5 for ; Tue, 03 May 2022 09:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rjNe8WYHq94qwxPfkB7ejnsycgKuHwRpDdWOp3PORwU=; b=LNHzAfPaYx60d2ypsQ8ECWj1biKUAKm/yyNN1/soRbTPv1Z9jXmGmJpmXwSc4tzNZE K/9tDg2N0i3Mdj4xU3qOVNh1oHLQ7o99DqbJ3cdGXLl7se53Q8ePo3B1r8Hg0+Tp/Lrq JlY0Q4DtQnxhT2+zENUfH4X2L9TxiAaiSrvXi61ZGyjy8nS5jB9b9xHouWquwRi+DFKz UtRrWxR+BAOYLegI8HkLQdXLcTa3MFCZ6Im3G71DV8+ce+uwqcSwQEzeWqrW3IF7fGn9 OY+KcEWHYRPQWXlTFGR4cytSBXeVeMRTb1zBdyttXYnBNsebLq/BE/wv45Kg66R+ym+r IV5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rjNe8WYHq94qwxPfkB7ejnsycgKuHwRpDdWOp3PORwU=; b=ubQBpUR8fXHaFBj3kVhHUdBAdKvsDbLhLFEr4d7A5hBMc7Tg442Swqqm/c6vRgT6Db HGkP9uKIwHhkzYzWqfz3RM5e0frM9eAToqqzCm55NFvQ4gZHIpUd3tUFdRtLSTJDPjii lEvvl1OsbGUDE/Xh5y75uP7AJxpg7CLFmrDr66pqRh+N2VdzTF1ypm80lxJ6EhmgM5ba OltKQRSQQxPMjtDiHTBPIy8zH+Kpj/VICvvi9OSn3BM+1KDn/3LuzaPRUZ3iWZvfanea 43cko5aU8L0OltPQER7p2Dj3srPhZi/H75AvGkRHLNzs9xJ5YMDSBkyjVxBH87hBqhjG 5H+A== X-Gm-Message-State: AOAM532c2eB++LQN0S8xLQxL2K+VV4bYyuhzlTgNMJwZkZmVCmRKHteO QVUGsbWtlOhxok9UwH1IBDjJSAt6Of+F X-Received: by 2002:a05:622a:190e:b0:2e1:d655:d447 with SMTP id w14-20020a05622a190e00b002e1d655d447mr15477182qtc.571.1651594432903; Tue, 03 May 2022 09:13:52 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:52 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:20 -0400 Message-Id: <20220503161328.842587-5-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/12] Initialize ass library only once! X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Qc8l0ZBh7Yaa --- fftools/ffmpeg.c | 50 ++++------- libavcodec/Makefile | 1 + libavcodec/avcodec.h | 9 ++ libavcodec/text_to_bitmap.c | 170 ++++++++++++++++++++++++++++++++++++ libavcodec/text_to_bitmap.h | 18 ++++ libavfilter/vf_subtitles.c | 97 -------------------- 6 files changed, 217 insertions(+), 128 deletions(-) create mode 100644 libavcodec/text_to_bitmap.c create mode 100644 libavcodec/text_to_bitmap.h diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index a74800bb68..31acf08a6a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -71,6 +71,10 @@ # include "libavfilter/buffersrc.h" # include "libavfilter/buffersink.h" +#if CONFIG_LIBASS +#include "libavcodec/text_to_bitmap.h" +#endif + #if HAVE_SYS_RESOURCE_H #include #include @@ -2325,8 +2329,6 @@ fail: return err < 0 ? err : ret; } -void render_avsub_ass(InputStream *, AVSubtitle *, int, int); - static void print_subtitle(AVSubtitle sub) { printf("sub.format: %u\n", sub.format); @@ -2434,30 +2436,8 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, // Support text to bitmap if (avcodec_descriptor_get(ost->enc_ctx->codec_id)->props & AV_CODEC_PROP_BITMAP_SUB) if (avcodec_descriptor_get(ist->dec_ctx->codec_id)->props & AV_CODEC_PROP_TEXT_SUB) - if (!rendered) { - // Try to get a height and width from a video - int width = 0, height = 0; - // Try output streams - for (int j = 0; j < nb_output_streams; j++) - if (output_streams[j]->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) - { - width = output_streams[j]->enc_ctx->width; - height = output_streams[j]->enc_ctx->height; - break; - } - if (width == 0) - // Try input streams - for (int j = 0; j < nb_input_streams; j++) - if (input_streams[j]->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) - { - width = input_streams[j]->dec_ctx->width; - height = input_streams[j]->dec_ctx->height; - break; - } - if (width == 0) { - // TODO Error: Cannot render without a video stream - } - render_avsub_ass(ist, &subtitle, width, height); + if (!rendered) { // Make sure not to render twice + render_avsub_ass(ist->dec_ctx->ass_context, &subtitle); for (int r = 0; r < subtitle.num_rects; r++) subtitle.rects[r]->type = SUBTITLE_BITMAP; rendered = 1; @@ -2757,6 +2737,9 @@ static int init_input_stream(int ist_index, char *error, int error_len) * audio, and video decoders such as cuvid or mediacodec */ ist->dec_ctx->pkt_timebase = ist->st->time_base; + // For text to bitmap rendering + ist->dec_ctx->ass_context = NULL; + if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) av_dict_set(&ist->decoder_opts, "threads", "auto", 0); /* Attached pics are sparse, therefore we would not want to delay their decoding till EOF. */ @@ -3285,16 +3268,21 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); if (output_descriptor) output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB); - /*if (input_props && output_props && input_props != output_props) { +#if CONFIG_LIBASS + if (input_props == AV_CODEC_PROP_BITMAP_SUB && output_props == AV_CODEC_PROP_TEXT_SUB) { + snprintf(error, error_len, "Subtitle encoding from bitmap to text currently not possible"); + return AVERROR_INVALIDDATA; + } + if (input_props == AV_CODEC_PROP_TEXT_SUB && output_props == AV_CODEC_PROP_BITMAP_SUB) + init_ass_context(ist, ost); +#else + if (input_props && output_props && input_props != output_props) { snprintf(error, error_len, "Subtitle encoding currently only possible from text to text " "or bitmap to bitmap"); return AVERROR_INVALIDDATA; - }*/ - if (input_props == AV_CODEC_PROP_BITMAP_SUB && output_props == AV_CODEC_PROP_TEXT_SUB) { - snprintf(error, error_len, "Subtitle encoding from bitmap to text currently not possible"); - return AVERROR_INVALIDDATA; } +#endif } if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cfaa6f196a..6d28513129 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -151,6 +151,7 @@ OBJS-$(CONFIG_RV34DSP) += rv34dsp.o OBJS-$(CONFIG_SINEWIN) += sinewin.o OBJS-$(CONFIG_SNAPPY) += snappy.o OBJS-$(CONFIG_STARTCODE) += startcode.o +OBJS-$(CONFIG_LIBASS) += text_to_bitmap.o OBJS-$(CONFIG_TEXTUREDSP) += texturedsp.o OBJS-$(CONFIG_TEXTUREDSPENC) += texturedspenc.o OBJS-$(CONFIG_TPELDSP) += tpeldsp.o diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 4dae23d06e..530c01f193 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -2055,6 +2055,15 @@ typedef struct AVCodecContext { * The decoder can then override during decoding as needed. */ AVChannelLayout ch_layout; + + /** + * Pointer to ASS_Library instance (cast to void *) + * - encoding: unused + * - decoding: is set to NULL initially in init_input_stream, and if + * there must be a text to bitmap conversion, is set to a + * new instance of ASS_Library in init_output_stream + */ + void *ass_context; } AVCodecContext; /** diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c new file mode 100644 index 0000000000..87c46985d9 --- /dev/null +++ b/libavcodec/text_to_bitmap.c @@ -0,0 +1,170 @@ +// +// Created by traian on 2022-05-02. +// + +#include "text_to_bitmap.h" + +#include "fftools/ffmpeg.h" +#include "avcodec.h" +#include "ass_split.h" + +struct ASS_Context { + ASS_Library *library; + ASS_Renderer *renderer; + ASS_Track *track; + ASSSplitContext *ass_split_context; +}; + +void init_ass_context(InputStream *ist, OutputStream *ost) +{ + if (ist->dec_ctx->ass_context) return; + ASS_Context *context = (ASS_Context *)malloc(sizeof(ASS_Context)); + context->library = ass_library_init(); + ass_set_extract_fonts(context->library, 1); + // TODO: ass_add_font(context->library, ); + + // Try to get a height and width from somewhere + int width = 0, height = 0; + do + { + // Try input stream + if (ost->enc_ctx->width != 0 && ost->enc_ctx->height != 0) + { + width = ost->enc_ctx->width; + height = ost->enc_ctx->height; + break; + } + // Try output stream + if (ist->dec_ctx->width != 0 && ist->dec_ctx->height != 0) + { + width = ist->dec_ctx->width; + height = ist->dec_ctx->height; + break; + } + // Try output streams + for (int j = 0; j < nb_output_streams; j++) + if (output_streams[j]->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + { + width = output_streams[j]->enc_ctx->width; + height = output_streams[j]->enc_ctx->height; + break; + } + if (width && height) break; + // Try input streams + for (int j = 0; j < nb_input_streams; j++) + if (input_streams[j]->dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + { + width = input_streams[j]->dec_ctx->width; + height = input_streams[j]->dec_ctx->height; + break; + } + if (width && height) break; + + // TODO Error: Cannot render without a width and height + } while (0); + + context->renderer = ass_renderer_init(context->library); + ass_set_frame_size(context->renderer, width, height); + ass_set_pixel_aspect(context->renderer, 1); + ass_set_storage_size(context->renderer, width, height); + ass_set_shaper(context->renderer, 0); + ass_set_fonts(context->renderer, NULL, NULL, 1, NULL, 1); + + context->track = ass_read_memory(context->library, (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); + context->ass_split_context = ff_ass_split((char *)ist->dec_ctx->subtitle_header); + + ist->dec_ctx->ass_context = context; +} + +void free_ass_context(ASS_Context *context) { + ass_library_done(context->library); + ass_renderer_done(context->renderer); + ass_free_track(context->track); + ff_ass_split_free(context->ass_split_context); + free(context); +} + +/* libass stores an RGBA color in the format RRGGBBTT, where TT is the transparency level */ +#define AR(c) ((c)>>24) +#define AG(c) (((c)>>16)&0xFF) +#define AB(c) (((c)>>8) &0xFF) +#define AA(c) ((0xFF-(c)) &0xFF) + +#define ALPHA_THRESHOLD 0b10000000 + +void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) +{ + printf("render_avsub_ass\n"); + for (int r = 0; r < sub->num_rects; r++) + { + AVSubtitleRect *rect = sub->rects[r]; + if (rect->data[0]) continue; + + ASSDialog *dialog = ff_ass_split_dialog(context->ass_split_context, rect->ass); + ASS_Track *track = context->track; + if (track->n_events > 0) + ass_free_event(track, 0); + track->n_events = 0; + ass_alloc_event(track); + track->n_events = track->max_events = 1; + track->events[0].Start = sub->start_display_time + sub->pts / (AV_TIME_BASE / 1000); + track->events[0].Duration = sub->end_display_time - sub->start_display_time; + track->events[0].Effect = strdup(dialog->effect); + track->events[0].Layer = dialog->layer; + track->events[0].MarginL = dialog->margin_l; + track->events[0].MarginR = dialog->margin_r; + track->events[0].MarginV = dialog->margin_v; + track->events[0].Name = strdup(dialog->name); + track->events[0].Text = strdup(dialog->text); + track->events[0].ReadOrder = dialog->readorder; + track->events[0].Style = 0; + for (int style = 0; style < track->n_styles; style++) + if (!strcmp(track->styles[style].Name, dialog->style)) + track->events[0].Style = style; + track->events[0].render_priv = NULL; + ff_ass_free_dialog(&dialog); + + ASS_Image *image = ass_render_frame(context->renderer, track, + track->events[0].Start + track->events[0].Duration / 2, NULL); + if (image == NULL) printf("WARNING: failed to render ass\n"); + + rect->x = image ? image->dst_x : 0; rect->w = 0; + rect->y = image ? image->dst_y : 0; rect->h = 0; + rect->nb_colors = 1; // Transparent background counts as a color + for (ASS_Image *img = image; img != NULL; img = img->next) + { + // Set image bounds to encompass all images + if (img->dst_x < rect->x) rect->x = img->dst_x; + if (img->dst_y < rect->y) rect->y = img->dst_y; + if (img->dst_x + img->w > rect->x + rect->w) + rect->w = img->dst_x + img->w - rect->x; + if (img->dst_y + img->h > rect->y + rect->h) + rect->h = img->dst_y + img->h - rect->y; + rect->nb_colors++; + } + rect->linesize[0] = rect->w; + rect->data[0] = (uint8_t *)malloc(rect->w * rect->h * sizeof(uint8_t)); + rect->data[1] = (uint8_t *)malloc(4 * rect->nb_colors * sizeof(uint8_t)); + memset(rect->data[0], 0, rect->w * rect->h); // Set all to transparent + memset(rect->data[1], 0, 4); // Set transparent color + memset(&rect->linesize[1], 0, 3 * sizeof(int)); + rect->data[2] = rect->data[3] = NULL; + for (int color = 1; image != NULL; image = image->next, color++) + { + // Set color + rect->data[1][4 * color + 0] = AR(image->color); + rect->data[1][4 * color + 1] = AG(image->color); + rect->data[1][4 * color + 2] = AB(image->color); + rect->data[1][4 * color + 3] = AA(image->color); + // Set pixels + for (int y = 0; y < image->h; y++) + for (int x = 0; x < image->w; x++) + if (image->bitmap[y * image->stride + x] >= ALPHA_THRESHOLD) + { + int x_rect = image->dst_x + x - rect->x; + int y_rect = image->dst_y + y - rect->y; + rect->data[0][y_rect * rect->w + x_rect] = color; + } + } + } +} \ No newline at end of file diff --git a/libavcodec/text_to_bitmap.h b/libavcodec/text_to_bitmap.h new file mode 100644 index 0000000000..4cba5889f4 --- /dev/null +++ b/libavcodec/text_to_bitmap.h @@ -0,0 +1,18 @@ +// +// Created by traian on 2022-05-02. +// + +#ifndef FFMPEG_TEXT_TO_BITMAP_H +#define FFMPEG_TEXT_TO_BITMAP_H + +#include +#include "fftools/ffmpeg.h" + +struct ASS_Context; +typedef struct ASS_Context ASS_Context; + +void init_ass_context(InputStream *ist, OutputStream *ost); +void render_avsub_ass(ASS_Context *, AVSubtitle *); +void free_ass_context(ASS_Context *context); + +#endif //FFMPEG_TEXT_TO_BITMAP_H diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 7226911f6c..703dbec37d 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -217,103 +217,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *picref) return ff_filter_frame(outlink, picref); } -#include "../fftools/ffmpeg.h" -#include "libavcodec/avcodec.h" -#include "../libavcodec/ass_split.h" - -#define ALPHA_THRESHOLD 0b10000000 - -void render_avsub_ass(InputStream *, AVSubtitle *, int, int); -void render_avsub_ass(InputStream *ist, AVSubtitle *sub, int frame_width, int frame_height) -{ - ASS_Library *library = ass_library_init(); - ass_set_extract_fonts(library, 1); - ASS_Renderer *renderer = ass_renderer_init(library); - ass_set_frame_size(renderer, frame_width, frame_height); - ass_set_pixel_aspect(renderer, 1); - ass_set_storage_size(renderer, frame_width, frame_height); - ass_set_shaper(renderer, 0); - ass_set_fonts(renderer, NULL, NULL, 1, NULL, 1); - - for (int r = 0; r < sub->num_rects; r++) - { - AVSubtitleRect *rect = sub->rects[r]; - if (rect->data[0]) continue; - - ASSSplitContext *ass_context = ff_ass_split((char *)ist->dec_ctx->subtitle_header); - ASSDialog *dialog = ff_ass_split_dialog(ass_context, rect->ass); - - ASS_Track *track = ass_read_memory(library, (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); - track->n_events = track->max_events = 1; - track->events = (ASS_Event *)malloc(sizeof(ASS_Event)); - track->events[0].Start = sub->start_display_time + sub->pts / (AV_TIME_BASE / 1000); - track->events[0].Duration = sub->end_display_time - sub->start_display_time; - track->events[0].Effect = strdup(dialog->effect); - track->events[0].Layer = dialog->layer; - track->events[0].MarginL = dialog->margin_l; - track->events[0].MarginR = dialog->margin_r; - track->events[0].MarginV = dialog->margin_v; - track->events[0].Name = strdup(dialog->name); - track->events[0].Text = strdup(dialog->text); - track->events[0].ReadOrder = dialog->readorder; - track->events[0].Style = 0; - for (int style = 0; style < track->n_styles; style++) - if (!strcmp(track->styles[style].Name, dialog->style)) - track->events[0].Style = style; - track->events[0].render_priv = NULL; - ff_ass_free_dialog(&dialog); - ff_ass_split_free(ass_context); - - int change; - ASS_Image *image = ass_render_frame(renderer, track, track->events[0].Start + 1, &change); // Don't have to free it for some reason - printf("image: %p\n", image); - - rect->x = image->dst_x; rect->w = 0; - rect->y = image->dst_y; rect->h = 0; - rect->nb_colors = 1; // Transparent background counts as a color - for (ASS_Image *img = image; img != NULL; img = img->next) - { - // Set image bounds to encompass all images - if (img->dst_x < rect->x) rect->x = img->dst_x; - if (img->dst_y < rect->y) rect->y = img->dst_y; - if (img->dst_x + img->w > rect->x + rect->w) - rect->w = img->dst_x + img->w - rect->x; - if (img->dst_y + img->h > rect->y + rect->h) - rect->h = img->dst_y + img->h - rect->y; - rect->nb_colors++; - } - rect->linesize[0] = rect->w; - rect->data[0] = (uint8_t *)malloc(rect->w * rect->h * sizeof(uint8_t)); - rect->data[1] = (uint8_t *)malloc(4 * rect->nb_colors * sizeof(uint8_t)); - memset(rect->data[0], 0, rect->w * rect->h); // Set all to transparent - memset(rect->data[1], 0, 4); // Set transparent color - memset(&rect->linesize[1], 0, 3 * sizeof(int)); - rect->data[2] = rect->data[3] = NULL; - for (int color = 1; image != NULL; image = image->next, color++) - { - // Set color - rect->data[1][4 * color + 0] = AR(image->color); - rect->data[1][4 * color + 1] = AG(image->color); - rect->data[1][4 * color + 2] = AB(image->color); - rect->data[1][4 * color + 3] = AA(image->color); - // Set pixels - for (int y = 0; y < image->h; y++) - for (int x = 0; x < image->w; x++) - if (image->bitmap[y * image->stride + x] >= ALPHA_THRESHOLD) - { - int x_rect = image->dst_x + x - rect->x; - int y_rect = image->dst_y + y - rect->y; - rect->data[0][y_rect * rect->w + x_rect] = color; - } - } - - ass_free_track(track); - } - - ass_renderer_done(renderer); - ass_library_done(library); -} - static const AVFilterPad ass_inputs[] = { { .name = "default", From patchwork Tue May 3 16:13:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35572 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496775pzb; Tue, 3 May 2022 09:15:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5ZkktVtI5wecLaiEfr77Z/kr1IHM9zfC82x+XQpqU4/aqsWyZ48xSx2bjKss6m0AS8A3d X-Received: by 2002:a17:906:7f02:b0:6cf:86d8:c31c with SMTP id d2-20020a1709067f0200b006cf86d8c31cmr16919243ejr.518.1651594509986; Tue, 03 May 2022 09:15:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594509; cv=none; d=google.com; s=arc-20160816; b=mVupz0ZAhp0IDEdtNXR7U+bAE6inyJyrlqePZ8QsXPOLR02X6vx9KM2nC9SSJRq6Nx GyyE5vYd2hKTHU88UR3OVFzsrc8EA4IgXh+M79ksrxtq0o/xGiY7br4eKJBibPbDeIbE YXpMy7eSU4aEf0g8QehukEiDhE6u7JDMHlJSxByhE6qvJckSfdmHMcSx48b22fhVw3hX QuHpLn1cKewtcMoxIZI2gmV9HZGgUhfKHddJnF2kgEgPURgjVbkNpvhtN7bzehySAdAu F4JDsZgjMtKZWCXLj0xMtPoH2eunuMoQeXRHYVZCiMNu8BRNEGBRd1IBdwKOwKPSyrD6 SbSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=tvktJClgfDAug2Sh4U/Z+mQutJWh0FExnA3pb2rtlaY=; b=loO45yqaXwwItFKAuawS8XUUYKYJqaFfvfpoopAzDP0KBKQ1Dx9h/JRKV6T5Gdycej 0UjndCZo/7adFRRHxJQyqmI89LnySszsWXr0su6zHFMEnikwmSK3q3oQ934EMzyF0KK/ QEXEIqY66C+D7hj206G2EA3/Zf+WyFUFminQ79Fy5iHSlVHn80bqlcgFgWp3Y/yZqx94 Np+7X6ua1+p79EXzmryqHfA6fbIWY2a9sdLQ32Ndb8HvxGjP5vqig/GafcjKbfamjhn3 876PXH1ZfbQbX6CoZpi8ACpfeNttiXRTYhPfIH241fs1HJ4l/aqmeyynsf93I+m1/Z87 2GdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=EfC+tJyr; 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 x18-20020a50f192000000b0041d9354ecacsi14336950edl.222.2022.05.03.09.15.09; Tue, 03 May 2022 09:15:09 -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=20210112 header.b=EfC+tJyr; 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 543AE68B37F; Tue, 3 May 2022 19:14:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3613E68B3AB for ; Tue, 3 May 2022 19:13:55 +0300 (EEST) Received: by mail-qt1-f181.google.com with SMTP id hh4so13875729qtb.10 for ; Tue, 03 May 2022 09:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kEV9h0Wn4yluFZi4z6x3hYJkhCw/nvaLORhTvKrbitk=; b=EfC+tJyrV20vYZc4K4m3Zh102bkGXAUeYFH7sb6djTDq2lgVnKltlXvEQbkHis0HVr EVwBjq1+CHVeDGGAGoNWiu5EvLGTF7gS+jaYAOnduoxpo9t2PzYjOrhx1Eyj9Vay1HJg MpdEusDYS+2t9/SHCKu3VbYexmHZ1SBDViQhlvPiy6JbIE/KSahiaeZxFz+00qRpaOUW zec4xueC8CkxHNDJ9s6Pcv95hu9+meD1pTry2/waoAqDXx0SY2lM7sRGHk3eeCsINZyX pj0HGV5SAOHs8DXLi91naL5BFWGHavFrYJj1ree/i995gcEH77wucIAYXX702pr2P1fv eWnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kEV9h0Wn4yluFZi4z6x3hYJkhCw/nvaLORhTvKrbitk=; b=vCamc+cmIGjKbknvrccsLEX2ljljCmq0mGSo3bPc7g7G5OxFQIyuj+/fZn0WFMuKuo oQmHTYKmgmm8s3g+9261O/D4aZwrIMwfEXTj64d9q+nGTsT5hrF/5tSyJzAJTxVYIrC3 yhijnbeiojW+q07knLEbAT+53fOwAsdX7W2852NSdBAY+mzMUaGSWvEKE7zE5+ULswcV Cbyp2qleUpQKyTVZ1Xi2qe0EQtF8AR2uD1xG7qqse6MRD6wlKZAFPp0/vbu9bphLNddJ KAo82NOPtnxwXfd2j8PVYNopU3hyGUG/lQYqL7hRkd1nOpBVxcuSYJzNGwKg3QGMZ0wp zspg== X-Gm-Message-State: AOAM5302Hi+9dDPBtVMTWUpU5THCqK0OvFkXbNz71ZLpTh9q6KBGz5C3 FnziCV5gftJodAjyUE+X1iqYewobEcmW X-Received: by 2002:a05:622a:587:b0:2f3:a51d:9215 with SMTP id c7-20020a05622a058700b002f3a51d9215mr9760846qtb.345.1651594433807; Tue, 03 May 2022 09:13:53 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:53 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:21 -0400 Message-Id: <20220503161328.842587-6-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/12] Cleaned up X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Nm1tb0I1Zceh --- fftools/ffmpeg.c | 39 ++----------------------- libavcodec/text_to_bitmap.c | 58 +++++++++++++++++++++++++++++++++++-- libavfilter/vf_subtitles.c | 18 ------------ 3 files changed, 58 insertions(+), 57 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 31acf08a6a..0ff9da7bf4 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2329,43 +2329,6 @@ fail: return err < 0 ? err : ret; } -static void print_subtitle(AVSubtitle sub) -{ - printf("sub.format: %u\n", sub.format); - printf("sub.start_display_time: %u\n", sub.start_display_time); - printf("sub.end_display_time: %u\n", sub.end_display_time); - printf("sub.num_rects: %u\n", sub.num_rects); - printf("sub.pts: %ld\n", sub.pts); - for (int i = 0; i < sub.num_rects; i++) - { - printf("sub.rects[%d]->type: %d\n", i, sub.rects[i]->type); - printf("sub.rects[%d]->nb_colors: %d\n", i, sub.rects[i]->nb_colors); - printf("sub.rects[%d]->(x,y,w,h): (%d,%d,%d,%d)\n", i, sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h); - printf("sub.rects[%d]->linesize: [%d,%d,%d,%d]\n", i, sub.rects[i]->linesize[0], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1]); - switch (sub.rects[i]->type) - { - case SUBTITLE_TEXT: - printf("sub.rects[%d]->text: %s\n", i, sub.rects[i]->text); - break; - case SUBTITLE_ASS: - printf("sub.rects[%d]->ass: %s\n", i, sub.rects[i]->ass); - break; - case SUBTITLE_BITMAP: - for (int c = 0; c < sub.rects[i]->nb_colors; c++) - printf("color %d: [%u,%u,%u,%u]\n", c, - sub.rects[i]->data[1][c * 4 + 0], - sub.rects[i]->data[1][c * 4 + 1], - sub.rects[i]->data[1][c * 4 + 2], - sub.rects[i]->data[1][c * 4 + 3]); - for (int y = 0; y < sub.rects[i]->h; y++, printf("\n")) - for (int x = 0; x < sub.rects[i]->w; x++) - printf("%d", sub.rects[i]->data[0][y * sub.rects[i]->w + x]); - break; - } - } - printf("\n"); -} - static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, int *decode_failed) { @@ -2433,6 +2396,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) continue; +#if CONFIG_LIBASS // Support text to bitmap if (avcodec_descriptor_get(ost->enc_ctx->codec_id)->props & AV_CODEC_PROP_BITMAP_SUB) if (avcodec_descriptor_get(ist->dec_ctx->codec_id)->props & AV_CODEC_PROP_TEXT_SUB) @@ -2442,6 +2406,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, subtitle.rects[r]->type = SUBTITLE_BITMAP; rendered = 1; } +#endif do_subtitle_out(output_files[ost->file_index], ost, &subtitle); } diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c index 87c46985d9..50c72afc55 100644 --- a/libavcodec/text_to_bitmap.c +++ b/libavcodec/text_to_bitmap.c @@ -94,7 +94,6 @@ void free_ass_context(ASS_Context *context) { void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) { - printf("render_avsub_ass\n"); for (int r = 0; r < sub->num_rects; r++) { AVSubtitleRect *rect = sub->rects[r]; @@ -167,4 +166,59 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) } } } -} \ No newline at end of file +} + +static void print_ass_image(const ASS_Image *image) +{ + int index = 0; + for (; image != NULL; image = image->next, index++) + { + printf("index: %d\n", index); + printf("image->(dst_x,dst_y): (%d,%d)\n", image->dst_x, image->dst_y); + printf("image->(w,h): (%d,%d)\n", image->w, image->h); + printf("image->stride: %d\n", image->stride); + printf("image->type: %d\n", image->type); + printf("image->color: [%u,%u,%u,%u]\n", AR(image->color), AG(image->color), AB(image->color), AA(image->color)); + for (int y = 0; y < image->h; y++, printf("\n")) + for (int x = 0; x < image->w; x++) + printf("%02X", image->bitmap[y * image->stride + x]); + printf("\n"); + } +} + +static void print_subtitle(AVSubtitle sub) +{ + printf("sub.format: %u\n", sub.format); + printf("sub.start_display_time: %u\n", sub.start_display_time); + printf("sub.end_display_time: %u\n", sub.end_display_time); + printf("sub.num_rects: %u\n", sub.num_rects); + printf("sub.pts: %ld\n", sub.pts); + for (int i = 0; i < sub.num_rects; i++) + { + printf("sub.rects[%d]->type: %d\n", i, sub.rects[i]->type); + printf("sub.rects[%d]->nb_colors: %d\n", i, sub.rects[i]->nb_colors); + printf("sub.rects[%d]->(x,y,w,h): (%d,%d,%d,%d)\n", i, sub.rects[i]->x, sub.rects[i]->y, sub.rects[i]->w, sub.rects[i]->h); + printf("sub.rects[%d]->linesize: [%d,%d,%d,%d]\n", i, sub.rects[i]->linesize[0], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1], sub.rects[i]->linesize[1]); + switch (sub.rects[i]->type) + { + case SUBTITLE_TEXT: + printf("sub.rects[%d]->text: %s\n", i, sub.rects[i]->text); + break; + case SUBTITLE_ASS: + printf("sub.rects[%d]->ass: %s\n", i, sub.rects[i]->ass); + break; + case SUBTITLE_BITMAP: + for (int c = 0; c < sub.rects[i]->nb_colors; c++) + printf("color %d: [%u,%u,%u,%u]\n", c, + sub.rects[i]->data[1][c * 4 + 0], + sub.rects[i]->data[1][c * 4 + 1], + sub.rects[i]->data[1][c * 4 + 2], + sub.rects[i]->data[1][c * 4 + 3]); + for (int y = 0; y < sub.rects[i]->h; y++, printf("\n")) + for (int x = 0; x < sub.rects[i]->w; x++) + printf("%d", sub.rects[i]->data[0][y * sub.rects[i]->w + x]); + break; + } + } + printf("\n"); +} diff --git a/libavfilter/vf_subtitles.c b/libavfilter/vf_subtitles.c index 703dbec37d..82e140e986 100644 --- a/libavfilter/vf_subtitles.c +++ b/libavfilter/vf_subtitles.c @@ -181,24 +181,6 @@ static void overlay_ass_image(AssContext *ass, AVFrame *picref, } } -static void print_ass_image(const ASS_Image *image) -{ - int index = 0; - for (; image != NULL; image = image->next, index++) - { - printf("index: %d\n", index); - printf("image->(dst_x,dst_y): (%d,%d)\n", image->dst_x, image->dst_y); - printf("image->(w,h): (%d,%d)\n", image->w, image->h); - printf("image->stride: %d\n", image->stride); - printf("image->type: %d\n", image->type); - printf("image->color: [%u,%u,%u,%u]\n", AR(image->color), AG(image->color), AB(image->color), AA(image->color)); - for (int y = 0; y < image->h; y++, printf("\n")) - for (int x = 0; x < image->w; x++) - printf("%02X", image->bitmap[y * image->stride + x]); - printf("\n"); - } -} - static int filter_frame(AVFilterLink *inlink, AVFrame *picref) { AVFilterContext *ctx = inlink->dst; From patchwork Tue May 3 16:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35565 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp497091pzb; Tue, 3 May 2022 09:15:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwNNRfzPGuMgd4WCGkex/6KhgvYnCTh13Obxb0o7FLEHTWslgWwAM4GLIY3vKTlWOgTFGM X-Received: by 2002:aa7:d4d4:0:b0:427:5f6:c5d0 with SMTP id t20-20020aa7d4d4000000b0042705f6c5d0mr18772463edr.207.1651594544814; Tue, 03 May 2022 09:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594544; cv=none; d=google.com; s=arc-20160816; b=al8HNrlPRMfZR4hS5DbwLJYeuwbG7iOLKF6OSBCR44dqUQjZbiAgwR1iUTOjz4Ejp9 s5m7UVuWCawSIEJofHQvf1MinAkQjaVB7tHI2CMFnVbX1hPrSYlI32rBXpRS8+eEBRDB wGCl9aVpeZ2OuSYOO+gPpIiucLKzPZ669Pq2uDhP4s5zXWTIZxTZC5NUdRNl2np09eoN QZlScKF/hIKI6erARZgDCV1ekrqicf/VnKCPvO77USLBGCIZgRGoXxZiZtkExT7wr6IS yDkDHocdP2s8lnUzEmqVuc+Nyt/n2d1Af3ykAvCeGfT5WFdCtGjozRZF33YzocWc595E qsyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=UnGqe+kESueD11BgMP2EDRiauZ64nGLa/wnRvC5Lf6A=; b=QZ8/IrfzIVDTtrlQKQEqZFjeZm5zH/cS5LV3SoscI18/7I/PB28E8dw/cIJN16cpfL 4l1Kxf7kJFjncAQRi2jTxgNTZo4pkDNZFcOzGAyfTucCAKkTaSzwSPbQtHKxbdTaNzaX Z/JWsPZDTuMKsFfAjWcjwOz/diQntz+ttlG7n0H370a8lIH36ilIN2Vov/vbKWi9sRTq QJ5+tc4DQyOFaZtlZo3DYPyn8FZNM+K30gNoVpO4IAOEwyZY1WCEj1rGie3CpucUlWFr drKcA9UBnzibIsMDx4GkdctjBpeeq0cAWtdMVnvxRX2jgQhASV3vZcO/fMum1+XPlOCr rjDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="PBz/wt90"; 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 g15-20020a056402424f00b00427b097c73dsi8034423edb.75.2022.05.03.09.15.43; Tue, 03 May 2022 09:15:44 -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=20210112 header.b="PBz/wt90"; 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 3B4B068B3D8; Tue, 3 May 2022 19:14:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE38168B3BA for ; Tue, 3 May 2022 19:13:55 +0300 (EEST) Received: by mail-qk1-f176.google.com with SMTP id v9so3373181qkp.11 for ; Tue, 03 May 2022 09:13:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=j1xfHNu2QFCAJ4EEs+qJZOVuUu9vH/mRvksIDMD1Fa4=; b=PBz/wt90nE6CXZDEO4Q0pE9ofv3CPyJtgRgXuSRcNd2FMBwcA53oHhqHNCrCjZXMFg 1GdOmlrkWPXmUyUrviA7FYs82TELU41xeZ43aDBIbCKDB+PLQs6cU+0WK26CFtZU7QHY QNznJpuUyxWcZROm0mhWixiBO5LWDoBrrLWx/6KpN9BJzI11b4rQ/jA17V50bs8wVUh8 g7FcoNjIBTIZnrqZ2FcYyw5AkROJIfDOLq+6fW7IQMH312w8zQkxcF+qQpUEfLTss+o2 AaRukJSNsmwbKAZGY/1pmVOzMfFjnlRh86SD3DUCvwDgzJK8ySSYYuS74Yo8t6eYAw/H mrRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=j1xfHNu2QFCAJ4EEs+qJZOVuUu9vH/mRvksIDMD1Fa4=; b=zfcU3Y7UdWuO+49kMhyOcFLHncpyz5mgmyDmt1ckm7FLe3lqikZwkvj9ViYC2DzkrG jPZHYeghPXAG3xgqeyJx3y6oEY3UIj78cLuSShOopopsPZqwo0rnSA8lu+iwfdz8E+ks IoBZIB22+bILdV2HsOSD4gFjJ7rQ5CM9nubxMnsmV2NB23yp9NQ0nBTqSxAtPyTwj1NS AR/az5c1xayoC7FM+uzwaIFI6gQi7lbzbsjXZDSCjki4WWd518DtLWAoAOldFxYHo8gw oflgWKOzMCvHBOgPNPP8dRku3SVyB+/Gm5jMWbekA+qYmC87C3Wz49SErCuR+W7vqjuT Wbog== X-Gm-Message-State: AOAM531fmw8y7MVXCtuT7F0vHWLPSLpwi5TO3KdDpGpjQTxE7aG/t7FR /6eAjlBQPif1w40YzvtKRxvNKvgL3XUA X-Received: by 2002:ae9:e887:0:b0:69f:9a9d:aa04 with SMTP id a129-20020ae9e887000000b0069f9a9daa04mr12781932qkg.31.1651594434591; Tue, 03 May 2022 09:13:54 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:54 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:22 -0400 Message-Id: <20220503161328.842587-7-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/12] Wrote proper headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: gaHWFvnbidmr --- libavcodec/text_to_bitmap.c | 9 ++++++--- libavcodec/text_to_bitmap.h | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c index 50c72afc55..273564cb67 100644 --- a/libavcodec/text_to_bitmap.c +++ b/libavcodec/text_to_bitmap.c @@ -1,6 +1,9 @@ -// -// Created by traian on 2022-05-02. -// +/** + * text to bitmap support code. + * + * This file contains a function to initiate the functionality for a stream, + * to render any AVSubtitle structure, and to free the structures allocated at the start + */ #include "text_to_bitmap.h" diff --git a/libavcodec/text_to_bitmap.h b/libavcodec/text_to_bitmap.h index 4cba5889f4..37d346ae0c 100644 --- a/libavcodec/text_to_bitmap.h +++ b/libavcodec/text_to_bitmap.h @@ -1,6 +1,6 @@ -// -// Created by traian on 2022-05-02. -// +/** + * text_to_bitmap header file + */ #ifndef FFMPEG_TEXT_TO_BITMAP_H #define FFMPEG_TEXT_TO_BITMAP_H From patchwork Tue May 3 16:13:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35576 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp497350pzb; Tue, 3 May 2022 09:16:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZI9aOZart19U67A4dsfQ3ZnkyNG+VG2gn296KdGjYglYtigLvZKXGKmhatWQKcGXO7+zS X-Received: by 2002:a50:fa94:0:b0:425:e8ac:3fb4 with SMTP id w20-20020a50fa94000000b00425e8ac3fb4mr18631182edr.43.1651594568007; Tue, 03 May 2022 09:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594568; cv=none; d=google.com; s=arc-20160816; b=z9vlZD45zz8L2vQSEehUmjXox8Gi7S1D7UAUpl7H+3fwlDhtcZEceA3oI7pgBBzeVv qcqEyNZs3C+aJTnjWk0PG0qAET8EUuEuA3Cb+dBOkvAg0R9keRB0R+v1MxC2gxlfcIWW vHyxVxEEbKM2SWZVVidxsrt0MRWIcbBHkds3/L7MFgPgSDNvEYDWUwNoZNKY0EYSEGy4 QMkDD45cKTgsp6c8hi5ShuN5AL9bAD3axjdshKypksDG33aYiN65028BFCdL9p7CDmhR zHyn2u3dPcMV5qTCduFZIl2ftUV57JEJMFRmiryBKJuC+sL3UmygV3Y5tI+YedLOHKYw sGOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=QcYDsI8d3lEL+QM+bqc0+QXNoRrxxl5iqIoBwxUX1F0=; b=lasRJyIXTTMFu3R4jgBIg2QgGjU0s7eZlm57cvUTConm4YcqgkUxsKcMchjYg6TBdf VxCLlj6Qz4OZCFp8NSZU0Jt5wsBhX014LHsQSxsim8FPRSRpcanrQL/CaW3z4DdlT0II ogTMhSe6yrVE0TcAAFyMgMBaUhdGM7cq3Rn9gw/0dp1D6ZjdDOfcYWzQ1y8z4lCncOWq BYKPFkozlUkx5+ix/afoz9BqRhWD0aNk7k1nqFh9ksC2hWLo7UWyz7bfC6MVpELrL44m rvXjq7cly+0p085v31wwgoeTgTYcMLk6QaDUfewKyeWlHRs6cQqG//eOiPX2HYmcXDlX HEow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Ny91Dmqv; 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 f14-20020a170906c08e00b006e87e97d30csi14563563ejz.197.2022.05.03.09.16.07; Tue, 03 May 2022 09:16:07 -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=20210112 header.b=Ny91Dmqv; 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 42BF868B3ED; Tue, 3 May 2022 19:14:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D8A8968B3BD for ; Tue, 3 May 2022 19:13:56 +0300 (EEST) Received: by mail-qk1-f178.google.com with SMTP id j9so14120544qkg.1 for ; Tue, 03 May 2022 09:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tGf462WMOWga0AoPIOKuTodklNzjJbQlP7q7/GSJwt4=; b=Ny91Dmqv6H//dayFWNKXz5E7K43Dy8ts5dAIqVDMFkmcYH1stvkjSusEp8g/Zryeiq JHLFwl/d6pwMJZ0x+kvjAuYHGFbXeHrCw/RCNa4LcdjITyP29oD5TGlSSKZdx7/2qNhy MupeBhVvj2gs8POBaoSkov+Hljb6UqMGssL0CT0zdYdhj1ZkWvyiEdkvbkRQ955aZlM+ dYyi1zq9sQ3u1n9BPW5rB1MtGqeaqoeqT7dh1TcDd6izhbKje3kpAe71z5i8uSKUnLcx tzpQJ4WGslK7GFwF+V++MQQ2fF2FPYhXuKkX6tunqe2OmIn5afb7qCEaq/uxe5JUzXrH bptQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tGf462WMOWga0AoPIOKuTodklNzjJbQlP7q7/GSJwt4=; b=7QEgvm4WvgJ7Wiz2rmCjtz5m4e0KtzzOVUkLWMvDTfQObCxdEMjNr88mAOXFwbaFE1 g9hbERMVGhXJCxmrSw93qZTr2lFZ/KDjW4j0PdY8PgFpMf2hbsndy6uoVXfgAbbF+NFm oywIR/TPhuXFtv8NXXvX9xNMjnJpi2Ors5DrNL/MHe7FEEwUPUI7CveCZYotnwa6yF9W VUmvGBgiaMAQ8ElT/2AHePewJRpFOPhy8uBslibgFVMDqcsKh/fX7vha1bevYKUeZfYu 85q+U1C0P7qjdmPqdSgeRJ8D5z5rC0wU6C4OLNQ3Rw+vvIH6qEtEQpgQGQrGRpNFyo1K n7yA== X-Gm-Message-State: AOAM533EX5eVjfrFV3RuWy79r1R60yg2fKZ1BnSq37AQvTz2DmXT7MZV Yr4iND5m2kGTKRTg6FV17ZpzUHVUkp3I X-Received: by 2002:a37:b95:0:b0:69f:b96d:ff4e with SMTP id 143-20020a370b95000000b0069fb96dff4emr12895796qkl.373.1651594435493; Tue, 03 May 2022 09:13:55 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:55 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:23 -0400 Message-Id: <20220503161328.842587-8-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/12] Close libass after using X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UBVVViQhYAdJ --- fftools/ffmpeg.c | 2 +- libavcodec/avcodec.c | 9 +++++++++ libavcodec/text_to_bitmap.c | 13 +++++++++++-- libavcodec/text_to_bitmap.h | 8 +++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 0ff9da7bf4..ae622492ee 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3239,7 +3239,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return AVERROR_INVALIDDATA; } if (input_props == AV_CODEC_PROP_TEXT_SUB && output_props == AV_CODEC_PROP_BITMAP_SUB) - init_ass_context(ist, ost); + init_ass_context(input_streams, output_streams, nb_input_streams, nb_output_streams, ost->source_index, ost->index); #else if (input_props && output_props && input_props != output_props) { snprintf(error, error_len, diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index d11f035481..1e308f39c2 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -42,6 +42,10 @@ #include "thread.h" #include "version.h" +#if CONFIG_LIBASS +#include "libavcodec/text_to_bitmap.h" +#endif + #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; @@ -534,6 +538,11 @@ av_cold int avcodec_close(AVCodecContext *avctx) } else if (av_codec_is_decoder(avctx->codec)) av_freep(&avctx->subtitle_header); +#if CONFIG_LIBASS + if (av_codec_is_decoder(avctx->codec) && avctx->ass_context != NULL) + free_ass_context(avctx->ass_context); +#endif + avctx->codec = NULL; avctx->active_thread_type = 0; diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c index 273564cb67..c419e89c20 100644 --- a/libavcodec/text_to_bitmap.c +++ b/libavcodec/text_to_bitmap.c @@ -18,13 +18,22 @@ struct ASS_Context { ASSSplitContext *ass_split_context; }; -void init_ass_context(InputStream *ist, OutputStream *ost) +void init_ass_context( + InputStream **input_streams, + OutputStream **output_streams, + int nb_input_streams, + int nb_output_streams, + int ist_i, + int ost_i) { + InputStream *ist = input_streams[ist_i]; + OutputStream *ost = output_streams[ost_i]; if (ist->dec_ctx->ass_context) return; + ASS_Context *context = (ASS_Context *)malloc(sizeof(ASS_Context)); context->library = ass_library_init(); ass_set_extract_fonts(context->library, 1); - // TODO: ass_add_font(context->library, ); + // TODO: ass_add_font(context->library, ...); // Try to get a height and width from somewhere int width = 0, height = 0; diff --git a/libavcodec/text_to_bitmap.h b/libavcodec/text_to_bitmap.h index 37d346ae0c..0c4689b039 100644 --- a/libavcodec/text_to_bitmap.h +++ b/libavcodec/text_to_bitmap.h @@ -11,7 +11,13 @@ struct ASS_Context; typedef struct ASS_Context ASS_Context; -void init_ass_context(InputStream *ist, OutputStream *ost); +void init_ass_context( + InputStream **input_streams, + OutputStream **output_streams, + int nb_input_streams, + int nb_output_streams, + int ist_i, + int ost_i); void render_avsub_ass(ASS_Context *, AVSubtitle *); void free_ass_context(ASS_Context *context); From patchwork Tue May 3 16:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35569 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496450pzb; Tue, 3 May 2022 09:14:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwODh6R5Pb4ZVEBktYLQdLi5xN/pGAN0BZ2A+2slmqV2ZO2jxnkU9Va7HG04ek9g7qnrfd4 X-Received: by 2002:a17:907:7282:b0:6ef:f412:f7c4 with SMTP id dt2-20020a170907728200b006eff412f7c4mr16123359ejc.258.1651594473604; Tue, 03 May 2022 09:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594473; cv=none; d=google.com; s=arc-20160816; b=PG40acRK/hO/62coAj9tztJMkA18BF6v6gyph+C2A3pC4cgIQoi+Ai3k2NFFDMUxpL 1vaHNdoMs9U1IgTK4ldDmZ7D7BaLhQpUQg2mMuXe0OiZTR0Ir/CH0x+PHjSC37yrX4n9 29MUUAw0T6rd0cKRAiDqapcq1EGf5drnt+Kloo5pMiB+dEiZVhqt3/Jd77R6LgburMna XF/LQh3EAWN2YQcPfb5RJ52OKIKQT54cLmAqg8z/LZUgUuDusTSDh3KF7d3+Yvhn4PDR 9Spw6dcy/CXaQzDWf5s4oSuykWldxo7JrXCiu9wskmgDYMLwIMAVkrP8BidpOPadP4Tv K+sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=9XmzVQplqNppWbt/n7+1dq3mCuVc8PX+IDWYOtSg3wg=; b=Ae+Y5oFH6FtJY82oHAFBxGg9JwGhchEo9ylAzm9gVvCW2QsiEHMeFY5qkAhru6pzXQ WBrH9NTJ3D5nqNOa4jkea4icNIPRS5Bpv2S8xKErlO1wFN+e8sGgbo+0JHz33kuNMjfa aPluX6/plEcpVbCJqZsz+CYgExDdK9LJm4etp5dA/aS3vh5M2XH6oAqawwJfsSbfcDLK FAoiqskEdbXGGps/SBenrB0f6XkJEyvDAFKR0h9TlkX1bHF+vLWt2AmzkMfgJhJ0N6+h X1QcgVs8nhyCJxNL+17gmnB8SHJjIMnS6G9Zm0J0sgHELpwTON9QZ33ZpjqUZ51CSd4T 829w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=iRx3MXaD; 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 cw27-20020a056402229b00b00423fb5cb330si11910308edb.187.2022.05.03.09.14.33; Tue, 03 May 2022 09:14:33 -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=20210112 header.b=iRx3MXaD; 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 49F6F68B3AD; Tue, 3 May 2022 19:14:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10E3568B37A for ; Tue, 3 May 2022 19:13:57 +0300 (EEST) Received: by mail-qt1-f173.google.com with SMTP id hf18so13891275qtb.0 for ; Tue, 03 May 2022 09:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6fHKcLGUJ923gfkioUAXu+P5r3PLkV2chh8tb8r2CAo=; b=iRx3MXaDzzsnha3dYW8MKfCY9kZRtKRdKBVNp3M1sdY2r2wEC/IZNGXZth3M0Rpa+X TxRBCE+Vtbjxx31o5+fjsL6Y6ln+jvnK1q79YDrkIhqsTAc5K/PumBj7KJAIKBH6U571 vWSqcjoutZLpPz2sWXjj3iFIKjP1H+tdA/9po0Xr6CyEH7qWOLugwABG0oiLEesUlSMV Qj5Oy+xutNJuv26fC4KFU8Dc0N9O6bo7zV0b6fy5v4RO4lUwceDiIO+FCscufgix462b n+Qv4/5Gzn1CRwMZQwq4l53othHlOvV23+RTMjdiKsEM+jSHdq6WF7FJFmqTuJeokJoe 9P5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6fHKcLGUJ923gfkioUAXu+P5r3PLkV2chh8tb8r2CAo=; b=CrQQq7v3lp5twUjy4RPwghEwlG3jWtqEJl2hJmgSaL9yCxCWcbzNGS66CqhevGUA1V sTK9DMF4VeZX4cMeVKRhJAd61OgKL+8+gehQjeW4CwoRpgkf5icwCzLTsU8xWsYn608j dstVbqtXA7lmL3rHoQ1t9c5b3NZc9QzoYKVGXL2lBmVPj5pYw9SB4TX+tnHbvhWehL0W VYIoiTAxpqXEycqvJDXTo7A3ub/ScojCKeDp64b0a0rEmAbW/lo3aaaxM8WhvbjhrUo4 G0lPk7FzudjF6HQYfPjuDPdPEF4rrSz2YoruHb44a5XcpUbeevpWWgu6UxPP7BwDH3Gb x4TA== X-Gm-Message-State: AOAM531C3TQ3C0XRjRM85jQKyLE2muBCXZbXEz66Zn5R4gYMdWP9n+fg 8uOBYSwnsmHi4/NFCHn86mJkzENKJAvt X-Received: by 2002:a05:622a:44d:b0:2f3:b4ea:1bb6 with SMTP id o13-20020a05622a044d00b002f3b4ea1bb6mr323208qtx.480.1651594436383; Tue, 03 May 2022 09:13:56 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:55 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:24 -0400 Message-Id: <20220503161328.842587-9-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/12] Added standard headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: g+FhxV/dQPcF --- libavcodec/text_to_bitmap.c | 47 ++++++++++++++++++++++++++++++++++++- libavcodec/text_to_bitmap.h | 25 +++++++++++++++++--- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c index c419e89c20..52d161d7b1 100644 --- a/libavcodec/text_to_bitmap.c +++ b/libavcodec/text_to_bitmap.c @@ -1,4 +1,23 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** + * @file * text to bitmap support code. * * This file contains a function to initiate the functionality for a stream, @@ -11,6 +30,9 @@ #include "avcodec.h" #include "ass_split.h" +/** + * Holds the objects used by the rendering function so they don't have to be reinitialized every time + */ struct ASS_Context { ASS_Library *library; ASS_Renderer *renderer; @@ -18,6 +40,17 @@ struct ASS_Context { ASSSplitContext *ass_split_context; }; +/** + * Initiates the ASS_Context structure and adds it to the input stream decoder context. + * Does nothing if ist->dec_ctx->ass_context is already set. + * It needs all these arguments because it searches for a frame size in all the streams + * @param input_streams + * @param output_streams + * @param nb_input_streams + * @param nb_output_streams + * @param ist_i index of input stream for transcoding + * @param ost_i index of output stream for transcoding + */ void init_ass_context( InputStream **input_streams, OutputStream **output_streams, @@ -82,12 +115,17 @@ void init_ass_context( ass_set_shaper(context->renderer, 0); ass_set_fonts(context->renderer, NULL, NULL, 1, NULL, 1); - context->track = ass_read_memory(context->library, (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); + context->track = ass_read_memory(context->library, + (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); context->ass_split_context = ff_ass_split((char *)ist->dec_ctx->subtitle_header); ist->dec_ctx->ass_context = context; } +/** + * Frees what was allocated in init_ass_context + * @param context + */ void free_ass_context(ASS_Context *context) { ass_library_done(context->library); ass_renderer_done(context->renderer); @@ -104,6 +142,11 @@ void free_ass_context(ASS_Context *context) { #define ALPHA_THRESHOLD 0b10000000 +/** + * Renders the AVSubtitle and sets the bitmap data for each AVSubtitleRect + * @param context + * @param sub + */ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) { for (int r = 0; r < sub->num_rects; r++) @@ -180,6 +223,7 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) } } +/* static void print_ass_image(const ASS_Image *image) { int index = 0; @@ -234,3 +278,4 @@ static void print_subtitle(AVSubtitle sub) } printf("\n"); } +*/ \ No newline at end of file diff --git a/libavcodec/text_to_bitmap.h b/libavcodec/text_to_bitmap.h index 0c4689b039..29037150c2 100644 --- a/libavcodec/text_to_bitmap.h +++ b/libavcodec/text_to_bitmap.h @@ -1,9 +1,28 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** + * @file * text_to_bitmap header file */ -#ifndef FFMPEG_TEXT_TO_BITMAP_H -#define FFMPEG_TEXT_TO_BITMAP_H +#ifndef AVCODEC_TEXT_TO_BITMAP_H +#define AVCODEC_TEXT_TO_BITMAP_H #include #include "fftools/ffmpeg.h" @@ -21,4 +40,4 @@ void init_ass_context( void render_avsub_ass(ASS_Context *, AVSubtitle *); void free_ass_context(ASS_Context *context); -#endif //FFMPEG_TEXT_TO_BITMAP_H +#endif //AVCODEC_TEXT_TO_BITMAP_H From patchwork Tue May 3 16:13:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35571 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496677pzb; Tue, 3 May 2022 09:14:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOH9YklmpAYBiLcWqFueIrVdZqOwuHbn+YocQwF4PThwD8Vl0sc9f5mgoMWuBlGZReQeIn X-Received: by 2002:a05:6402:2804:b0:420:caf1:961c with SMTP id h4-20020a056402280400b00420caf1961cmr18775657ede.280.1651594498375; Tue, 03 May 2022 09:14:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594498; cv=none; d=google.com; s=arc-20160816; b=WGiuKfRcFumgrUJtFTp9qpz3JdkqMR8gSt7SFx/DH8sEUit2tc8aUu+QQNgZdySeOa lJEBbs+K5IVfOg7dy6qnEXOMXpcY8l5xYK6sd3+fY8DKCxs9eUayYBfS/4H+fDVQWC96 1BgxNeyGYPGZkV+WPgwjLVGLnXS3qWfiHTcsrqHnuz/RYt8cgrJmAZBZAmc1TCHK1zWy q62snAKXPdZRQCwB25EYhdLZCFxFvBt5c6O7iUUz/qA+z2CFGR/qgnthFnC3gdvQosZw CZibU7ZWrceri1hogXh/hMG05KH6Z5ArQe0wf3P/0ag4ZcSQCC8JK3SVc0cjt9ii1tdl k5AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=5m4Y2Y4B3z9ax2nDAZJrMlO4BHT5unOVo0v7eB+bkHw=; b=YOl2vrr/vkaEoDhbQhTw7LoGJS8hx4ZtY0HiKUTVA0ZqUxgmiV3mViyUTBHl0vV9Ti gMzqbFnGLTXi8maIUxPaCceADDlQC9uVcg1fBce098JpbzjtqIq8FN6JMj+wjlHtPwtF 6PTpUe9as/wGxUur6roK8GaS9BdYCG5vOcKEt5k95M9ytQBNtn8NOz/tBSTZYqHmu9/q zo9z3bOUFGHPj5UJC+DaYaBTZ0NBH9lzWnj9OIEZYnLoRSPNvqGUxP119T/n5MdwMRgd ZwFt6iSuBPisZ42OXZErjA6r7qPx9vD8xHbthimch7o6wG3HmF/MFjcLoqfqTygN/LF+ YrIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=BCIYf8lz; 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 z16-20020a1709060ad000b006f01fd542c2si13921782ejf.606.2022.05.03.09.14.58; Tue, 03 May 2022 09:14: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=20210112 header.b=BCIYf8lz; 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 491E168B3BD; Tue, 3 May 2022 19:14:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9FBD568B3A8 for ; Tue, 3 May 2022 19:13:58 +0300 (EEST) Received: by mail-qk1-f172.google.com with SMTP id c1so14070511qkf.13 for ; Tue, 03 May 2022 09:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=L4yYh83y0//brfb4x9RxTPqQ/IhjV6WrglZVAYeGebQ=; b=BCIYf8lzn6tOYM01t98ugLewVKhKA+BfeGieEInnTEL0ARowYENjJW3q3NDLqEqFci DQD4wfsckSqcRVxjev+YZ111jS1eg63ke0G+A/uXnBAtwyoTy6RzgN1M8ctu+PEQexNd lBVopM17K7C8rZiyC0EXlmxfPrGmOA7uYXgT5uvADdDLxXnJj9hO4A83lvWsgZS654uF 2XynIYuZMbmMfZBZiu7+us8Ww530L90Uu2P1uWSN47u7HVkWt7hrMH4Mco5vJvnISPIO nVzSdRgZYU4tFkuwqcmAY7Fgn6tPeqkOXeWbSN8qShzM9lQp+dxzkeXdgheiInVQT5po ndgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=L4yYh83y0//brfb4x9RxTPqQ/IhjV6WrglZVAYeGebQ=; b=IVA5PXNArxzw65AIIih8idGxEyVizTcvKcXq9oH6NMbYaJJgSepyasVK28sA2tNqjh PwFPFIOvrzkK9X2TsADOSJSPXE5lTTxnH+0GuLR/Vs6xdF7jEw/uWG1+/14CpH8GpjoW HavqTWWJsiLm3lsqadAL3FmvdmSx6gzkEqzVRCbP9NdX1fu+YSJiLV/FdyeQr065P11z lKMe0lf+FnijAQ9vgrgq9hC+pUwCzfz+vN9SqXErePRqHdAfrpK1LIN1O4JnRFuVATn6 W7+H+i1qnNitfz8A73Dim2Ktd5sbJ/bj69aOFXTC+wFDt1oZ6V6l1nwcH0agMPdvRJMK LHMQ== X-Gm-Message-State: AOAM531++UZoGSOcvPS36LeCwjrqPIXvd3sLZNQgG/qyWo6itPmeCptH B1hUTC0gdrfImcus3u2S/4S7vBNVvKQI X-Received: by 2002:a05:620a:2a09:b0:6a0:924:a3b4 with SMTP id o9-20020a05620a2a0900b006a00924a3b4mr1464240qkp.548.1651594437230; Tue, 03 May 2022 09:13:57 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:56 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:25 -0400 Message-Id: <20220503161328.842587-10-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/12] Rearranged files, all tests are passing! X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Ej4J5qa+14Ty --- {libavcodec => fftools}/text_to_bitmap.c | 0 {libavcodec => fftools}/text_to_bitmap.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {libavcodec => fftools}/text_to_bitmap.c (100%) rename {libavcodec => fftools}/text_to_bitmap.h (100%) diff --git a/libavcodec/text_to_bitmap.c b/fftools/text_to_bitmap.c similarity index 100% rename from libavcodec/text_to_bitmap.c rename to fftools/text_to_bitmap.c diff --git a/libavcodec/text_to_bitmap.h b/fftools/text_to_bitmap.h similarity index 100% rename from libavcodec/text_to_bitmap.h rename to fftools/text_to_bitmap.h From patchwork Tue May 3 16:13:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35570 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496562pzb; Tue, 3 May 2022 09:14:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzeoFklye4fv5cXJUY5Q+eUTKLbUr/+EPjq9idXwDe/TVYvv4LfS6+ZqIaa6eO8qPRvnuF X-Received: by 2002:a17:906:301a:b0:6f3:fdd3:4d1c with SMTP id 26-20020a170906301a00b006f3fdd34d1cmr16054716ejz.235.1651594485549; Tue, 03 May 2022 09:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594485; cv=none; d=google.com; s=arc-20160816; b=bw6gvRkl3PuNIDMxxxYnGjADKqU2Igvn2ktOZGMbC8o0jMTPEE7zIN5x/UiSPzQ6Lh 8nE4MvPYUcwVSnd0Hn2si9GhtTo+gAYsCd3Gms897NfnUO+2hulguZDVzJoLhFX/i5TO 4djikRNte++Zsh5hO7BWi4T1ueSa7t0Fm+HSPrSqpSc+ec3cmeFG7hqQBVF2ee9xi9ox tpW0tVXuseu1Qn8ri09LbvFC8pyKvgLqdtSR3hkBo6bdYwQjxX9nEG4lhM2n5j9krO6j 8vMEHyZEIvRd55j1XlY09Va69Y4RZJlF+ocvtqmWIUtNcsoXsHeAyd98FodCsNxvpuxT Ia3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=mY/Bo120L4P36lSn1r58lGhvEwadiuqe5go4S0gN7Lc=; b=hKT0Cb+iwauq9hviCUhDD1h7uGCowOb1c2JW5b/VGWBmuSzUgvheZ/ur4eY8+t/G2B DpFT5q8QSaabXxwUn9bxONpETakPG6kW9n7UE8/Qf9MdmMgMuqtnGot6fMlAmlKIdLKS RSvMFuBKff193wAiY/Rz3f+fG8H7ykDpBcNCcc8li3H8ZvsuH1hj5DNWXwpQuFsbcAge jTfieRltIPOsNB0DZKDb8c48StT5+NmGEoWZv/AfUU8XDmbh++2oaJgyB64/ZF+19f4d hJ2UKF6b7nQ8aaWhz+x11V7tJDHCZFBqOFxtpx/KjzIYNZLjIrwsie/UfFnE/hP5mkx7 ftAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=K34gBIFk; 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 f11-20020a05640214cb00b00425d3d8afe2si13962536edx.106.2022.05.03.09.14.45; Tue, 03 May 2022 09:14:45 -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=20210112 header.b=K34gBIFk; 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 4D94368B3B2; Tue, 3 May 2022 19:14:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 635E568B3A1 for ; Tue, 3 May 2022 19:13:59 +0300 (EEST) Received: by mail-qt1-f173.google.com with SMTP id p4so13310905qtq.12 for ; Tue, 03 May 2022 09:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EJy4EkCHTPKT+Md14Uwd3jqv/38w377N1wHEbw0EbuA=; b=K34gBIFkfsSAz2sJxvumoM6rh22agNfdtBypxoFiIcpYWqgbKl0fQzL7GwOJnqneo0 HQX/qpIHxV7GhSTU4yVLnkF67h4ehpZr/LDlPGdkDpPfeGfRvw4bBQBkpRN7IHY9ej73 KR2nXsAdW4o5zdKc1sGnKYUH7BUIL9IG3fYtnwNUG5Rcsq5AiBQnBRk0oggM9C2efBvS Au0F7ARW0HcLe+lwTXUaLms4WQMPBz7BKTTG7sAEwR0MeYAlaD5FruO+8R/kv6KkrIEX ef6krSfxEUdImONYsRNFKlimlD0Wd6b72zgCSxOblq8dso8SUrjbM5OrNFrIRhhXMwdl qsuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EJy4EkCHTPKT+Md14Uwd3jqv/38w377N1wHEbw0EbuA=; b=jlYpgfYy6Xon7ui/nLPLsSZtwoJ2/AIxfTir2qLuLlMIFJ1e9iUKQ3OtL3nFSSPXgf kuItOUBVZMhliv6Z4gqeO8g/zGNm2blm9za5jcLaIIrQJ3JRUxcj9XURnagyTrVTiR+o 8ATVKbSs6hIIlNo/kPiD3RGp26EjdkK1zxQb/hW8cuOIJetPRevNXQQBgTPE/nPjljOx ggLwc8NJpnxqn39Vdaye13q3nXooFQOZ3vk17sb5Z4g9BpIFp2ibmJr0kAyia8WWPsQC 4HUg/1Ofi3GOFNcNcpx03+gMY5N0ayHEZymPRmDv8yzapW6wzWHKk2TXYY47S0fo3xrx XJZg== X-Gm-Message-State: AOAM530osAU0CAAwtySZ4DOEHlQzvqYZn0cjL7Hvzql7kNoB+wvBd2Fm 7ZbNG+0E7GaIIr0qUws76fUuo2Gx/7v+ X-Received: by 2002:a05:622a:14a:b0:2f3:9c08:7971 with SMTP id v10-20020a05622a014a00b002f39c087971mr14170242qtw.117.1651594438096; Tue, 03 May 2022 09:13:58 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:57 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:26 -0400 Message-Id: <20220503161328.842587-11-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/12] Rearranged files, all tests are passing! X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sfvnsNXgmGyR --- fftools/Makefile | 2 ++ fftools/ffmpeg.c | 6 ++++-- fftools/text_to_bitmap.c | 14 +++----------- fftools/text_to_bitmap.h | 14 ++++---------- libavcodec/Makefile | 1 - libavcodec/avcodec.c | 9 --------- 6 files changed, 13 insertions(+), 33 deletions(-) diff --git a/fftools/Makefile b/fftools/Makefile index 81ad6c4f4f..f9334a5622 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -15,6 +15,8 @@ OBJS-ffmpeg += \ fftools/ffmpeg_mux.o \ fftools/ffmpeg_opt.o \ +OBJS-ffmpeg-$(CONFIG_LIBASS) += fftools/text_to_bitmap.o + define DOFFTOOL OBJS-$(1) += fftools/cmdutils.o fftools/opt_common.o fftools/$(1).o $(OBJS-$(1)-yes) $(1)$(PROGSSUF)_g$(EXESUF): $$(OBJS-$(1)) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index ae622492ee..251a3ce427 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -72,7 +72,7 @@ # include "libavfilter/buffersink.h" #if CONFIG_LIBASS -#include "libavcodec/text_to_bitmap.h" +#include "fftools/text_to_bitmap.h" #endif #if HAVE_SYS_RESOURCE_H @@ -3239,7 +3239,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, return AVERROR_INVALIDDATA; } if (input_props == AV_CODEC_PROP_TEXT_SUB && output_props == AV_CODEC_PROP_BITMAP_SUB) - init_ass_context(input_streams, output_streams, nb_input_streams, nb_output_streams, ost->source_index, ost->index); + init_ass_context(ist, ost); #else if (input_props && output_props && input_props != output_props) { snprintf(error, error_len, @@ -4514,6 +4514,8 @@ static int transcode(void) ist = input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->dec_ctx); + if (ist->dec_ctx->ass_context != NULL) // This really has to be done here, sorry + free_ass_context(ist->dec_ctx->ass_context); if (ist->hwaccel_uninit) ist->hwaccel_uninit(ist->dec_ctx); } diff --git a/fftools/text_to_bitmap.c b/fftools/text_to_bitmap.c index 52d161d7b1..b4a0157174 100644 --- a/fftools/text_to_bitmap.c +++ b/fftools/text_to_bitmap.c @@ -27,8 +27,8 @@ #include "text_to_bitmap.h" #include "fftools/ffmpeg.h" -#include "avcodec.h" -#include "ass_split.h" +#include "../libavcodec/avcodec.h" +#include "../libavcodec/ass_split.h" /** * Holds the objects used by the rendering function so they don't have to be reinitialized every time @@ -51,16 +51,8 @@ struct ASS_Context { * @param ist_i index of input stream for transcoding * @param ost_i index of output stream for transcoding */ -void init_ass_context( - InputStream **input_streams, - OutputStream **output_streams, - int nb_input_streams, - int nb_output_streams, - int ist_i, - int ost_i) +void init_ass_context(InputStream *ist, OutputStream *ost) { - InputStream *ist = input_streams[ist_i]; - OutputStream *ost = output_streams[ost_i]; if (ist->dec_ctx->ass_context) return; ASS_Context *context = (ASS_Context *)malloc(sizeof(ASS_Context)); diff --git a/fftools/text_to_bitmap.h b/fftools/text_to_bitmap.h index 29037150c2..a9b48c6cf3 100644 --- a/fftools/text_to_bitmap.h +++ b/fftools/text_to_bitmap.h @@ -21,8 +21,8 @@ * text_to_bitmap header file */ -#ifndef AVCODEC_TEXT_TO_BITMAP_H -#define AVCODEC_TEXT_TO_BITMAP_H +#ifndef FFTOOLS_TEXT_TO_BITMAP_H +#define FFTOOLS_TEXT_TO_BITMAP_H #include #include "fftools/ffmpeg.h" @@ -30,14 +30,8 @@ struct ASS_Context; typedef struct ASS_Context ASS_Context; -void init_ass_context( - InputStream **input_streams, - OutputStream **output_streams, - int nb_input_streams, - int nb_output_streams, - int ist_i, - int ost_i); +void init_ass_context(InputStream *ist, OutputStream *ost); void render_avsub_ass(ASS_Context *, AVSubtitle *); void free_ass_context(ASS_Context *context); -#endif //AVCODEC_TEXT_TO_BITMAP_H +#endif //FFTOOLS_TEXT_TO_BITMAP_H diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6d28513129..cfaa6f196a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -151,7 +151,6 @@ OBJS-$(CONFIG_RV34DSP) += rv34dsp.o OBJS-$(CONFIG_SINEWIN) += sinewin.o OBJS-$(CONFIG_SNAPPY) += snappy.o OBJS-$(CONFIG_STARTCODE) += startcode.o -OBJS-$(CONFIG_LIBASS) += text_to_bitmap.o OBJS-$(CONFIG_TEXTUREDSP) += texturedsp.o OBJS-$(CONFIG_TEXTUREDSPENC) += texturedspenc.o OBJS-$(CONFIG_TPELDSP) += tpeldsp.o diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 1e308f39c2..d11f035481 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -42,10 +42,6 @@ #include "thread.h" #include "version.h" -#if CONFIG_LIBASS -#include "libavcodec/text_to_bitmap.h" -#endif - #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; @@ -538,11 +534,6 @@ av_cold int avcodec_close(AVCodecContext *avctx) } else if (av_codec_is_decoder(avctx->codec)) av_freep(&avctx->subtitle_header); -#if CONFIG_LIBASS - if (av_codec_is_decoder(avctx->codec) && avctx->ass_context != NULL) - free_ass_context(avctx->ass_context); -#endif - avctx->codec = NULL; avctx->active_thread_type = 0; From patchwork Tue May 3 16:13:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35574 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496971pzb; Tue, 3 May 2022 09:15:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzENGXtpFi1MxUVdXM+Ng9a0yydCZpZzSsEtrxN/PMPpRekMSLsVTCI6zQ78Z8/oORmP/c5 X-Received: by 2002:a17:906:a454:b0:6f3:98ab:473d with SMTP id cb20-20020a170906a45400b006f398ab473dmr16038829ejb.423.1651594532752; Tue, 03 May 2022 09:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594532; cv=none; d=google.com; s=arc-20160816; b=X0s5q6dflLEONvjwQAq8QAeO7l8VlREEYjcWhpIHiX1ZwdPZSSYBYSTfMO9fAGBx2h NhGers4nDLZ955hhQkNJl4iHzPbbeJIpvMlXycf007KYE/aKBusRewKeZNPWZjQ6lylD LB4Gmbr8VhLFQTZ0KjdSsTnd+wLtenO7lKVk1oWwyKvJVgrcZwZlMH2XBLueNOIgK76s FFrW35pFFrQ8Vt3RlRVT5GWAfcdDzXD5zwSFpXVWuf/vmIrxtEZkwYcMnve9Rq6frGTh ZJiVd6bk1/MXxK/qx3ibcLMpVh1v/3wAADhc1PqddPThc7slWDyVWasfUzcIfjmyCGpe UzOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=KHkCIJpaSL9u7iOUH+6eP+Ck7Edelhphh/qCWoHldVQ=; b=hjiE0UzM0DKsoUo3FUtTCmBa7VWg1Gj9uJxs6jOV6RU03GRB3evRWQr1apiwDt2Ji7 wGutrSHXG8KkGM9Fi5L9QiYCG9H0shnjBc16dJN54ywG0gatXl6mRTfabOCTHETdwT7n Ok7LgGD92fjYJdNzP+D9F5O9HqmShz5PQhYDBjIZpcpRegFkCr/PtMPQZsx2hs1b7B7z 3C1xahOKYYcTPV/wA57K4C9tfLC2Ryp8127mjdU0dT4pkdoA6w6XyJWB/tbJxPIYgG3Y JKXHaH6ftTXMaA6MsIzvaqQSjQk0kvmG9o5l5O8x75D8XszLT78VskfqxHj58n4Cm8pl YG6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=WpWHLCjq; 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 ca7-20020aa7cd67000000b00425b38d4de3si13438140edb.178.2022.05.03.09.15.32; Tue, 03 May 2022 09:15:32 -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=20210112 header.b=WpWHLCjq; 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 42AD068B3D6; Tue, 3 May 2022 19:14:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 818E568B3AB for ; Tue, 3 May 2022 19:14:00 +0300 (EEST) Received: by mail-qt1-f179.google.com with SMTP id o11so13835302qtp.13 for ; Tue, 03 May 2022 09:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FNWBREmPOz00ix4ARQtcFegK/3Fr0l/77E1bgQgJhmI=; b=WpWHLCjqT8BFlx/iD1ZII29zQProS0DZuKa6A1eiC3YqqnRMhmrtH6vDfmNWZN1X78 JsoBC5Ab6ibf51/ILrIXSu7+MmSGxovAJurn3jG4QcGGJZXNE1pyXTLPeCwo1isiVldd 2INT1nkKzXM0IBSoejir32JvCZlGpGYPp2ZXGz4DfSA5tRscxb8wUM2mmDKmp/jRky0i lH776Jgv7OLE9odLB1Sjw0+7w/30il8pDdtgT5k6aNUSup6EPRMeeCIqNfgBo99IloA5 ocMctxqpfOe9K9kLeL5Ie2ZSHtTErXqo3/dmKzM991FRP8hgCGM6L4Om4dGpPQ1I7Tin Zp3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FNWBREmPOz00ix4ARQtcFegK/3Fr0l/77E1bgQgJhmI=; b=uQp9+jRSQC/6q35Lu6ublehEbqMStmxR4omlMNnDHPALpeQutUIa/rFo5N4KHkqbAS oNkgXTBq2ueOj9tWF6WXxx92zMn1K5utty4BRuAQawCPbIRV6FXHJDjKPD24qOlq0V74 +4Zu7/BerywS0CXiTAq4HJYMslnpkbas8K7FFhBI7H2A6iXS0qGH5CKqgAsXaBTEaBt2 AAnEKF6bDnF2RuWrNZnOBmJT6eTZR8PJInV0SxMONTVsshUffh/K1eDbAKn8kHEdyeIo fah9ZpTawPg+jj5pirSmfO6G4B/crhgyCkoJCZf9B9NOOdrzWp/UeYx9hdnoGmlNHCRa ouAw== X-Gm-Message-State: AOAM533X1ZWpqQbECKHnyQ3V7WuiogvwvWaJosd3qD1AtNRHuG72Tfue HxaRRUoVTFsN/Nb9IO84+p+JjxbSInjh X-Received: by 2002:ac8:5c07:0:b0:2f1:fe44:e72b with SMTP id i7-20020ac85c07000000b002f1fe44e72bmr15608144qti.319.1651594438932; Tue, 03 May 2022 09:13:58 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:58 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:27 -0400 Message-Id: <20220503161328.842587-12-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/12] Added logging X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: TymPYxnlWMo2 --- fftools/ffmpeg.c | 4 +++- fftools/text_to_bitmap.c | 27 ++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 251a3ce427..b4d3d491de 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3244,7 +3244,7 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame, if (input_props && output_props && input_props != output_props) { snprintf(error, error_len, "Subtitle encoding currently only possible from text to text " - "or bitmap to bitmap"); + "or bitmap to bitmap (configure with --enable-libass for text to bitmap support)"); return AVERROR_INVALIDDATA; } #endif @@ -4514,8 +4514,10 @@ static int transcode(void) ist = input_streams[i]; if (ist->decoding_needed) { avcodec_close(ist->dec_ctx); +#if CONFIG_LIBASS if (ist->dec_ctx->ass_context != NULL) // This really has to be done here, sorry free_ass_context(ist->dec_ctx->ass_context); +#endif if (ist->hwaccel_uninit) ist->hwaccel_uninit(ist->dec_ctx); } diff --git a/fftools/text_to_bitmap.c b/fftools/text_to_bitmap.c index b4a0157174..0f165e7722 100644 --- a/fftools/text_to_bitmap.c +++ b/fftools/text_to_bitmap.c @@ -40,6 +40,30 @@ struct ASS_Context { ASSSplitContext *ass_split_context; }; +// Copied from vf_subtitles.c +/* libass supports a log level ranging from 0 to 7 */ +static const int ass_libavfilter_log_level_map[] = { + [0] = AV_LOG_FATAL, /* MSGL_FATAL */ + [1] = AV_LOG_ERROR, /* MSGL_ERR */ + [2] = AV_LOG_WARNING, /* MSGL_WARN */ + [3] = AV_LOG_WARNING, /* */ + [4] = AV_LOG_INFO, /* MSGL_INFO */ + [5] = AV_LOG_INFO, /* */ + [6] = AV_LOG_VERBOSE, /* MSGL_V */ + [7] = AV_LOG_DEBUG, /* MSGL_DBG2 */ +}; + +// Also copied +static void ass_log(int ass_level, const char *fmt, va_list args, void *ctx) +{ + const int ass_level_clip = av_clip(ass_level, 0, + FF_ARRAY_ELEMS(ass_libavfilter_log_level_map) - 1); + const int level = ass_libavfilter_log_level_map[ass_level_clip]; + + av_vlog(NULL, level, fmt, args); + av_log(NULL, level, "\n"); +} + /** * Initiates the ASS_Context structure and adds it to the input stream decoder context. * Does nothing if ist->dec_ctx->ass_context is already set. @@ -57,6 +81,7 @@ void init_ass_context(InputStream *ist, OutputStream *ost) ASS_Context *context = (ASS_Context *)malloc(sizeof(ASS_Context)); context->library = ass_library_init(); + ass_set_message_cb(context->library, ass_log, NULL); ass_set_extract_fonts(context->library, 1); // TODO: ass_add_font(context->library, ...); @@ -172,7 +197,7 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) ASS_Image *image = ass_render_frame(context->renderer, track, track->events[0].Start + track->events[0].Duration / 2, NULL); - if (image == NULL) printf("WARNING: failed to render ass\n"); + if (image == NULL) av_log(NULL, AV_LOG_WARNING, "failed to render ass\n"); rect->x = image ? image->dst_x : 0; rect->w = 0; rect->y = image ? image->dst_y : 0; rect->h = 0; From patchwork Tue May 3 16:13:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35575 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp497207pzb; Tue, 3 May 2022 09:15:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUtNSBE0z14cFuQcmktN0Z3KBzdeCNwV1fa2tF2Jxw3DlxLvVix0Q3xIv2HsP++VMfm8fI X-Received: by 2002:a17:907:6e1d:b0:6f4:60e6:9fa6 with SMTP id sd29-20020a1709076e1d00b006f460e69fa6mr8040675ejc.184.1651594555637; Tue, 03 May 2022 09:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594555; cv=none; d=google.com; s=arc-20160816; b=Qc757scXFY4w/96S+dQK1kvJzzxT7nujno7Om3B0BNPWd29TWjgNoYUQXjVxeIx5Fk kpIGFu5/wMGMN/OfTSXVt4XzauPMaa/4gE0OxIL0CU8GN0G1Y7sY4nBcTo5dtU1FxBbL cKLohjbWkOl8IJNPNJVNjtvO4SHOUHO9B8gxo8daqXhQ3lBQZkn62oniCJP6cZ5QQGSQ foJ4VgkCrKgDDD8T1KRiAcSR5lS/7b8Q+1bRDRzcHZlsi+9Or65FsSV9PhUAPvjoFXNg VTc+qYbHoYejoY4Pm5GpSn4g1qlYBNv7N88LdM37vxCnSgwBPa4qA2V5mRYGwGK1WHjF ppoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=xqcO1YgNreUEOY417ReKdSgbigTdoEk+hXUOGuZzFpk=; b=RABQYfDKEgH2lkwW8fORcljEsUj/5GPBJS6lD0BOOYRzoysHI/j2gSjI5ZD/yit4CO bm3SEIQgm9lv54fAZSv8aU3lppP1RChP1GnMuOYu1/gCZEHrPNO2zMVqp0aen1tTFfk0 whlH4Ksq1LKFNYmTIcrtuxB4xbaUhC/cN2jO2uVYKCNUQ8v/buO+nqSKHFtvEgHXpOTa qDoJfXtkb1x4HXO0AfPRsQ9t+yJht2DlOCjwG+nqr8mBw9NAcepqP8cxVNdOWMEfXKx9 HS7xoZetwsFWObjLR94Xw1be1XH33B7WOhnJb7DBUujAnYGu/9/5j6eUKuSuyAf88Xa7 ocPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="La6/NeAt"; 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 fe5-20020a1709072a4500b006f396dc0ad3si13479381ejc.266.2022.05.03.09.15.55; Tue, 03 May 2022 09:15:55 -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=20210112 header.b="La6/NeAt"; 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 33ECC68B3E1; Tue, 3 May 2022 19:14:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E86F68B3BB for ; Tue, 3 May 2022 19:14:01 +0300 (EEST) Received: by mail-qt1-f172.google.com with SMTP id h3so9262988qtn.4 for ; Tue, 03 May 2022 09:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NfIgOzyaw8pW9qTR/AXEV6xp3G7BYhhXgdd8k1Ctd5M=; b=La6/NeAta1kyt8LjRYfLDB5MK7b97Vt/JS/mESB+OV2utIxGtlsiV5eeG4GJxmxntw vUcF9xDMkuR1nevqxozMvAbI3Gy0RHcsZ2gf87mXt9ub9Ou8FKNzPuDvSRbthjnsHXLx m8PNsa+r2Z5U3v4HNrw+ytX4FJ/2I5PNFHPKxfwg7TwxviSWMRYDcLOKKgkZ0YHzFill 79KYhDESjfzV5SJTO0TzrIvJOpmrbCWNBX4DgXmHoQcSU71FwyLFiP8MgDa9sRJJeSO1 kJAF4IUk/YyVM+dCJNegUFUfwIcNvjswzkbAY2P7hBVeTCCVIhAidG1yPHCBkY2VHVFi wAWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NfIgOzyaw8pW9qTR/AXEV6xp3G7BYhhXgdd8k1Ctd5M=; b=2NCdiuEU4VSs+zd37wGG9Pes3K6zut51Cx9wBsR5wDXpr67NbtX5HVBow6NzyIKv5B qqk7ZfGcsrBT+1nDeuZE4tJXdkkZfiAex144fEr62/lWHgEDHy2MRg1gFbRNeIdasgtD 9GtShe39+d+o0xnPYFlDNyeh+CJXWvmedQ7Ys/xnwwRJxc57rLf6jZGwt0FhxaKCtsZ5 qBWwF53lY7KgBFRahZ9qk022E2ELBiVYfDXyAgV6S8KPyhVC9JZ5l51BQVXDr7B0KpRw eSy1uS50HyS7Ov3hsKWGX0p9PmfoQBEBaGbrWB42PzaF7fsyxmzXPkJ0gKBkbJzZ2BSq 4V3w== X-Gm-Message-State: AOAM533uOEn8mODQlpJQcdPFabH45Yt6Y1LPwkNZmL8p390xOzrHovtg 7Z3zNqsl9fErm75hjdWTWltC/RBTc/Ix X-Received: by 2002:a05:622a:1451:b0:2f3:9e80:9b56 with SMTP id v17-20020a05622a145100b002f39e809b56mr13107196qtx.490.1651594439749; Tue, 03 May 2022 09:13:59 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:59 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:28 -0400 Message-Id: <20220503161328.842587-13-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/12] Added more logging X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: G9G7UwN7IcYI --- fftools/text_to_bitmap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fftools/text_to_bitmap.c b/fftools/text_to_bitmap.c index 0f165e7722..e05e485713 100644 --- a/fftools/text_to_bitmap.c +++ b/fftools/text_to_bitmap.c @@ -122,7 +122,8 @@ void init_ass_context(InputStream *ist, OutputStream *ost) } if (width && height) break; - // TODO Error: Cannot render without a width and height + av_log(NULL, AV_LOG_ERROR, "Cannot render text subtitle without frame size\n"); + return; } while (0); context->renderer = ass_renderer_init(context->library); @@ -197,7 +198,8 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) ASS_Image *image = ass_render_frame(context->renderer, track, track->events[0].Start + track->events[0].Duration / 2, NULL); - if (image == NULL) av_log(NULL, AV_LOG_WARNING, "failed to render ass\n"); + if (image == NULL) av_log(NULL, AV_LOG_WARNING, + "failed to render ass: %s\n", rect->ass); rect->x = image ? image->dst_x : 0; rect->w = 0; rect->y = image ? image->dst_y : 0; rect->h = 0;