[FFmpeg-devel] [PATCH 01/10] lavu: add av_fourcc_make_string() and av_4cc2str()
Clément Bœsch
u at pkh.me
Wed Mar 29 11:03:15 EEST 2017
On Wed, Mar 29, 2017 at 09:56:14AM +0200, Clément Bœsch wrote:
> On Wed, Mar 29, 2017 at 09:52:51AM +0200, Carl Eugen Hoyos wrote:
> > 2017-03-29 9:43 GMT+02:00 Clément Bœsch <u at pkh.me>:
> > > On Wed, Mar 29, 2017 at 09:31:57AM +0200, Carl Eugen Hoyos wrote:
> > >> 2017-03-28 17:31 GMT+02:00 Clément Bœsch <u at pkh.me>:
> > >> > On Mon, Mar 27, 2017 at 09:51:54AM +0200, Clément Bœsch wrote:
> > >> >> ---
> > >> >> doc/APIchanges | 4 ++++
> > >> >> libavutil/avutil.h | 14 ++++++++++++++
> > >> >> libavutil/utils.c | 21 +++++++++++++++++++++
> > >> >> libavutil/version.h | 2 +-
> > >> >> 4 files changed, 40 insertions(+), 1 deletion(-)
> > >> >>
> > >> >
> > >> > I'll start pushing that patchset tomorrow if I see no objection.
> > >>
> > >> > +#define av_4cc2str(fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc)
> > >>
> > >> Sorry, I really don't understand:
> > >> If the preferred name for this function is "av_4cc2str", why not name
> > >> it av_4cc2str()?
> > >>
> > >
> > > I don't understand your question: are you asking why there is a macro
> > > and a function with different names?
> >
> > Yes, why is a function with the preferred name not sufficient?
> >
>
> Because we save the user the need to create a buffer thanks the compound
> literal in the macro which can only exist in a macro. It's exactly like
> av_ts2str().
>
If that's still not clear, here is a typical use case:
diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 75dcf74a0c..e1ea29b713 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -404,13 +404,9 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
return 0;
default:
- {
- char tag_buf[32];
-
- av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag);
- avpriv_request_sample(s, "In-stream tag=%s (0x%08X) len=%"PRIu32, tag_buf, tag, len);
+ avpriv_request_sample(s, "In-stream tag=%s (0x%08X) len=%"PRIu32,
+ av_fourcc2str(tag), tag, len);
avio_skip(pb, len + 4);
- }
}
/* Handle the unsupported yet cases */
You can't do the same with a function only unless you ask the user to inline
av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]{0}, tag)
--
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170329/1c0a7d71/attachment.sig>
More information about the ffmpeg-devel
mailing list