tools: K&R reformatting cosmetics

release/0.10
Diego Biurrun 13 years ago
parent 50639cbefe
commit 4e81b5f517
  1. 2
      tools/aviocat.c
  2. 34
      tools/cws2fws.c
  3. 24
      tools/graph2dot.c
  4. 23
      tools/ismindex.c
  5. 6
      tools/lavfi-showfiltfmts.c
  6. 8
      tools/pktdumper.c
  7. 24
      tools/probetest.c
  8. 1
      tools/qt-faststart.c
  9. 9
      tools/trasher.c

@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "libavformat/avformat.h"
static int usage(const char *argv0, int ret)
@ -87,6 +88,7 @@ int main(int argc, char **argv)
avio_flush(output);
avio_close(output);
fail:
avio_close(input);
avformat_network_deinit();

@ -26,37 +26,32 @@ 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]);
return 1;
}
fd_in = open(argv[1], O_RDONLY);
if (fd_in < 0)
{
if (fd_in < 0) {
perror("Error opening input file");
return 1;
}
fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
if (fd_out < 0)
{
if (fd_out < 0) {
perror("Error opening output file");
close(fd_in);
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);
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");
return 1;
}
@ -65,7 +60,8 @@ int main(int argc, char *argv[])
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';
@ -79,8 +75,7 @@ int main(int argc, char *argv[])
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);
@ -93,18 +88,18 @@ int main(int argc, char *argv[])
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);
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");
return 1;
}
@ -115,8 +110,7 @@ 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);

@ -63,19 +63,25 @@ 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\" ]",
av_get_sample_fmt_name(link->format),
link->sample_rate, buf);
}
@ -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;
}

@ -35,6 +35,7 @@
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "libavformat/avformat.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mathematics.h"
@ -149,10 +150,9 @@ static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f)
version = avio_r8(f);
avio_rb24(f);
track_id = avio_rb32(f); /* track id */
for (i = start_index; i < files->nb_files && !vf; i++) {
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;
@ -187,6 +187,7 @@ static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f)
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;
@ -254,6 +255,7 @@ static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
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;
@ -307,8 +309,9 @@ static int handle_file(struct VideoFiles *files, const char *file, int split)
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);
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;
}
@ -414,7 +417,8 @@ static void output_client_manifest(struct VideoFiles *files,
if (files->video_file >= 0) {
struct VideoFile *vf = files->files[files->video_file];
int index = 0;
fprintf(out, "\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" "
fprintf(out,
"\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" "
"Chunks=\"%d\" "
"Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n",
files->nb_video_files, vf->chunks);
@ -422,7 +426,8 @@ static void output_client_manifest(struct VideoFiles *files,
vf = files->files[i];
if (!vf->is_video)
continue;
fprintf(out, "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
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);
@ -440,7 +445,8 @@ static void output_client_manifest(struct VideoFiles *files,
if (files->audio_file >= 0) {
struct VideoFile *vf = files->files[files->audio_file];
int index = 0;
fprintf(out, "\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" "
fprintf(out,
"\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" "
"Chunks=\"%d\" "
"Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n",
files->nb_audio_files, vf->chunks);
@ -448,7 +454,8 @@ static void output_client_manifest(struct VideoFiles *files,
vf = files->files[i];
if (!vf->is_audio)
continue;
fprintf(out, "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
fprintf(out,
"\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
"FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" "
"BitsPerSample=\"16\" PacketSize=\"%d\" "
"AudioTag=\"%d\" CodecPrivateData=\"",

@ -50,11 +50,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, "Inpossible 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;
}

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libavformat/avformat.h"
#define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
@ -99,8 +100,11 @@ 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);

@ -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++) {
@ -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;
}

@ -138,7 +138,6 @@ 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) {

@ -23,7 +23,8 @@
#include <inttypes.h>
static uint32_t state;
static uint32_t ran(void){
static uint32_t ran(void)
{
return state = state * 1664525 + 1013904223;
}
@ -55,7 +56,8 @@ int main(int argc, char** argv)
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)
continue;
@ -63,7 +65,8 @@ int main(int argc, char** argv)
while (burst--) {
int val = ran() * 256ULL / UINT32_MAX;
if(maxburst<0) val=0;
if (maxburst < 0)
val = 0;
fwrite(&val, 1, 1, f);
}

Loading…
Cancel
Save