| @@ -28,6 +28,7 @@ · 27 unmodified lines |
| 28 | #include "float.h" /* DBL_MIN, DBL_MAX */ | 28 | #include "float.h" /* DBL_MIN, DBL_MAX */ |
| 29 | | 29 | |
| 30 | #include "libavutil/bprint.h" | 30 | #include "libavutil/bprint.h" |
| | 31 | #include "libavutil/file.h" |
| 31 | #include "libavutil/log.h" | 32 | #include "libavutil/log.h" |
| 32 | #include "libavutil/mem.h" | 33 | #include "libavutil/mem.h" |
| 33 | #include "libavutil/opt.h" | 34 | #include "libavutil/opt.h" |
| @@ -43,6 +44,7 @@ · 9 unmodified lines |
| 43 | typedef struct { | 44 | typedef struct { |
| 44 | AVClass *class; ///< class for private options | 45 | AVClass *class; ///< class for private options |
| 45 | char *graph_str; | 46 | char *graph_str; |
| | 47 | char *graph_filename; |
| 46 | char *dump_graph; | 48 | char *dump_graph; |
| 47 | AVFilterGraph *graph; | 49 | AVFilterGraph *graph; |
| 48 | AVFilterContext **sinks; | 50 | AVFilterContext **sinks; |
| @@ -104,6 +106,32 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) · 55 unmodified lines |
| 104 | buffersink = avfilter_get_by_name("ffbuffersink"); | 106 | buffersink = avfilter_get_by_name("ffbuffersink"); |
| 105 | abuffersink = avfilter_get_by_name("ffabuffersink"); | 107 | abuffersink = avfilter_get_by_name("ffabuffersink"); |
| 106 | | 108 | |
| | 109 | if (lavfi->graph_filename && lavfi->graph_str) { |
| | 110 | av_log(avctx, AV_LOG_ERROR, |
| | 111 | "Only one of the graph or graph_file options must be specified\n"); |
| | 112 | return AVERROR(EINVAL); |
| | 113 | } |
| | 114 | |
| | 115 | if (lavfi->graph_filename) { |
| | 116 | uint8_t *file_buf, *graph_buf; |
| | 117 | size_t file_bufsize; |
| | 118 | ret = av_file_map(lavfi->graph_filename, |
| | 119 | &file_buf, &file_bufsize, 0, avctx); |
| | 120 | if (ret < 0) |
| | 121 | return ret; |
| | 122 | |
| | 123 | /* create a 0-terminated string based on the read file */ |
| | 124 | graph_buf = av_malloc(file_bufsize + 1); |
| | 125 | if (!graph_buf) { |
| | 126 | av_file_unmap(file_buf, file_bufsize); |
| | 127 | return AVERROR(ENOMEM); |
| | 128 | } |
| | 129 | memcpy(graph_buf, file_buf, file_bufsize); |
| | 130 | graph_buf[file_bufsize] = 0; |
| | 131 | av_file_unmap(file_buf, file_bufsize); |
| | 132 | lavfi->graph_str = graph_buf; |
| | 133 | } |
| | 134 | |
| 107 | if (!lavfi->graph_str) | 135 | if (!lavfi->graph_str) |
| 108 | lavfi->graph_str = av_strdup(avctx->filename); | 136 | lavfi->graph_str = av_strdup(avctx->filename); |
| 109 | | 137 | |
| @@ -376,6 +404,7 @@ static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) · 266 unmodified lines |
| 376 | | 404 | |
| 377 | static const AVOption options[] = { | 405 | static const AVOption options[] = { |
| 378 | { "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | 406 | { "graph", "set libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, |
| | 407 | { "graph_file","set libavfilter graph filename", OFFSET(graph_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC}, |
| 379 | { "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, | 408 | { "dumpgraph", "dump graph to stderr", OFFSET(dump_graph), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, |
| 380 | { NULL }, | 409 | { NULL }, |
| 381 | }; | 410 | }; |