[FFmpeg-devel] [PATCH 01/11] lavu: add public timecode API.

Stefano Sabatini stefasab at gmail.com
Mon Jan 16 19:06:07 CET 2012


On date Monday 2012-01-16 17:30:04 +0100, Clément Bœsch encoded:
> From: Clément Bœsch <clement.boesch at smartjog.com>
> 
> ---
>  doc/APIchanges       |    3 +
>  libavutil/Makefile   |    2 +
>  libavutil/avutil.h   |    2 +-
>  libavutil/timecode.c |  171 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  libavutil/timecode.h |  125 ++++++++++++++++++++++++++++++++++++
>  5 files changed, 302 insertions(+), 1 deletions(-)
>  create mode 100644 libavutil/timecode.c
>  create mode 100644 libavutil/timecode.h
[...]
> +/**
> + * @file
> + * Timecode helpers header
> + */
> +
> +#ifndef AVUTIL_TIMECODE_H
> +#define AVUTIL_TIMECODE_H
> +
> +#include <stdint.h>
> +#include "rational.h"
> +
> +#define AVTIMECODE_STR_LEN 16
> +
> +#define AVTIMECODE_OPTION(ctx, string_field, flags)                      \
> +    "timecode", "set timecode value following hh:mm:ss[:;.]ff format, "  \
> +                "use ';' or '.' before frame number for drop frame",     \
> +    offsetof(ctx, string_field),                                         \
> +    AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, flags
> +
> +enum AVTimecodeFlag {
> +    AVTIMECODE_FLAG_DROPFRAME  = 1<<0,
> +    AVTIMECODE_FLAG_24HOURSMAX = 1<<1,
> +    AVTIMECODE_FLAG_NEGATIVEOK = 1<<2,
> +};
> +
> +typedef struct {
> +    int start;          ///< timecode frame start (first base frame number)
> +    uint32_t flags;     ///< flags such as drop frame, +24 hours support, ...
> +    AVRational rate;    ///< frame rate in rational form
> +    unsigned fps;       ///< frame per second; must be consistent with the rate field
> +} AVTimecode;
> +
> +/**
> + * Get the timecode string from the 25-bit timecode format (MPEG GOP format).
> + *
> + * @param buf     destination buffer, must be at least AVTIMECODE_STR_LEN long.
> + * @param tc25bit the 25-bits timecode
> + * @return        the buf parameter
> + */
> +char *av_mpegtc_to_timecode_string(char *buf, uint32_t tc25bit);

Overall naming remarks.

Maybe av_*_timecode -> av_timecode_...

for providing a hierarchical naming scheme (grep/completion friendly),
for consistency with the rest of the API maybe add "_" after the AV in
AVTIMECODE_ (AVTIMECODE -> AV_TIMECODE), libav* is inconsistent
regarding this convenction so I don't know which should we attempt to
follow, but AV_ seems more consistent with av_ used for function
names.

I'll possibly have more comments later.
-- 
FFmpeg = Fast & Freak Marvellous Pitiful Exciting Gadget


More information about the ffmpeg-devel mailing list