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 {
32 char *format;
34
35 if (!buf)
36 buf = &(
AVBPrint){ 0 };
/* dummy buffer */
43 format);
44 break;
45
52 break;
53
54 default:
56 break;
57 }
58 return buf->len;
59 }
60
62 {
63 unsigned i, j, x, e;
64
67 unsigned max_src_name = 0, max_dst_name = 0;
68 unsigned max_in_name = 0, max_out_name = 0;
69 unsigned max_in_fmt = 0, max_out_fmt = 0;
71 unsigned lname = strlen(filter->
name);
73
74 for (j = 0; j < filter->input_count; j++) {
77 max_src_name =
FFMAX(max_src_name, ln);
80 }
81 for (j = 0; j < filter->output_count; j++) {
84 max_dst_name =
FFMAX(max_dst_name, ln);
87 }
88 in_indent = max_src_name + max_in_name + max_in_fmt;
89 in_indent += in_indent ? 4 : 0;
90 width =
FFMAX(lname + 2, ltype + 4);
91 height =
FFMAX3(2, filter->input_count, filter->output_count);
96 for (j = 0; j <
height; j++) {
97 unsigned in_no = j - (height - filter->input_count ) / 2;
98 unsigned out_no = j - (height - filter->output_count) / 2;
99
100 /* Input link */
101 if (in_no < filter->input_count) {
103 e = buf->len + max_src_name + 2;
106 e = buf->len + max_in_fmt + 2 +
111 } else {
113 }
114
115 /* Filter */
117 if (j == (height - 2) / 2) {
118 x = (width - lname) / 2;
120 } else if (j == (height - 2) / 2 + 1) {
121 x = (width - ltype - 2) / 2;
123 width - ltype - 2 - x, "");
124 } else {
126 }
128
129 /* Output link */
130 if (out_no < filter->output_count) {
132 unsigned ln = strlen(l->
dst->
name) + 1 +
134 e = buf->len + max_out_name + 2;
137 e = buf->len + max_out_fmt + 2 +
138 max_dst_name - ln;
142 }
144 }
150 }
151 }
152
154 {
156 char *dump;
157
163 return dump;
164 }