[FFmpeg-devel] [PATCH] swscale: Make sws_alloc_set_opts() public
Michael Niedermayer
michael at niedermayer.cc
Sat Aug 8 18:17:37 CEST 2015
On Sat, Aug 08, 2015 at 05:58:29PM +0200, wm4 wrote:
> On Sat, 8 Aug 2015 17:14:58 +0200
> Michael Niedermayer <michaelni at gmx.at> wrote:
>
> > From: Michael Niedermayer <michael at niedermayer.cc>
> >
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> > libswscale/swscale.h | 11 +++++++++++
> > libswscale/swscale_internal.h | 11 -----------
> > libswscale/version.h | 4 ++--
> > 3 files changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> > index 903e120..055c9fc 100644
> > --- a/libswscale/swscale.h
> > +++ b/libswscale/swscale.h
> > @@ -161,6 +161,17 @@ int sws_isSupportedEndiannessConversion(enum AVPixelFormat pix_fmt);
> > struct SwsContext *sws_alloc_context(void);
> >
> > /**
> > + * Allocate and return an SwsContext.
> > + * This is like sws_getContext() but does not perform the init step, allowing
> > + * the user to set additional AVOptions.
> > + *
> > + * @see sws_getContext()
> > + */
> > +struct SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat,
> > + int dstW, int dstH, enum AVPixelFormat dstFormat,
> > + int flags, const double *param);
> > +
>
> This looks excessively useless and un-nice to use.
what do you suggest ?
The function is intended to replace:
context = sws_alloc_context()
if (!context)
handle error
ret0 = av_opt_set_int(context, "sws_flags", flags, 0);
ret1 = av_opt_set_int(context, "srcw", srcW, 0);
ret2 = av_opt_set_int(context, "srch", srcH, 0);
ret3 = av_opt_set_int(context, "dstw", dstW, 0);
ret4 = av_opt_set_int(context, "dsth", dstH, 0);
ret5 = av_opt_set_int(context, "src_format", srcFormat, 0);
ret6 = av_opt_set_int(context, "dst_format", dstFormat, 0);
ret7 = av_opt_set(context, "alphablend", "none", 0);
if (ret0 <0)
handle error, free context, return ret0
if (ret1 <0)
handle error, free context, return ret1
if (ret2 <0)
handle error, free context, return ret2
if (ret3 <0)
handle error, free context, return ret3
if (ret4 <0)
handle error, free context, return ret4
if (ret5 <0)
handle error, free context, return ret5
if (ret6 <0)
handle error, free context, return ret6
if (ret7 <0)
handle error, free context, return ret7
by this:
context = sws_alloc_set_opts(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL);
if (!context)
handle error
ret = av_opt_set(context, "alphablend", "none", 0);
if (ret <0)
handle error, free context, return ret
and that looks alot nicer to me,
but if someone has a even better idea?
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/20150808/86b17422/attachment.sig>
More information about the ffmpeg-devel
mailing list