Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/aviocat.c96
-rw-r--r--[-rwxr-xr-x]tools/build_libstagefright0
-rwxr-xr-xtools/clean-diff11
-rw-r--r--tools/cws2fws.c74
-rw-r--r--tools/enum_options.c143
-rw-r--r--tools/ffeval.c128
-rw-r--r--tools/graph2dot.c48
-rw-r--r--tools/ismindex.c525
-rw-r--r--tools/lavfi-showfiltfmts.c81
-rwxr-xr-xtools/patcheck12
-rw-r--r--tools/pktdumper.c44
-rw-r--r--tools/probetest.c36
-rw-r--r--tools/qt-faststart.c109
-rw-r--r--tools/trasher.c47
-rwxr-xr-xtools/unwrap-diff2
15 files changed, 1153 insertions, 203 deletions
diff --git a/tools/aviocat.c b/tools/aviocat.c
new file mode 100644
index 0000000000..f5da526ba9
--- /dev/null
+++ b/tools/aviocat.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "libavformat/avformat.h"
+
+static int usage(const char *argv0, int ret)
+{
+ fprintf(stderr, "%s [-b bytespersec] input_url output_url\n", argv0);
+ return ret;
+}
+
+int main(int argc, char **argv)
+{
+ int bps = 0, ret, i;
+ const char *input_url = NULL, *output_url = NULL;
+ int64_t stream_pos = 0;
+ int64_t start_time;
+ char errbuf[50];
+ AVIOContext *input, *output;
+
+ av_register_all();
+ avformat_network_init();
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-b")) {
+ bps = atoi(argv[i + 1]);
+ i++;
+ } else if (!input_url) {
+ input_url = argv[i];
+ } else if (!output_url) {
+ output_url = argv[i];
+ } else {
+ return usage(argv[0], 1);
+ }
+ }
+ if (!output_url)
+ return usage(argv[0], 1);
+
+ ret = avio_open2(&input, input_url, AVIO_FLAG_READ, NULL, NULL);
+ if (ret) {
+ av_strerror(ret, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Unable to open %s: %s\n", input_url, errbuf);
+ return 1;
+ }
+ ret = avio_open2(&output, output_url, AVIO_FLAG_WRITE, NULL, NULL);
+ if (ret) {
+ av_strerror(ret, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Unable to open %s: %s\n", output_url, errbuf);
+ goto fail;
+ }
+
+ start_time = av_gettime();
+ while (1) {
+ uint8_t buf[1024];
+ int n;
+ n = avio_read(input, buf, sizeof(buf));
+ if (n <= 0)
+ break;
+ avio_write(output, buf, n);
+ stream_pos += n;
+ if (bps) {
+ avio_flush(output);
+ while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos)
+ usleep(50 * 1000);
+ }
+ }
+
+ avio_flush(output);
+ avio_close(output);
+
+fail:
+ avio_close(input);
+ avformat_network_deinit();
+ return ret ? 1 : 0;
+}
diff --git a/tools/build_libstagefright b/tools/build_libstagefright
index 8b3a0930f9..8b3a0930f9 100755..100644
--- a/tools/build_libstagefright
+++ b/tools/build_libstagefright
diff --git a/tools/clean-diff b/tools/clean-diff
new file mode 100755
index 0000000000..4600702b10
--- /dev/null
+++ b/tools/clean-diff
@@ -0,0 +1,11 @@
+#!/bin/sh
+sed '/^+[^+]/!s/ /TaBBaT/g' |\
+ expand -t $(seq -s , 9 8 200) |\
+ sed 's/TaBBaT/ /g' |\
+ sed '/^+[^+]/s/ * $//' |\
+ tr -d '\015' |\
+ tr '\n' '°' |\
+ sed 's/\(@@[^@]*@@°[^@]*\)/\n\1/g' |\
+ egrep -v '@@[^@]*@@°(( [^°]*°)|([+-][[:space:]]*°)|(-[[:space:]]*([^°]*)°\+[[:space:]]*\5°))*$' |\
+ tr -d '\n' |\
+ tr '°' '\n'
diff --git a/tools/cws2fws.c b/tools/cws2fws.c
index b8535feaa4..68f7953b56 100644
--- a/tools/cws2fws.c
+++ b/tools/cws2fws.c
@@ -26,87 +26,82 @@ int main(int argc, char *argv[])
z_stream zstream;
struct stat statbuf;
- if (argc < 3)
- {
+ if (argc < 3) {
printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
- exit(1);
+ return 1;
}
fd_in = open(argv[1], O_RDONLY);
- if (fd_in < 0)
- {
+ if (fd_in < 0) {
perror("Error opening input file");
- exit(1);
+ return 1;
}
- fd_out = open(argv[2], O_WRONLY|O_CREAT, 00644);
- if (fd_out < 0)
- {
+ fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
+ if (fd_out < 0) {
perror("Error opening output file");
close(fd_in);
- exit(1);
+ return 1;
}
- if (read(fd_in, &buf_in, 8) != 8)
- {
+ if (read(fd_in, &buf_in, 8) != 8) {
printf("Header error\n");
close(fd_in);
close(fd_out);
- exit(1);
+ return 1;
}
- if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S')
- {
+ if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') {
printf("Not a compressed flash file\n");
- exit(1);
+ return 1;
}
fstat(fd_in, &statbuf);
- comp_len = statbuf.st_size;
+ comp_len = statbuf.st_size;
uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24);
- printf("Compressed size: %d Uncompressed size: %d\n", comp_len-4, uncomp_len-4);
+ printf("Compressed size: %d Uncompressed size: %d\n",
+ comp_len - 4, uncomp_len - 4);
// write out modified header
buf_in[0] = 'F';
if (write(fd_out, &buf_in, 8) < 8) {
perror("Error writing output file");
- exit(1);
+ return 1;
}
zstream.zalloc = NULL;
- zstream.zfree = NULL;
+ zstream.zfree = NULL;
zstream.opaque = NULL;
inflateInit(&zstream);
- for (i = 0; i < comp_len-8;)
- {
+ for (i = 0; i < comp_len - 8;) {
int ret, len = read(fd_in, &buf_in, 1024);
dbgprintf("read %d bytes\n", len);
last_out = zstream.total_out;
- zstream.next_in = &buf_in[0];
- zstream.avail_in = len;
- zstream.next_out = &buf_out[0];
+ zstream.next_in = &buf_in[0];
+ zstream.avail_in = len;
+ zstream.next_out = &buf_out[0];
zstream.avail_out = 65536;
ret = inflate(&zstream, Z_SYNC_FLUSH);
- if (ret != Z_STREAM_END && ret != Z_OK)
- {
+ if (ret != Z_STREAM_END && ret != Z_OK) {
printf("Error while decompressing: %d\n", ret);
inflateEnd(&zstream);
- exit(1);
+ return 1;
}
dbgprintf("a_in: %d t_in: %lu a_out: %d t_out: %lu -- %lu out\n",
- zstream.avail_in, zstream.total_in, zstream.avail_out, zstream.total_out,
- zstream.total_out-last_out);
+ zstream.avail_in, zstream.total_in, zstream.avail_out,
+ zstream.total_out, zstream.total_out - last_out);
- if (write(fd_out, &buf_out, zstream.total_out - last_out) < zstream.total_out - last_out) {
+ if (write(fd_out, &buf_out, zstream.total_out - last_out) <
+ zstream.total_out - last_out) {
perror("Error writing output file");
- exit(1);
+ return 1;
}
i += len;
@@ -115,20 +110,19 @@ int main(int argc, char *argv[])
break;
}
- if (zstream.total_out != uncomp_len-8)
- {
+ if (zstream.total_out != uncomp_len - 8) {
printf("Size mismatch (%lu != %d), updating header...\n",
- zstream.total_out, uncomp_len-8);
+ zstream.total_out, uncomp_len - 8);
- buf_in[0] = (zstream.total_out+8) & 0xff;
- buf_in[1] = ((zstream.total_out+8) >> 8) & 0xff;
- buf_in[2] = ((zstream.total_out+8) >> 16) & 0xff;
- buf_in[3] = ((zstream.total_out+8) >> 24) & 0xff;
+ buf_in[0] = (zstream.total_out + 8) & 0xff;
+ buf_in[1] = ((zstream.total_out + 8) >> 8) & 0xff;
+ buf_in[2] = ((zstream.total_out + 8) >> 16) & 0xff;
+ buf_in[3] = ((zstream.total_out + 8) >> 24) & 0xff;
lseek(fd_out, 4, SEEK_SET);
if (write(fd_out, &buf_in, 4) < 4) {
perror("Error writing output file");
- exit(1);
+ return 1;
}
}
diff --git a/tools/enum_options.c b/tools/enum_options.c
new file mode 100644
index 0000000000..45ac727d04
--- /dev/null
+++ b/tools/enum_options.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011 Anton Khirnov
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * enumerate avoptions and format them in texinfo format
+ */
+
+#include <string.h>
+
+#include "libavformat/avformat.h"
+#include "libavcodec/avcodec.h"
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
+
+static void print_usage(void)
+{
+ fprintf(stderr, "Usage: enum_options type\n"
+ "type: format codec\n");
+ exit(1);
+}
+
+static void print_option(const AVClass *class, const AVOption *o)
+{
+ printf("@item -%s @var{", o->name);
+ switch (o->type) {
+ case FF_OPT_TYPE_BINARY: printf("hexadecimal string"); break;
+ case FF_OPT_TYPE_STRING: printf("string"); break;
+ case FF_OPT_TYPE_INT:
+ case FF_OPT_TYPE_INT64: printf("integer"); break;
+ case FF_OPT_TYPE_FLOAT:
+ case FF_OPT_TYPE_DOUBLE: printf("float"); break;
+ case FF_OPT_TYPE_RATIONAL: printf("rational number"); break;
+ case FF_OPT_TYPE_FLAGS: printf("flags"); break;
+ default: printf("value"); break;
+ }
+ printf("} (@emph{");
+
+ if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) {
+ printf("input");
+ if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
+ printf("/");
+ }
+ if (o->flags & AV_OPT_FLAG_ENCODING_PARAM)
+ printf("output");
+
+ printf("})\n");
+ if (o->help)
+ printf("%s\n", o->help);
+
+ if (o->unit) {
+ const AVOption *u = NULL;
+ printf("\nPossible values:\n@table @samp\n");
+
+ while ((u = av_next_option(&class, u)))
+ if (u->type == FF_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit))
+ printf("@item %s\n%s\n", u->name, u->help ? u->help : "");
+ printf("@end table\n");
+ }
+}
+
+static void show_opts(const AVClass *class)
+{
+ const AVOption *o = NULL;
+
+ printf("@table @option\n");
+ while ((o = av_next_option(&class, o)))
+ if (o->type != FF_OPT_TYPE_CONST)
+ print_option(class, o);
+ printf("@end table\n");
+}
+
+static void show_format_opts(void)
+{
+ AVInputFormat *iformat = NULL;
+ AVOutputFormat *oformat = NULL;
+
+ printf("@section Generic format AVOptions\n");
+ show_opts(avformat_get_class());
+
+ printf("@section Format-specific AVOptions\n");
+ while ((iformat = av_iformat_next(iformat))) {
+ if (!iformat->priv_class)
+ continue;
+ printf("@subsection %s AVOptions\n", iformat->priv_class->class_name);
+ show_opts(iformat->priv_class);
+ }
+ while ((oformat = av_oformat_next(oformat))) {
+ if (!oformat->priv_class)
+ continue;
+ printf("@subsection %s AVOptions\n", oformat->priv_class->class_name);
+ show_opts(oformat->priv_class);
+ }
+}
+
+static void show_codec_opts(void)
+{
+ AVCodec *c = NULL;
+
+ printf("@section Generic codec AVOptions\n");
+ show_opts(avcodec_get_class());
+
+ printf("@section Codec-specific AVOptions\n");
+ while ((c = av_codec_next(c))) {
+ if (!c->priv_class)
+ continue;
+ printf("@subsection %s AVOptions\n", c->priv_class->class_name);
+ show_opts(c->priv_class);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 2)
+ print_usage();
+
+ av_register_all();
+
+ if (!strcmp(argv[1], "format"))
+ show_format_opts();
+ else if (!strcmp(argv[1], "codec"))
+ show_codec_opts();
+ else
+ print_usage();
+
+ return 0;
+}
diff --git a/tools/ffeval.c b/tools/ffeval.c
new file mode 100644
index 0000000000..027cd48237
--- /dev/null
+++ b/tools/ffeval.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2012 Stefano Sabatini
+ *
+ * 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
+ */
+
+#include <unistd.h> /* getopt */
+#include "libavutil/eval.h"
+
+/**
+ * @file
+ * simple arithmetic expression evaluator
+ */
+
+static void usage(void)
+{
+ printf("Simple expression evalutor, please *don't* turn me to a feature-complete language interpreter\n");
+ printf("usage: ffeval [OPTIONS]\n");
+ printf("\n"
+ "Options:\n"
+ "-e echo each input line on output\n"
+ "-h print this help\n"
+ "-i INFILE set INFILE as input file, stdin if omitted\n"
+ "-o OUTFILE set OUTFILE as output file, stdout if omitted\n"
+ "-p PROMPT set output prompt\n");
+}
+
+#define MAX_BLOCK_SIZE SIZE_MAX
+
+int main(int argc, char **argv)
+{
+ size_t buf_size = 256;
+ char *buf = av_malloc(buf_size);
+ const char *outfilename = NULL, *infilename = NULL;
+ FILE *outfile = NULL, *infile = NULL;
+ const char *prompt = "=> ";
+ int count = 0, echo = 0;
+ char c;
+
+ av_max_alloc(MAX_BLOCK_SIZE);
+
+ while ((c = getopt(argc, argv, "ehi:o:p:")) != -1) {
+ switch (c) {
+ case 'e':
+ echo = 1;
+ break;
+ case 'h':
+ usage();
+ return 0;
+ case 'i':
+ infilename = optarg;
+ break;
+ case 'o':
+ outfilename = optarg;
+ break;
+ case 'p':
+ prompt = optarg;
+ break;
+ case '?':
+ return 1;
+ }
+ }
+
+ if (!infilename || !strcmp(infilename, "-"))
+ infilename = "/dev/stdin";
+ infile = fopen(infilename, "r");
+ if (!infile) {
+ fprintf(stderr, "Impossible to open input file '%s': %s\n", infilename, strerror(errno));
+ return 1;
+ }
+
+ if (!outfilename || !strcmp(outfilename, "-"))
+ outfilename = "/dev/stdout";
+ outfile = fopen(outfilename, "w");
+ if (!outfile) {
+ fprintf(stderr, "Impossible to open output file '%s': %s\n", outfilename, strerror(errno));
+ return 1;
+ }
+
+ while ((c = fgetc(infile)) != EOF) {
+ if (c == '\n') {
+ double d;
+
+ buf[count] = 0;
+ if (buf[0] != '#') {
+ av_expr_parse_and_eval(&d, buf,
+ NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, 0, NULL);
+ if (echo)
+ fprintf(outfile, "%s ", buf);
+ fprintf(outfile, "%s%f\n", prompt, d);
+ }
+ count = 0;
+ } else {
+ if (count >= buf_size-1) {
+ if (buf_size == MAX_BLOCK_SIZE) {
+ av_log(NULL, AV_LOG_ERROR, "Memory allocation problem, "
+ "max block size '%zd' reached\n", MAX_BLOCK_SIZE);
+ return 1;
+ }
+ buf_size = FFMIN(buf_size, MAX_BLOCK_SIZE / 2) * 2;
+ buf = av_realloc_f((void *)buf, buf_size, 1);
+ if (!buf) {
+ av_log(NULL, AV_LOG_ERROR, "Memory allocation problem occurred\n");
+ return 1;
+ }
+ }
+ buf[count++] = c;
+ }
+ }
+
+ av_free(buf);
+ return 0;
+}
diff --git a/tools/graph2dot.c b/tools/graph2dot.c
index 5ec6e204f7..c000c4ca3a 100644
--- a/tools/graph2dot.c
+++ b/tools/graph2dot.c
@@ -1,26 +1,25 @@
/*
* Copyright (c) 2008-2010 Stefano Sabatini
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <unistd.h> /* getopt */
-#undef HAVE_AV_CONFIG_H
#include "libavutil/pixdesc.h"
#include "libavutil/audioconvert.h"
#include "libavfilter/avfiltergraph.h"
@@ -63,21 +62,28 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
char dst_filter_ctx_label[128];
const AVFilterContext *dst_filter_ctx = link->dst;
- snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label), "%s (%s)",
+ snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label),
+ "%s (%s)",
dst_filter_ctx->name,
dst_filter_ctx->filter->name);
- fprintf(outfile, "\"%s\" -> \"%s\"", filter_ctx_label, dst_filter_ctx_label);
+ fprintf(outfile, "\"%s\" -> \"%s\"",
+ filter_ctx_label, dst_filter_ctx_label);
if (link->type == AVMEDIA_TYPE_VIDEO) {
- fprintf(outfile, " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
+ fprintf(outfile,
+ " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]",
av_pix_fmt_descriptors[link->format].name,
- link->w, link->h, link->time_base.num, link->time_base.den);
+ link->w, link->h, link->time_base.num,
+ link->time_base.den);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
char buf[255];
- av_get_channel_layout_string(buf, sizeof(buf), -1, link->channel_layout);
- fprintf(outfile, " [ label= \"fmt:%s sr:%"PRId64" cl:%s\" ]",
+ av_get_channel_layout_string(buf, sizeof(buf), -1,
+ link->channel_layout);
+ fprintf(outfile,
+ " [ label= \"fmt:%s sr:%"PRId64" cl:%s tb:%d/%d\" ]",
av_get_sample_fmt_name(link->format),
- link->sample_rate, buf);
+ link->sample_rate, buf,
+ link->time_base.num, link->time_base.den);
}
fprintf(outfile, ";\n");
}
@@ -89,17 +95,17 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
int main(int argc, char **argv)
{
const char *outfilename = NULL;
- const char *infilename = NULL;
- FILE *outfile = NULL;
- FILE *infile = NULL;
- char *graph_string = NULL;
+ const char *infilename = NULL;
+ FILE *outfile = NULL;
+ FILE *infile = NULL;
+ char *graph_string = NULL;
AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph));
char c;
av_log_set_level(AV_LOG_DEBUG);
while ((c = getopt(argc, argv, "hi:o:")) != -1) {
- switch(c) {
+ switch (c) {
case 'h':
usage();
return 0;
@@ -118,7 +124,8 @@ int main(int argc, char **argv)
infilename = "/dev/stdin";
infile = fopen(infilename, "r");
if (!infile) {
- fprintf(stderr, "Impossible to open input file '%s': %s\n", infilename, strerror(errno));
+ fprintf(stderr, "Impossible to open input file '%s': %s\n",
+ infilename, strerror(errno));
return 1;
}
@@ -126,7 +133,8 @@ int main(int argc, char **argv)
outfilename = "/dev/stdout";
outfile = fopen(outfilename, "w");
if (!outfile) {
- fprintf(stderr, "Impossible to open output file '%s': %s\n", outfilename, strerror(errno));
+ fprintf(stderr, "Impossible to open output file '%s': %s\n",
+ outfilename, strerror(errno));
return 1;
}
@@ -141,7 +149,7 @@ int main(int argc, char **argv)
struct line *new_line = av_malloc(sizeof(struct line));
count += strlen(last_line->data);
last_line->next = new_line;
- last_line = new_line;
+ last_line = new_line;
}
last_line->next = NULL;
diff --git a/tools/ismindex.c b/tools/ismindex.c
new file mode 100644
index 0000000000..5980869c24
--- /dev/null
+++ b/tools/ismindex.c
@@ -0,0 +1,525 @@
+/*
+ * Copyright (c) 2012 Martin Storsjo
+ *
+ * This file is part of Libav.
+ *
+ * Libav 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.
+ *
+ * Libav 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 Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * To create a simple file for smooth streaming:
+ * avconv <normal input/transcoding options> -movflags frag_keyframe foo.ismv
+ * ismindex -n foo foo.ismv
+ * This step creates foo.ism and foo.ismc that is required by IIS for
+ * serving it.
+ *
+ * To pre-split files for serving as static files by a web server without
+ * any extra server support, create the ismv file as above, and split it:
+ * ismindex -split foo.ismv
+ * This step creates a file Manifest and directories QualityLevel(...),
+ * that can be read directly by a smooth streaming player.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#ifdef _WIN32
+#include <io.h>
+#define mkdir(a, b) mkdir(a)
+#endif
+
+#include "libavformat/avformat.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/mathematics.h"
+
+static int usage(const char *argv0, int ret)
+{
+ fprintf(stderr, "%s [-split] [-n basename] file1 [file2] ...\n", argv0);
+ return ret;
+}
+
+struct MoofOffset {
+ int64_t time;
+ int64_t offset;
+ int duration;
+};
+
+struct VideoFile {
+ const char *name;
+ int64_t duration;
+ int bitrate;
+ int track_id;
+ int is_audio, is_video;
+ int width, height;
+ int chunks;
+ int sample_rate, channels;
+ uint8_t *codec_private;
+ int codec_private_size;
+ struct MoofOffset *offsets;
+ int timescale;
+ const char *fourcc;
+ int blocksize;
+ int tag;
+};
+
+struct VideoFiles {
+ int nb_files;
+ int64_t duration;
+ struct VideoFile **files;
+ int video_file, audio_file;
+ int nb_video_files, nb_audio_files;
+};
+
+static int copy_tag(AVIOContext *in, AVIOContext *out, int32_t tag_name)
+{
+ int32_t size, tag;
+
+ size = avio_rb32(in);
+ tag = avio_rb32(in);
+ avio_wb32(out, size);
+ avio_wb32(out, tag);
+ if (tag != tag_name)
+ return -1;
+ size -= 8;
+ while (size > 0) {
+ char buf[1024];
+ int len = FFMIN(sizeof(buf), size);
+ if (avio_read(in, buf, len) != len)
+ break;
+ avio_write(out, buf, len);
+ size -= len;
+ }
+ return 0;
+}
+
+static int write_fragment(const char *filename, AVIOContext *in)
+{
+ AVIOContext *out = NULL;
+ int ret;
+
+ if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, NULL, NULL)) < 0)
+ return ret;
+ copy_tag(in, out, MKBETAG('m', 'o', 'o', 'f'));
+ copy_tag(in, out, MKBETAG('m', 'd', 'a', 't'));
+
+ avio_flush(out);
+ avio_close(out);
+
+ return ret;
+}
+
+static int write_fragments(struct VideoFiles *files, int start_index,
+ AVIOContext *in)
+{
+ char dirname[100], filename[500];
+ int i, j;
+
+ for (i = start_index; i < files->nb_files; i++) {
+ struct VideoFile *vf = files->files[i];
+ const char *type = vf->is_video ? "video" : "audio";
+ snprintf(dirname, sizeof(dirname), "QualityLevels(%d)", vf->bitrate);
+ mkdir(dirname, 0777);
+ for (j = 0; j < vf->chunks; j++) {
+ snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
+ dirname, type, vf->offsets[j].time);
+ avio_seek(in, vf->offsets[j].offset, SEEK_SET);
+ write_fragment(filename, in);
+ }
+ }
+ return 0;
+}
+
+static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f)
+{
+ int ret = AVERROR_EOF, track_id;
+ int version, fieldlength, i, j;
+ int64_t pos = avio_tell(f);
+ uint32_t size = avio_rb32(f);
+ struct VideoFile *vf = NULL;
+
+ if (avio_rb32(f) != MKBETAG('t', 'f', 'r', 'a'))
+ goto fail;
+ version = avio_r8(f);
+ avio_rb24(f);
+ track_id = avio_rb32(f); /* track id */
+ for (i = start_index; i < files->nb_files && !vf; i++)
+ if (files->files[i]->track_id == track_id)
+ vf = files->files[i];
+ if (!vf) {
+ /* Ok, continue parsing the next atom */
+ ret = 0;
+ goto fail;
+ }
+ fieldlength = avio_rb32(f);
+ vf->chunks = avio_rb32(f);
+ vf->offsets = av_mallocz(sizeof(*vf->offsets) * vf->chunks);
+ if (!vf->offsets) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+ for (i = 0; i < vf->chunks; i++) {
+ if (version == 1) {
+ vf->offsets[i].time = avio_rb64(f);
+ vf->offsets[i].offset = avio_rb64(f);
+ } else {
+ vf->offsets[i].time = avio_rb32(f);
+ vf->offsets[i].offset = avio_rb32(f);
+ }
+ for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
+ avio_r8(f);
+ for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
+ avio_r8(f);
+ for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
+ avio_r8(f);
+ if (i > 0)
+ vf->offsets[i - 1].duration = vf->offsets[i].time -
+ vf->offsets[i - 1].time;
+ }
+ if (vf->chunks > 0)
+ vf->offsets[vf->chunks - 1].duration = vf->duration -
+ vf->offsets[vf->chunks - 1].time;
+ ret = 0;
+
+fail:
+ avio_seek(f, pos + size, SEEK_SET);
+ return ret;
+}
+
+static int read_mfra(struct VideoFiles *files, int start_index,
+ const char *file, int split)
+{
+ int err = 0;
+ AVIOContext *f = NULL;
+ int32_t mfra_size;
+
+ if ((err = avio_open2(&f, file, AVIO_FLAG_READ, NULL, NULL)) < 0)
+ goto fail;
+ avio_seek(f, avio_size(f) - 4, SEEK_SET);
+ mfra_size = avio_rb32(f);
+ avio_seek(f, -mfra_size, SEEK_CUR);
+ if (avio_rb32(f) != mfra_size)
+ goto fail;
+ if (avio_rb32(f) != MKBETAG('m', 'f', 'r', 'a'))
+ goto fail;
+ while (!read_tfra(files, start_index, f)) {
+ /* Empty */
+ }
+
+ if (split)
+ write_fragments(files, start_index, f);
+
+fail:
+ if (f)
+ avio_close(f);
+ return err;
+}
+
+static int get_private_data(struct VideoFile *vf, AVCodecContext *codec)
+{
+ vf->codec_private_size = codec->extradata_size;
+ vf->codec_private = av_mallocz(codec->extradata_size);
+ if (!vf->codec_private)
+ return AVERROR(ENOMEM);
+ memcpy(vf->codec_private, codec->extradata, codec->extradata_size);
+ return 0;
+}
+
+static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
+{
+ AVIOContext *io = NULL;
+ uint16_t sps_size, pps_size;
+ int err = AVERROR(EINVAL);
+
+ if (codec->codec_id == CODEC_ID_VC1)
+ return get_private_data(vf, codec);
+
+ avio_open_dyn_buf(&io);
+ if (codec->extradata_size < 11 || codec->extradata[0] != 1)
+ goto fail;
+ sps_size = AV_RB16(&codec->extradata[6]);
+ if (11 + sps_size > codec->extradata_size)
+ goto fail;
+ avio_wb32(io, 0x00000001);
+ avio_write(io, &codec->extradata[8], sps_size);
+ pps_size = AV_RB16(&codec->extradata[9 + sps_size]);
+ if (11 + sps_size + pps_size > codec->extradata_size)
+ goto fail;
+ avio_wb32(io, 0x00000001);
+ avio_write(io, &codec->extradata[11 + sps_size], pps_size);
+ err = 0;
+
+fail:
+ vf->codec_private_size = avio_close_dyn_buf(io, &vf->codec_private);
+ return err;
+}
+
+static int handle_file(struct VideoFiles *files, const char *file, int split)
+{
+ AVFormatContext *ctx = NULL;
+ int err = 0, i, orig_files = files->nb_files;
+ char errbuf[50], *ptr;
+ struct VideoFile *vf;
+
+ err = avformat_open_input(&ctx, file, NULL, NULL);
+ if (err < 0) {
+ av_strerror(err, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Unable to open %s: %s\n", file, errbuf);
+ return 1;
+ }
+
+ err = avformat_find_stream_info(ctx, NULL);
+ if (err < 0) {
+ av_strerror(err, errbuf, sizeof(errbuf));
+ fprintf(stderr, "Unable to identify %s: %s\n", file, errbuf);
+ goto fail;
+ }
+
+ if (ctx->nb_streams < 1) {
+ fprintf(stderr, "No streams found in %s\n", file);
+ goto fail;
+ }
+ if (!files->duration)
+ files->duration = ctx->duration;
+
+ for (i = 0; i < ctx->nb_streams; i++) {
+ AVStream *st = ctx->streams[i];
+ vf = av_mallocz(sizeof(*vf));
+ files->files = av_realloc(files->files,
+ sizeof(*files->files) * (files->nb_files + 1));
+ files->files[files->nb_files] = vf;
+
+ vf->name = file;
+ if ((ptr = strrchr(file, '/')) != NULL)
+ vf->name = ptr + 1;
+
+ vf->bitrate = st->codec->bit_rate;
+ vf->track_id = st->id;
+ vf->timescale = st->time_base.den;
+ vf->duration = av_rescale_rnd(ctx->duration, vf->timescale,
+ AV_TIME_BASE, AV_ROUND_UP);
+ vf->is_audio = st->codec->codec_type == AVMEDIA_TYPE_AUDIO;
+ vf->is_video = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
+
+ if (!vf->is_audio && !vf->is_video) {
+ fprintf(stderr,
+ "Track %d in %s is neither video nor audio, skipping\n",
+ vf->track_id, file);
+ av_freep(&files->files[files->nb_files]);
+ continue;
+ }
+
+ if (vf->is_audio) {
+ if (files->audio_file < 0)
+ files->audio_file = files->nb_files;
+ files->nb_audio_files++;
+ vf->channels = st->codec->channels;
+ vf->sample_rate = st->codec->sample_rate;
+ if (st->codec->codec_id == CODEC_ID_AAC) {
+ vf->fourcc = "AACL";
+ vf->tag = 255;
+ vf->blocksize = 4;
+ } else if (st->codec->codec_id == CODEC_ID_WMAPRO) {
+ vf->fourcc = "WMAP";
+ vf->tag = st->codec->codec_tag;
+ vf->blocksize = st->codec->block_align;
+ }
+ get_private_data(vf, st->codec);
+ }
+ if (vf->is_video) {
+ if (files->video_file < 0)
+ files->video_file = files->nb_files;
+ files->nb_video_files++;
+ vf->width = st->codec->width;
+ vf->height = st->codec->height;
+ if (st->codec->codec_id == CODEC_ID_H264)
+ vf->fourcc = "H264";
+ else if (st->codec->codec_id == CODEC_ID_VC1)
+ vf->fourcc = "WVC1";
+ get_video_private_data(vf, st->codec);
+ }
+
+ files->nb_files++;
+ }
+
+ avformat_close_input(&ctx);
+
+ read_mfra(files, orig_files, file, split);
+
+fail:
+ if (ctx)
+ avformat_close_input(&ctx);
+ return err;
+}
+
+static void output_server_manifest(struct VideoFiles *files,
+ const char *basename)
+{
+ char filename[1000];
+ FILE *out;
+ int i;
+
+ snprintf(filename, sizeof(filename), "%s.ism", basename);
+ out = fopen(filename, "w");
+ if (!out) {
+ perror(filename);
+ return;
+ }
+ fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
+ fprintf(out, "<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n");
+ fprintf(out, "\t<head>\n");
+ fprintf(out, "\t\t<meta name=\"clientManifestRelativePath\" "
+ "content=\"%s.ismc\" />\n", basename);
+ fprintf(out, "\t</head>\n");
+ fprintf(out, "\t<body>\n");
+ fprintf(out, "\t\t<switch>\n");
+ for (i = 0; i < files->nb_files; i++) {
+ struct VideoFile *vf = files->files[i];
+ const char *type = vf->is_video ? "video" : "audio";
+ fprintf(out, "\t\t\t<%s src=\"%s\" systemBitrate=\"%d\">\n",
+ type, vf->name, vf->bitrate);
+ fprintf(out, "\t\t\t\t<param name=\"trackID\" value=\"%d\" "
+ "valueType=\"data\" />\n", vf->track_id);
+ fprintf(out, "\t\t\t</%s>\n", type);
+ }
+ fprintf(out, "\t\t</switch>\n");
+ fprintf(out, "\t</body>\n");
+ fprintf(out, "</smil>\n");
+ fclose(out);
+}
+
+static void output_client_manifest(struct VideoFiles *files,
+ const char *basename, int split)
+{
+ char filename[1000];
+ FILE *out;
+ int i, j;
+
+ if (split)
+ snprintf(filename, sizeof(filename), "Manifest");
+ else
+ snprintf(filename, sizeof(filename), "%s.ismc", basename);
+ out = fopen(filename, "w");
+ if (!out) {
+ perror(filename);
+ return;
+ }
+ fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
+ fprintf(out, "<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" "
+ "Duration=\"%"PRId64 "\">\n", files->duration * 10);
+ if (files->video_file >= 0) {
+ struct VideoFile *vf = files->files[files->video_file];
+ int index = 0;
+ fprintf(out,
+ "\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" "
+ "Chunks=\"%d\" "
+ "Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n",
+ files->nb_video_files, vf->chunks);
+ for (i = 0; i < files->nb_files; i++) {
+ vf = files->files[i];
+ if (!vf->is_video)
+ continue;
+ fprintf(out,
+ "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
+ "FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" "
+ "CodecPrivateData=\"",
+ index, vf->bitrate, vf->fourcc, vf->width, vf->height);
+ for (j = 0; j < vf->codec_private_size; j++)
+ fprintf(out, "%02X", vf->codec_private[j]);
+ fprintf(out, "\" />\n");
+ index++;
+ }
+ vf = files->files[files->video_file];
+ for (i = 0; i < vf->chunks; i++)
+ fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n", i,
+ vf->offsets[i].duration);
+ fprintf(out, "\t</StreamIndex>\n");
+ }
+ if (files->audio_file >= 0) {
+ struct VideoFile *vf = files->files[files->audio_file];
+ int index = 0;
+ fprintf(out,
+ "\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" "
+ "Chunks=\"%d\" "
+ "Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n",
+ files->nb_audio_files, vf->chunks);
+ for (i = 0; i < files->nb_files; i++) {
+ vf = files->files[i];
+ if (!vf->is_audio)
+ continue;
+ fprintf(out,
+ "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
+ "FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" "
+ "BitsPerSample=\"16\" PacketSize=\"%d\" "
+ "AudioTag=\"%d\" CodecPrivateData=\"",
+ index, vf->bitrate, vf->fourcc, vf->sample_rate,
+ vf->channels, vf->blocksize, vf->tag);
+ for (j = 0; j < vf->codec_private_size; j++)
+ fprintf(out, "%02X", vf->codec_private[j]);
+ fprintf(out, "\" />\n");
+ index++;
+ }
+ vf = files->files[files->audio_file];
+ for (i = 0; i < vf->chunks; i++)
+ fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n",
+ i, vf->offsets[i].duration);
+ fprintf(out, "\t</StreamIndex>\n");
+ }
+ fprintf(out, "</SmoothStreamingMedia>\n");
+ fclose(out);
+}
+
+static void clean_files(struct VideoFiles *files)
+{
+ int i;
+ for (i = 0; i < files->nb_files; i++) {
+ av_freep(&files->files[i]->codec_private);
+ av_freep(&files->files[i]->offsets);
+ av_freep(&files->files[i]);
+ }
+ av_freep(&files->files);
+ files->nb_files = 0;
+}
+
+int main(int argc, char **argv)
+{
+ const char *basename = NULL;
+ int split = 0, i;
+ struct VideoFiles vf = { 0, .video_file = -1, .audio_file = -1 };
+
+ av_register_all();
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-n")) {
+ basename = argv[i + 1];
+ i++;
+ } else if (!strcmp(argv[i], "-split")) {
+ split = 1;
+ } else if (argv[i][0] == '-') {
+ return usage(argv[0], 1);
+ } else {
+ handle_file(&vf, argv[i], split);
+ }
+ }
+ if (!vf.nb_files || (!basename && !split))
+ return usage(argv[0], 1);
+
+ if (!split)
+ output_server_manifest(&vf, basename);
+ output_client_manifest(&vf, basename, split);
+
+ clean_files(&vf);
+
+ return 0;
+}
diff --git a/tools/lavfi-showfiltfmts.c b/tools/lavfi-showfiltfmts.c
index 30d472559c..9f9029dcfd 100644
--- a/tools/lavfi-showfiltfmts.c
+++ b/tools/lavfi-showfiltfmts.c
@@ -1,34 +1,81 @@
/*
* Copyright (c) 2009 Stefano Sabatini
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libavformat/avformat.h"
#include "libavutil/pixdesc.h"
+#include "libavutil/samplefmt.h"
#include "libavfilter/avfilter.h"
+static void print_formats(AVFilterContext *filter_ctx)
+{
+ int i, j;
+
+#define PRINT_FMTS(inout, outin, INOUT) \
+ for (i = 0; i < filter_ctx->inout##put_count; i++) { \
+ if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_VIDEO) { \
+ AVFilterFormats *fmts = \
+ filter_ctx->inout##puts[i]->outin##_formats; \
+ for (j = 0; j < fmts->format_count; j++) \
+ if(av_get_pix_fmt_name(fmts->formats[j])) \
+ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
+ i, filter_ctx->filter->inout##puts[i].name, \
+ av_get_pix_fmt_name(fmts->formats[j])); \
+ } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \
+ AVFilterFormats *fmts; \
+ \
+ fmts = filter_ctx->inout##puts[i]->outin##_formats; \
+ for (j = 0; j < fmts->format_count; j++) \
+ printf(#INOUT "PUT[%d] %s: fmt:%s\n", \
+ i, filter_ctx->filter->inout##puts[i].name, \
+ av_get_sample_fmt_name(fmts->formats[j])); \
+ \
+ fmts = filter_ctx->inout##puts[i]->outin##_chlayouts; \
+ for (j = 0; j < fmts->format_count; j++) { \
+ char buf[256]; \
+ av_get_channel_layout_string(buf, sizeof(buf), -1, \
+ fmts->formats[j]); \
+ printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \
+ i, filter_ctx->filter->inout##puts[i].name, buf); \
+ } \
+ \
+ fmts = filter_ctx->inout##puts[i]->outin##_packing; \
+ for (j = 0; j < fmts->format_count; j++) { \
+ printf(#INOUT "PUT[%d] %s: packing:%s\n", \
+ i, filter_ctx->filter->inout##puts[i].name, \
+ fmts->formats[j] == AVFILTER_PACKED ? \
+ "packed" : "planar"); \
+ } \
+ } \
+ } \
+
+ PRINT_FMTS(in, out, IN);
+ PRINT_FMTS(out, in, OUT);
+}
+
int main(int argc, char **argv)
{
AVFilter *filter;
AVFilterContext *filter_ctx;
const char *filter_name;
const char *filter_args = NULL;
- int i, j;
+ int i;
av_log_set_level(AV_LOG_DEBUG);
@@ -50,11 +97,13 @@ int main(int argc, char **argv)
}
if (avfilter_open(&filter_ctx, filter, NULL) < 0) {
- fprintf(stderr, "Inpossible to open filter with name '%s'\n", filter_name);
+ fprintf(stderr, "Impossible to open filter with name '%s'\n",
+ filter_name);
return 1;
}
if (avfilter_init_filter(filter_ctx, filter_args, NULL) < 0) {
- fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n", filter_name, filter_args);
+ fprintf(stderr, "Impossible to init filter '%s' with arguments '%s'\n",
+ filter_name, filter_args);
return 1;
}
@@ -75,23 +124,7 @@ int main(int argc, char **argv)
else
avfilter_default_query_formats(filter_ctx);
- /* print the supported formats in input */
- for (i = 0; i < filter_ctx->input_count; i++) {
- AVFilterFormats *fmts = filter_ctx->inputs[i]->out_formats;
- for (j = 0; j < fmts->format_count; j++)
- printf("INPUT[%d] %s: %s\n",
- i, filter_ctx->filter->inputs[i].name,
- av_pix_fmt_descriptors[fmts->formats[j]].name);
- }
-
- /* print the supported formats in output */
- for (i = 0; i < filter_ctx->output_count; i++) {
- AVFilterFormats *fmts = filter_ctx->outputs[i]->in_formats;
- for (j = 0; j < fmts->format_count; j++)
- printf("OUTPUT[%d] %s: %s\n",
- i, filter_ctx->filter->outputs[i].name,
- av_pix_fmt_descriptors[fmts->formats[j]].name);
- }
+ print_formats(filter_ctx);
avfilter_free(filter_ctx);
fflush(stdout);
diff --git a/tools/patcheck b/tools/patcheck
index 19faf47b1d..28cd19361f 100755
--- a/tools/patcheck
+++ b/tools/patcheck
@@ -15,11 +15,11 @@ OPT="-nH"
#FILES=$($GREP '^+++' $* | sed 's/+++ //g')
echo patCHeck 1e10.0
-echo This tool is intended to help a human check/review patches it is very far from
-echo being free of false positives and negatives, its output are just hints of what
+echo This tool is intended to help a human check/review patches. It is very far from
+echo being free of false positives and negatives, and its output are just hints of what
echo may or may not be bad. When you use it and it misses something or detects
-echo something wrong, fix it and send a patch to the libav-devel mailing list.
-echo License:GPL Autor: Michael Niedermayer
+echo something wrong, fix it and send a patch to the ffmpeg-devel mailing list.
+echo License: GPL, Author: Michael Niedermayer
ERE_PRITYP='(unsigned *|)(char|short|long|int|long *int|short *int|void|float|double|(u|)int(8|16|32|64)_t)'
ERE_TYPES='(const|static|av_cold|inline| *)*('$ERE_PRITYP'|[a-zA-Z][a-zA-Z0-9_]*)[* ]{1,}[a-zA-Z][a-zA-Z0-9_]*'
@@ -55,6 +55,7 @@ hiegrep 'INIT_VLC_USE_STATIC' 'forbidden ancient vlc type' $*
hiegrep '=[-+\*\&] ' 'looks like compound assignment' $*
hiegrep2 '/\*\* *[a-zA-Z0-9].*' '\*/' 'Inconsistently formatted doxygen comment' $*
hiegrep '; */\*\*[^<]' 'Misformatted doxygen comment' $*
+hiegrep '//!|/\*!' 'inconsistent doxygen syntax' $*
hiegrep2 '(int|unsigned|static|void)[a-zA-Z0-9 _]*(init|end)[a-zA-Z0-9 _]*\(.*[^;]$' '(av_cold|:\+[^a-zA-Z_])' 'These functions may need av_cold, please review the whole patch for similar functions needing av_cold' $*
@@ -66,8 +67,7 @@ $EGREP $OPT '^\+ *(const *|)static' $*| $EGREP --color=always '[^=]= *(0|NULL)[^
cat $TMP
hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
-hiegrep '\b(awnser|cant|dont|quantised|quantisation|teh|wont)\b' 'common typos' $*
-
+hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|ouput|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention)\b' 'common typos' $*
hiegrep 'av_log\( *NULL' 'Missing context in av_log' $*
hiegrep '[^sn]printf' 'Please use av_log' $*
hiegrep '\bmalloc' 'Please use av_malloc' $*
diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index 56bc7b7ce0..0daa8e0941 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2005 Francois Revol
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -24,11 +24,10 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include "libavformat/avformat.h"
-#define PKTFILESUFF "_%08"PRId64"_%02d_%010"PRId64"_%06d_%c.bin"
+#include "libavformat/avformat.h"
-#undef strcat
+#define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
static int usage(int ret)
{
@@ -44,12 +43,12 @@ int main(int argc, char **argv)
{
char fntemplate[PATH_MAX];
char pktfilename[PATH_MAX];
- AVFormatContext *fctx;
+ AVFormatContext *fctx = NULL;
AVPacket pkt;
- int64_t pktnum = 0;
+ int64_t pktnum = 0;
int64_t maxpkts = 0;
- int donotquit = 0;
- int nowrite = 0;
+ int donotquit = 0;
+ int nowrite = 0;
int err;
if ((argc > 1) && !strncmp(argv[1], "-", 1)) {
@@ -64,16 +63,16 @@ int main(int argc, char **argv)
return usage(1);
if (argc > 2)
maxpkts = atoi(argv[2]);
- strncpy(fntemplate, argv[1], PATH_MAX-1);
+ strncpy(fntemplate, argv[1], PATH_MAX - 1);
if (strrchr(argv[1], '/'))
- strncpy(fntemplate, strrchr(argv[1], '/')+1, PATH_MAX-1);
+ strncpy(fntemplate, strrchr(argv[1], '/') + 1, PATH_MAX - 1);
if (strrchr(fntemplate, '.'))
*strrchr(fntemplate, '.') = '\0';
if (strchr(fntemplate, '%')) {
fprintf(stderr, "can't use filenames containing '%%'\n");
return usage(1);
}
- if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= PATH_MAX-1) {
+ if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= PATH_MAX - 1) {
fprintf(stderr, "filename too long\n");
return usage(1);
}
@@ -83,9 +82,9 @@ int main(int argc, char **argv)
// register all file formats
av_register_all();
- err = av_open_input_file(&fctx, argv[1], NULL, 0, NULL);
+ err = avformat_open_input(&fctx, argv[1], NULL, NULL);
if (err < 0) {
- fprintf(stderr, "av_open_input_file: error %d\n", err);
+ fprintf(stderr, "cannot open input: error %d\n", err);
return 1;
}
@@ -99,11 +98,14 @@ int main(int argc, char **argv)
while ((err = av_read_frame(fctx, &pkt)) >= 0) {
int fd;
- snprintf(pktfilename, PATH_MAX-1, fntemplate, pktnum, pkt.stream_index, pkt.pts, pkt.size, (pkt.flags & AV_PKT_FLAG_KEY)?'K':'_');
- printf(PKTFILESUFF"\n", pktnum, pkt.stream_index, pkt.pts, pkt.size, (pkt.flags & AV_PKT_FLAG_KEY)?'K':'_');
+ snprintf(pktfilename, PATH_MAX - 1, fntemplate, pktnum,
+ pkt.stream_index, pkt.pts, pkt.size,
+ (pkt.flags & AV_PKT_FLAG_KEY) ? 'K' : '_');
+ printf(PKTFILESUFF "\n", pktnum, pkt.stream_index, pkt.pts, pkt.size,
+ (pkt.flags & AV_PKT_FLAG_KEY) ? 'K' : '_');
//printf("open(\"%s\")\n", pktfilename);
if (!nowrite) {
- fd = open(pktfilename, O_WRONLY|O_CREAT, 0644);
+ fd = open(pktfilename, O_WRONLY | O_CREAT, 0644);
err = write(fd, pkt.data, pkt.size);
if (err < 0) {
fprintf(stderr, "write: error %d\n", err);
@@ -117,10 +119,10 @@ int main(int argc, char **argv)
break;
}
- av_close_input_file(fctx);
+ avformat_close_input(&fctx);
while (donotquit)
- sleep(60);
+ usleep(60 * 1000000);
return 0;
}
diff --git a/tools/probetest.c b/tools/probetest.c
index 7f8d54e973..36a05a3de1 100644
--- a/tools/probetest.c
+++ b/tools/probetest.c
@@ -1,20 +1,20 @@
/*
* copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -39,7 +39,8 @@ static void probe(AVProbeData *pd, int type, int p, int size)
int score = fmt->read_probe(pd);
if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) {
score_array[i] = score;
- fprintf(stderr, "Failure of %s probing code with score=%d type=%d p=%X size=%d\n",
+ fprintf(stderr,
+ "Failure of %s probing code with score=%d type=%d p=%X size=%d\n",
fmt->name, score, type, p, size);
failures++;
}
@@ -75,9 +76,8 @@ int main(void)
init_put_bits(&pb, pd.buf, size);
switch (type) {
case 0:
- for (i = 0; i < size * 8; i++) {
+ for (i = 0; i < size * 8; i++)
put_bits(&pb, 1, (av_lfg_get(&state) & 0xFFFFFFFF) > p << 20);
- }
break;
case 1:
for (i = 0; i < size * 8; i++) {
@@ -89,10 +89,10 @@ int main(void)
break;
case 2:
for (i = 0; i < size * 8; i++) {
- unsigned int p2 = (p >> (hist*3)) & 7;
+ unsigned int p2 = (p >> (hist * 3)) & 7;
unsigned int v = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 29;
put_bits(&pb, 1, v);
- hist = (2*hist + v) & 3;
+ hist = (2 * hist + v) & 3;
}
break;
case 3:
@@ -100,12 +100,18 @@ int main(void)
int c = 0;
while (p & 63) {
c = (av_lfg_get(&state) & 0xFFFFFFFF) >> 24;
- if (c >= 'a' && c <= 'z' && (p & 1)) break;
- else if(c >= 'A' && c <= 'Z' && (p & 2)) break;
- else if(c >= '0' && c <= '9' && (p & 4)) break;
- else if(c == ' ' && (p & 8)) break;
- else if(c == 0 && (p & 16)) break;
- else if(c == 1 && (p & 32)) break;
+ if (c >= 'a' && c <= 'z' && (p & 1))
+ break;
+ else if (c >= 'A' && c <= 'Z' && (p & 2))
+ break;
+ else if (c >= '0' && c <= '9' && (p & 4))
+ break;
+ else if (c == ' ' && (p & 8))
+ break;
+ else if (c == 0 && (p & 16))
+ break;
+ else if (c == 1 && (p & 32))
+ break;
}
pd.buf[i] = c;
}
diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c
index eefeafdfac..bb8e02eac9 100644
--- a/tools/qt-faststart.c
+++ b/tools/qt-faststart.c
@@ -8,7 +8,7 @@
* is in front of the data, thus facilitating network streaming.
*
* To compile this program, start from the base directory from which you
- * are building Libav and type:
+ * are building FFmpeg and type:
* make tools/qt-faststart
* The qt-faststart program will be built in the tools/ directory. If you
* do not build the program in this manner, correct results are not
@@ -30,29 +30,31 @@
#include <string.h>
#ifdef __MINGW32__
-#define fseeko(x,y,z) fseeko64(x,y,z)
-#define ftello(x) ftello64(x)
+#define fseeko(x, y, z) fseeko64(x, y, z)
+#define ftello(x) ftello64(x)
#endif
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
- (((uint8_t*)(x))[1] << 16) | \
- (((uint8_t*)(x))[2] << 8) | \
+#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+
+#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+ (((uint8_t*)(x))[1] << 16) | \
+ (((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
-#define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
- ((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
- ((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
- ((uint64_t)(((uint8_t*)(x))[3]) << 32) | \
- ((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
- ((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
- ((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
- ((uint64_t)((uint8_t*)(x))[7]))
-#define BE_FOURCC( ch0, ch1, ch2, ch3 ) \
- ( (uint32_t)(unsigned char)(ch3) | \
- ( (uint32_t)(unsigned char)(ch2) << 8 ) | \
- ( (uint32_t)(unsigned char)(ch1) << 16 ) | \
- ( (uint32_t)(unsigned char)(ch0) << 24 ) )
+#define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
+ ((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
+ ((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
+ ((uint64_t)(((uint8_t*)(x))[3]) << 32) | \
+ ((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
+ ((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
+ ((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
+ ((uint64_t)( (uint8_t*)(x))[7]))
+
+#define BE_FOURCC(ch0, ch1, ch2, ch3) \
+ ( (uint32_t)(unsigned char)(ch3) | \
+ ((uint32_t)(unsigned char)(ch2) << 8) | \
+ ((uint32_t)(unsigned char)(ch1) << 16) | \
+ ((uint32_t)(unsigned char)(ch0) << 24) )
#define QT_ATOM BE_FOURCC
/* top level atoms */
@@ -71,16 +73,16 @@
#define STCO_ATOM QT_ATOM('s', 't', 'c', 'o')
#define CO64_ATOM QT_ATOM('c', 'o', '6', '4')
-#define ATOM_PREAMBLE_SIZE 8
-#define COPY_BUFFER_SIZE 1024
+#define ATOM_PREAMBLE_SIZE 8
+#define COPY_BUFFER_SIZE 1024
int main(int argc, char *argv[])
{
FILE *infile = NULL;
FILE *outfile = NULL;
unsigned char atom_bytes[ATOM_PREAMBLE_SIZE];
- uint32_t atom_type = 0;
- uint64_t atom_size = 0;
+ uint32_t atom_type = 0;
+ uint64_t atom_size = 0;
uint64_t atom_offset = 0;
uint64_t last_offset;
unsigned char *moov_atom = NULL;
@@ -95,7 +97,7 @@ int main(int argc, char *argv[])
int bytes_to_copy;
if (argc != 3) {
- printf ("Usage: qt-faststart <infile.mov> <outfile.mov>\n");
+ printf("Usage: qt-faststart <infile.mov> <outfile.mov>\n");
return 0;
}
@@ -116,7 +118,7 @@ int main(int argc, char *argv[])
if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
break;
}
- atom_size = (uint32_t)BE_32(&atom_bytes[0]);
+ atom_size = (uint32_t) BE_32(&atom_bytes[0]);
atom_type = BE_32(&atom_bytes[4]);
/* keep ftyp atom */
@@ -125,8 +127,8 @@ int main(int argc, char *argv[])
free(ftyp_atom);
ftyp_atom = malloc(ftyp_atom_size);
if (!ftyp_atom) {
- printf ("could not allocate %"PRIu64" byte for ftyp atom\n",
- atom_size);
+ printf("could not allocate %"PRIu64" bytes for ftyp atom\n",
+ atom_size);
goto error_out;
}
fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
@@ -136,18 +138,17 @@ int main(int argc, char *argv[])
}
start_offset = ftello(infile);
} else {
-
- /* 64-bit special case */
- if (atom_size == 1) {
- if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
- break;
+ /* 64-bit special case */
+ if (atom_size == 1) {
+ if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
+ break;
+ }
+ atom_size = BE_64(&atom_bytes[0]);
+ fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
+ } else {
+ fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
}
- atom_size = BE_64(&atom_bytes[0]);
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
- } else {
- fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
}
- }
printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n",
(atom_type >> 24) & 255,
(atom_type >> 16) & 255,
@@ -165,7 +166,7 @@ int main(int argc, char *argv[])
(atom_type != PICT_ATOM) &&
(atom_type != UUID_ATOM) &&
(atom_type != FTYP_ATOM)) {
- printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n");
+ printf("encountered non-QT top-level atom (is this a QuickTime file?)\n");
break;
}
atom_offset += atom_size;
@@ -178,7 +179,7 @@ int main(int argc, char *argv[])
}
if (atom_type != MOOV_ATOM) {
- printf ("last atom in file was not a moov atom\n");
+ printf("last atom in file was not a moov atom\n");
free(ftyp_atom);
fclose(infile);
return 0;
@@ -187,12 +188,11 @@ int main(int argc, char *argv[])
/* moov atom was, in fact, the last atom in the chunk; load the whole
* moov atom */
fseeko(infile, -atom_size, SEEK_END);
- last_offset = ftello(infile);
+ last_offset = ftello(infile);
moov_atom_size = atom_size;
- moov_atom = malloc(moov_atom_size);
+ moov_atom = malloc(moov_atom_size);
if (!moov_atom) {
- printf ("could not allocate %"PRIu64" byte for moov atom\n",
- atom_size);
+ printf("could not allocate %"PRIu64" bytes for moov atom\n", atom_size);
goto error_out;
}
if (fread(moov_atom, atom_size, 1, infile) != 1) {
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
/* this utility does not support compressed atoms yet, so disqualify
* files with compressed QT atoms */
if (BE_32(&moov_atom[12]) == CMOV_ATOM) {
- printf ("this utility does not support compressed moov atoms yet\n");
+ printf("this utility does not support compressed moov atoms yet\n");
goto error_out;
}
@@ -215,15 +215,15 @@ int main(int argc, char *argv[])
for (i = 4; i < moov_atom_size - 4; i++) {
atom_type = BE_32(&moov_atom[i]);
if (atom_type == STCO_ATOM) {
- printf (" patching stco atom...\n");
+ printf(" patching stco atom...\n");
atom_size = BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
- printf (" bad atom size\n");
+ printf(" bad atom size\n");
goto error_out;
}
offset_count = BE_32(&moov_atom[i + 8]);
for (j = 0; j < offset_count; j++) {
- current_offset = BE_32(&moov_atom[i + 12 + j * 4]);
+ current_offset = BE_32(&moov_atom[i + 12 + j * 4]);
current_offset += moov_atom_size;
moov_atom[i + 12 + j * 4 + 0] = (current_offset >> 24) & 0xFF;
moov_atom[i + 12 + j * 4 + 1] = (current_offset >> 16) & 0xFF;
@@ -232,15 +232,15 @@ int main(int argc, char *argv[])
}
i += atom_size - 4;
} else if (atom_type == CO64_ATOM) {
- printf (" patching co64 atom...\n");
+ printf(" patching co64 atom...\n");
atom_size = BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
- printf (" bad atom size\n");
+ printf(" bad atom size\n");
goto error_out;
}
offset_count = BE_32(&moov_atom[i + 8]);
for (j = 0; j < offset_count; j++) {
- current_offset = BE_64(&moov_atom[i + 12 + j * 8]);
+ current_offset = BE_64(&moov_atom[i + 12 + j * 8]);
current_offset += moov_atom_size;
moov_atom[i + 12 + j * 8 + 0] = (current_offset >> 56) & 0xFF;
moov_atom[i + 12 + j * 8 + 1] = (current_offset >> 48) & 0xFF;
@@ -275,7 +275,7 @@ int main(int argc, char *argv[])
/* dump the same ftyp atom */
if (ftyp_atom_size > 0) {
- printf (" writing ftyp atom...\n");
+ printf(" writing ftyp atom...\n");
if (fwrite(ftyp_atom, ftyp_atom_size, 1, outfile) != 1) {
perror(argv[2]);
goto error_out;
@@ -283,14 +283,14 @@ int main(int argc, char *argv[])
}
/* dump the new moov atom */
- printf (" writing moov atom...\n");
+ printf(" writing moov atom...\n");
if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) {
perror(argv[2]);
goto error_out;
}
/* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
- printf (" copying rest of file...\n");
+ printf(" copying rest of file...\n");
while (last_offset) {
if (last_offset > COPY_BUFFER_SIZE)
bytes_to_copy = COPY_BUFFER_SIZE;
@@ -305,7 +305,6 @@ int main(int argc, char *argv[])
perror(argv[2]);
goto error_out;
}
-
last_offset -= bytes_to_copy;
}
diff --git a/tools/trasher.c b/tools/trasher.c
index e099aa30d6..61fd395f28 100644
--- a/tools/trasher.c
+++ b/tools/trasher.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2007 Michael Niedermayer
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * 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.
*
- * Libav is distributed in the hope that it will be useful,
+ * 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 Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -23,47 +23,50 @@
#include <inttypes.h>
static uint32_t state;
-static uint32_t ran(void){
- return state= state*1664525+1013904223;
+static uint32_t ran(void)
+{
+ return state = state * 1664525 + 1013904223;
}
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
FILE *f;
int count, maxburst, length;
- if (argc < 5){
+ if (argc < 5) {
printf("USAGE: trasher <filename> <count> <maxburst> <seed>\n");
return 1;
}
- f= fopen(argv[1], "rb+");
- if (!f){
+ f = fopen(argv[1], "rb+");
+ if (!f) {
perror(argv[1]);
return 2;
}
- count= atoi(argv[2]);
- maxburst= atoi(argv[3]);
- state= atoi(argv[4]);
+ count = atoi(argv[2]);
+ maxburst = atoi(argv[3]);
+ state = atoi(argv[4]);
fseek(f, 0, SEEK_END);
- length= ftell(f);
+ length = ftell(f);
fseek(f, 0, SEEK_SET);
- while(count--){
- int burst= 1 + ran() * (uint64_t) (abs(maxburst)-1) / UINT32_MAX;
- int pos= ran() * (uint64_t) length / UINT32_MAX;
+ while (count--) {
+ int burst = 1 + ran() * (uint64_t) (abs(maxburst) - 1) / UINT32_MAX;
+ int pos = ran() * (uint64_t) length / UINT32_MAX;
fseek(f, pos, SEEK_SET);
- if(maxburst<0) burst= -maxburst;
+ if (maxburst < 0)
+ burst = -maxburst;
- if(pos + burst > length)
+ if (pos + burst > length)
continue;
- while(burst--){
- int val= ran() * 256ULL / UINT32_MAX;
+ while (burst--) {
+ int val = ran() * 256ULL / UINT32_MAX;
- if(maxburst<0) val=0;
+ if (maxburst < 0)
+ val = 0;
fwrite(&val, 1, 1, f);
}
diff --git a/tools/unwrap-diff b/tools/unwrap-diff
new file mode 100755
index 0000000000..ccea99b7b4
--- /dev/null
+++ b/tools/unwrap-diff
@@ -0,0 +1,2 @@
+#!/bin/sh
+tr '\n' '\001' | sed 's/\x01\x01/\x01 \x01/g' | sed 's/\x01\([^-+ @]\)/ \1/g' | tr '\001' '\n'