Re: [libav-devel] [PATCH 2/2] avcodec: Add a RFC 3389 comfort noise codec

2012-10-26 Thread Kostya Shishkov
On Fri, Oct 26, 2012 at 11:13:49PM +0300, Martin Storsjö wrote:
> This isn't too useful as a normal codec, but can be used in
> voip style applications. The decoder updates the noise
> generator parameters when a packet is given to it for decoding,
> but if called with an empty packet, it generates more noise
> according to the last parameters.
> 
> ---
> References:
> https://tools.ietf.org/html/rfc3389
> http://www.itu.int/rec/T-REC-G.711-22-I!AppII/en
> http://webrtc.googlecode.com/svn/trunk/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.c
> ---
>  configure |1 +
>  libavcodec/Makefile   |2 +
>  libavcodec/allcodecs.c|1 +
>  libavcodec/avcodec.h  |1 +
>  libavcodec/codec_desc.c   |7 ++
>  libavcodec/comfortnoise.c |  258 
> +
>  libavcodec/version.h  |2 +-
>  7 files changed, 271 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/comfortnoise.c

LGTM beside Diego's comment and some missing spaces around multiplication
operator here and there (e.g. energy += samples[i]*samples[i];)
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] avcodec: Add a RFC 3389 comfort noise codec

2012-10-26 Thread Martin Storsjö

On Fri, 26 Oct 2012, Diego Biurrun wrote:


On Fri, Oct 26, 2012 at 11:13:49PM +0300, Martin Storsjö wrote:


--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -129,6 +129,8 @@ OBJS-$(CONFIG_CLJR_DECODER)+= cljr.o
 OBJS-$(CONFIG_CLJR_ENCODER)+= cljr.o
 OBJS-$(CONFIG_CLLC_DECODER)+= cllc.o
 OBJS-$(CONFIG_COOK_DECODER)+= cook.o
+OBJS-$(CONFIG_COMFORTNOISE_DECODER)+= comfortnoise.o celp_filters.o
+OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= comfortnoise.o
 OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o
 OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o
 OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o  \
index 000..144c566
--- /dev/null
+++ b/libavcodec/comfortnoise.c
@@ -0,0 +1,258 @@
+
+typedef struct CNGContext {
+AVFrame avframe;
+float *refl_coef, *target_refl_coef;
+float *lpc_coef;
+int order;
+int energy, target_energy;
+float *filter_out;
+float *excitation;
+AVLFG lfg;
+} CNGContext;
+
+typedef struct CNGEncContext {
+LPCContext lpc;
+int order;
+int32_t *samples32;
+float *refl_coef;
+} CNGEncContext;
+
+#if CONFIG_COMFORTNOISE_DECODER
+#endif
+
+#if CONFIG_COMFORTNOISE_ENCODER
+#endif


Each context struct is only used in one of decoder/encoder, so you could
move them below the ifdef; better yet, you could split the file in two
and compile conditionally.


Split into cngdec.c and cngenc.c locally.

// Martin___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/2] avcodec: Add a RFC 3389 comfort noise codec

2012-10-26 Thread Diego Biurrun
On Fri, Oct 26, 2012 at 11:13:49PM +0300, Martin Storsjö wrote:
> 
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -129,6 +129,8 @@ OBJS-$(CONFIG_CLJR_DECODER)+= cljr.o
>  OBJS-$(CONFIG_CLJR_ENCODER)+= cljr.o
>  OBJS-$(CONFIG_CLLC_DECODER)+= cllc.o
>  OBJS-$(CONFIG_COOK_DECODER)+= cook.o
> +OBJS-$(CONFIG_COMFORTNOISE_DECODER)+= comfortnoise.o celp_filters.o
> +OBJS-$(CONFIG_COMFORTNOISE_ENCODER)+= comfortnoise.o
>  OBJS-$(CONFIG_CSCD_DECODER)+= cscd.o
>  OBJS-$(CONFIG_CYUV_DECODER)+= cyuv.o
>  OBJS-$(CONFIG_DCA_DECODER) += dcadec.o dca.o dcadsp.o  \
> index 000..144c566
> --- /dev/null
> +++ b/libavcodec/comfortnoise.c
> @@ -0,0 +1,258 @@
> +
> +typedef struct CNGContext {
> +AVFrame avframe;
> +float *refl_coef, *target_refl_coef;
> +float *lpc_coef;
> +int order;
> +int energy, target_energy;
> +float *filter_out;
> +float *excitation;
> +AVLFG lfg;
> +} CNGContext;
> +
> +typedef struct CNGEncContext {
> +LPCContext lpc;
> +int order;
> +int32_t *samples32;
> +float *refl_coef;
> +} CNGEncContext;
> +
> +#if CONFIG_COMFORTNOISE_DECODER
> +#endif
> +
> +#if CONFIG_COMFORTNOISE_ENCODER
> +#endif

Each context struct is only used in one of decoder/encoder, so you could
move them below the ifdef; better yet, you could split the file in two
and compile conditionally.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel