From: Soft Works <softworkz@hotmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavf/avio: add avio_vprintf() Date: Thu, 16 Jun 2022 16:23:58 +0000 Message-ID: <DM8P223MB0365B2312AE0070FAF5E0394BAAC9@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw) In-Reply-To: <YqYbufb4SARtjGOa@phare.normalesup.org> > -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of > Nicolas George > Sent: Sunday, June 12, 2022 7:01 PM > To: FFmpeg development discussions and patches <ffmpeg- > devel@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavf/avio: add avio_vprintf() > > Stefano Sabatini (12022-06-12): > > Updated. > > Hi. Since it is somewhat related, I would appreciate if you gave your > opinion on the option of having a good string API in FFmpeg: > > https://ffmpeg.org/pipermail/ffmpeg-devel/2021-December/290226.html > > Eventually, I would like to have the more generic writers from > ffprobe > (JSON, XML) in lavu to be used by diagnostic filters. But I will not > be > doing that with pedestrian strings. Hi, as mentioned a while ago, I am quite interested in this and I would be glad when it would be possible to find a way for going forward. My primary interest would be the generalization of ffprobe string writing code, from which I have two duplicates by now. I had put further work on hold as I became aware that were plans or proposals for this. Now I've read your "Intro to AVWriter" from April 2021 and I have some questions. > ## Scenario 2: Concatenating the string into a message. > > Let us say you have two foobars to present to the user. Good old C: > > char msg[2500], foo1_buf[1000], foo2_buf[1000]; > av_foobar_to_string(foo1_buf, sizeof(foo1_buf), foo1); > av_foobar_to_string(foo2_buf, sizeof(foo2_buf), foo2); > snprintf(msg, sizeof(msg), "F%d = [ %s, %s ]", num, foo1_buf, foo2_buf); > > But it's ugly. Less ugly, but more complicated: [skip that version] > Well, that was the first thing AVWriter was meant to do: allow to build > strings by concatenating them together. So, the AVWraper version of this > code: > > char msg[2500]; > AVWriter wr = av_buf_writer_array(msg); > av_writer_printf(wr, "F%d = [ ", num); > av_foobar_write(wr, foo1); > av_writer_print(wr, ", "); > av_foobar_write(wr, foo2); > av_writer_print(wr, " ]"); There are cases where it might be preferable to subsequently append to a buffer like that, but it requires many lines of code and it's not as easy to get a picture of how the produced string will actually look like. Maybe you meant it just as one possible example to use AVWriter, but in this context it looks like as if that's the supposed way to replace the "Good old C" version? When you would ask me which code I would _wish_ to be able to write in this example case, then it would be this: char msg[2500]; snprintf(msg, sizeof(msg), "F%d = [ %s, %s ]", num, foo1, foo2); Of course it doesn't need to be snprintf, it could also be av_xprintf(). It would also be fine to have some macro around those params like XX(foo1). Or a custom format specifier would also be fine. Basically I think there are a number of possible ways, but I'm not sure whether this would be possible with regards to the automatisms you are planning to checking for a matching string conversion function? This might be a tough one: it would be cool when this could be used in av_log() calls for logging, but in this case it would be of course required that the string writing will be performed upstream, only when the log level condition would be satisfied. Could that even work? PS: Yes, I have read it to the end; the mentioned av_writer_fmt() might be related to what I'm asking, but I wasn't sure. Thanks, softworkz _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-06-16 16:24 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20210418213058.24475-1-stefasab@gmail.com> [not found] ` <20210421215335.GC12140@mariano> 2022-04-03 14:03 ` Stefano Sabatini 2022-06-09 19:03 ` Marton Balint 2022-06-12 15:32 ` Stefano Sabatini 2022-06-12 17:00 ` Nicolas George 2022-06-16 16:23 ` Soft Works [this message] [not found] ` <20210418213058.24475-2-stefasab@gmail.com> [not found] ` <20210419092649.GJ4777@pb2> [not found] ` <20210421215704.GD12140@mariano> 2022-04-03 14:06 ` [FFmpeg-devel] [PATCH 2/2] ffprobe: add -o option Stefano Sabatini 2022-06-09 19:09 ` Marton Balint 2022-06-12 15:33 ` Stefano Sabatini 2022-06-13 20:47 ` Marton Balint
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=DM8P223MB0365B2312AE0070FAF5E0394BAAC9@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \ --to=softworkz@hotmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git