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

Alexander Strasser eclipse7 at gmx.net
Tue Mar 28 23:31:00 EEST 2017


On 2017-03-28 18:16 +0200, Clément Bœsch wrote:
> On Tue, Mar 28, 2017 at 06:12:14PM +0200, Michael Niedermayer wrote:
> > 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
> > 
> 
> oh i thought i changed that to const int c = ... 
> forgot to resend the patch, consider it fixed locally

  Sorry, I probably hinted you in the wrong direction there. It came to my
mind while brushing my teeth yesterday. Using int for the var holding the 
byte value should be sufficient and especially avoid the unwanted sign
extension.


  LGTM with the fix you mentioned; thank you for making the adjustments!


  Alexander


More information about the ffmpeg-devel mailing list