[FFmpeg-devel] [PATCH 1/2] lavc: add ffwavesynth pseudo-codec.
Michael Niedermayer
michaelni at gmx.at
Wed Dec 7 22:35:59 CET 2011
On Wed, Dec 07, 2011 at 03:44:27PM +0100, Nicolas George wrote:
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> doc/decoders.texi | 13 ++
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 1 +
> libavcodec/avcodec.h | 1 +
> libavcodec/ffwavesynth.c | 482 ++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 498 insertions(+), 0 deletions(-)
> create mode 100644 libavcodec/ffwavesynth.c
>
> diff --git a/doc/decoders.texi b/doc/decoders.texi
> index e7baada..87ad4ee 100644
> --- a/doc/decoders.texi
> +++ b/doc/decoders.texi
> @@ -48,3 +48,16 @@ top-field-first is assumed
> @end table
>
> @c man end VIDEO DECODERS
> +
> + at chapter Audio Decoders
> + at c man begin AUDIO DECODERS
> +
> + at section ffwavesynth
> +
> +Internal wave synthetizer.
> +
> +This decoder generates wave patterns according to predefined sequences. Its
> +use is purely internal and the format of the data it accepts is not publicly
> +documented.
> +
> + at c man end AUDIO DECODERS
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 77662d8..fea4701 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -154,6 +154,7 @@ OBJS-$(CONFIG_FFV1_DECODER) += ffv1.o rangecoder.o
> OBJS-$(CONFIG_FFV1_ENCODER) += ffv1.o rangecoder.o
> OBJS-$(CONFIG_FFVHUFF_DECODER) += huffyuv.o
> OBJS-$(CONFIG_FFVHUFF_ENCODER) += huffyuv.o
> +OBJS-$(CONFIG_FFWAVESYNTH_DECODER) += ffwavesynth.o
> OBJS-$(CONFIG_FLAC_DECODER) += flacdec.o flacdata.o flac.o vorbis_data.o
> OBJS-$(CONFIG_FLAC_ENCODER) += flacenc.o flacdata.o flac.o vorbis_data.o
> OBJS-$(CONFIG_FLASHSV_DECODER) += flashsv.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index 690a327..b5f21f1 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -262,6 +262,7 @@ void avcodec_register_all(void)
> REGISTER_ENCDEC (DCA, dca);
> REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
> REGISTER_ENCDEC (EAC3, eac3);
> + REGISTER_DECODER (FFWAVESYNTH, ffwavesynth);
> REGISTER_ENCDEC (FLAC, flac);
> REGISTER_ENCDEC (G723_1, g723_1);
> REGISTER_DECODER (G729, g729);
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index e937c94..fcd71a5 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -400,6 +400,7 @@ enum CodecID {
> CODEC_ID_BMV_AUDIO,
> CODEC_ID_G729 = 0x15800,
> CODEC_ID_G723_1= 0x15801,
> + CODEC_ID_FFWAVESYNTH,
this should be a MKBETAG() to decrease collision chance
[...]
static int wavesynth_parse_extradata(AVCodecContext *avc)
> +{
> + struct wavesynth_context *ws = avc->priv_data;
> + struct ws_interval *in;
> + uint8_t *edata, *edata_end;
> + int32_t f1, f2, a1, a2;
> + uint32_t phi;
> + int64_t dphi1, dphi2, dt, cur_ts = -0x8000000000000000;
> + int i;
> +
> + if (avc->extradata_size < 4)
> + return AVERROR(EINVAL);
> + edata = avc->extradata;
> + edata_end = edata + avc->extradata_size;
> + ws->nb_inter = AV_RL32(edata);
> + edata += 4;
> + if (ws->nb_inter < 0)
> + return AVERROR(EINVAL);
> + ws->inter = av_malloc(ws->nb_inter * sizeof(*ws->inter));
the multiplication can overflow, see av_calloc()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111207/2428c804/attachment.asc>
More information about the ffmpeg-devel
mailing list