On Mon, Sep 7, 2015 at 2:06 PM, Anton Khirnov <an...@khirnov.net> wrote: > Quoting Vittorio Giovara (2015-09-07 13:54:02) >> On Mon, Sep 7, 2015 at 1:12 PM, Hendrik Leppkes <h.lepp...@gmail.com> wrote: >> >> by that reasoning we should drop AV_PIX_FMT_FLAG_RGB and just do >> >> >> >> if (strstr(pix_fmt, "rgb") || strstr(pix_fmt, "bgr")) >> >> >> >> sometimes you need redundant data for consistency and for simpler >> >> interfaces, without having N different ways to access the same kind of >> >> information, in my opinion >> > >> > Now you're just being silly. >> >> I was rather being sarcastic, it's silly to discuss over a simple 1bit flag. >> >> I can see the point that macros are "useful" to hide the complexity of >> the test, but an interface to check for this kind of thing already >> exists (flags) and the downside of public macros is that you need to >> document, maintain and make sure the new interfaces work. >> >> I insist that a single bitwise check is simpler to understand, use and >> support for users and devs alike. > > The argument is not over one bit, but whether we want to store redundant > information in the descriptor. Having the bit there introduces the > possibility of doing it wrong, by someone adding a new format, but > forgetting to set the flag. So I'd say a function (not a macro, because > that inlines the logic in the caller and that is better avoided) is > preferable.
Yes, but my point is that having a single function to only check for a single color space (gray) is not ideal either. Can you think of users reading the flag "check flag&RGB to see if pixel format is rgb, check flag&ALPHA to see if pixel format has alpha, but where is the check for gray? oh i have to check for number of components or call a function, let's read documentation there too... [skip to a different section of the documentation] hmm this function checks if pixel format is gray" it's terribly inconsistent and the likelihood of someone forgetting to add the bitmask for a new format is the same for rgb too, and yet that hasn't prevented the flag check to be the standard way to check for rgb -- Vittorio _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel