[FFmpeg-devel] [PATCH 01/10] lavu: add av_fourcc_make_string() and av_4cc2str()

Michael Niedermayer michael at niedermayer.cc
Tue Mar 28 19:12:14 EEST 2017


On Tue, Mar 28, 2017 at 10:19:46AM +0200, Clément Bœsch wrote:
[...]
> diff --git a/libavutil/utils.c b/libavutil/utils.c
> index 36e4dd5fdb..29f2746338 100644
> --- a/libavutil/utils.c
> +++ b/libavutil/utils.c
> @@ -121,6 +121,29 @@ unsigned av_int_list_length_for_size(unsigned elsize,
>      return i;
>  }
>  
> +char *av_fourcc_make_string(char *buf, uint32_t fourcc)
> +{
> +    int i;
> +    char *orig_buf = buf;
> +    size_t buf_size = AV_FOURCC_MAX_STRING_SIZE;
> +
> +    for (i = 0; i < 4; i++) {
> +        const char c = fourcc & 0xff;
> +        const int print_chr = (c >= '0' && c <= '9') ||
> +                              (c >= 'a' && c <= 'z') ||
> +                              (c >= 'A' && c <= 'Z') ||
> +                              (c && strchr(". -_", c));
> +        const int len = snprintf(buf, buf_size, print_chr ? "%c" : "[%d]", c);

this prints values over 127 as negative if char is signed

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170328/a4010317/attachment.sig>


More information about the ffmpeg-devel mailing list