---
 avprobe.c         |   59 +++++++++++++++--------
 cmdutils.h        |   18 +++++--
 tests/audiogen.c  |   32 ++++++------
 tests/base64.c    |    6 +-
 tests/rotozoom.c  |   80 +++++++++++++++---------------
 tests/tiny_psnr.c |  116 +++++++++++++++++++++++---------------------
 tests/videogen.c  |  138 ++++++++++++++++++++++++++--------------------------
 7 files changed, 239 insertions(+), 210 deletions(-)

diff --git a/avprobe.c b/avprobe.c
index de9657b..a50e83d 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -78,17 +78,18 @@ static char *value_string(char *buf, int buf_size, double 
val, const char *unit)
 
         if (unit == unit_byte_str && use_byte_value_binary_prefix) {
             index = (int) (log(val)/log(2)) / 10;
-            index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) -1);
-            val /= pow(2, index*10);
+            index = av_clip(index, 0, FF_ARRAY_ELEMS(binary_unit_prefixes) - 
1);
+            val  /= pow(2, index * 10);
             prefix_string = binary_unit_prefixes[index];
         } else {
             index = (int) (log10(val)) / 3;
-            index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) 
-1);
-            val /= pow(10, index*3);
+            index = av_clip(index, 0, FF_ARRAY_ELEMS(decimal_unit_prefixes) - 
1);
+            val  /= pow(10, index * 3);
             prefix_string = decimal_unit_prefixes[index];
         }
 
-        snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string, 
show_value_unit ? unit : "");
+        snprintf(buf, buf_size, "%.3f %s%s", val, prefix_string,
+                 show_value_unit ? unit : "");
     } else {
         snprintf(buf, buf_size, "%f %s", val, show_value_unit ? unit : "");
     }
@@ -96,7 +97,8 @@ static char *value_string(char *buf, int buf_size, double 
val, const char *unit)
     return buf;
 }
 
-static char *time_value_string(char *buf, int buf_size, int64_t val, const 
AVRational *time_base)
+static char *time_value_string(char *buf, int buf_size, int64_t val,
+                               const AVRational *time_base)
 {
     if (val == AV_NOPTS_VALUE) {
         snprintf(buf, buf_size, "N/A");
@@ -138,13 +140,24 @@ static void show_packet(AVFormatContext *fmt_ctx, 
AVPacket *pkt)
     printf("[PACKET]\n");
     printf("codec_type=%s\n"   , media_type_string(st->codec->codec_type));
     printf("stream_index=%d\n" , pkt->stream_index);
-    printf("pts=%s\n"          , ts_value_string  (val_str, sizeof(val_str), 
pkt->pts));
-    printf("pts_time=%s\n"     , time_value_string(val_str, sizeof(val_str), 
pkt->pts, &st->time_base));
-    printf("dts=%s\n"          , ts_value_string  (val_str, sizeof(val_str), 
pkt->dts));
-    printf("dts_time=%s\n"     , time_value_string(val_str, sizeof(val_str), 
pkt->dts, &st->time_base));
-    printf("duration=%s\n"     , ts_value_string  (val_str, sizeof(val_str), 
pkt->duration));
-    printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str), 
pkt->duration, &st->time_base));
-    printf("size=%s\n"         , value_string     (val_str, sizeof(val_str), 
pkt->size, unit_byte_str));
+    printf("pts=%s\n"          , ts_value_string  (val_str, sizeof(val_str),
+                                                   pkt->pts));
+    printf("pts_time=%s\n"     , time_value_string(val_str, sizeof(val_str),
+                                                   pkt->pts,
+                                                   &st->time_base));
+    printf("dts=%s\n"          , ts_value_string  (val_str, sizeof(val_str),
+                                                   pkt->dts));
+    printf("dts_time=%s\n"     , time_value_string(val_str, sizeof(val_str),
+                                                   pkt->dts,
+                                                   &st->time_base));
+    printf("duration=%s\n"     , ts_value_string  (val_str, sizeof(val_str),
+                                                   pkt->duration));
+    printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str),
+                                                   pkt->duration,
+                                                   &st->time_base));
+    printf("size=%s\n"         , value_string     (val_str, sizeof(val_str),
+                                                   pkt->size,
+                                                   unit_byte_str));
     printf("pos=%"PRId64"\n"   , pkt->pos);
     printf("flags=%c\n"        , pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
     printf("[/PACKET]\n");
@@ -171,7 +184,7 @@ static void show_stream(AVFormatContext *fmt_ctx, int 
stream_idx)
 
     printf("[STREAM]\n");
 
-    printf("index=%d\n",        stream->index);
+    printf("index=%d\n", stream->index);
 
     if ((dec_ctx = stream->codec)) {
         if ((dec = dec_ctx->codec)) {
@@ -250,13 +263,17 @@ static void show_format(AVFormatContext *fmt_ctx)
     printf("nb_streams=%d\n",       fmt_ctx->nb_streams);
     printf("format_name=%s\n",      fmt_ctx->iformat->name);
     printf("format_long_name=%s\n", fmt_ctx->iformat->long_name);
-    printf("start_time=%s\n",       time_value_string(val_str, 
sizeof(val_str), fmt_ctx->start_time,
+    printf("start_time=%s\n",       time_value_string(val_str, sizeof(val_str),
+                                                      fmt_ctx->start_time,
                                                       &AV_TIME_BASE_Q));
-    printf("duration=%s\n",         time_value_string(val_str, 
sizeof(val_str), fmt_ctx->duration,
+    printf("duration=%s\n",         time_value_string(val_str, sizeof(val_str),
+                                                      fmt_ctx->duration,
                                                       &AV_TIME_BASE_Q));
-    printf("size=%s\n",             value_string(val_str, sizeof(val_str), 
fmt_ctx->file_size,
+    printf("size=%s\n",             value_string(val_str, sizeof(val_str),
+                                                 fmt_ctx->file_size,
                                                  unit_byte_str));
-    printf("bit_rate=%s\n",         value_string(val_str, sizeof(val_str), 
fmt_ctx->bit_rate,
+    printf("bit_rate=%s\n",         value_string(val_str, sizeof(val_str),
+                                                 fmt_ctx->bit_rate,
                                                  unit_bit_per_second_str));
 
     while ((tag = av_dict_get(fmt_ctx->metadata, "", tag, 
AV_DICT_IGNORE_SUFFIX)))
@@ -389,7 +406,8 @@ static const OptionDef options[] = {
     { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show 
format/container info" },
     { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" 
},
     { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" 
},
-    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, 
{(void*)opt_default}, "generic catch all option", "" },
+    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, 
{(void*)opt_default},
+      "generic catch all option", "" },
     { NULL, },
 };
 
@@ -411,7 +429,8 @@ int main(int argc, char **argv)
     if (!input_filename) {
         show_usage();
         fprintf(stderr, "You have to specify one input file.\n");
-        fprintf(stderr, "Use -h to get full help or, even better, run 'man 
%s'.\n", program_name);
+        fprintf(stderr, "Use -h to get full help or, even better, run 'man 
%s'.\n",
+                program_name);
         exit(1);
     }
 
diff --git a/cmdutils.h b/cmdutils.h
index db75d53..8cbac1f 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -90,7 +90,8 @@ int opt_timelimit(const char *opt, const char *arg);
  * @param min the minimum valid accepted value
  * @param max the maximum valid accepted value
  */
-double parse_number_or_die(const char *context, const char *numstr, int type, 
double min, double max);
+double parse_number_or_die(const char *context, const char *numstr, int type,
+                           double min, double max);
 
 /**
  * Parse a string specifying a time and return its corresponding
@@ -106,7 +107,8 @@ double parse_number_or_die(const char *context, const char 
*numstr, int type, do
  *
  * @see parse_date()
  */
-int64_t parse_time_or_die(const char *context, const char *timestr, int 
is_duration);
+int64_t parse_time_or_die(const char *context, const char *timestr,
+                          int is_duration);
 
 typedef struct SpecifierOpt {
     char *specifier;    /**< stream/chapter/program/... specifier */
@@ -152,7 +154,8 @@ typedef struct {
     const char *argname;
 } OptionDef;
 
-void show_help_options(const OptionDef *options, const char *msg, int mask, 
int value);
+void show_help_options(const OptionDef *options, const char *msg, int mask,
+                       int value);
 
 /**
  * Show help for all options with given flags in class and all its
@@ -178,7 +181,8 @@ void parse_options(void *optctx, int argc, char **argv, 
const OptionDef *options
  *
  * @return on success 1 if arg was consumed, 0 otherwise; negative number on 
error
  */
-int parse_option(void *optctx, const char *opt, const char *arg, const 
OptionDef *options);
+int parse_option(void *optctx, const char *opt, const char *arg,
+                 const OptionDef *options);
 
 /**
  * Find the '-loglevel' option in the command line args and apply it.
@@ -206,7 +210,8 @@ int check_stream_specifier(AVFormatContext *s, AVStream 
*st, const char *spec);
  * @param st A stream from s for which the options should be filtered.
  * @return a pointer to the created dictionary
  */
-AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id, 
AVFormatContext *s, AVStream *st);
+AVDictionary *filter_codec_opts(AVDictionary *opts, enum CodecID codec_id,
+                                AVFormatContext *s, AVStream *st);
 
 /**
  * Setup AVCodecContext options for avformat_find_stream_info().
@@ -219,7 +224,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum 
CodecID codec_id, AVFor
  * @return pointer to the created array of dictionaries, NULL if it
  * cannot be created
  */
-AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, AVDictionary 
*codec_opts);
+AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
+                                           AVDictionary *codec_opts);
 
 /**
  * Print an error message to stderr, indicating filename and a human
diff --git a/tests/audiogen.c b/tests/audiogen.c
index d48b591..fe2e208 100644
--- a/tests/audiogen.c
+++ b/tests/audiogen.c
@@ -80,7 +80,7 @@ static int int_cos(int a)
     neg = 0;
     if (a > (FRAC_ONE / 4)) {
         neg = -1;
-        a = (FRAC_ONE / 2) - a;
+        a   = (FRAC_ONE / 2) - a;
     }
     p = cos_table + (a >> CSHIFT);
     /* linear interpolation */
@@ -139,45 +139,45 @@ int main(int argc, char **argv)
 
     /* 1 second of single freq sinus at 1000 Hz */
     a = 0;
-    for(i=0;i<1 * sample_rate;i++) {
+    for (i = 0; i < 1 * sample_rate; i++) {
         v = (int_cos(a) * 10000) >> FRAC_BITS;
-        for(j=0;j<nb_channels;j++)
+        for (j = 0; j < nb_channels; j++)
             put_sample(v);
         a += (1000 * FRAC_ONE) / sample_rate;
     }
 
     /* 1 second of varing frequency between 100 and 10000 Hz */
     a = 0;
-    for(i=0;i<1 * sample_rate;i++) {
+    for (i = 0; i < 1 * sample_rate; i++) {
         v = (int_cos(a) * 10000) >> FRAC_BITS;
-        for(j=0;j<nb_channels;j++)
+        for (j = 0; j < nb_channels; j++)
             put_sample(v);
-        f = 100 + (((10000 - 100) * i) / sample_rate);
+        f  = 100 + (((10000 - 100) * i) / sample_rate);
         a += (f * FRAC_ONE) / sample_rate;
     }
 
     /* 0.5 second of low amplitude white noise */
-    for(i=0;i<sample_rate / 2;i++) {
+    for (i = 0; i < sample_rate / 2; i++) {
         v = myrnd(&seed, 20000) - 10000;
-        for(j=0;j<nb_channels;j++)
+        for (j = 0; j < nb_channels; j++)
             put_sample(v);
     }
 
     /* 0.5 second of high amplitude white noise */
-    for(i=0;i<sample_rate / 2;i++) {
+    for (i = 0; i < sample_rate / 2; i++) {
         v = myrnd(&seed, 65535) - 32768;
-        for(j=0;j<nb_channels;j++)
+        for (j = 0; j < nb_channels; j++)
             put_sample(v);
     }
 
     /* 1 second of unrelated ramps for each channel */
-    for(j=0;j<nb_channels;j++) {
-        taba[j] = 0;
+    for (j = 0; j < nb_channels; j++) {
+        taba[j]  = 0;
         tabf1[j] = 100 + myrnd(&seed, 5000);
         tabf2[j] = 100 + myrnd(&seed, 5000);
     }
-    for(i=0;i<1 * sample_rate;i++) {
-        for(j=0;j<nb_channels;j++) {
+    for (i = 0; i < 1 * sample_rate; i++) {
+        for (j = 0; j < nb_channels; j++) {
             v = (int_cos(taba[j]) * 10000) >> FRAC_BITS;
             put_sample(v);
             f = tabf1[j] + (((tabf2[j] - tabf1[j]) * i) / sample_rate);
@@ -188,8 +188,8 @@ int main(int argc, char **argv)
     /* 2 seconds of 500 Hz with varying volume */
     a = 0;
     ampa = 0;
-    for(i=0;i<2 * sample_rate;i++) {
-        for(j=0;j<nb_channels;j++) {
+    for (i = 0; i < 2 * sample_rate; i++) {
+        for (j = 0; j < nb_channels; j++) {
             amp = ((FRAC_ONE + int_cos(ampa)) * 5000) >> FRAC_BITS;
             if (j & 1)
                 amp = 10000 - amp;
diff --git a/tests/base64.c b/tests/base64.c
index aad7dfb..4d26dbc 100644
--- a/tests/base64.c
+++ b/tests/base64.c
@@ -27,8 +27,8 @@ int main(void)
     static const char b64[] =
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
     unsigned i_bits = 0;
-    int i_shift = 0;
-    int out_len = 0;
+    int i_shift     = 0;
+    int out_len     = 0;
     int in;
 
 #define putb64() do {                                   \
@@ -38,7 +38,7 @@ int main(void)
     } while (0)
 
     while ((in = getchar()) != EOF) {
-        i_bits = (i_bits << 8) + in;
+        i_bits   = (i_bits << 8) + in;
         i_shift += 8;
         while (i_shift > 6)
             putb64();
diff --git a/tests/rotozoom.c b/tests/rotozoom.c
index ba1db29..0c8e1e5 100644
--- a/tests/rotozoom.c
+++ b/tests/rotozoom.c
@@ -47,7 +47,7 @@ static int64_t int_sin(int64_t a)
 
     if (a >= MY_PI * 3 / 2)
         a -= 2 * MY_PI; // -PI / 2 .. 3PI / 2
-    if (a >= MY_PI /2)
+    if (a >= MY_PI / 2)
         a = MY_PI - a;  // -PI / 2 ..  PI / 2
 
     return a - int_pow(a, 3) / 6 + int_pow(a, 5) / 120 - int_pow(a, 7) / 5040;
@@ -70,50 +70,50 @@ static void rgb24_to_yuv420p(unsigned char *lum, unsigned 
char *cb,
     p = src;
     for (y = 0; y < height; y += 2) {
         for (x = 0; x < width; x += 2) {
-            r = p[0];
-            g = p[1];
-            b = p[2];
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            r = p[3];
-            g = p[4];
-            b = p[5];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            p   += wrap3;
-            lum += wrap;
-
-            r = p[0];
-            g = p[1];
-            b = p[2];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            r = p[3];
-            g = p[4];
-            b = p[5];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-
-            cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
-                      FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
-            cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
-                      FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
+            r       = p[0];
+            g       = p[1];
+            b       = p[2];
+            r1      = r;
+            g1      = g;
+            b1      = b;
+            lum[0]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            r       = p[3];
+            g       = p[4];
+            b       = p[5];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[1]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            p      += wrap3;
+            lum    += wrap;
+
+            r       = p[0];
+            g       = p[1];
+            b       = p[2];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[0]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            r       = p[3];
+            g       = p[4];
+            b       = p[5];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[1]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+
+            cb[0]   = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
+                       FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
+            cr[0]   = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
+                       FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
 
             cb++;
             cr++;
-            p   += -wrap3 + 2 * 3;
+            p += -wrap3 + 2 * 3;
             lum += -wrap  + 2;
         }
         p   += wrap3;
diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c
index 2bdb439..408a81f 100644
--- a/tests/tiny_psnr.c
+++ b/tests/tiny_psnr.c
@@ -24,7 +24,7 @@
 #include <inttypes.h>
 #include <assert.h>
 
-#define FFMIN(a,b) ((a) > (b) ? (b) : (a))
+#define FFMIN(a, b) ((a) > (b) ? (b) : (a))
 #define F 100
 #define SIZE 2048
 
@@ -53,63 +53,66 @@ uint64_t exp16_table[21]={
 };
 
 // 16.16 fixpoint log()
-static int64_t log16(uint64_t a){
+static int64_t log16(uint64_t a)
+{
     int i;
-    int out=0;
-
-    if(a < 1<<16)
-        return -log16((1LL<<32) / a);
-    a<<=16;
-
-    for(i=20;i>=0;i--){
-        int64_t b= exp16_table[i];
-        if(a<(b<<16)) continue;
-        out |= 1<<i;
-        a = ((a/b)<<16) + (((a%b)<<16) + b/2)/b;
+    int out = 0;
+
+    if (a < 1 << 16)
+        return -log16((1LL << 32) / a);
+    a <<= 16;
+
+    for (i = 20; i >= 0; i--) {
+        int64_t b = exp16_table[i];
+        if (a < (b << 16))
+            continue;
+        out |= 1 << i;
+        a = ((a / b) << 16) + (((a % b) << 16) + b/2) / b;
     }
     return out;
 }
 
 static uint64_t int_sqrt(uint64_t a)
 {
-    uint64_t ret=0;
+    uint64_t ret = 0;
     int s;
-    uint64_t ret_sq=0;
+    uint64_t ret_sq = 0;
 
-    for(s=31; s>=0; s--){
-        uint64_t b= ret_sq + (1ULL<<(s*2)) + (ret<<s)*2;
-        if(b<=a){
-            ret_sq=b;
-            ret+= 1ULL<<s;
+    for (s = 31; s >= 0; s--) {
+        uint64_t b = ret_sq + (1ULL << (s * 2)) + (ret << s) * 2;
+        if (b <= a) {
+            ret_sq = b;
+            ret   += 1ULL << s;
         }
     }
     return ret;
 }
 
-int main(int argc,char* argv[]){
+int main(int argc, char* argv[])
+{
     int i, j;
-    uint64_t sse=0;
+    uint64_t sse = 0;
     uint64_t dev;
     FILE *f[2];
     uint8_t buf[2][SIZE];
     uint64_t psnr;
-    int len= argc<4 ? 1 : atoi(argv[3]);
-    int64_t max= (1<<(8*len))-1;
-    int shift= argc<5 ? 0 : atoi(argv[4]);
-    int skip_bytes = argc<6 ? 0 : atoi(argv[5]);
-    int size0=0;
-    int size1=0;
-    int maxdist = 0;
-
-    if(argc<3){
+    int len         = argc < 4 ? 1 : atoi(argv[3]);
+    int64_t max     = (1 << (8 * len)) - 1;
+    int shift       = argc < 5 ? 0 : atoi(argv[4]);
+    int skip_bytes  = argc<6 ? 0 : atoi(argv[5]);
+    int size0       = 0;
+    int size1       = 0;
+    int maxdist     = 0;
+
+    if (argc < 3) {
         printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip 
bytes>]]]\n");
         printf("WAV headers are skipped automatically.\n");
         return 1;
     }
 
-    f[0]= fopen(argv[1], "rb");
-    f[1]= fopen(argv[2], "rb");
-    if(!f[0] || !f[1]){
+    f[0] = fopen(argv[1], "rb");
+    f[1] = fopen(argv[2], "rb");
+    if (!f[0] || !f[1]) {
         fprintf(stderr, "Could not open input files.\n");
         return 1;
     }
@@ -135,42 +138,43 @@ int main(int argc,char* argv[]){
 
     fseek(f[shift<0], abs(shift), SEEK_CUR);
 
-    fseek(f[0],skip_bytes,SEEK_CUR);
-    fseek(f[1],skip_bytes,SEEK_CUR);
+    fseek(f[0], skip_bytes, SEEK_CUR);
+    fseek(f[1], skip_bytes, SEEK_CUR);
 
-    for(;;){
-        int s0= fread(buf[0], 1, SIZE, f[0]);
-        int s1= fread(buf[1], 1, SIZE, f[1]);
+    for (;;) {
+        int s0 = fread(buf[0], 1, SIZE, f[0]);
+        int s1 = fread(buf[1], 1, SIZE, f[1]);
 
-        for(j=0; j<FFMIN(s0,s1); j++){
-            int64_t a= buf[0][j];
-            int64_t b= buf[1][j];
+        for (j = 0; j < FFMIN(s0, s1); j++) {
+            int64_t a = buf[0][j];
+            int64_t b = buf[1][j];
             int dist;
-            if(len==2){
-                a= (int16_t)(a | (buf[0][++j]<<8));
-                b= (int16_t)(b | (buf[1][  j]<<8));
+            if (len == 2) {
+                a = (int16_t)(a | (buf[0][++j] << 8));
+                b = (int16_t)(b | (buf[1][  j] << 8));
             }
-            sse += (a-b) * (a-b);
-            dist = abs(a-b);
+            sse += (a - b) * (a - b);
+            dist = abs(a - b);
             if (dist > maxdist) maxdist = dist;
         }
         size0 += s0;
         size1 += s1;
-        if(s0+s1<=0)
+        if (s0 + s1 <= 0)
             break;
     }
 
-    i= FFMIN(size0,size1)/len;
-    if(!i) i=1;
-    dev= int_sqrt( ((sse/i)*F*F) + (((sse%i)*F*F) + i/2)/i );
-    if(sse)
-        psnr= ((2*log16(max<<16) + log16(i) - log16(sse))*284619LL*F + 
(1LL<<31)) / (1LL<<32);
+    i = FFMIN(size0, size1) / len;
+    if (!i)
+        i = 1;
+    dev = int_sqrt(((sse / i) * F * F) + (((sse % i) * F * F) + i / 2) / i);
+    if (sse)
+        psnr = ((2 * log16(max << 16) + log16(i) - log16(sse)) * 284619LL * F 
+ (1LL << 31)) / (1LL << 32);
     else
-        psnr= 1000*F-1; //floating point free infinity :)
+        psnr = 1000 * F - 1; //floating point free infinity :)
 
     printf("stddev:%5d.%02d PSNR:%3d.%02d MAXDIFF:%5d bytes:%9d/%9d\n",
-        (int)(dev/F), (int)(dev%F),
-        (int)(psnr/F), (int)(psnr%F),
+        (int)(dev / F), (int)(dev % F),
+        (int)(psnr / F), (int)(psnr % F),
         maxdist,
         size0, size1);
     return 0;
diff --git a/tests/videogen.c b/tests/videogen.c
index 957692d..a90681f 100644
--- a/tests/videogen.c
+++ b/tests/videogen.c
@@ -27,65 +27,65 @@
 
 #define SCALEBITS 8
 #define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)    ((int) ((x) * (1L<<SCALEBITS) + 0.5))
+#define FIX(x)    ((int) ((x) * (1L << SCALEBITS) + 0.5))
 
 static void rgb24_to_yuv420p(uint8_t *lum, uint8_t *cb, uint8_t *cr,
-                              uint8_t *src, int width, int height)
+                             uint8_t *src, int width, int height)
 {
     int wrap, wrap3, x, y;
     int r, g, b, r1, g1, b1;
     uint8_t *p;
 
-    wrap = width;
-    wrap3 = width * 3;
-    p = src;
-    for(y=0;y<height;y+=2) {
-        for(x=0;x<width;x+=2) {
-            r = p[0];
-            g = p[1];
-            b = p[2];
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            r = p[3];
-            g = p[4];
-            b = p[5];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            p += wrap3;
-            lum += wrap;
-
-            r = p[0];
-            g = p[1];
-            b = p[2];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-            r = p[3];
-            g = p[4];
-            b = p[5];
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = (FIX(0.29900) * r + FIX(0.58700) * g +
-                      FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
-
-            cb[0] = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
-                      FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
-            cr[0] = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
-                     FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 2)) 
+ 128;
+    wrap    = width;
+    wrap3   = width * 3;
+    p       = src;
+    for (y = 0; y < height; y += 2) {
+        for (x = 0; x < width; x += 2) {
+            r       = p[0];
+            g       = p[1];
+            b       = p[2];
+            r1      = r;
+            g1      = g;
+            b1      = b;
+            lum[0]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            r       = p[3];
+            g       = p[4];
+            b       = p[5];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[1]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            p      += wrap3;
+            lum    += wrap;
+
+            r       = p[0];
+            g       = p[1];
+            b       = p[2];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[0]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+            r       = p[3];
+            g       = p[4];
+            b       = p[5];
+            r1     += r;
+            g1     += g;
+            b1     += b;
+            lum[1]  = (FIX(0.29900) * r + FIX(0.58700) * g +
+                       FIX(0.11400) * b + ONE_HALF) >> SCALEBITS;
+
+            cb[0]   = ((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +
+                       FIX(0.50000) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
+            cr[0]   = ((FIX(0.50000) * r1 - FIX(0.41869) * g1 -
+                       FIX(0.08131) * b1 + 4 * ONE_HALF - 1) >> (SCALEBITS + 
2)) + 128;
 
             cb++;
             cr++;
-            p += -wrap3 + 2 * 3;
-            lum += -wrap + 2;
+            p      += -wrap3 + 2 * 3;
+            lum    += -wrap + 2;
         }
         p += wrap3;
         lum += wrap;
@@ -106,8 +106,8 @@ static void pgmyuv_save(const char *filename, int w, int h,
     unsigned char *lum_tab, *cb_tab, *cr_tab;
 
     lum_tab = malloc(w * h);
-    cb_tab = malloc((w * h) / 4);
-    cr_tab = malloc((w * h) / 4);
+    cb_tab  = malloc((w * h) / 4);
+    cr_tab  = malloc((w * h) / 4);
 
     rgb24_to_yuv420p(lum_tab, cb_tab, cr_tab, rgb_tab, w, h);
 
@@ -118,7 +118,7 @@ static void pgmyuv_save(const char *filename, int w, int h,
     w2 = w / 2;
     cb = cb_tab;
     cr = cr_tab;
-    for(i=0;i<h2;i++) {
+    for (i = 0; i < h2; i++) {
         fwrite(cb, 1, w2, f);
         fwrite(cr, 1, w2, f);
         cb += w2;
@@ -204,7 +204,7 @@ static void gen_image(int num, int w, int h)
     unsigned int seed1;
 
     if (num == 0) {
-        for(i=0;i<NB_OBJS;i++) {
+        for (i = 0; i < NB_OBJS; i++) {
             objs[i].x = myrnd(&seed, w);
             objs[i].y = myrnd(&seed, h);
             objs[i].w = myrnd(&seed, w / 4) + 10;
@@ -219,21 +219,21 @@ static void gen_image(int num, int w, int h)
     /* test motion estimation */
     dx = int_cos(num * FRAC_ONE / 50) * 35;
     dy = int_cos(num * FRAC_ONE / 50 + FRAC_ONE / 10) * 30;
-    for(y=0;y<h;y++) {
-        for(x=0;x<w;x++) {
-            x1 = (x << FRAC_BITS) + dx;
-            y1 = (y << FRAC_BITS) + dy;
-            r = ((y1 * 7) >> FRAC_BITS) & 0xff;
-            g = (((x1 + y1) * 9) >> FRAC_BITS) & 0xff;
-            b = ((x1 * 5) >> FRAC_BITS) & 0xff;
+    for (y = 0; y < h; y++) {
+        for (x = 0; x < w; x++) {
+            x1  = (x << FRAC_BITS) + dx;
+            y1  = (y << FRAC_BITS) + dy;
+            r   = ((y1 * 7) >> FRAC_BITS) & 0xff;
+            g   = (((x1 + y1) * 9) >> FRAC_BITS) & 0xff;
+            b   = ((x1 * 5) >> FRAC_BITS) & 0xff;
             put_pixel(x, y, r, g, b);
         }
     }
 
     /* then some noise with very high intensity to test saturation */
     seed1 = num;
-    for(y=0;y<NOISE_W;y++) {
-        for(x=0;x<NOISE_W;x++) {
+    for (y = 0; y < NOISE_W; y++) {
+        for (x = 0; x < NOISE_W; x++) {
             r = myrnd(&seed1, 256);
             g = myrnd(&seed1, 256);
             b = myrnd(&seed1, 256);
@@ -242,11 +242,11 @@ static void gen_image(int num, int w, int h)
     }
 
     /* then moving objects */
-    for(i=0;i<NB_OBJS;i++) {
+    for (i = 0; i < NB_OBJS; i++) {
         VObj *p = &objs[i];
         seed1 = i;
-        for(y=0;y<p->h;y++) {
-            for(x=0;x<p->w;x++) {
+        for (y = 0; y < p->h; y++) {
+            for (x = 0; x < p->w; x++) {
                 r = p->r;
                 g = p->g;
                 b = p->b;
@@ -277,11 +277,11 @@ int main(int argc, char **argv)
     h = DEFAULT_HEIGHT;
 
     rgb_tab = malloc(w * h * 3);
-    wrap = w * 3;
-    width = w;
-    height = h;
+    wrap    = w * 3;
+    width   = w;
+    height  = h;
 
-    for(i=0;i<DEFAULT_NB_PICT;i++) {
+    for (i = 0; i < DEFAULT_NB_PICT; i++) {
         snprintf(buf, sizeof(buf), "%s%02d.pgm", argv[1], i);
         gen_image(i, w, h);
         pgmyuv_save(buf, w, h, rgb_tab);
-- 
1.7.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to