diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/bisect-create | 46 | ||||
-rw-r--r-- | tools/build_libstagefright | 58 | ||||
-rwxr-xr-x | tools/clean-diff | 11 | ||||
-rw-r--r-- | tools/enum_options.c | 143 | ||||
-rw-r--r-- | tools/ffeval.c | 128 | ||||
-rw-r--r-- | tools/fourcc2pixfmt.c | 120 | ||||
-rw-r--r-- | tools/graph2dot.c | 31 | ||||
-rw-r--r-- | tools/ismindex.c | 2 | ||||
-rwxr-xr-x | tools/make_chlayout_test | 114 | ||||
-rwxr-xr-x | tools/missing_codec_desc | 37 | ||||
-rwxr-xr-x | tools/patcheck | 10 | ||||
-rw-r--r-- | tools/pktdumper.c | 8 | ||||
-rw-r--r-- | tools/probetest.c | 21 | ||||
-rw-r--r-- | tools/qt-faststart.c | 21 | ||||
-rw-r--r-- | tools/trasher.c | 8 | ||||
-rwxr-xr-x | tools/unwrap-diff | 2 | ||||
-rw-r--r-- | tools/yuvcmp.c | 182 |
17 files changed, 900 insertions, 42 deletions
diff --git a/tools/bisect-create b/tools/bisect-create new file mode 100755 index 0000000..fc60e86 --- /dev/null +++ b/tools/bisect-create @@ -0,0 +1,46 @@ +#!/bin/sh + +set -e + +if test "bisect-create" = "`basename $0`" ; then + echo tools/ffbisect created + git show master:tools/bisect-create > tools/ffbisect + chmod u+x tools/ffbisect + exit 1 +fi + +if ! git show master:tools/bisect-create | diff - tools/ffbisect > /dev/null ; then + echo updating tools/ffbisect script to HEAD. + git show master:tools/bisect-create > tools/ffbisect + chmod u+x tools/ffbisect + tools/ffbisect $* + exit 0 +fi + +case "$1" in + need) + case $2 in + ffmpeg|ffplay|ffprobe|ffserver) + echo $2.c >> tools/bisect.need + ;; + esac + ;; + start|reset) + echo . > tools/bisect.need + git bisect $* + ;; + skip) + git bisect $* + ;; + good|bad) + git bisect $* + + until ls `cat tools/bisect.need` > /dev/null 2> /dev/null; do + git bisect skip || break + done + ;; + run) + shift # remove "run" from arguments + git bisect run sh -c "ls \`cat tools/bisect.need\` > /dev/null 2> /dev/null || exit 125; \"\$@\"" sh "$@" + ;; +esac diff --git a/tools/build_libstagefright b/tools/build_libstagefright new file mode 100644 index 0000000..8b3a093 --- /dev/null +++ b/tools/build_libstagefright @@ -0,0 +1,58 @@ +#!/bin/bash + +if [ "$NDK" = "" ]; then + echo NDK variable not set, assuming ${HOME}/android-ndk + export NDK=${HOME}/android-ndk +fi + +echo "Fetching Android system headers" +git clone --depth=1 --branch gingerbread-release git://github.com/CyanogenMod/android_frameworks_base.git ../android-source/frameworks/base +git clone --depth=1 --branch gingerbread-release git://github.com/CyanogenMod/android_system_core.git ../android-source/system/core + +echo "Fetching Android libraries for linking" +# Libraries from any froyo/gingerbread device/emulator should work +# fine, since the symbols used should be available on most of them. +if [ ! -d "../android-libs" ]; then + if [ ! -f "../update-cm-7.0.3-N1-signed.zip" ]; then + wget http://download.cyanogenmod.com/get/update-cm-7.0.3-N1-signed.zip -P../ + fi + unzip ../update-cm-7.0.3-N1-signed.zip system/lib/* -d../ + mv ../system/lib ../android-libs + rmdir ../system +fi + + +SYSROOT=$NDK/platforms/android-9/arch-arm +# Expand the prebuilt/* path into the correct one +TOOLCHAIN=`echo $NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/*-x86` +export PATH=$TOOLCHAIN/bin:$PATH +ANDROID_SOURCE=../android-source +ANDROID_LIBS=../android-libs +ABI="armeabi-v7a" + +rm -rf ../build/stagefright +mkdir -p ../build/stagefright + +DEST=../build/stagefright +FLAGS="--target-os=linux --cross-prefix=arm-linux-androideabi- --arch=arm --cpu=armv7-a" +FLAGS="$FLAGS --sysroot=$SYSROOT" +FLAGS="$FLAGS --disable-avdevice --disable-decoder=h264 --disable-decoder=h264_vdpau --enable-libstagefright-h264" + +EXTRA_CFLAGS="-I$ANDROID_SOURCE/frameworks/base/include -I$ANDROID_SOURCE/system/core/include" +EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/base/media/libstagefright" +EXTRA_CFLAGS="$EXTRA_CFLAGS -I$ANDROID_SOURCE/frameworks/base/include/media/stagefright/openmax" +EXTRA_CFLAGS="$EXTRA_CFLAGS -I$NDK/sources/cxx-stl/gnu-libstdc++/include -I$NDK/sources/cxx-stl/gnu-libstdc++/libs/$ABI/include" + +EXTRA_CFLAGS="$EXTRA_CFLAGS -march=armv7-a -mfloat-abi=softfp -mfpu=neon" +EXTRA_LDFLAGS="-Wl,--fix-cortex-a8 -L$ANDROID_LIBS -Wl,-rpath-link,$ANDROID_LIBS -L$NDK/sources/cxx-stl/gnu-libstdc++/libs/$ABI" +EXTRA_CXXFLAGS="-Wno-multichar -fno-exceptions -fno-rtti" +DEST="$DEST/$ABI" +FLAGS="$FLAGS --prefix=$DEST" + +mkdir -p $DEST + +echo $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" > $DEST/info.txt +./configure $FLAGS --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-cxxflags="$EXTRA_CXXFLAGS" | tee $DEST/configuration.txt +[ $PIPESTATUS == 0 ] || exit 1 +make clean +make -j4 || exit 1 diff --git a/tools/clean-diff b/tools/clean-diff new file mode 100755 index 0000000..4600702 --- /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/enum_options.c b/tools/enum_options.c new file mode 100644 index 0000000..45ac727 --- /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 0000000..027cd48 --- /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/fourcc2pixfmt.c b/tools/fourcc2pixfmt.c new file mode 100644 index 0000000..84d5af3 --- /dev/null +++ b/tools/fourcc2pixfmt.c @@ -0,0 +1,120 @@ +/* + * 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 "config.h" +#if HAVE_UNISTD_H +#include <unistd.h> /* getopt */ +#endif + +#include "libavutil/pixdesc.h" +#include "libavcodec/avcodec.h" +#include "libavutil/common.h" +#include "libavcodec/raw.h" + +#if !HAVE_GETOPT +#include "compat/getopt.c" +#endif + +static void usage(void) +{ + printf("Show the relationships between rawvideo pixel formats and FourCC tags.\n"); + printf("usage: fourcc2pixfmt [OPTIONS]\n"); + printf("\n" + "Options:\n" + "-l list the pixel format for each fourcc\n" + "-L list the fourccs for each pixel format\n" + "-p PIX_FMT given a pixel format, print the list of associated fourccs (one per line)\n" + "-h print this help\n"); +} + +static void print_pix_fmt_fourccs(enum PixelFormat pix_fmt, char sep) +{ + int i; + + for (i = 0; ff_raw_pix_fmt_tags[i].pix_fmt != PIX_FMT_NONE; i++) { + if (ff_raw_pix_fmt_tags[i].pix_fmt == pix_fmt) { + char buf[32]; + av_get_codec_tag_string(buf, sizeof(buf), ff_raw_pix_fmt_tags[i].fourcc); + printf("%s%c", buf, sep); + } + } +} + +int main(int argc, char **argv) +{ + int i, list_fourcc_pix_fmt = 0, list_pix_fmt_fourccs = 0; + const char *pix_fmt_name = NULL; + char c; + + if (argc == 1) { + usage(); + return 0; + } + + while ((c = getopt(argc, argv, "hp:lL")) != -1) { + switch (c) { + case 'h': + usage(); + return 0; + case 'l': + list_fourcc_pix_fmt = 1; + break; + case 'L': + list_pix_fmt_fourccs = 1; + break; + case 'p': + pix_fmt_name = optarg; + break; + case '?': + usage(); + return 1; + } + } + + if (list_fourcc_pix_fmt) { + for (i = 0; ff_raw_pix_fmt_tags[i].pix_fmt != PIX_FMT_NONE; i++) { + char buf[32]; + av_get_codec_tag_string(buf, sizeof(buf), ff_raw_pix_fmt_tags[i].fourcc); + printf("%s: %s\n", buf, av_get_pix_fmt_name(ff_raw_pix_fmt_tags[i].pix_fmt)); + } + } + + if (list_pix_fmt_fourccs) { + for (i = 0; i < PIX_FMT_NB; i++) { + const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[i]; + if (!pix_desc->name || pix_desc->flags & PIX_FMT_HWACCEL) + continue; + printf("%s: ", pix_desc->name); + print_pix_fmt_fourccs(i, ' '); + printf("\n"); + } + } + + if (pix_fmt_name) { + enum PixelFormat pix_fmt = av_get_pix_fmt(pix_fmt_name); + if (pix_fmt == PIX_FMT_NONE) { + fprintf(stderr, "Invalid pixel format selected '%s'\n", pix_fmt_name); + return 1; + } + print_pix_fmt_fourccs(pix_fmt, '\n'); + } + + return 0; +} diff --git a/tools/graph2dot.c b/tools/graph2dot.c index e7f487d..c4a50a8 100644 --- a/tools/graph2dot.c +++ b/tools/graph2dot.c @@ -1,20 +1,20 @@ /* * 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 */ @@ -62,7 +62,7 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) char filter_ctx_label[128]; const AVFilterContext *filter_ctx = graph->filters[i]; - snprintf(filter_ctx_label, sizeof(filter_ctx_label), "%s (%s)", + snprintf(filter_ctx_label, sizeof(filter_ctx_label), "%s\\n(%s)", filter_ctx->name, filter_ctx->filter->name); @@ -73,28 +73,31 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph) const AVFilterContext *dst_filter_ctx = link->dst; snprintf(dst_filter_ctx_label, sizeof(dst_filter_ctx_label), - "%s (%s)", + "%s\\n(%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\" [ label= \"inpad:%s -> outpad:%s\\n", + filter_ctx_label, dst_filter_ctx_label, + link->srcpad->name, link->dstpad->name); + if (link->type == AVMEDIA_TYPE_VIDEO) { fprintf(outfile, - " [ label= \"fmt:%s w:%d h:%d tb:%d/%d\" ]", + "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:%d cl:%s\" ]", + "fmt:%s sr:%d 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"); + fprintf(outfile, "\" ];\n"); } } } diff --git a/tools/ismindex.c b/tools/ismindex.c index bf8c69d..b801d43 100644 --- a/tools/ismindex.c +++ b/tools/ismindex.c @@ -20,7 +20,7 @@ /* * To create a simple file for smooth streaming: - * avconv <normal input/transcoding options> -movflags frag_keyframe foo.ismv + * ffmpeg <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. diff --git a/tools/make_chlayout_test b/tools/make_chlayout_test new file mode 100755 index 0000000..fcdbda3 --- /dev/null +++ b/tools/make_chlayout_test @@ -0,0 +1,114 @@ +#!/usr/bin/env perl + +# Copyright (c) 2012 Nicolas George +# +# 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 + +=head1 NAME + +make_chlayout_test - produce a multichannel test file with the channels +clearly identified + +=head1 SYNOPSIS + +tools/make_chlayout_test I<channels> I<out_options> + +=head1 DESCRIPTION + +This script uses B<ffmpeg> and B<libflite> to produce a file with audio +channels clearly identified by their name. The resulting file can be used to +check that the layout and order of channels is correctly handled by a piece +of software, either a part of B<FFmpeg> or not. + +I<channels> is a list of channels or channel layouts, separated by '+'. + +I<out_options> is a list of valid ffmpeg outout options, including the +output file. + +Note that some output codecs or formats can not handle arbitrary channel +layout. + +This script requires a B<ffmpeg> binary, either in the source tree or in the +search path; it must have the flite audio source enabled. + +=head1 EXAMPLES + +Check that the speakers are correctly plugged: + + tools/make_chlayout_test FL+FR -f alsa default + +Produce a 5.1 FLAC file: + + tools/make_chlayout_test 5.1 surround.flac + +=cut + +use strict; +use warnings; +use Getopt::Long ":config" => "require_order"; +use Pod::Usage; + +GetOptions ( + "help|usage|?|h" => sub { pod2usage({ -verbose => 1, -exitval => 0 }) }, + "manpage|m" => sub { pod2usage({ -verbose => 2, -exitval => 0 }) }, +) and @ARGV >= 2 or pod2usage({ -verbose => 1, -exitval => 1 }); + +my $channels = shift @ARGV; +my @out_options = @ARGV; + +my $ffmpeg = exists $ENV{FFMPEG} ? $ENV{FFMPEG} : + $0 =~ /(.*)\// && -e "$1/../ffmpeg" ? "$1/../ffmpeg" : + "ffmpeg"; + +my %channel_label_to_descr; +my %layout_to_channels; + +{ + open my $stderr, ">&STDERR"; + open STDERR, ">", "/dev/null"; + open my $f, "-|", $ffmpeg, "-layouts" or die "$ffmpeg: $!\n"; + open STDERR, ">&", $stderr; + while (<$f>) { + chomp; + next if /^NAME/ or /:$/ or /^$/; # skip headings + my ($name, $descr) = split " ", $_, 2; + next unless $descr; + if ($descr =~ /^[[:upper:]]+(?:\+[[:upper:]]+)*$/) { + $layout_to_channels{$name} = [ split /\+/, $descr ]; + } else { + $channel_label_to_descr{$name} = $descr; + } + } +} + +my @channels = map { @{$layout_to_channels{$_} // [$_]} } split /\+/, $channels; + +my $layout = join "+", @channels; +my $graph = ""; +my $concat_in = ""; +for my $i (0 .. $#channels) { + my $label = $channels[$i]; + my $descr = $channel_label_to_descr{$label} + or die "Channel $label not found\n"; + $graph .= "flite=text='${descr}', aformat=channel_layouts=mono, " . + "pan=${layout}:${label}=c0 [ch$i] ;\n"; + $concat_in .= "[ch$i] "; +} +$graph .= "${concat_in}concat=v=0:a=1:n=" . scalar(@channels); + +exec $ffmpeg, "-f", "lavfi", "-i", $graph, @out_options + or die "$ffmpeg: $!\n"; diff --git a/tools/missing_codec_desc b/tools/missing_codec_desc new file mode 100755 index 0000000..093d02e --- /dev/null +++ b/tools/missing_codec_desc @@ -0,0 +1,37 @@ +#!/bin/sh + +srcdir=${0%/*}/.. + +while read -r field equal value; do + case "$field $equal" in + ".id =") + eval "known_${value%,}=1" + ;; + esac +done < $srcdir/libavcodec/codec_desc.c + +known_AV_CODEC_ID_NONE=1 +known_AV_CODEC_ID_FIRST_AUDIO=1 +known_AV_CODEC_ID_FIRST_SUBTITLE=1 +known_AV_CODEC_ID_FIRST_UNKNOWN=1 +known_AV_CODEC_ID_TTF=1 +known_AV_CODEC_ID_PROBE=1 +known_AV_CODEC_ID_MPEG2TS=1 +known_AV_CODEC_ID_MPEG4SYSTEMS=1 +known_AV_CODEC_ID_FFMETADATA=1 + +in=0 +while read -r line; do + case "$in-$line" in + 0-"enum AVCodecID"*) in=1;; + 1-*"};"*) in=0;; + 1-*AV_CODEC_ID_*,*) + cid="${line%%[, =]*}" + eval "known=\$known_$cid" + case "$known" in + 1) ;; + *) echo "$cid missing";; + esac + ;; + esac +done < $srcdir/libavcodec/avcodec.h diff --git a/tools/patcheck b/tools/patcheck index 78ca824..f82787b 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_]*' @@ -67,7 +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|wont|usefull|successfull|occured|teh|alot|wether|skiped|heigth|informations|colums|loosy|loosing|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention|acheive)\b' 'common typos' $* +hiegrep '\b(awnser|cant|dont|wont|usefull|successfull|occured|teh|alot|wether|skiped|skiping|heigth|informations|colums|loosy|loosing|ouput|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention|acheive|funtions|overriden|outputing|seperation|initalize|compatibilty)\b' 'common typos' $* hiegrep 'av_log\( *NULL' 'Missing context in av_log' $* hiegrep '[^sn]printf' 'Please use av_log' $* diff --git a/tools/pktdumper.c b/tools/pktdumper.c index 98b9327..920397b 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 */ diff --git a/tools/probetest.c b/tools/probetest.c index 678f4dd..f8a617d 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 */ @@ -49,12 +49,19 @@ static void probe(AVProbeData *pd, int type, int p, int size) } } -int main(void) +int main(int argc, char **argv) { unsigned int p, i, type, size, retry; AVProbeData pd; AVLFG state; PutBitContext pb; + int retry_count= 4097; + int max_size = 65537; + + if(argc >= 2) + retry_count = atoi(argv[1]); + if(argc >= 3) + max_size = atoi(argv[2]); avcodec_register_all(); av_register_all(); @@ -62,14 +69,14 @@ int main(void) av_lfg_init(&state, 0xdeadbeef); pd.buf = NULL; - for (size = 1; size < 65537; size *= 2) { + for (size = 1; size < max_size; size *= 2) { pd.buf_size = size; pd.buf = av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE); pd.filename = ""; fprintf(stderr, "testing size=%d\n", size); - for (retry = 0; retry < 4097; retry += FFMAX(size, 32)) { + for (retry = 0; retry < retry_count; retry += FFMAX(size, 32)) { for (type = 0; type < 4; type++) { for (p = 0; p < 4096; p++) { unsigned hist = 0; diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index f33d6fa..b9dbdfd 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 @@ -37,6 +37,8 @@ #define ftello(x) _ftelli64(x) #endif +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) + #define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) #define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \ @@ -77,7 +79,7 @@ #define CO64_ATOM QT_ATOM('c', 'o', '6', '4') #define ATOM_PREAMBLE_SIZE 8 -#define COPY_BUFFER_SIZE 1024 +#define COPY_BUFFER_SIZE 33554432 int main(int argc, char *argv[]) { @@ -96,7 +98,7 @@ int main(int argc, char *argv[]) uint32_t offset_count; uint64_t current_offset; uint64_t start_offset = 0; - unsigned char copy_buffer[COPY_BUFFER_SIZE]; + unsigned char *copy_buffer = NULL; int bytes_to_copy; if (argc != 3) { @@ -293,12 +295,15 @@ int main(int argc, char *argv[]) } /* copy the remainder of the infile, from offset 0 -> last_offset - 1 */ + bytes_to_copy = FFMIN(COPY_BUFFER_SIZE, last_offset); + copy_buffer = malloc(bytes_to_copy); + if (!copy_buffer) { + printf("could not allocate %"PRIu64" bytes for copy_buffer\n", bytes_to_copy); + goto error_out; + } printf(" copying rest of file...\n"); while (last_offset) { - if (last_offset > COPY_BUFFER_SIZE) - bytes_to_copy = COPY_BUFFER_SIZE; - else - bytes_to_copy = last_offset; + bytes_to_copy = FFMIN(bytes_to_copy, last_offset); if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) { perror(argv[1]); @@ -315,6 +320,7 @@ int main(int argc, char *argv[]) fclose(outfile); free(moov_atom); free(ftyp_atom); + free(copy_buffer); return 0; @@ -325,5 +331,6 @@ error_out: fclose(outfile); free(moov_atom); free(ftyp_atom); + free(copy_buffer); return 1; } diff --git a/tools/trasher.c b/tools/trasher.c index 35625e9..93bfc0c 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 */ diff --git a/tools/unwrap-diff b/tools/unwrap-diff new file mode 100755 index 0000000..ccea99b --- /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' diff --git a/tools/yuvcmp.c b/tools/yuvcmp.c new file mode 100644 index 0000000..11585f9 --- /dev/null +++ b/tools/yuvcmp.c @@ -0,0 +1,182 @@ +/* + * originally by Andreas Ă–man (andoma) + * some changes by Alexander Strange + */ + +#include <string.h> +#include <stdlib.h> +#include <inttypes.h> +#include <stdio.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> + + +int +main(int argc, char **argv) +{ + int fd[2]; + int print_pixels = 0; + int dump_blocks = 0; + + int width; + int height; + int to_skip = 0; + + if (argc < 6) { + fprintf(stderr, "%s [YUV file 1] [YUV file 2] width height pixelcmp|blockdump (# to skip)\n", argv[0]); + return 1; + } + + width = atoi(argv[3]); + height = atoi(argv[4]); + if (argc > 6) + to_skip = atoi(argv[6]); + + uint8_t *Y[2], *C[2][2]; + int i, v, c, p; + int lsiz = width * height; + int csiz = width * height / 4; + int x, y; + int cwidth = width / 2; + int fr = to_skip; + int mb; + char *mberrors; + int mb_x, mb_y; + uint8_t *a; + uint8_t *b; + int die = 0; + + print_pixels = strstr(argv[5], "pixelcmp") ? 1 : 0; + dump_blocks = strstr(argv[5], "blockdump") ? 1 : 0; + + for(i = 0; i < 2; i++) { + Y[i] = malloc(lsiz); + C[0][i] = malloc(csiz); + C[1][i] = malloc(csiz); + + fd[i] = open(argv[1 + i], O_RDONLY); + if(fd[i] == -1) { + perror("open"); + exit(1); + } + fcntl(fd[i], F_NOCACHE, 1); + + if (to_skip) + lseek(fd[i], to_skip * (lsiz + 2*csiz), SEEK_SET); + } + + mb_x = width / 16; + mb_y = height / 16; + + mberrors = malloc(mb_x * mb_y); + + while(!die) { + memset(mberrors, 0, mb_x * mb_y); + + printf("Loading frame %d\n", ++fr); + + for(i = 0; i < 2; i++) { + v = read(fd[i], Y[i], lsiz); + if(v != lsiz) { + fprintf(stderr, "Unable to read Y from file %d, exiting\n", i + 1); + return 1; + } + } + + + for(c = 0; c < lsiz; c++) { + if(Y[0][c] != Y[1][c]) { + x = c % width; + y = c / width; + + mb = x / 16 + (y / 16) * mb_x; + + if(print_pixels) + printf("Luma diff 0x%02x != 0x%02x at pixel (%4d,%-4d) mb(%d,%d) #%d\n", + Y[0][c], + Y[1][c], + x, y, + x / 16, + y / 16, + mb); + + mberrors[mb] |= 1; + } + } + + /* Chroma planes */ + + for(p = 0; p < 2; p++) { + + for(i = 0; i < 2; i++) { + v = read(fd[i], C[p][i], csiz); + if(v != csiz) { + fprintf(stderr, "Unable to read %c from file %d, exiting\n", + "UV"[p], i + 1); + return 1; + } + } + + for(c = 0; c < csiz; c++) { + if(C[p][0][c] != C[p][1][c]) { + x = c % cwidth; + y = c / cwidth; + + mb = x / 8 + (y / 8) * mb_x; + + mberrors[mb] |= 2 << p; + + if(print_pixels) + + printf("c%c diff 0x%02x != 0x%02x at pixel (%4d,%-4d) " + "mb(%3d,%-3d) #%d\n", + p ? 'r' : 'b', + C[p][0][c], + C[p][1][c], + + x, y, + x / 8, + y / 8, + x / 8 + y / 8 * cwidth / 8); + } + } + } + + for(i = 0; i < mb_x * mb_y; i++) { + x = i % mb_x; + y = i / mb_x; + + if(mberrors[i]) { + die = 1; + + printf("MB (%3d,%-3d) %4d %d %c%c%c damaged\n", + x, y, i, mberrors[i], + mberrors[i] & 1 ? 'Y' : ' ', + mberrors[i] & 2 ? 'U' : ' ', + mberrors[i] & 4 ? 'V' : ' '); + + if(dump_blocks) { + a = Y[0] + x * 16 + y * 16 * width; + b = Y[1] + x * 16 + y * 16 * width; + + for(y = 0; y < 16; y++) { + printf("%c ", "TB"[y&1]); + for(x = 0; x < 16; x++) + printf("%02x%c", a[x + y * width], + a[x + y * width] != b[x + y * width] ? '<' : ' '); + + printf("| "); + for(x = 0; x < 16; x++) + printf("%02x%c", b[x + y * width], + a[x + y * width] != b[x + y * width] ? '<' : ' '); + + printf("\n"); + } + } + } + } + } + + return 0; +} |