[FFmpeg-devel] [PATCH] ffprobe integration

Michael Niedermayer michaelni
Sun Jan 3 01:23:25 CET 2010


On Sun, Jan 03, 2010 at 12:21:20AM +0100, Stefano Sabatini wrote:
[...]
> +#undef exit
> +#undef printf
> +#undef fprintf

no chance
new applications using libav* must be compileable without this hackery
this is just a bad example



> +
> +const char program_name[] = "FFprobe";
> +const int program_birth_year = 2007;
> +
> +/* globals */
> +const OptionDef options[];
> +
> +/* FFprobe context */
> +static const char *input_filename;
> +static int value_string_flags = 0;
> +static int do_show_format = 0;
> +static int do_show_streams = 0;
> +

> +const char *binary_unit_prefixes[] = { "", "Ki", "Mi", "Gi", "Ti", "Pi" };
> +static const int binary_unit_prefixes_nb = FF_ARRAY_ELEMS(binary_unit_prefixes);
> +
> +const char *decimal_unit_prefixes[] = { "", "K", "M", "G", "T", "P" };
> +static const int decimal_unit_prefixes_nb = FF_ARRAY_ELEMS(decimal_unit_prefixes);

dont we have this already somewhere?


[...]
> +    if (unit == UNIT_SECOND && flags & VALUE_STRING_USE_SEXAGESIMAL_TIME_FORMAT) {
> +        int hours, mins, secs, usecs;
> +        /* takes the 6 digits representing the microseconds and round */
> +        usecs = (int)(round((val - floor(val)) * 1000000));
> +        secs  = (int)val;
> +        mins  = secs / 60;
> +        secs %= 60;
> +        hours = mins / 60;
> +        mins %= 60;
> +
> +        snprintf(buf, buf_size, "%d:%02d:%02d.%06d", hours, mins, secs, usecs);

isnt there some formatting with %f possible for sec/usec?


> +        return buf;
> +    }
> +
> +    if (flags & VALUE_STRING_USE_PREFIX) {
> +        if (flags & VALUE_STRING_USE_BINARY_PREFIX) {
> +            index = (int) (log2(val)) / 10;
> +            index = FFMAX(0, index);
> +            index = FFMIN(index, binary_unit_prefixes_nb -1);

av_clip()


> +            val /= pow(2, index*10);
> +            prefix_str = binary_unit_prefixes[index];
> +        } else {
> +            index = (int) (log10(val)) / 3;
> +            index = FFMAX(0, index);
> +            index = FFMIN(index, decimal_unit_prefixes_nb -1);
> +            val /= pow(10, index*3);
> +            prefix_str = decimal_unit_prefixes[index];
> +        }
> +    } else
> +        prefix_str = "";
> +
> +    unit_str = flags & VALUE_STRING_USE_UNIT ? measure_units[unit].str : "";
> +

> +    if (flags & VALUE_STRING_USE_PREFIX)
> +        snprintf(buf, buf_size, "%.3f %s%s", val, prefix_str, unit_str);
> +    else

{}


> +        snprintf(buf, buf_size, "%f %s", val, unit_str);
> +
> +    return buf;
> +}
> +
> +static char *time_value_string(char *buf, int buf_size, int64_t val,
> +                               AVRational *time_base, int value_string_flags)
> +{
> +    double d;
> +
> +    if (val == AV_NOPTS_VALUE) {
> +        snprintf(buf, buf_size, "N/A");
> +    } else {
> +        d = (double) (val * time_base->num) / (double) time_base->den;

av_q2d()


[...]
> +#define P(...) do { printf(__VA_ARGS__); } while(0)

obfuscated mess
next comes
#define I if(
#define SV static void
and so on


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100103/58773061/attachment.pgp>



More information about the ffmpeg-devel mailing list