summaryrefslogtreecommitdiff
path: root/ffmpeg/tools
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/tools
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/tools')
-rw-r--r--ffmpeg/tools/aviocat.c8
-rw-r--r--ffmpeg/tools/enum_options.c8
-rw-r--r--ffmpeg/tools/ffeval.c41
-rw-r--r--ffmpeg/tools/fourcc2pixfmt.c2
-rw-r--r--ffmpeg/tools/graph2dot.c12
-rw-r--r--ffmpeg/tools/ismindex.c32
-rwxr-xr-xffmpeg/tools/patcheck4
-rw-r--r--ffmpeg/tools/pktdumper.c10
-rw-r--r--ffmpeg/tools/probetest.c37
-rw-r--r--ffmpeg/tools/qt-faststart.c6
-rw-r--r--ffmpeg/tools/seek_print.c4
11 files changed, 95 insertions, 69 deletions
diff --git a/ffmpeg/tools/aviocat.c b/ffmpeg/tools/aviocat.c
index 52a96bd..e161d58 100644
--- a/ffmpeg/tools/aviocat.c
+++ b/ffmpeg/tools/aviocat.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2012 Martin Storsjo
*
- * 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/ffmpeg/tools/enum_options.c b/ffmpeg/tools/enum_options.c
index 45ac727..c2a295c 100644
--- a/ffmpeg/tools/enum_options.c
+++ b/ffmpeg/tools/enum_options.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2011 Anton Khirnov
*
- * 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/ffmpeg/tools/ffeval.c b/ffmpeg/tools/ffeval.c
index 0fab877..66b1032 100644
--- a/ffmpeg/tools/ffeval.c
+++ b/ffmpeg/tools/ffeval.c
@@ -24,6 +24,7 @@
#endif
#include "libavutil/eval.h"
+#include "libavutil/mem.h"
#if !HAVE_GETOPT
#include "compat/getopt.c"
@@ -47,20 +48,26 @@ static void usage(void)
"-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);
+ int buf_size = 0;
+ char *buf = NULL;
const char *outfilename = NULL, *infilename = NULL;
FILE *outfile = NULL, *infile = NULL;
const char *prompt = "=> ";
int count = 0, echo = 0;
int c;
- av_max_alloc(MAX_BLOCK_SIZE);
+#define GROW_ARRAY() \
+ do { \
+ if (!av_dynarray2_add((void **)&buf, &buf_size, 1, NULL)) { \
+ av_log(NULL, AV_LOG_ERROR, \
+ "Memory allocation problem occurred\n"); \
+ return 1; \
+ } \
+ } while (0)
+ GROW_ARRAY();
while ((c = getopt(argc, argv, "ehi:o:p:")) != -1) {
switch (c) {
case 'e':
@@ -111,28 +118,18 @@ int main(int argc, char **argv)
buf[count] = 0;
if (buf[0] != '#') {
- av_expr_parse_and_eval(&d, buf,
- NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, 0, NULL);
+ int ret = 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);
+ if (ret >= 0) fprintf(outfile, "%s%f\n", prompt, d);
+ else fprintf(outfile, "%s%s\n", prompt, av_err2str(ret));
}
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;
- }
- }
+ if (count >= buf_size-1)
+ GROW_ARRAY();
buf[count++] = c;
}
}
diff --git a/ffmpeg/tools/fourcc2pixfmt.c b/ffmpeg/tools/fourcc2pixfmt.c
index 77cb0b6..1a653ed 100644
--- a/ffmpeg/tools/fourcc2pixfmt.c
+++ b/ffmpeg/tools/fourcc2pixfmt.c
@@ -102,7 +102,7 @@ int main(int argc, char **argv)
if (list_pix_fmt_fourccs) {
for (i = 0; i < AV_PIX_FMT_NB; i++) {
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(i);
- if (!pix_desc->name || pix_desc->flags & PIX_FMT_HWACCEL)
+ if (!pix_desc->name || pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL)
continue;
printf("%s: ", pix_desc->name);
print_pix_fmt_fourccs(i, ' ');
diff --git a/ffmpeg/tools/graph2dot.c b/ffmpeg/tools/graph2dot.c
index d53642f..964322d 100644
--- a/ffmpeg/tools/graph2dot.c
+++ b/ffmpeg/tools/graph2dot.c
@@ -28,7 +28,7 @@
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "libavutil/pixdesc.h"
-#include "libavfilter/avfiltergraph.h"
+#include "libavfilter/avfilter.h"
#if !HAVE_GETOPT
#include "compat/getopt.c"
@@ -36,7 +36,7 @@
static void usage(void)
{
- printf("Convert a libavfilter graph to a dot file\n");
+ printf("Convert a libavfilter graph to a dot file.\n");
printf("Usage: graph2dot [OPTIONS]\n");
printf("\n"
"Options:\n"
@@ -66,7 +66,7 @@ static void print_digraph(FILE *outfile, AVFilterGraph *graph)
filter_ctx->name,
filter_ctx->filter->name);
- for (j = 0; j < filter_ctx->output_count; j++) {
+ for (j = 0; j < filter_ctx->nb_outputs; j++) {
AVFilterLink *link = filter_ctx->outputs[j];
if (link) {
char dst_filter_ctx_label[128];
@@ -137,7 +137,7 @@ 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",
+ fprintf(stderr, "Failed to open input file '%s': %s\n",
infilename, strerror(errno));
return 1;
}
@@ -146,7 +146,7 @@ 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",
+ fprintf(stderr, "Failed to open output file '%s': %s\n",
outfilename, strerror(errno));
return 1;
}
@@ -179,7 +179,7 @@ int main(int argc, char **argv)
avfilter_register_all();
if (avfilter_graph_parse(graph, graph_string, NULL, NULL, NULL) < 0) {
- fprintf(stderr, "Impossible to parse the graph description\n");
+ fprintf(stderr, "Failed to parse the graph description\n");
return 1;
}
diff --git a/ffmpeg/tools/ismindex.c b/ffmpeg/tools/ismindex.c
index 502a7dc..4dc3e12 100644
--- a/ffmpeg/tools/ismindex.c
+++ b/ffmpeg/tools/ismindex.c
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2012 Martin Storsjo
*
- * 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
*/
@@ -34,15 +34,11 @@
#include <stdio.h>
#include <string.h>
-#include <sys/stat.h>
-#ifdef _WIN32
-#include <direct.h>
-#define mkdir(a, b) _mkdir(a)
-#endif
#include "cmdutils.h"
#include "libavformat/avformat.h"
+#include "libavformat/os_support.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@@ -55,7 +51,7 @@ static int usage(const char *argv0, int ret)
struct MoofOffset {
int64_t time;
int64_t offset;
- int duration;
+ int64_t duration;
};
struct Track {
@@ -132,7 +128,8 @@ static int write_fragments(struct Tracks *tracks, int start_index,
struct Track *track = tracks->tracks[i];
const char *type = track->is_video ? "video" : "audio";
snprintf(dirname, sizeof(dirname), "QualityLevels(%d)", track->bitrate);
- mkdir(dirname, 0777);
+ if (mkdir(dirname, 0777) == -1)
+ return AVERROR(errno);
for (j = 0; j < track->chunks; j++) {
snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
dirname, type, track->offsets[j].time);
@@ -224,7 +221,7 @@ static int read_mfra(struct Tracks *tracks, int start_index,
}
if (split)
- write_fragments(tracks, start_index, f);
+ err = write_fragments(tracks, start_index, f);
fail:
if (f)
@@ -301,8 +298,6 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
fprintf(stderr, "No streams found in %s\n", file);
goto fail;
}
- if (!tracks->duration)
- tracks->duration = ctx->duration;
for (i = 0; i < ctx->nb_streams; i++) {
struct Track **temp;
@@ -329,8 +324,7 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
track->bitrate = st->codec->bit_rate;
track->track_id = st->id;
track->timescale = st->time_base.den;
- track->duration = av_rescale_rnd(ctx->duration, track->timescale,
- AV_TIME_BASE, AV_ROUND_UP);
+ track->duration = st->duration;
track->is_audio = st->codec->codec_type == AVMEDIA_TYPE_AUDIO;
track->is_video = st->codec->codec_type == AVMEDIA_TYPE_VIDEO;
@@ -342,6 +336,10 @@ static int handle_file(struct Tracks *tracks, const char *file, int split)
continue;
}
+ tracks->duration = FFMAX(tracks->duration,
+ av_rescale_rnd(track->duration, AV_TIME_BASE,
+ track->timescale, AV_ROUND_UP));
+
if (track->is_audio) {
if (tracks->audio_track < 0)
tracks->audio_track = tracks->nb_tracks;
@@ -433,7 +431,7 @@ static void print_track_chunks(FILE *out, struct Tracks *tracks, int main,
fprintf(stderr, "Mismatched duration of %s chunk %d in %s and %s\n",
type, i, track->name, tracks->tracks[j]->name);
}
- fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n",
+ fprintf(out, "\t\t<c n=\"%d\" d=\"%"PRId64"\" />\n",
i, track->offsets[i].duration);
}
}
diff --git a/ffmpeg/tools/patcheck b/ffmpeg/tools/patcheck
index 83db4c0..59a16ef 100755
--- a/ffmpeg/tools/patcheck
+++ b/ffmpeg/tools/patcheck
@@ -50,7 +50,7 @@ hiegrep2 '\b_[a-zA-Z0-9_]{1,}' '__(asm|attribute)([^a-zA-Z0-9]|$)' 'reserved ide
hiegrep '//[-/<\* ]*$' 'empty comment' $*
hiegrep '/\*[-<\* ]*\*/' 'empty comment' $*
hiegrep 'for *\( *'"$ERE_PRITYP"' ' 'not gcc 2.95 compatible' $*
-hiegrep '(static|inline|const) *\1' 'duplicate word' $*
+hiegrep '(static|inline|const) *\1[^_a-zA-Z]' 'duplicate word' $*
hiegrep 'INIT_VLC_USE_STATIC' 'forbidden ancient vlc type' $*
hiegrep '=[-+\*\&] ' 'looks like compound assignment' $*
hiegrep2 '/\*\* *[a-zA-Z0-9].*' '\*/' 'Inconsistently formatted doxygen comment' $*
@@ -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|skiping|heigth|informations|colums|loosy|loosing|ouput|seperate|preceed|upto|paket|posible|unkown|inpossible|dimention|acheive|funtions|overriden|outputing|seperation|initalize|compatibilty|bistream|knwon|unknwon)\b' 'common typos' $*
+hiegrep '\b(awnser|cant|dont|wont|doesnt|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|bistream|knwon|unknwon)\b' 'common typos' $*
hiegrep 'av_log\( *NULL' 'Missing context in av_log' $*
hiegrep '[^sn]printf' 'Please use av_log' $*
diff --git a/ffmpeg/tools/pktdumper.c b/ffmpeg/tools/pktdumper.c
index 920397b..61cb5cc 100644
--- a/ffmpeg/tools/pktdumper.c
+++ b/ffmpeg/tools/pktdumper.c
@@ -31,18 +31,18 @@
#include <io.h>
#endif
-#define FILENAME_BUF_SIZE 4096
-
#include "libavutil/avstring.h"
#include "libavutil/time.h"
#include "libavformat/avformat.h"
+#define FILENAME_BUF_SIZE 4096
#define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
static int usage(int ret)
{
- fprintf(stderr, "dump (up to maxpkts) AVPackets as they are demuxed by libavformat.\n");
- fprintf(stderr, "each packet is dumped in its own file named like `basename file.ext`_$PKTNUM_$STREAMINDEX_$STAMP_$SIZE_$FLAGS.bin\n");
+ fprintf(stderr, "Dump (up to maxpkts) AVPackets as they are demuxed by libavformat.\n");
+ fprintf(stderr, "Each packet is dumped in its own file named like\n");
+ fprintf(stderr, "$(basename file.ext)_$PKTNUM_$STREAMINDEX_$STAMP_$SIZE_$FLAGS.bin\n");
fprintf(stderr, "pktdumper [-nw] file [maxpkts]\n");
fprintf(stderr, "-n\twrite No file at all, only demux.\n");
fprintf(stderr, "-w\tWait at end of processing instead of quitting.\n");
@@ -79,7 +79,7 @@ int main(int argc, char **argv)
if (strrchr(fntemplate, '.'))
*strrchr(fntemplate, '.') = '\0';
if (strchr(fntemplate, '%')) {
- fprintf(stderr, "can't use filenames containing '%%'\n");
+ fprintf(stderr, "cannot use filenames containing '%%'\n");
return usage(1);
}
if (strlen(fntemplate) + sizeof(PKTFILESUFF) >= sizeof(fntemplate) - 1) {
diff --git a/ffmpeg/tools/probetest.c b/ffmpeg/tools/probetest.c
index b13c6f9..b685e3d 100644
--- a/ffmpeg/tools/probetest.c
+++ b/ffmpeg/tools/probetest.c
@@ -23,10 +23,17 @@
#include "libavformat/avformat.h"
#include "libavcodec/put_bits.h"
#include "libavutil/lfg.h"
+#include "libavutil/timer.h"
-static int score_array[1000]; //this must be larger than the number of formats
+#define MAX_FORMATS 1000 //this must be larger than the number of formats
+static int score_array[MAX_FORMATS];
+static int64_t time_array[MAX_FORMATS];
static int failures = 0;
+#ifndef AV_READ_TIME
+#define AV_READ_TIME(x) 0
+#endif
+
static void probe(AVProbeData *pd, int type, int p, int size)
{
int i = 0;
@@ -36,7 +43,10 @@ static void probe(AVProbeData *pd, int type, int p, int size)
if (fmt->flags & AVFMT_NOFILE)
continue;
if (fmt->read_probe) {
- int score = fmt->read_probe(pd);
+ int score;
+ int64_t start = AV_READ_TIME();
+ score = fmt->read_probe(pd);
+ time_array[i] += AV_READ_TIME() - start;
if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) {
score_array[i] = score;
fprintf(stderr,
@@ -49,6 +59,22 @@ static void probe(AVProbeData *pd, int type, int p, int size)
}
}
+static void print_times(void)
+{
+ int i = 0;
+ AVInputFormat *fmt = NULL;
+
+ while ((fmt = av_iformat_next(fmt))) {
+ if (fmt->flags & AVFMT_NOFILE)
+ continue;
+ if (time_array[i] > 1000000) {
+ fprintf(stderr, "%12"PRIu64" cycles, %12s\n",
+ time_array[i], fmt->name);
+ }
+ i++;
+ }
+}
+
int main(int argc, char **argv)
{
unsigned int p, i, type, size, retry;
@@ -84,6 +110,11 @@ int main(int argc, char **argv)
pd.buf = av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE);
pd.filename = "";
+ if (!pd.buf) {
+ fprintf(stderr, "out of memory\n");
+ return 1;
+ }
+
memset(pd.buf, 0, size + AVPROBE_PADDING_SIZE);
fprintf(stderr, "testing size=%d\n", size);
@@ -141,5 +172,7 @@ int main(int argc, char **argv)
}
}
}
+ if(AV_READ_TIME())
+ print_times();
return failures;
}
diff --git a/ffmpeg/tools/qt-faststart.c b/ffmpeg/tools/qt-faststart.c
index c9aa6e8..cb36c43 100644
--- a/ffmpeg/tools/qt-faststart.c
+++ b/ffmpeg/tools/qt-faststart.c
@@ -229,7 +229,7 @@ int main(int argc, char *argv[])
atom_type = BE_32(&moov_atom[i]);
if (atom_type == STCO_ATOM) {
printf(" patching stco atom...\n");
- atom_size = BE_32(&moov_atom[i - 4]);
+ atom_size = (uint32_t)BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
printf(" bad atom size\n");
goto error_out;
@@ -240,7 +240,7 @@ int main(int argc, char *argv[])
goto error_out;
}
for (j = 0; j < offset_count; j++) {
- current_offset = BE_32(&moov_atom[i + 12 + j * 4]);
+ current_offset = (uint32_t)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;
@@ -250,7 +250,7 @@ int main(int argc, char *argv[])
i += atom_size - 4;
} else if (atom_type == CO64_ATOM) {
printf(" patching co64 atom...\n");
- atom_size = BE_32(&moov_atom[i - 4]);
+ atom_size = (uint32_t)BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
printf(" bad atom size\n");
goto error_out;
diff --git a/ffmpeg/tools/seek_print.c b/ffmpeg/tools/seek_print.c
index a99a0ad..c42b28d 100644
--- a/ffmpeg/tools/seek_print.c
+++ b/ffmpeg/tools/seek_print.c
@@ -18,8 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <unistd.h>
-
#include "config.h"
#if HAVE_UNISTD_H
#include <unistd.h> /* getopt */
@@ -91,7 +89,7 @@ int main(int argc, char **argv)
av_ts2str(packet.pts), av_ts2timestr(packet.pts, tb));
av_free_packet(&packet);
}
- } else if (sscanf(*argv, "seek:%i:%"PRIi64":%"PRIi64":%"PRIi64":%i",
+ } else if (sscanf(*argv, "seek:%i:%"SCNi64":%"SCNi64":%"SCNi64":%i",
&stream, &min_ts, &ts, &max_ts, &flags) == 5) {
ret = avformat_seek_file(avf, stream, min_ts, ts, max_ts, flags);
printf("seek: %d (%s)\n", ret, av_err2str(ret));