Re: [FFmpeg-devel] [GSoC][PATCH v2 2/2] mlpenc: Working MLP/TrueHD encoder

2016-12-28 Thread Michael Niedermayer
On Tue, Aug 30, 2016 at 03:53:02PM +0530, Jai Luthra wrote:
> * Multichannel support for TrueHD is experimental
> 
> There should be downmix substreams present for 2+ channel bitstreams,
> but ffmpeg decoder doesn't need it. Will add support for this soon.
> 
> * There might be lossless check failures on LFE channels
> 
> * 32-bit sample support has been removed for now, will add it later
> 
> While testing, some samples gave lossless check failures when enforcing
> s32. Probably this will also get solved with the LFE issues.
> 
> Signed-off-by: Jai Luthra 
> ---
> 
> > a fate test could also be added
> 
> sure. i will add it in a separate patch later.
> 
>  libavcodec/Makefile|2 +
>  libavcodec/allcodecs.c |4 +-
>  libavcodec/mlp.c   |   21 +
>  libavcodec/mlp.h   |   40 +
>  libavcodec/mlpenc.c| 2416 
> 
>  5 files changed, 2481 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/mlpenc.c

[...]

> +/** Determines the amount of bits needed to encode the samples using no
> + *  codebooks and a specified offset.
> + */
> +static void no_codebook_bits_offset(MLPEncodeContext *ctx,
> +unsigned int channel, int16_t offset,
> +int32_t min, int32_t max,
> +BestOffset *bo)
> +{
> +DecodingParams *dp = ctx->cur_decoding_params;
> +int32_t unsign;
> +int lsb_bits;
> +
> +min -= offset;
> +max -= offset;
> +
> +lsb_bits = FFMAX(number_sbits(min), number_sbits(max)) - 1;
> +
> +lsb_bits += !!lsb_bits;
> +
> +unsign = 1 << (lsb_bits - 1);

coverity issue 1396239 says lsb_bits can be 0 here
which would result in an undefined shift
ill send you a invite to coverity so you can take a look

thx


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [GSoC][PATCH v2 2/2] mlpenc: Working MLP/TrueHD encoder

2016-09-17 Thread Rostislav Pehlivanov
On 30 August 2016 at 11:23, Jai Luthra  wrote:

> * Multichannel support for TrueHD is experimental
>
> There should be downmix substreams present for 2+ channel bitstreams,
> but ffmpeg decoder doesn't need it. Will add support for this soon.
>
> * There might be lossless check failures on LFE channels
>
> * 32-bit sample support has been removed for now, will add it later
>
> While testing, some samples gave lossless check failures when enforcing
> s32. Probably this will also get solved with the LFE issues.
>
> Signed-off-by: Jai Luthra 
> ---
>
> > a fate test could also be added
>
> sure. i will add it in a separate patch later.
>
>  libavcodec/Makefile|2 +
>  libavcodec/allcodecs.c |4 +-
>  libavcodec/mlp.c   |   21 +
>  libavcodec/mlp.h   |   40 +
>  libavcodec/mlpenc.c| 2416 ++
> ++
>  5 files changed, 2481 insertions(+), 2 deletions(-)
>  create mode 100644 libavcodec/mlpenc.c
>

Pushed!
Thanks a lot!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [GSoC][PATCH v2 2/2] mlpenc: Working MLP/TrueHD encoder

2016-08-30 Thread Jai Luthra
* Multichannel support for TrueHD is experimental

There should be downmix substreams present for 2+ channel bitstreams,
but ffmpeg decoder doesn't need it. Will add support for this soon.

* There might be lossless check failures on LFE channels

* 32-bit sample support has been removed for now, will add it later

While testing, some samples gave lossless check failures when enforcing
s32. Probably this will also get solved with the LFE issues.

Signed-off-by: Jai Luthra 
---

> a fate test could also be added

sure. i will add it in a separate patch later.

 libavcodec/Makefile|2 +
 libavcodec/allcodecs.c |4 +-
 libavcodec/mlp.c   |   21 +
 libavcodec/mlp.h   |   40 +
 libavcodec/mlpenc.c| 2416 
 5 files changed, 2481 insertions(+), 2 deletions(-)
 create mode 100644 libavcodec/mlpenc.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 7396468..b8d2a4c 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -382,6 +382,7 @@ OBJS-$(CONFIG_MJPEG_ENCODER)   += mjpegenc.o 
mjpegenc_common.o
 OBJS-$(CONFIG_MJPEGB_DECODER)  += mjpegbdec.o
 OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += vaapi_encode_mjpeg.o
 OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o
+OBJS-$(CONFIG_MLP_ENCODER) += mlpenc.o
 OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
 OBJS-$(CONFIG_MOTIONPIXELS_DECODER)+= motionpixels.o
 OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
@@ -545,6 +546,7 @@ OBJS-$(CONFIG_TIFF_DECODER)+= tiff.o lzw.o 
faxcompr.o tiff_data.o ti
 OBJS-$(CONFIG_TIFF_ENCODER)+= tiffenc.o rle.o lzwenc.o tiff_data.o
 OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
 OBJS-$(CONFIG_TRUEHD_DECODER)  += mlpdec.o mlpdsp.o
+OBJS-$(CONFIG_TRUEHD_ENCODER)  += mlpenc.o
 OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
 OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o
 OBJS-$(CONFIG_TRUEMOTION2RT_DECODER)   += truemotion2rt.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4c6b94e..64e0514 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -419,7 +419,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(MACE3, mace3);
 REGISTER_DECODER(MACE6, mace6);
 REGISTER_DECODER(METASOUND, metasound);
-REGISTER_DECODER(MLP,   mlp);
+REGISTER_ENCDEC (MLP,   mlp);
 REGISTER_DECODER(MP1,   mp1);
 REGISTER_DECODER(MP1FLOAT,  mp1float);
 REGISTER_ENCDEC (MP2,   mp2);
@@ -448,7 +448,7 @@ void avcodec_register_all(void)
 REGISTER_ENCDEC (SONIC, sonic);
 REGISTER_ENCODER(SONIC_LS,  sonic_ls);
 REGISTER_DECODER(TAK,   tak);
-REGISTER_DECODER(TRUEHD,truehd);
+REGISTER_ENCDEC (TRUEHD,truehd);
 REGISTER_DECODER(TRUESPEECH,truespeech);
 REGISTER_ENCDEC (TTA,   tta);
 REGISTER_DECODER(TWINVQ,twinvq);
diff --git a/libavcodec/mlp.c b/libavcodec/mlp.c
index 87f7c77..ddbab60 100644
--- a/libavcodec/mlp.c
+++ b/libavcodec/mlp.c
@@ -41,6 +41,27 @@ const uint8_t ff_mlp_huffman_tables[3][18][2] = {
 }
 };
 
+const ChannelInformation ff_mlp_ch_info[21] = {
+{ 0x01, 0x01, 0x00, 0x1f }, { 0x03, 0x02, 0x00, 0x1b },
+{ 0x07, 0x02, 0x01, 0x1f }, { 0x0F, 0x02, 0x02, 0x19 },
+{ 0x07, 0x02, 0x01, 0x03 }, { 0x0F, 0x02, 0x02, 0x1f },
+{ 0x1F, 0x02, 0x03, 0x01 }, { 0x07, 0x02, 0x01, 0x1a },
+{ 0x0F, 0x02, 0x02, 0x1f }, { 0x1F, 0x02, 0x03, 0x18 },
+{ 0x0F, 0x02, 0x02, 0x02 }, { 0x1F, 0x02, 0x03, 0x1f },
+{ 0x3F, 0x02, 0x04, 0x00 }, { 0x0F, 0x03, 0x01, 0x1f },
+{ 0x1F, 0x03, 0x02, 0x18 }, { 0x0F, 0x03, 0x01, 0x02 },
+{ 0x1F, 0x03, 0x02, 0x1f }, { 0x3F, 0x03, 0x03, 0x00 },
+{ 0x1F, 0x04, 0x01, 0x01 }, { 0x1F, 0x04, 0x01, 0x18 },
+{ 0x3F, 0x04, 0x02, 0x00 },
+};
+
+const uint64_t ff_mlp_channel_layouts[12] = {
+AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_2_1,
+AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_2POINT1, AV_CH_LAYOUT_SURROUND,
+AV_CH_LAYOUT_4POINT0, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_3POINT1,
+AV_CH_LAYOUT_4POINT1, AV_CH_LAYOUT_5POINT1_BACK, 0,
+};
+
 static int crc_init = 0;
 #if CONFIG_SMALL
 #define CRC_TABLE_SIZE 257
diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h
index 05d8dba..41a45a3 100644
--- a/libavcodec/mlp.h
+++ b/libavcodec/mlp.h
@@ -76,6 +76,9 @@ typedef struct FilterParams {
 uint8_t shift; ///< Right shift to apply to output of filter.
 
 int32_t state[MAX_FIR_ORDER];
+
+int coeff_bits;
+int coeff_shift;
 } FilterParams;
 
 /** sample data coding information */
@@ -96,6 +99,43 @@ typedef struct ChannelParams {
  */
 extern const uint8_t ff_mlp_huffman_tables[3][18][2];
 
+typedef struct {
+uint8_t channel_occupancy;
+uint8_t group1_channels;
+