[FFmpeg-devel] [PATCH 1/4] blowfish: add av_blowfish_alloc()

Michael Niedermayer michael at niedermayer.cc
Sat Aug 1 04:09:48 CEST 2015


On Fri, Jul 31, 2015 at 05:58:48PM -0300, James Almer wrote:
> On 31/07/15 5:40 PM, Michael Niedermayer wrote:
> > On Fri, Jul 31, 2015 at 02:18:07PM -0300, James Almer wrote:
> >> Signed-off-by: James Almer <jamrial at gmail.com>
> >> ---
> >>  doc/APIchanges       |  3 +++
> >>  libavutil/blowfish.c | 15 +++++++++++++++
> >>  libavutil/blowfish.h | 10 ++++++++++
> >>  libavutil/version.h  |  5 ++++-
> >>  4 files changed, 32 insertions(+), 1 deletion(-)
> > [...]
> >> @@ -30,12 +31,21 @@
> >>   * @{
> >>   */
> >>  
> >> +#if FF_API_CRYPTO_CONTEXT
> >>  #define AV_BF_ROUNDS 16
> >>  
> >>  typedef struct AVBlowfish {
> >>      uint32_t p[AV_BF_ROUNDS + 2];
> >>      uint32_t s[4][256];
> >>  } AVBlowfish;
> >> +#else
> >> +typedef struct AVBlowfish AVBlowfish;
> >> +#endif
> > 
> > Is it intended to remove all means to allocate the context on the
> > stack ?
> > 
> > this would avoid dealing with malloc/free and malloc failure handling
> > and could be a signifiant advantage also if any usecase is in a API
> > that lacks the possibility to fail, like maybe some crypto callbacks
> > with "void return"
> 
> I have no preferences regarding the context, really, I'm just trying to get the
> API for all the modules consistent. Not sure what would be the use of an alloc
> function if the context is not opaque, though.

ive no oppinion on the API at all, just remembered that usage without
alloc was something we thought about in some of the things in avutil
long ago. That is some of the APIs in there where designed so they
could be used without *alloc() and the implied complexity.
iam not against droping that if thats what people prefer

It would also be possible to add the alloc code and leave the on stack
usage possibility or try to change the struct to be opaque and still
usable o the stack. There are many possibilities, i dont know which
people prefer.


>
> And you're right, rtmp for example needs some considerable changes to actually
> use the alloc functions.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- 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/20150801/af5fec19/attachment.sig>


More information about the ffmpeg-devel mailing list