1 /*
2 * Filter graphs to bad ASCII-art
3 * Copyright (c) 2012 Nicolas George
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <string.h>
23
29
31 {
33 AVBPrint dummy_buffer;
34
35 if (!buf) {
36 buf = &dummy_buffer;
38 }
46 break;
47
54 break;
55
56 default:
58 break;
59 }
60 return buf->len;
61 }
62
64 {
66
67 for (
i = 0;
i <
graph->nb_filters;
i++) {
69 unsigned max_src_name = 0, max_dst_name = 0;
70 unsigned max_in_name = 0, max_out_name = 0;
71 unsigned max_in_fmt = 0, max_out_fmt = 0;
73 unsigned lname = strlen(
filter->name);
74 unsigned ltype = strlen(
filter->filter->name);
75
76 for (j = 0; j <
filter->nb_inputs; j++) {
79 max_src_name =
FFMAX(max_src_name, ln);
82 }
83 for (j = 0; j <
filter->nb_outputs; j++) {
86 max_dst_name =
FFMAX(max_dst_name, ln);
89 }
90 in_indent = max_src_name + max_in_name + max_in_fmt;
91 in_indent += in_indent ? 4 : 0;
98 for (j = 0; j <
height; j++) {
100 unsigned out_no = j - (
height -
filter->nb_outputs) / 2;
101
102 /* Input link */
103 if (in_no < filter->nb_inputs) {
105 e = buf->len + max_src_name + 2;
108 e = buf->len + max_in_fmt + 2 +
113 } else {
115 }
116
117 /* Filter */
119 if (j == (
height - 2) / 2) {
120 x = (
width - lname) / 2;
122 }
else if (j == (
height - 2) / 2 + 1) {
123 x = (
width - ltype - 2) / 2;
125 width - ltype - 2 - x,
"");
126 } else {
128 }
130
131 /* Output link */
132 if (out_no < filter->nb_outputs) {
134 unsigned ln = strlen(l->
dst->
name) + 1 +
136 e = buf->len + max_out_name + 2;
139 e = buf->len + max_out_fmt + 2 +
140 max_dst_name - ln;
144 }
146 }
152 }
153 }
154
156 {
157 AVBPrint buf;
159
163 if (!dump)
167 return dump;
168 }