Re: [libav-devel] [PATCH] riff: support ProRes in avi (APCH fourcc)

2015-02-10 Thread Alex Converse
On Tue, Feb 10, 2015 at 11:33 AM, Vittorio Giovara
 wrote:
> ---
>  libavformat/riff.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libavformat/riff.c b/libavformat/riff.c
> index 776a25f..a093986 100644
> --- a/libavformat/riff.c
> +++ b/libavformat/riff.c
> @@ -349,6 +349,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
>  { AV_CODEC_ID_G2M,  MKTAG('G', '2', 'M', '4') },
>  { AV_CODEC_ID_FIC,  MKTAG('F', 'I', 'C', 'V') },
>  { AV_CODEC_ID_PRORES,   MKTAG('A', 'P', 'C', 'N') },
> +{ AV_CODEC_ID_PRORES,   MKTAG('A', 'P', 'C', 'H') },
>  { AV_CODEC_ID_NONE, 0 }
>  };
>

Should we go ahead and put all the prores 4CCs in here? 0, 1, many,
and all that jazz?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH v2 4/6] aacdec: Tables for length 480 AAC ELD.

2015-01-27 Thread Alex Converse
From: Niel van der Westhuizen 

---
 libavcodec/aacdec.c |   2 +-
 libavcodec/aactab.c | 494 +++-
 libavcodec/aactab.h |   6 +-
 3 files changed, 499 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 5408e20..e21ed0d 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2457,7 +2457,7 @@ static void imdct_and_windowing_eld(AACContext *ac, 
SingleChannelElement *sce)
 float *in= sce->coeffs;
 float *out   = sce->ret;
 float *saved = sce->saved;
-const float *const window = ff_aac_eld_window;
+const float *const window = ff_aac_eld_window_512;
 float *buf  = ac->buf_mdct;
 int i;
 const int n  = 512;
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index ee9a735..9f1e8af 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -44,6 +44,10 @@ const uint8_t ff_aac_num_swb_512[] = {
  0,  0,  0, 36, 36, 37, 31, 31,  0,  0,  0,  0,  0
 };
 
+const uint8_t ff_aac_num_swb_480[] = {
+ 0,  0,  0, 35, 35, 37, 30, 30,  0,  0,  0,  0,  0
+};
+
 const uint8_t ff_aac_num_swb_128[] = {
 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
 };
@@ -1126,6 +1130,14 @@ static const uint16_t swb_offset_512_48[] = {
 364, 396, 428, 460, 512
 };
 
+static const uint16_t swb_offset_480_48[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  48,  52,  56,  64,
+ 72,  80,  88,  96, 108, 120, 132, 144,
+156, 172, 188, 212, 240, 272, 304, 336,
+368, 400, 432, 480
+};
+
 static const uint16_t swb_offset_128_48[] = {
  0,   4,   8,  12,  16,  20,  28,  36,
 44,  56,  68,  80,  96, 112, 128
@@ -1149,6 +1161,14 @@ static const uint16_t swb_offset_512_32[] = {
 352, 384, 416, 448, 480, 512
 };
 
+static const uint16_t swb_offset_480_32[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  48,  52,  56,  60,
+ 64,  72,  80,  88,  96, 104, 112, 124,
+136, 148, 164, 180, 200, 224, 256, 288,
+320, 352, 384, 416, 448, 480
+ };
+
 static const uint16_t swb_offset_1024_24[] = {
   0,   4,   8,  12,  16,  20,  24,  28,
  32,  36,  40,  44,  52,  60,  68,  76,
@@ -1165,6 +1185,13 @@ static const uint16_t swb_offset_512_24[] = {
 288, 320, 352, 384, 416, 448, 480, 512,
 };
 
+static const uint16_t swb_offset_480_24[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  52,  60,  68,  80,
+ 92, 104, 120, 140, 164, 192, 224, 256,
+288, 320, 352, 384, 416, 448, 480
+};
+
 static const uint16_t swb_offset_128_24[] = {
  0,   4,   8,  12,  16,  20,  24,  28,
 36,  44,  52,  64,  76,  92, 108, 128
@@ -1214,6 +1241,14 @@ const uint16_t * const ff_swb_offset_512[] = {
 NULL
 };
 
+const uint16_t * const ff_swb_offset_480[] = {
+NULL,   NULL,   NULL,
+swb_offset_480_48,  swb_offset_480_48,  swb_offset_480_32,
+swb_offset_480_24,  swb_offset_480_24,  NULL,
+NULL,   NULL,   NULL,
+NULL
+};
+
 const uint16_t * const ff_swb_offset_128[] = {
 /* The last entry on the following row is swb_offset_128_64 but is a
duplicate of swb_offset_128_96. */
@@ -1240,12 +1275,16 @@ const uint8_t ff_tns_max_bands_512[] = {
 0, 0, 0, 31, 32, 37, 31, 31, 0, 0, 0, 0, 0
 };
 
+const uint8_t ff_tns_max_bands_480[] = {
+0, 0, 0, 31, 32, 37, 30, 30, 0, 0, 0, 0, 0
+};
+
 const uint8_t ff_tns_max_bands_128[] = {
 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
 };
 // @}
 
-const DECLARE_ALIGNED(32, float, ff_aac_eld_window)[1920] = {
+const DECLARE_ALIGNED(32, float, ff_aac_eld_window_512)[1920] = {
  0.00338834,  0.00567745,  0.00847677,  0.01172641,
  0.01532555,  0.01917664,  0.02318809,  0.02729259,
  0.03144503,  0.03560261,  0.03972499,  0.04379783,
@@ -1727,3 +1766,456 @@ const DECLARE_ALIGNED(32, float, 
ff_aac_eld_window)[1920] = {
 -0.00116552, -0.00115223, -0.00113877, -0.00112517,
 -0.0044, -0.00109764, -0.00108377, -0.00106989,
 };
+
+const DECLARE_ALIGNED(32, float, ff_aac_eld_window_480)[1800] = {
+ 0.00101191,  0.00440397,  0.00718669,  0.01072130,
+ 0.01459757,  0.01875954,  0.02308987,  0.02751541,
+ 0.03198130,  0.03643738,  0.04085290,  0.04522835,
+ 0.04957620,  0.05390454,  0.05821503,  0.06251214,
+ 0.06680463,  0.07109582,  0.07538014,  0.07965207,
+ 0.08390857,  0.08815177,  0.09238785,  0.09662163,
+ 0.10085860,  0.10510892,  0.10938110,  0.11367819,
+ 0.11800355,  0.12236410,  0.12676834,  0.13122384,
+ 0.13573476,  0.14030106,  0.14492340,  0.14960315,
+ 0.15433828,  0.15912396,  0.16395663,  0.16883310,
+ 0.17374837,  0.17869679,  0.18367394,  0.18867661,
+ 0.19370368,  0.19875413,  0.20382641,  0.20892055,
+ 0.21403775,  0.21917761,  0.22433899,  0.22952250,
+ 0.23472991,  0.23996189,  0.24521859,  0.25049930,
+ 0.25580312,  0.26112942,  0.26647748,  0.27184703,
+ 0.27723785,  0.282649

[libav-devel] [PATCH v2 5/6] aacdec: Support for ER AAC ELD 480.

2015-01-27 Thread Alex Converse
Based in part on work from Niel van der Westhuizen .
---
 libavcodec/Makefile |  3 ++-
 libavcodec/aac.h|  2 ++
 libavcodec/aacdec.c | 38 ++
 libavcodec/mpeg4audio.h |  1 +
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8c0c345..92e8b67 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_WMA_FREQS)   += wma_freqs.o
 OBJS-$(CONFIG_A64MULTI_ENCODER)+= a64multienc.o elbg.o
 OBJS-$(CONFIG_A64MULTI5_ENCODER)   += a64multienc.o elbg.o
 OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \
-  aacadtsdec.o mpeg4audio.o kbdwin.o \
+  aacadtsdec.o opus_imdct.o \
+  mpeg4audio.o kbdwin.o \
   sbrdsp.o aacpsdsp.o
 OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o\
   aacpsy.o aactab.o  \
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 375e6b1..e80b518 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -32,6 +32,7 @@
 
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
+#include "opus_imdct.h"
 #include "fft.h"
 #include "mpeg4audio.h"
 #include "sbr.h"
@@ -291,6 +292,7 @@ typedef struct AACContext {
 FFTContext mdct_small;
 FFTContext mdct_ld;
 FFTContext mdct_ltp;
+CeltIMDCTContext *mdct480;
 FmtConvertContext fmt_conv;
 AVFloatDSPContext fdsp;
 int random_state;
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index e21ed0d..a1a3f49 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -84,6 +84,7 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
+#include "opus_imdct.h"
 #include "fft.h"
 #include "fmtconvert.h"
 #include "lpc.h"
@@ -719,6 +720,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 avpriv_request_sample(avctx, "960/120 MDCT window");
 return AVERROR_PATCHWELCOME;
 }
+m4ac->frame_length_short = 0;
 
 if (get_bits1(gb))   // dependsOnCoreCoder
 skip_bits(gb, 14);   // coreCoderDelay
@@ -796,11 +798,7 @@ static int decode_eld_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 m4ac->ps  = 0;
 m4ac->sbr = 0;
 
-if (get_bits1(gb)) { // frameLengthFlag
-avpriv_request_sample(avctx, "960/120 MDCT window");
-return AVERROR_PATCHWELCOME;
-}
-
+m4ac->frame_length_short = get_bits1(gb);
 res_flags = get_bits(gb, 3);
 if (res_flags) {
 avpriv_report_missing_feature(avctx,
@@ -1066,6 +1064,10 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 ff_mdct_init(&ac->mdct_ld,10, 1, 1.0 / (32768.0 * 512.0));
 ff_mdct_init(&ac->mdct_small,  8, 1, 1.0 / (32768.0 * 128.0));
 ff_mdct_init(&ac->mdct_ltp,   11, 0, -2.0 * 32768.0);
+ret = ff_celt_imdct_init(&ac->mdct480, 5);
+if (ret < 0)
+return ret;
+
 // window initialization
 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
@@ -1180,9 +1182,15 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 ics->max_sfb   = get_bits(gb, 6);
 ics->num_windows   = 1;
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
-ics->swb_offset= ff_swb_offset_512[sampling_index];
-ics->num_swb   =ff_aac_num_swb_512[sampling_index];
-ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
+if (m4ac->frame_length_short) {
+ics->swb_offset= ff_swb_offset_480[sampling_index];
+ics->num_swb   =ff_aac_num_swb_480[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_480[sampling_index];
+} else {
+ics->swb_offset= ff_swb_offset_512[sampling_index];
+ics->num_swb   =ff_aac_num_swb_512[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
+}
 if (!ics->num_swb || !ics->swb_offset)
 return AVERROR_BUG;
 } else {
@@ -2457,12 +2465,13 @@ static void imdct_and_windowing_eld(AACContext *ac, 
SingleChannelElement *sce)
 float *in= sce->coeffs;
 float *out   = sce->ret;
 float *saved = sce->saved;
-const float *const window = ff_aac_eld_window_512;
 float *buf  = ac->buf_mdct;
 int i;
-const int n  = 512;
+const int n  = ac->oc[1].m4ac.frame_length_short ? 480 : 512;
 const int n2 = n >> 1;
 const int n4 = n >> 2;
+const float *const window = n == 480 ? ff_aac_eld_window_480 :
+   ff_aac_eld_window_512;
 
 // Inverse transform, mapped to the conventio

[libav-devel] [PATCH v2 3/6] aacdec: Support for ER AAC in LATM

2015-01-27 Thread Alex Converse
From: Niel van der Westhuizen 

---
 libavcodec/aacdec.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 90de276..5408e20 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -3235,8 +3235,18 @@ static int latm_decode_frame(AVCodecContext *avctx, void 
*out,
 return AVERROR_INVALIDDATA;
 }
 
-if ((err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb)) < 0)
-return err;
+switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
+case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LTP:
+case AOT_ER_AAC_LD:
+case AOT_ER_AAC_ELD:
+err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
+break;
+default:
+err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb);
+}
+if (err < 0)
+return err;
 
 return muxlength;
 }
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH v2 2/6] aacdec: Refactor aac_er_decode_frame.

2015-01-27 Thread Alex Converse
---
 libavcodec/aacdec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 549e5e5..90de276 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2703,11 +2703,12 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
void *data,
int *got_frame_ptr, GetBitContext *gb)
 {
 AACContext *ac = avctx->priv_data;
+const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
 ChannelElement *che;
 int err, i;
 int samples = 1024;
-int chan_config = ac->oc[1].m4ac.chan_config;
-int aot = ac->oc[1].m4ac.object_type;
+int chan_config = m4ac->chan_config;
+int aot = m4ac->object_type;
 
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD)
 samples >>= 1;
@@ -2719,13 +2720,13 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
void *data,
 
 // The FF_PROFILE_AAC_* defines are all object_type - 1
 // This may lead to an undefined profile being signaled
-ac->avctx->profile = ac->oc[1].m4ac.object_type - 1;
+ac->avctx->profile = aot - 1;
 
 ac->tags_mapped = 0;
 
 if (chan_config < 0 || chan_config >= 8) {
 avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
-  ac->oc[1].m4ac.chan_config);
+  chan_config);
 return AVERROR_INVALIDDATA;
 }
 for (i = 0; i < tags_per_config[chan_config]; i++) {
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH v2 6/6] fate: Add a test for AAC ELD480.

2015-01-27 Thread Alex Converse
The source is er_eld_2100np_48_ep0.mp4 from the official test set.
---
 tests/fate/aac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index b3f07cb..63ea06c 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -66,6 +66,10 @@ FATE_AAC += fate-aac-er_eld2000np_48_ep0
 fate-aac-er_eld2000np_48_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld2000np_48_ep0.mp4
 fate-aac-er_eld2000np_48_ep0: REF = $(SAMPLES)/aac/er_eld2000np_48_ep0.s16
 
+FATE_AAC += fate-aac-er_eld2100np_48_ep0
+fate-aac-er_eld2100np_48_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld2100np_48_ep0.mp4
+fate-aac-er_eld2100np_48_ep0: REF = $(SAMPLES)/aac/er_eld2100np_48.s16
+
 
 fate-aac-ct%: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/CT_DecoderCheck/$(@:fate-aac-ct-%=%)
 fate-aac-ct%: REF = $(SAMPLES)/aac/CT_DecoderCheck/aacPlusv2.wav
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH v2 1/6] aacdec: Refactor decode_ics_info.

2015-01-27 Thread Alex Converse
---
 libavcodec/aacdec.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 9c0a46d..549e5e5 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -1137,7 +1137,9 @@ static void decode_ltp(LongTermPrediction *ltp,
 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
 {
-int aot = ac->oc[1].m4ac.object_type;
+const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
+const int aot = m4ac->object_type;
+const int sampling_index = m4ac->sampling_index;
 if (aot != AOT_ER_AAC_ELD) {
 if (get_bits1(gb)) {
 av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
@@ -1170,23 +1172,23 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 }
 }
 ics->num_windows   = 8;
-ics->swb_offset=
ff_swb_offset_128[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands = 
ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset=ff_swb_offset_128[sampling_index];
+ics->num_swb   =   ff_aac_num_swb_128[sampling_index];
+ics->tns_max_bands = ff_tns_max_bands_128[sampling_index];
 ics->predictor_present = 0;
 } else {
-ics->max_sfb   = get_bits(gb, 6);
-ics->num_windows   = 1;
+ics->max_sfb   = get_bits(gb, 6);
+ics->num_windows   = 1;
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
-ics->swb_offset= 
ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =
ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands =  
ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset= ff_swb_offset_512[sampling_index];
+ics->num_swb   =ff_aac_num_swb_512[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
 if (!ics->num_swb || !ics->swb_offset)
 return AVERROR_BUG;
 } else {
-ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset=ff_swb_offset_1024[sampling_index];
+ics->num_swb   =   ff_aac_num_swb_1024[sampling_index];
+ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index];
 }
 if (aot != AOT_ER_AAC_ELD) {
 ics->predictor_present = get_bits1(gb);
-- 
2.2.0.rc0.207.ga3a616c

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


Re: [libav-devel] [PATCH 5/5] aacdec: Support for ER AAC ELD 480.

2015-01-26 Thread Alex Converse
On Mon, Jan 26, 2015 at 2:29 AM, Anton Khirnov  wrote:
> Quoting Alex Converse (2015-01-22 20:04:41)
>> Based in part on work from espes 
>> ---
>>  libavcodec/Makefile |  3 ++-
>>  libavcodec/aac.h|  2 ++
>>  libavcodec/aacdec.c | 38 ++
>>  libavcodec/mpeg4audio.h |  1 +
>>  4 files changed, 31 insertions(+), 13 deletions(-)
>>
>
> Besides the imdct naming bikeshed, looks fine to me.
> Having some FATE tests would be really nice.
>

er_eld2100np_48_ep0.mp4 would be a perfect testvector for the eld480
part of this patchset. The only official latm test vectors are CELP
(why!). We could probably make one with FDK.

Someone needs to walk me through the upload process again or do the
upload for me.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 5/5] aacdec: Support for ER AAC ELD 480.

2015-01-24 Thread Alex Converse
On Jan 24, 2015 10:44 PM, "Diego Biurrun"  wrote:
>
> On Thu, Jan 22, 2015 at 11:04:41AM -0800, Alex Converse wrote:
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -91,7 +91,8 @@ OBJS-$(CONFIG_WMA_FREQS)   += wma_freqs.o
> >  OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o
aacps.o \
> > -  aacadtsdec.o mpeg4audio.o
kbdwin.o \
> > +  aacadtsdec.o opus_imdct.o \
> > +  mpeg4audio.o kbdwin.o \
> >sbrdsp.o aacpsdsp.o
> > --- a/libavcodec/aac.h
> > +++ b/libavcodec/aac.h
> > @@ -32,6 +32,7 @@
> >
> >  #include "libavutil/float_dsp.h"
> >  #include "avcodec.h"
> > +#include "opus_imdct.h"
> >  #include "fft.h"
>
> Maybe this IMDCT should be renamed to something else now?
> It's obviously not specific to Opus ...
>

Currently it can't even seem to decide if it wants to be called the celt
imdct or the opus imdct. Maybe imdct15 would be a better name. It would
also be nice if I could call it from the same interface as the 2**n imdct.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/5] aacdec: Refactor aac_decode_frame_int.

2015-01-22 Thread Alex Converse
On Thu, Jan 22, 2015 at 11:04 AM, Alex Converse  wrote:
> ---
>  libavcodec/aacdec.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> index 549e5e5..bca785c 100644
> --- a/libavcodec/aacdec.c
> +++ b/libavcodec/aacdec.c
> @@ -2703,11 +2703,12 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
> void *data,
> int *got_frame_ptr, GetBitContext *gb)

My commit message references the wrong function, oops

>  {
>  AACContext *ac = avctx->priv_data;
> +MPEG4AudioConfig *m4ac = &ac->oc[1].m4ac;
>  ChannelElement *che;
>  int err, i;
>  int samples = 1024;
> -int chan_config = ac->oc[1].m4ac.chan_config;
> -int aot = ac->oc[1].m4ac.object_type;
> +int chan_config = m4ac->chan_config;
> +int aot = m4ac->object_type;
>
>  if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD)
>  samples >>= 1;
> @@ -2719,13 +2720,13 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
> void *data,
>
>  // The FF_PROFILE_AAC_* defines are all object_type - 1
>  // This may lead to an undefined profile being signaled
> -ac->avctx->profile = ac->oc[1].m4ac.object_type - 1;
> +ac->avctx->profile = m4ac->object_type - 1;
>
>  ac->tags_mapped = 0;
>
>  if (chan_config < 0 || chan_config >= 8) {
>  avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
> -  ac->oc[1].m4ac.chan_config);
> +  chan_config);
>  return AVERROR_INVALIDDATA;
>  }
>  for (i = 0; i < tags_per_config[chan_config]; i++) {
> --
> 2.2.0.rc0.207.ga3a616c
>
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] Regarding Reserved AAC SBR Extensions

2015-01-22 Thread Alex Converse
On Thu, Jan 22, 2015 at 1:40 PM, Akshay Garg  wrote:
> Hey Alex,
>
> Thanks for the reply. I'm glad that there is no functional issue associated
> with the warning. It turns out that ffmpeg version of the libavcodec
> library silences this warning already (Thanks to Carl Eugen for bringing
> this to my notice). Following is a commit that masks the log. So maybe we
> need to do something like this in libav.
>
> commit 1ac606bae60e46522189b678b58a7fb8376046ac
> Author: Reimar Döffinger 
> Date:   Mon Apr 9 21:19:30 2012 +0200
>
> aacsbr: silence message for SBR extension "padding".
>
> Some files contain a few additional, all-0 bits.
> Check for that case and don't print incorrect "not supported"
> message.
> Fixes trac issue #836.
>
> Signed-off-by: Reimar Döffinger 
>
> diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
> index 79a0ca2..ea2dcbb 100644
> --- a/libavcodec/aacsbr.c
> +++ b/libavcodec/aacsbr.c
> @@ -933,7 +933,9 @@ static void read_sbr_extension(AACContext *ac,
> SpectralBandReplication *sbr,
>  }
>  break;
>  default:
> -av_log_missing_feature(ac->avctx, "Reserved SBR extensions are",
> 1);
> +// some files contain 0-padding
> +if (bs_extension_id || *num_bits_left > 16 || show_bits(gb,
> *num_bits_left))
> +av_log_missing_feature(ac->avctx, "Reserved SBR extensions
> are", 1);
>  skip_bits_long(gb, *num_bits_left); // bs_fill_bits
>  *num_bits_left = 0;
>  break;
>
> Let me know if you'd like me to upload a patch.
>
> Cheers..
> Akshay
>

That patch looks good to me. It might also be good to print the
extension id in missing feature log.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 2/5] aacdec: Refactor aac_decode_frame_int.

2015-01-22 Thread Alex Converse
On Thu, Jan 22, 2015 at 12:19 PM, Luca Barbato  wrote:
> On 22/01/15 20:04, Alex Converse wrote:
>>
>> +MPEG4AudioConfig *m4ac = &ac->oc[1].m4ac;
>
> vs
>
> > +const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
>
> Is there a particular reason?
>

I was worried about inband PCE. But that's impossible for ER AAC
[Thank god]. Fixed.

> > +ac->avctx->profile = m4ac->object_type - 1;
>
> why not using `aot` ?
>

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


Re: [libav-devel] Regarding Reserved AAC SBR Extensions

2015-01-22 Thread Alex Converse
So I capped the stream. Extension ID here is zero which is reserved for
future use. Decoders are supposed to skip extensions that they don't
understand yet, which is what we do. We spam the log to try to get samples
of new extensions being used in the wild. It looks like once upon a time
DRM used a PS draft with that extension ID.

In this case the unknown extension appears to be padding, which is
unfortunate because if a real extension is ever added here [which seems a
bit unlikely at this point] it will conflict. There are a few places in the
bit stream to add [optional] padding or application specific data and this
isn't one of them.

It's also possible that the PS decoder isn't reading as many bits as
required but not detecting an error.

It's also possible that they are unintentionally padding due to an encoder
bug that isn't getting caught because it's writing extra data that decoders
ignore.

Regardless of this warning the decoder processes all the data it has read
so far including SBR and PS so you aren't getting a quality drop here. We
could silence this warning, or do we have an av_log_once() yet?

Cheers,
Alex


On Wed, Jan 21, 2015 at 11:35 AM, Akshay Garg  wrote:

> My bad, sorry for posting an mp3 stream.
>
> Please use the following url
>
> http://edge.espn.cdn.abacast.net/espn-network-48
>
> The issue starts once we get an advertisement in the stream. Usually within
> 5-10 minutes of the playback start.
>
> I use GST_DEBUG=4 to check the logs.
>
> Thanks
> Akshay
>
> On 21 January 2015 at 11:01, Luca Barbato  wrote:
>
> > On 21/01/15 19:37, Akshay Garg wrote:
> > > Hi All,
> > >
> > > While trying to play the this ESPN Radio Station on Tune in:
> > >
> > > http://edge.espn.cdn.abacast.net/espn-networkmp3-48
> > >
> > > using the following Gstreamer pipeline
> > >
> > > gst-launch-0.1 soupthttpsrc
> > > location=http://edge.espn.cdn.abacast.net/espn-networkmp3-48 !
> > > decodebin ! pulsesink
> > >
> > > I keep getting the following warnings:
> > >
> > > "Reserved SBR extensions is not implemented. Update your Libav version
> > > to the newest one from Git. If the problem still occurs, it means that
> > > your file has a feature which has not been implemented."
> > >
> > > and eventually the playback stops. I have the latest version of libav
> > > (11.2) installed on my machine. Even the gstreamer (gst-libav) version
> > > is latest i.e. 1.4.5.
> > >
> > > Looking at the libav aacsbr code it seems like the only extension
> > > that's currently supported is SBR+Parametric Stereo.
> >
> > Right now it is sending mp3 so I can't check what's wrong =/
> >
> > lu
> >
> >
> >
> > ___
> > libav-devel mailing list
> > libav-devel@libav.org
> > https://lists.libav.org/mailman/listinfo/libav-devel
> >
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
>
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 5/5] aacdec: Support for ER AAC ELD 480.

2015-01-22 Thread Alex Converse
Based in part on work from espes 
---
 libavcodec/Makefile |  3 ++-
 libavcodec/aac.h|  2 ++
 libavcodec/aacdec.c | 38 ++
 libavcodec/mpeg4audio.h |  1 +
 4 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 419dcb6..aa3051d 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -91,7 +91,8 @@ OBJS-$(CONFIG_WMA_FREQS)   += wma_freqs.o
 OBJS-$(CONFIG_A64MULTI_ENCODER)+= a64multienc.o elbg.o
 OBJS-$(CONFIG_A64MULTI5_ENCODER)   += a64multienc.o elbg.o
 OBJS-$(CONFIG_AAC_DECODER) += aacdec.o aactab.o aacsbr.o aacps.o \
-  aacadtsdec.o mpeg4audio.o kbdwin.o \
+  aacadtsdec.o opus_imdct.o \
+  mpeg4audio.o kbdwin.o \
   sbrdsp.o aacpsdsp.o
 OBJS-$(CONFIG_AAC_ENCODER) += aacenc.o aaccoder.o\
   aacpsy.o aactab.o  \
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 375e6b1..e80b518 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -32,6 +32,7 @@
 
 #include "libavutil/float_dsp.h"
 #include "avcodec.h"
+#include "opus_imdct.h"
 #include "fft.h"
 #include "mpeg4audio.h"
 #include "sbr.h"
@@ -291,6 +292,7 @@ typedef struct AACContext {
 FFTContext mdct_small;
 FFTContext mdct_ld;
 FFTContext mdct_ltp;
+CeltIMDCTContext *mdct480;
 FmtConvertContext fmt_conv;
 AVFloatDSPContext fdsp;
 int random_state;
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index eefaa37..10c1400 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -84,6 +84,7 @@
 #include "avcodec.h"
 #include "internal.h"
 #include "get_bits.h"
+#include "opus_imdct.h"
 #include "fft.h"
 #include "fmtconvert.h"
 #include "lpc.h"
@@ -719,6 +720,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 avpriv_request_sample(avctx, "960/120 MDCT window");
 return AVERROR_PATCHWELCOME;
 }
+m4ac->frame_length_short = 0;
 
 if (get_bits1(gb))   // dependsOnCoreCoder
 skip_bits(gb, 14);   // coreCoderDelay
@@ -796,11 +798,7 @@ static int decode_eld_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 m4ac->ps  = 0;
 m4ac->sbr = 0;
 
-if (get_bits1(gb)) { // frameLengthFlag
-avpriv_request_sample(avctx, "960/120 MDCT window");
-return AVERROR_PATCHWELCOME;
-}
-
+m4ac->frame_length_short = get_bits1(gb);
 res_flags = get_bits(gb, 3);
 if (res_flags) {
 avpriv_report_missing_feature(avctx,
@@ -1066,6 +1064,10 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 ff_mdct_init(&ac->mdct_ld,10, 1, 1.0 / (32768.0 * 512.0));
 ff_mdct_init(&ac->mdct_small,  8, 1, 1.0 / (32768.0 * 128.0));
 ff_mdct_init(&ac->mdct_ltp,   11, 0, -2.0 * 32768.0);
+ret = ff_celt_imdct_init(&ac->mdct480, 5);
+if (ret < 0)
+return ret;
+
 // window initialization
 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
@@ -1180,9 +1182,15 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 ics->max_sfb   = get_bits(gb, 6);
 ics->num_windows   = 1;
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
-ics->swb_offset= ff_swb_offset_512[sampling_index];
-ics->num_swb   =ff_aac_num_swb_512[sampling_index];
-ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
+if (m4ac->frame_length_short) {
+ics->swb_offset= ff_swb_offset_480[sampling_index];
+ics->num_swb   =ff_aac_num_swb_480[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_480[sampling_index];
+} else {
+ics->swb_offset= ff_swb_offset_512[sampling_index];
+ics->num_swb   =ff_aac_num_swb_512[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
+}
 if (!ics->num_swb || !ics->swb_offset)
 return AVERROR_BUG;
 } else {
@@ -2457,12 +2465,13 @@ static void imdct_and_windowing_eld(AACContext *ac, 
SingleChannelElement *sce)
 float *in= sce->coeffs;
 float *out   = sce->ret;
 float *saved = sce->saved;
-const float *const window = ff_aac_eld_window;
 float *buf  = ac->buf_mdct;
 int i;
-const int n  = 512;
+const int n  = ac->oc[1].m4ac.frame_length_short ? 480 : 512;
 const int n2 = n >> 1;
 const int n4 = n >> 2;
+const float *const window = n == 480 ? ff_aac_eld_window_480 :
+   ff_aac_eld_window_512;
 
 // Inverse transform, mapped to the conventional IMDCT by
 // Ch

[libav-devel] [PATCH 2/5] aacdec: Refactor aac_decode_frame_int.

2015-01-22 Thread Alex Converse
---
 libavcodec/aacdec.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 549e5e5..bca785c 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2703,11 +2703,12 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
void *data,
int *got_frame_ptr, GetBitContext *gb)
 {
 AACContext *ac = avctx->priv_data;
+MPEG4AudioConfig *m4ac = &ac->oc[1].m4ac;
 ChannelElement *che;
 int err, i;
 int samples = 1024;
-int chan_config = ac->oc[1].m4ac.chan_config;
-int aot = ac->oc[1].m4ac.object_type;
+int chan_config = m4ac->chan_config;
+int aot = m4ac->object_type;
 
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD)
 samples >>= 1;
@@ -2719,13 +2720,13 @@ static int aac_decode_er_frame(AVCodecContext *avctx, 
void *data,
 
 // The FF_PROFILE_AAC_* defines are all object_type - 1
 // This may lead to an undefined profile being signaled
-ac->avctx->profile = ac->oc[1].m4ac.object_type - 1;
+ac->avctx->profile = m4ac->object_type - 1;
 
 ac->tags_mapped = 0;
 
 if (chan_config < 0 || chan_config >= 8) {
 avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
-  ac->oc[1].m4ac.chan_config);
+  chan_config);
 return AVERROR_INVALIDDATA;
 }
 for (i = 0; i < tags_per_config[chan_config]; i++) {
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH 3/5] aacdec: Support for ER AAC in LATM

2015-01-22 Thread Alex Converse
From: espes 

---
 libavcodec/aacdec.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index bca785c..eefaa37 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -3235,8 +3235,20 @@ static int latm_decode_frame(AVCodecContext *avctx, void 
*out,
 return AVERROR_INVALIDDATA;
 }
 
-if ((err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb)) < 0)
-return err;
+if (latmctx->initialized) {
+switch (latmctx->aac_ctx.oc[1].m4ac.object_type) {
+case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LTP:
+case AOT_ER_AAC_LD:
+case AOT_ER_AAC_ELD:
+err = aac_decode_er_frame(avctx, out, got_frame_ptr, &gb);
+break;
+default:
+err = aac_decode_frame_int(avctx, out, got_frame_ptr, &gb);
+}
+if (err < 0)
+return err;
+}
 
 return muxlength;
 }
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH 1/5] aacdec: Refactor decode_ics_info.

2015-01-22 Thread Alex Converse
---
 libavcodec/aacdec.c | 26 ++
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 9c0a46d..549e5e5 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -1137,7 +1137,9 @@ static void decode_ltp(LongTermPrediction *ltp,
 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
 {
-int aot = ac->oc[1].m4ac.object_type;
+const MPEG4AudioConfig *const m4ac = &ac->oc[1].m4ac;
+const int aot = m4ac->object_type;
+const int sampling_index = m4ac->sampling_index;
 if (aot != AOT_ER_AAC_ELD) {
 if (get_bits1(gb)) {
 av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
@@ -1170,23 +1172,23 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 }
 }
 ics->num_windows   = 8;
-ics->swb_offset=
ff_swb_offset_128[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_128[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands = 
ff_tns_max_bands_128[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset=ff_swb_offset_128[sampling_index];
+ics->num_swb   =   ff_aac_num_swb_128[sampling_index];
+ics->tns_max_bands = ff_tns_max_bands_128[sampling_index];
 ics->predictor_present = 0;
 } else {
-ics->max_sfb   = get_bits(gb, 6);
-ics->num_windows   = 1;
+ics->max_sfb   = get_bits(gb, 6);
+ics->num_windows   = 1;
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
-ics->swb_offset= 
ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =
ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands =  
ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset= ff_swb_offset_512[sampling_index];
+ics->num_swb   =ff_aac_num_swb_512[sampling_index];
+ics->tns_max_bands =  ff_tns_max_bands_512[sampling_index];
 if (!ics->num_swb || !ics->swb_offset)
 return AVERROR_BUG;
 } else {
-ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
-ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
+ics->swb_offset=ff_swb_offset_1024[sampling_index];
+ics->num_swb   =   ff_aac_num_swb_1024[sampling_index];
+ics->tns_max_bands = ff_tns_max_bands_1024[sampling_index];
 }
 if (aot != AOT_ER_AAC_ELD) {
 ics->predictor_present = get_bits1(gb);
-- 
2.2.0.rc0.207.ga3a616c

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


[libav-devel] [PATCH 4/5] aacdec: Tables for length 480 AAC ELD.

2015-01-22 Thread Alex Converse
From: espes 

---
 libavcodec/aactab.c | 494 +++-
 libavcodec/aactab.h |   6 +-
 2 files changed, 498 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index ee9a735..9f1e8af 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -44,6 +44,10 @@ const uint8_t ff_aac_num_swb_512[] = {
  0,  0,  0, 36, 36, 37, 31, 31,  0,  0,  0,  0,  0
 };
 
+const uint8_t ff_aac_num_swb_480[] = {
+ 0,  0,  0, 35, 35, 37, 30, 30,  0,  0,  0,  0,  0
+};
+
 const uint8_t ff_aac_num_swb_128[] = {
 12, 12, 12, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15
 };
@@ -1126,6 +1130,14 @@ static const uint16_t swb_offset_512_48[] = {
 364, 396, 428, 460, 512
 };
 
+static const uint16_t swb_offset_480_48[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  48,  52,  56,  64,
+ 72,  80,  88,  96, 108, 120, 132, 144,
+156, 172, 188, 212, 240, 272, 304, 336,
+368, 400, 432, 480
+};
+
 static const uint16_t swb_offset_128_48[] = {
  0,   4,   8,  12,  16,  20,  28,  36,
 44,  56,  68,  80,  96, 112, 128
@@ -1149,6 +1161,14 @@ static const uint16_t swb_offset_512_32[] = {
 352, 384, 416, 448, 480, 512
 };
 
+static const uint16_t swb_offset_480_32[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  48,  52,  56,  60,
+ 64,  72,  80,  88,  96, 104, 112, 124,
+136, 148, 164, 180, 200, 224, 256, 288,
+320, 352, 384, 416, 448, 480
+ };
+
 static const uint16_t swb_offset_1024_24[] = {
   0,   4,   8,  12,  16,  20,  24,  28,
  32,  36,  40,  44,  52,  60,  68,  76,
@@ -1165,6 +1185,13 @@ static const uint16_t swb_offset_512_24[] = {
 288, 320, 352, 384, 416, 448, 480, 512,
 };
 
+static const uint16_t swb_offset_480_24[] = {
+  0,   4,   8,  12,  16,  20,  24,  28,
+ 32,  36,  40,  44,  52,  60,  68,  80,
+ 92, 104, 120, 140, 164, 192, 224, 256,
+288, 320, 352, 384, 416, 448, 480
+};
+
 static const uint16_t swb_offset_128_24[] = {
  0,   4,   8,  12,  16,  20,  24,  28,
 36,  44,  52,  64,  76,  92, 108, 128
@@ -1214,6 +1241,14 @@ const uint16_t * const ff_swb_offset_512[] = {
 NULL
 };
 
+const uint16_t * const ff_swb_offset_480[] = {
+NULL,   NULL,   NULL,
+swb_offset_480_48,  swb_offset_480_48,  swb_offset_480_32,
+swb_offset_480_24,  swb_offset_480_24,  NULL,
+NULL,   NULL,   NULL,
+NULL
+};
+
 const uint16_t * const ff_swb_offset_128[] = {
 /* The last entry on the following row is swb_offset_128_64 but is a
duplicate of swb_offset_128_96. */
@@ -1240,12 +1275,16 @@ const uint8_t ff_tns_max_bands_512[] = {
 0, 0, 0, 31, 32, 37, 31, 31, 0, 0, 0, 0, 0
 };
 
+const uint8_t ff_tns_max_bands_480[] = {
+0, 0, 0, 31, 32, 37, 30, 30, 0, 0, 0, 0, 0
+};
+
 const uint8_t ff_tns_max_bands_128[] = {
 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
 };
 // @}
 
-const DECLARE_ALIGNED(32, float, ff_aac_eld_window)[1920] = {
+const DECLARE_ALIGNED(32, float, ff_aac_eld_window_512)[1920] = {
  0.00338834,  0.00567745,  0.00847677,  0.01172641,
  0.01532555,  0.01917664,  0.02318809,  0.02729259,
  0.03144503,  0.03560261,  0.03972499,  0.04379783,
@@ -1727,3 +1766,456 @@ const DECLARE_ALIGNED(32, float, 
ff_aac_eld_window)[1920] = {
 -0.00116552, -0.00115223, -0.00113877, -0.00112517,
 -0.0044, -0.00109764, -0.00108377, -0.00106989,
 };
+
+const DECLARE_ALIGNED(32, float, ff_aac_eld_window_480)[1800] = {
+ 0.00101191,  0.00440397,  0.00718669,  0.01072130,
+ 0.01459757,  0.01875954,  0.02308987,  0.02751541,
+ 0.03198130,  0.03643738,  0.04085290,  0.04522835,
+ 0.04957620,  0.05390454,  0.05821503,  0.06251214,
+ 0.06680463,  0.07109582,  0.07538014,  0.07965207,
+ 0.08390857,  0.08815177,  0.09238785,  0.09662163,
+ 0.10085860,  0.10510892,  0.10938110,  0.11367819,
+ 0.11800355,  0.12236410,  0.12676834,  0.13122384,
+ 0.13573476,  0.14030106,  0.14492340,  0.14960315,
+ 0.15433828,  0.15912396,  0.16395663,  0.16883310,
+ 0.17374837,  0.17869679,  0.18367394,  0.18867661,
+ 0.19370368,  0.19875413,  0.20382641,  0.20892055,
+ 0.21403775,  0.21917761,  0.22433899,  0.22952250,
+ 0.23472991,  0.23996189,  0.24521859,  0.25049930,
+ 0.25580312,  0.26112942,  0.26647748,  0.27184703,
+ 0.27723785,  0.28264967,  0.28808086,  0.29352832,
+ 0.29898979,  0.30446379,  0.30994292,  0.31541664,
+ 0.32087942,  0.32632772,  0.33176291,  0.33718641,
+ 0.34259612,  0.34799346,  0.35338857,  0.35878843,
+ 0.36419504,  0.36960630,  0.37501567,  0.38042067,
+ 0.38582069,  0.39121276,  0.39659312,  0.40195993,
+ 0.40731155,  0.41264382,  0.41795277,  0.42323670,
+ 0.42849480,  0.43372753,  0.43893452,  0.44411398,
+ 0.44927117,  0.45441882,  0.45956191,  0.46470167,
+ 0.46983016,  0.47493636,  0.48001827,  0.48507480,
+ 0.49010240,

Re: [libav-devel] [PATCH] fate: Add a downsampled SBR testvector

2013-12-26 Thread Alex Converse
On Dec 25, 2013 5:20 AM, "Christophe Gisquet" 
wrote:
>
> Hi,
>
> Le 23 déc. 2013 21:23, "Alex Converse"  a écrit :
> >
> > ---
> >  tests/fate/aac.mak | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
> > index c49106b..523344b 100644
> > --- a/tests/fate/aac.mak
> > +++ b/tests/fate/aac.mak
>
> Would this be something to test eg:
> http://patches.libav.org/patch/36884/ ?
>

Yes it should
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] fate: Add a downsampled SBR testvector

2013-12-24 Thread Alex Converse
On Mon, Dec 23, 2013 at 8:14 PM, Luca Barbato  wrote:
>
> On 23/12/13 21:23, Alex Converse wrote:
> > ---
> >  tests/fate/aac.mak | 4 
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
> > index c49106b..523344b 100644
> > --- a/tests/fate/aac.mak
> > +++ b/tests/fate/aac.mak
> > @@ -42,6 +42,10 @@ FATE_AAC += fate-aac-al_sbr_hq_cm_48_5.1
> >  fate-aac-al_sbr_hq_cm_48_5.1: CMD = pcm -i 
> > $(TARGET_SAMPLES)/aac/al_sbr_cm_48_5.1.mp4
> >  fate-aac-al_sbr_hq_cm_48_5.1: REF = 
> > $(SAMPLES)/aac/al_sbr_hq_cm_48_5.1_reorder.s16
> >
> > +FATE_AAC += fate-aac-al_sbr_hq_sr_48_2_fsaac48
> > +fate-aac-al_sbr_hq_sr_48_2_fsaac48: CMD = pcm -i 
> > $(TARGET_SAMPLES)/aac/al_sbr_sr_48_2_fsaac48.mp4
> > +fate-aac-al_sbr_hq_sr_48_2_fsaac48: REF = 
> > $(SAMPLES)/aac/al_sbr_hq_sr_48_2_fsaac48.s16
> > +
> >  FATE_AAC += fate-aac-al_sbr_ps_06_ur
> >  fate-aac-al_sbr_ps_06_ur: CMD = pcm -i 
> > $(TARGET_SAMPLES)/aac/al_sbr_ps_06_new.mp4
> >  fate-aac-al_sbr_ps_06_ur: REF = $(SAMPLES)/aac/al_sbr_ps_06_ur.s16
> >
>
> did you upload the sample already?

If people are conceptually ok with this I'll find someone on IRC to
help me upload this and the other two new samples from the other patch
set.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 3/4] aac: Fix low delay windowing.

2013-12-24 Thread Alex Converse
AAC LD uses a low overlap sine window instead of a KBD window.
---
 libavcodec/aacdec.c | 11 ---
 libavcodec/aactab.c |  1 -
 libavcodec/aactab.h |  1 -
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 4ed8f8f..70fbb53 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -1065,7 +1065,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 ff_mdct_init(&ac->mdct_ltp,   11, 0, -2.0 * 32768.0);
 // window initialization
 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
-ff_kbd_window_init(ff_aac_kbd_long_512,  4.0, 512);
 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
 ff_init_ff_sine_windows(10);
 ff_init_ff_sine_windows( 9);
@@ -2430,14 +2429,20 @@ static void imdct_and_windowing_ld(AACContext *ac, 
SingleChannelElement *sce)
 float *in= sce->coeffs;
 float *out   = sce->ret;
 float *saved = sce->saved;
-const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_512 : 
ff_sine_512;
 float *buf  = ac->buf_mdct;
 
 // imdct
 ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
 
 // window overlapping
-ac->fdsp.vector_fmul_window(out, saved, buf, lwindow_prev, 256);
+if (ics->use_kb_window[1]) {
+// AAC LD uses a low overlap sine window instead of a KBD window
+memcpy(out, saved, 192 * sizeof(float));
+ac->fdsp.vector_fmul_window(out + 192, saved + 192, buf, ff_sine_128, 
64);
+memcpy( out + 320, buf + 64, 192 * sizeof(float));
+} else {
+ac->fdsp.vector_fmul_window(out, saved, buf, ff_sine_512, 256);
+}
 
 // buffer update
 memcpy(saved, buf + 256, 256 * sizeof(float));
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 46aa10a..ee9a735 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -34,7 +34,6 @@
 #include 
 
 DECLARE_ALIGNED(32, float,  ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, float,  ff_aac_kbd_long_512 )[512];
 DECLARE_ALIGNED(32, float,  ff_aac_kbd_short_128)[128];
 
 const uint8_t ff_aac_num_swb_1024[] = {
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index adf2e2c..d19b3fd 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -45,7 +45,6 @@
  * @{
  */
 DECLARE_ALIGNED(32, extern float,  ff_aac_kbd_long_1024)[1024];
-DECLARE_ALIGNED(32, extern float,  ff_aac_kbd_long_512 )[512];
 DECLARE_ALIGNED(32, extern float,  ff_aac_kbd_short_128)[128];
 const DECLARE_ALIGNED(32, extern float, ff_aac_eld_window)[1920];
 // @}
-- 
1.8.4

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


[libav-devel] [PATCH 4/4] fate: Update AAC ELD 5.1 ref for recent bugfixes.

2013-12-24 Thread Alex Converse
---
 tests/fate/aac.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 20e7ad2..b3f07cb 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -56,7 +56,7 @@ fate-aac-ap05_48: REF = $(SAMPLES)/aac/ap05_48.s16
 
 FATE_AAC += fate-aac-er_ad6000np_44_ep0
 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4
-fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44_ep0.s16
+fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44.s16
 
 FATE_AAC += fate-aac-er_eld1001np_44_ep0
 fate-aac-er_eld1001np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld1001np_44_ep0.mp4
-- 
1.8.4

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


[libav-devel] [PATCH 2/4] fate: Add a test vector for AAC ELD with TNS.

2013-12-24 Thread Alex Converse
---
 tests/fate/aac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 523344b..20e7ad2 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -58,6 +58,10 @@ FATE_AAC += fate-aac-er_ad6000np_44_ep0
 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4
 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44_ep0.s16
 
+FATE_AAC += fate-aac-er_eld1001np_44_ep0
+fate-aac-er_eld1001np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld1001np_44_ep0.mp4
+fate-aac-er_eld1001np_44_ep0: REF = $(SAMPLES)/aac/er_eld1001np_44.s16
+
 FATE_AAC += fate-aac-er_eld2000np_48_ep0
 fate-aac-er_eld2000np_48_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld2000np_48_ep0.mp4
 fate-aac-er_eld2000np_48_ep0: REF = $(SAMPLES)/aac/er_eld2000np_48_ep0.s16
-- 
1.8.4

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


[libav-devel] [PATCH 1/4] aac: Fix TNS decoding for the 512 sample window family.

2013-12-24 Thread Alex Converse
---
 libavcodec/aacdec.c | 3 ++-
 libavcodec/aactab.c | 4 
 libavcodec/aactab.h | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 426a652..4ed8f8f 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -1178,13 +1178,14 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 if (aot == AOT_ER_AAC_LD || aot == AOT_ER_AAC_ELD) {
 ics->swb_offset= 
ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
 ics->num_swb   =
ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
+ics->tns_max_bands =  
ff_tns_max_bands_512[ac->oc[1].m4ac.sampling_index];
 if (!ics->num_swb || !ics->swb_offset)
 return AVERROR_BUG;
 } else {
 ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
 ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
 }
-ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
 if (aot != AOT_ER_AAC_ELD) {
 ics->predictor_present = get_bits1(gb);
 ics->predictor_reset_group = 0;
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index 77cbc2d..46aa10a 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -1237,6 +1237,10 @@ const uint8_t ff_tns_max_bands_1024[] = {
 31, 31, 34, 40, 42, 51, 46, 46, 42, 42, 42, 39, 39
 };
 
+const uint8_t ff_tns_max_bands_512[] = {
+0, 0, 0, 31, 32, 37, 31, 31, 0, 0, 0, 0, 0
+};
+
 const uint8_t ff_tns_max_bands_128[] = {
 9, 9, 10, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14
 };
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index a2dc46b..adf2e2c 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -76,6 +76,7 @@ extern const uint16_t * const ff_swb_offset_512 [13];
 extern const uint16_t * const ff_swb_offset_128 [13];
 
 extern const uint8_t ff_tns_max_bands_1024[13];
+extern const uint8_t ff_tns_max_bands_512 [13];
 extern const uint8_t ff_tns_max_bands_128 [13];
 
 #endif /* AVCODEC_AACTAB_H */
-- 
1.8.4

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


[libav-devel] [PATCH] fate: Add a downsampled SBR testvector

2013-12-23 Thread Alex Converse
---
 tests/fate/aac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index c49106b..523344b 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -42,6 +42,10 @@ FATE_AAC += fate-aac-al_sbr_hq_cm_48_5.1
 fate-aac-al_sbr_hq_cm_48_5.1: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/al_sbr_cm_48_5.1.mp4
 fate-aac-al_sbr_hq_cm_48_5.1: REF = 
$(SAMPLES)/aac/al_sbr_hq_cm_48_5.1_reorder.s16
 
+FATE_AAC += fate-aac-al_sbr_hq_sr_48_2_fsaac48
+fate-aac-al_sbr_hq_sr_48_2_fsaac48: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/al_sbr_sr_48_2_fsaac48.mp4
+fate-aac-al_sbr_hq_sr_48_2_fsaac48: REF = 
$(SAMPLES)/aac/al_sbr_hq_sr_48_2_fsaac48.s16
+
 FATE_AAC += fate-aac-al_sbr_ps_06_ur
 fate-aac-al_sbr_ps_06_ur: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/al_sbr_ps_06_new.mp4
 fate-aac-al_sbr_ps_06_ur: REF = $(SAMPLES)/aac/al_sbr_ps_06_ur.s16
-- 
1.8.4

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


Re: [libav-devel] [PATCH] aacsbr: Add some const casts to silence warnings in ff_sbr_apply()

2013-11-24 Thread Alex Converse
On Fri, Nov 22, 2013 at 6:27 PM, Diego Biurrun  wrote:
> ---
>
> Once again not exactly a beauty, but it silences 9 warnings, making
> a previously very noisy file entirely quiet.
>
>  libavcodec/aacsbr.c |   21 ++---
>  1 file changed, 14 insertions(+), 7 deletions(-)
>

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


Re: [libav-devel] [PATCH] aacps: Adjust some const qualifiers to suppress warnings

2013-11-21 Thread Alex Converse
On Sun, Nov 10, 2013 at 1:31 PM, Diego Biurrun  wrote:
>
> ---
>
> Now addresses most of Alex' comments and actually eliminates all warnings.
>
>  libavcodec/aacps.c  |   18 +++---
>  libavcodec/aacps_tablegen.c |2 +-
>  libavcodec/aacps_tablegen.h |4 +++-
>  libavcodec/aacpsdsp.h   |2 +-
>  4 files changed, 16 insertions(+), 10 deletions(-)
>

Seems ok

> diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h
> index 93737d2..dc380b1 100644
> --- a/libavcodec/aacpsdsp.h
> +++ b/libavcodec/aacpsdsp.h
> @@ -38,7 +38,7 @@ typedef struct PSDSPContext {
> int i, int len);
>  void (*decorrelate)(float (*out)[2], float (*delay)[2],
>  float 
> (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
> -const float phi_fract[2], float (*Q_fract)[2],
> +const float phi_fract[2], const float (*Q_fract)[2],
>  const float *transient_gain,
>  float g_decay_slope,
>  int len);

FWIW this part no longer matches the implementations
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] aacps: Adjust some const qualifiers to suppress warnings

2013-11-04 Thread Alex Converse
On Mon, Nov 4, 2013 at 10:14 AM, Diego Biurrun  wrote:
>
> ---
>
> While clearly not a thing of supreme beauty, this silences all warnings
> on a previously very noisy file, both with hardcoded and generated tables.
>

The only warning my compiler generates with this file is:
"warning: unknown warning option '-Wno-maybe-uninitialized'; did you
mean '-Wno-uninitialized'?"
but the gcc developers seem pretty emphatic that their warnings are
correct. So I guess I'm ok with this in general. See specific comments
below.

One alternate approach (that I'm not necessarily advocating), is to
make the actual arrays in aacps_table prefixed, do the casting in that
file and have all the pointers used from aacps.c full const, hiding
all the ugly in the tablegen header but ultimately giving both
implementations a consistent interface.

> diff --git a/libavcodec/aacps.c b/libavcodec/aacps.c
> index 1abafe2..2b9ca4f 100644
> --- a/libavcodec/aacps.c
> +++ b/libavcodec/aacps.c
> @@ -606,7 +609,8 @@ static void map_val_20_to_34(float par[PS_MAX_NR_IIDICC])
>  par[ 0] =  par[ 0];
>  }
>
> -static void decorrelation(PSContext *ps, float (*out)[32][2], const float 
> (*s)[32][2], int is34)
> +static void decorrelation(PSContext *ps, float (*out)[32][2],
> +  TABLE_CONST float (*s)[32][2], int is34)
>  {
>  LOCAL_ALIGNED_16(float, power, [34], [PS_QMF_TIME_SLOTS]);
>  LOCAL_ALIGNED_16(float, transient_gain, [34], [PS_QMF_TIME_SLOTS]);
> @@ -634,7 +638,7 @@ static void decorrelation(PSContext *ps, float 
> (*out)[32][2], const float (*s)[3
>
>  for (k = 0; k < NR_BANDS[is34]; k++) {
>  int i = k_to_i[k];
> -ps->dsp.add_squares(power[i], s[k], nL - n0);
> +ps->dsp.add_squares(power[i], (const float (*)[2]) s[k], nL - n0);
>  }
>
>  //Transient detection
> @@ -747,7 +751,7 @@ static void stereo_processing(PSContext *ps, float 
> (*l)[32][2], float (*r)[32][2
>  int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
>  int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
>  const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
> -const float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
> +TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? 
> HA : HB;

I'd rather see a cast on the RHS here.

>
>  //Remapping
>  if (ps->num_env_old) {
> @@ -897,7 +901,7 @@ int ff_ps_apply(AVCodecContext *avctx, PSContext *ps, 
> float L[2][38][64], float
>  memset(ps->ap_delay + top, 0, (NR_ALLPASS_BANDS[is34] - 
> top)*sizeof(ps->ap_delay[0]));
>
>  hybrid_analysis(&ps->dsp, Lbuf, ps->in_buf, L, is34, len);
> -decorrelation(ps, Rbuf, Lbuf, is34);
> +decorrelation(ps, Rbuf, (const float (*)[32][2]) Lbuf, is34);

The changes wrt this Lbuf (s inside the function) seem inconsistent.
You are unconditionally adding the const in the call, then using
TABLE_CONST in the function declaration, then recasting it again when
you pass it to add_squares().

Meanwhile calls inside this function that take transient_gain still warn.

> diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h
> index 701812b..87383bd 100644
> --- a/libavcodec/aacps_tablegen.h
> +++ b/libavcodec/aacps_tablegen.h
> @@ -28,6 +28,7 @@
>
>  #if CONFIG_HARDCODED_TABLES
>  #define ps_tableinit()
> +#define TABLE_CONST const
>  #include "libavcodec/aacps_tables.h"
>  #else
>  #include "libavutil/common.h"
> @@ -37,6 +38,7 @@
>  #define NR_ALLPASS_BANDS20 30
>  #define NR_ALLPASS_BANDS34 50
>  #define PS_AP_LINKS 3
> +#define TABLE_CONST
>  static float pd_re_smooth[8*8*8];
>  static float pd_im_smooth[8*8*8];
>  static float HA[46][8][4];
> diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h
> index 93737d2..dc380b1 100644
> --- a/libavcodec/aacpsdsp.h
> +++ b/libavcodec/aacpsdsp.h
> @@ -38,7 +38,7 @@ typedef struct PSDSPContext {
> int i, int len);
>  void (*decorrelate)(float (*out)[2], float (*delay)[2],
>  float 
> (*ap_delay)[PS_QMF_TIME_SLOTS+PS_MAX_AP_DELAY][2],
> -const float phi_fract[2], float (*Q_fract)[2],
> +const float phi_fract[2], const float (*Q_fract)[2],
>  const float *transient_gain,
>  float g_decay_slope,
>  int len);

Shouldn't the implementations be updated to match?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] aacdec: Fix calls to avpriv_report_missing_feature().

2013-10-25 Thread Alex Converse
It does not take log level as an argument.
---
 libavcodec/aacdec.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 9cc8149..ae22e67 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -755,7 +755,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 res_flags = get_bits(gb, 3);
 if (res_flags) {
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "AAC data resilience (flags %x)",
   res_flags);
 return AVERROR_PATCHWELCOME;
@@ -771,7 +771,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 ep_config = get_bits(gb, 2);
 if (ep_config) {
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "epConfig %d", ep_config);
 return AVERROR_PATCHWELCOME;
 }
@@ -799,14 +799,14 @@ static int decode_eld_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 
 res_flags = get_bits(gb, 3);
 if (res_flags) {
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "AAC data resilience (flags %x)",
   res_flags);
 return AVERROR_PATCHWELCOME;
 }
 
 if (get_bits1(gb)) { // ldSbrPresentFlag
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "Low Delay SBR");
 return AVERROR_PATCHWELCOME;
 }
@@ -833,7 +833,7 @@ static int decode_eld_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 
 ep_config = get_bits(gb, 2);
 if (ep_config) {
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "epConfig %d", ep_config);
 return AVERROR_PATCHWELCOME;
 }
@@ -904,7 +904,7 @@ static int decode_audio_specific_config(AACContext *ac,
 return ret;
 break;
 default:
-avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+avpriv_report_missing_feature(avctx,
   "Audio object type %s%d",
   m4ac->sbr == 1 ? "SBR+" : "",
   m4ac->object_type);
-- 
1.8.3.2

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


Re: [libav-devel] [PATCH 1/3] aacdec: Use avpriv_report_missing_feature() instead of custom logging.

2013-10-25 Thread Alex Converse
On Oct 23, 2013 4:56 PM, "Diego Biurrun"  wrote:
>
> On Tue, Oct 22, 2013 at 04:04:45AM -0700, Alex Converse wrote:
> > --- a/libavcodec/aacdec.c
> > +++ b/libavcodec/aacdec.c
> > @@ -754,9 +754,9 @@ static int decode_ga_specific_config(AACContext
*ac, AVCodecContext *avctx,
> >  case AOT_ER_AAC_LD:
> >  res_flags = get_bits(gb, 3);
> >  if (res_flags) {
> > -av_log(avctx, AV_LOG_ERROR,
> > -   "AAC data resilience not supported (flags
%x)\n",
> > -   res_flags);
> > +avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
> > +  "AAC data resilience
(flags %x)",
> > +  res_flags);
>
> stray extra AV_LOG_ERROR argument, same below
>

Sorry about that. I'll be away from a real computer until Monday. I can fix
it then but anyone else is welcome to act sooner.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/3] aac: Add support for Enhanced AAC Low Delay (ER AAC ELD).

2013-10-22 Thread Alex Converse
This does not include support for LD SBR, epTool, data resilience, nor
the 960 transform family.
---
 Changelog|   1 +
 libavcodec/aac.h |   2 +-
 libavcodec/aacdec.c  | 207 ++
 libavcodec/aactab.c  | 483 +++
 libavcodec/aactab.h  |   1 +
 libavcodec/version.h |   2 +-
 6 files changed, 661 insertions(+), 35 deletions(-)

diff --git a/Changelog b/Changelog
index 657e68c..fd12d90 100644
--- a/Changelog
+++ b/Changelog
@@ -38,6 +38,7 @@ version 10:
 - Low Delay AAC (ER AAC LD) decoding
 - mux chapters in ASF files
 - Opus in Ogg demuxing
+- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
 
 
 version 9:
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 40e8dfb..375e6b1 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -234,7 +234,7 @@ typedef struct SingleChannelElement {
 int sf_idx[128];///< scalefactor indices 
(used by encoder)
 uint8_t zeroes[128];///< band is not coded 
(used by encoder)
 DECLARE_ALIGNED(32, float,   coeffs)[1024]; ///< coefficients for IMDCT
-DECLARE_ALIGNED(32, float,   saved)[1024];  ///< overlap
+DECLARE_ALIGNED(32, float,   saved)[1536];  ///< overlap
 DECLARE_ALIGNED(32, float,   ret_buf)[2048];///< PCM output buffer
 DECLARE_ALIGNED(16, float,   ltp_state)[3072];  ///< time signal for LTP
 PredictorState predictor_state[MAX_PREDICTORS];
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 435caab..9cc8149 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2,6 +2,7 @@
  * AAC decoder
  * Copyright (c) 2005-2006 Oded Shimon ( ods15 ods15 dyndns org )
  * Copyright (c) 2006-2007 Maxim Gavrilov ( maxim.gavrilov gmail com )
+ * Copyright (c) 2008-2013 Alex Converse 
  *
  * AAC LATM decoder
  * Copyright (c) 2008-2010 Paul Kendall 
@@ -778,6 +779,67 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 return 0;
 }
 
+static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
+ GetBitContext *gb,
+ MPEG4AudioConfig *m4ac,
+ int channel_config)
+{
+int ret, ep_config, res_flags;
+uint8_t layout_map[MAX_ELEM_ID*4][3];
+int tags = 0;
+const int ELDEXT_TERM = 0;
+
+m4ac->ps  = 0;
+m4ac->sbr = 0;
+
+if (get_bits1(gb)) { // frameLengthFlag
+avpriv_request_sample(avctx, "960/120 MDCT window");
+return AVERROR_PATCHWELCOME;
+}
+
+res_flags = get_bits(gb, 3);
+if (res_flags) {
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "AAC data resilience (flags %x)",
+  res_flags);
+return AVERROR_PATCHWELCOME;
+}
+
+if (get_bits1(gb)) { // ldSbrPresentFlag
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "Low Delay SBR");
+return AVERROR_PATCHWELCOME;
+}
+
+while (get_bits(gb, 4) != ELDEXT_TERM) {
+int len = get_bits(gb, 4);
+if (len == 15)
+len += get_bits(gb, 8);
+if (len == 15 + 255)
+len += get_bits(gb, 16);
+if (get_bits_left(gb) < len * 8 + 4) {
+av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+return AVERROR_INVALIDDATA;
+}
+skip_bits_long(gb, 8 * len);
+}
+
+if ((ret = set_default_channel_config(avctx, layout_map,
+  &tags, channel_config)))
+return ret;
+
+if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0)))
+return ret;
+
+ep_config = get_bits(gb, 2);
+if (ep_config) {
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "epConfig %d", ep_config);
+return AVERROR_PATCHWELCOME;
+}
+return 0;
+}
+
 /**
  * Decode audio specific configuration; reference: table 1.13.
  *
@@ -836,6 +898,11 @@ static int decode_audio_specific_config(AACContext *ac,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
 break;
+case AOT_ER_AAC_ELD:
+if ((ret = decode_eld_specific_config(ac, avctx, &gb,
+  m4ac, m4ac->chan_config)) < 0)
+return ret;
+break;
 default:
 avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
   "Audio object type %s%d",
@@ -1067,22 +1134,25 @@ static void decode_ltp(LongTermPrediction *ltp,
 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
 {
-if (get_bi

[libav-devel] [PATCH 1/3] aacdec: Use avpriv_report_missing_feature() instead of custom logging.

2013-10-22 Thread Alex Converse
---
 libavcodec/aacdec.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 824839a..435caab 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -754,9 +754,9 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 res_flags = get_bits(gb, 3);
 if (res_flags) {
-av_log(avctx, AV_LOG_ERROR,
-   "AAC data resilience not supported (flags %x)\n",
-   res_flags);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "AAC data resilience (flags %x)",
+  res_flags);
 return AVERROR_PATCHWELCOME;
 }
 break;
@@ -770,9 +770,8 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LD:
 ep_config = get_bits(gb, 2);
 if (ep_config) {
-av_log(avctx, AV_LOG_ERROR,
-   "epConfig %d is not supported.\n",
-   ep_config);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "epConfig %d", ep_config);
 return AVERROR_PATCHWELCOME;
 }
 }
@@ -838,10 +837,10 @@ static int decode_audio_specific_config(AACContext *ac,
 return ret;
 break;
 default:
-av_log(avctx, AV_LOG_ERROR,
-   "Audio object type %s%d is not supported.\n",
-   m4ac->sbr == 1 ? "SBR+" : "",
-   m4ac->object_type);
+avpriv_report_missing_feature(avctx, AV_LOG_ERROR,
+  "Audio object type %s%d",
+  m4ac->sbr == 1 ? "SBR+" : "",
+  m4ac->object_type);
 return AVERROR(ENOSYS);
 }
 
-- 
1.8.3.2

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


[libav-devel] [PATCH 3/3] fate: aac: Add test for AAC-ELD

2013-10-22 Thread Alex Converse
---
 tests/fate/aac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 4a939dc..375b7f9 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -54,6 +54,10 @@ FATE_AAC += fate-aac-er_ad6000np_44_ep0
 fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_ad6000np_44_ep0.mp4
 fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_ad6000np_44_ep0.s16
 
+FATE_AAC += fate-aac-er_eld2000np_48_ep0
+fate-aac-er_ad6000np_44_ep0: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/er_eld2000np_48_ep0.mp4
+fate-aac-er_ad6000np_44_ep0: REF = $(SAMPLES)/aac/er_eld2000np_48_ep0.s16
+
 
 fate-aac-ct%: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/CT_DecoderCheck/$(@:fate-aac-ct-%=%)
 fate-aac-ct%: REF = $(SAMPLES)/aac/CT_DecoderCheck/aacPlusv2.wav
-- 
1.8.3.2

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


Re: [libav-devel] [PATCH] aac: Add support for Enhanced AAC Low Delay (ER AAC ELD).

2013-10-17 Thread Alex Converse
On Thu, Oct 17, 2013 at 4:12 PM, Alex Converse  wrote:
>
> This does not include support for LD SBR, epTool, data resialiance, nor
> the 960 transform family.
> ---
[...]
>
> +static void imdct_and_windowing_eld(AACContext *ac, SingleChannelElement 
> *sce)
> +{
> +float *in= sce->coeffs;
> +float *out   = sce->ret;
> +float *saved = sce->saved;
> +const float *const window = ff_aac_eld_window;
> +float *buf  = ac->buf_mdct;
> +int i;
> +const int n  = 512;
> +const int n2 = n >> 1;
> +const int n4 = n >> 2;
> +
> +// Inverse transform, mapped to the conventional IMDCT by
> +// Chivukula, R.K.; Reznik, Y.A.; Devarajan, V.,
> +// "Efficient algorithms for MPEG-4 AAC-ELD, AAC-LD and AAC-LC 
> filterbanks,"
> +// Audio, Language and Image Processing, 2008. ICALIP 2008. 
> International Conference on
> +// URL: 
> http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4590245&isnumber=4589950
> +for (i = 0; i < n2; i+=2) {
> +float temp;
> +temp =  in[i]; in[i] = -in[n - 1 - i]; in[n - 1 - i] = temp;
> +temp = -in[i + 1]; in[i + 1] =  in[n - 2 - i]; in[n - 2 - i] = temp;
> +}
> +ac->mdct.imdct_half(&ac->mdct_ld, buf, in);
> +for (i = 0; i < n; i+=2) {
> +buf[i] = -buf[i];
> +}
> +// Like with the regular IMDCT at this point we still have the middle 
> half
> +// of a transform but with even symmetry on the left and odd symmetry on
> +// the right
> +
> +// window overlapping
> +// The spec says to use samples [0..511] but the reference decoder uses
> +// samples [128..639].
> +for (i = n4; i < n2; i ++) {
> +out[i - n4] =buf[n2 - 1 - i]   * window[i   - n4] +
> +   saved[  i + n2] * window[i +   n - n4] +
> +  -saved[  n + n2 - 1 - i] * window[i + 2*n - n4] +
> +  -saved[2*n + n2 + i] * window[i + 3*n - n4];
> +}
> +for (i = 0; i < n2; i ++) {
> +out[n4 + i] =buf[i]   * window[i + n2   - n4] +
> +  -saved[  n - 1 - i] * window[i + n2 +   n - n4] +
> +  -saved[  n + i] * window[i + n2 + 2*n - n4] +
> +   saved[2*n + n - 1 - i] * window[i + n2 + 3*n - n4];
> +}
> +for (i = 0; i < n4; i ++) {
> +out[n2 + n4 + i] =buf[  i + n2] * window[i +   n - n4] +
> +   -saved[  n2 - 1 - i] * window[i + 2*n - n4] +
> +   -saved[  n + n2 + i] * window[i + 3*n - n4];
> +}
> +
> +// buffer update
> +memmove(saved + n, saved, 2 * n * sizeof(float));
> +memcpy( saved,   buf, n * sizeof(float));
> +}

I'm sure people have some really great ideas on how to optimize the
filterbank but unless I missed a set of dsp functions that map really
nicely to this, you are welcome to submit your own optimization
patches later.

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


[libav-devel] [PATCH] aac: Add support for Enhanced AAC Low Delay (ER AAC ELD).

2013-10-17 Thread Alex Converse
This does not include support for LD SBR, epTool, data resialiance, nor
the 960 transform family.
---
 Changelog|   1 +
 libavcodec/aac.h |   2 +-
 libavcodec/aacdec.c  | 208 ++
 libavcodec/aactab.c  | 483 +++
 libavcodec/aactab.h  |   1 +
 libavcodec/version.h |   2 +-
 6 files changed, 662 insertions(+), 35 deletions(-)

diff --git a/Changelog b/Changelog
index 657e68c..fd12d90 100644
--- a/Changelog
+++ b/Changelog
@@ -38,6 +38,7 @@ version 10:
 - Low Delay AAC (ER AAC LD) decoding
 - mux chapters in ASF files
 - Opus in Ogg demuxing
+- Enhanced Low Delay AAC (ER AAC ELD) decoding (no LD SBR support)
 
 
 version 9:
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 40e8dfb..375e6b1 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -234,7 +234,7 @@ typedef struct SingleChannelElement {
 int sf_idx[128];///< scalefactor indices 
(used by encoder)
 uint8_t zeroes[128];///< band is not coded 
(used by encoder)
 DECLARE_ALIGNED(32, float,   coeffs)[1024]; ///< coefficients for IMDCT
-DECLARE_ALIGNED(32, float,   saved)[1024];  ///< overlap
+DECLARE_ALIGNED(32, float,   saved)[1536];  ///< overlap
 DECLARE_ALIGNED(32, float,   ret_buf)[2048];///< PCM output buffer
 DECLARE_ALIGNED(16, float,   ltp_state)[3072];  ///< time signal for LTP
 PredictorState predictor_state[MAX_PREDICTORS];
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 824839a..4322d7d 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -779,6 +779,69 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 return 0;
 }
 
+static int decode_eld_specific_config(AACContext *ac, AVCodecContext *avctx,
+ GetBitContext *gb,
+ MPEG4AudioConfig *m4ac,
+ int channel_config)
+{
+int ret, ep_config, res_flags;
+uint8_t layout_map[MAX_ELEM_ID*4][3];
+int tags = 0;
+const int ELDEXT_TERM = 0;
+
+m4ac->ps = 0;
+m4ac->sbr = 0;
+
+if (get_bits1(gb)) { // frameLengthFlag
+avpriv_request_sample(avctx, "960/120 MDCT window");
+return AVERROR_PATCHWELCOME;
+}
+
+res_flags = get_bits(gb, 3);
+if (res_flags) {
+av_log(avctx, AV_LOG_ERROR,
+   "AAC data resilience not supported (flags %x)\n",
+   res_flags);
+return AVERROR_PATCHWELCOME;
+}
+
+if (get_bits1(gb)) { // ldSbrPresentFlag
+av_log(avctx, AV_LOG_ERROR, "Low Delay SBR not supported\n");
+return AVERROR_PATCHWELCOME;
+}
+
+while (get_bits(gb, 4) != ELDEXT_TERM) {
+int len = get_bits(gb, 4);
+if (len == 15)
+len += get_bits(gb, 8);
+if (len == 15 + 255)
+len += get_bits(gb, 16);
+skip_bits_long(gb, 8 * len);
+if (get_bits_left(gb) < 4) {
+av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+return AVERROR_INVALIDDATA;
+}
+break;
+}
+
+
+if ((ret = set_default_channel_config(avctx, layout_map,
+  &tags, channel_config)))
+return ret;
+
+if (ac && (ret = output_configure(ac, layout_map, tags, OC_GLOBAL_HDR, 0)))
+return ret;
+
+ep_config = get_bits(gb, 2);
+if (ep_config) {
+av_log(avctx, AV_LOG_ERROR,
+   "epConfig %d is not supported.\n",
+   ep_config);
+return AVERROR_PATCHWELCOME;
+}
+return 0;
+}
+
 /**
  * Decode audio specific configuration; reference: table 1.13.
  *
@@ -837,6 +900,11 @@ static int decode_audio_specific_config(AACContext *ac,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
 break;
+case AOT_ER_AAC_ELD:
+if ((ret = decode_eld_specific_config(ac, avctx, &gb,
+  m4ac, m4ac->chan_config)) < 0)
+return ret;
+break;
 default:
 av_log(avctx, AV_LOG_ERROR,
"Audio object type %s%d is not supported.\n",
@@ -1068,22 +1136,25 @@ static void decode_ltp(LongTermPrediction *ltp,
 static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics,
GetBitContext *gb)
 {
-if (get_bits1(gb)) {
-av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n");
-return AVERROR_INVALIDDATA;
-}
-ics->window_sequence[1] = ics->window_sequence[0];
-ics->window_sequence[0] = get_bits(gb, 2);
-if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD &&
-ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {
-av_log(ac->avctx, AV_LOG_ERROR,
-   "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
-   "window sequence %d found.\n", ics->window_sequence[0]);
-ics->w

[libav-devel] [PATCH 2/2] aacdec: Add support for LD (Low Delay) AAC

2013-09-17 Thread Alex Converse
version.h
---
 Changelog|  1 +
 libavcodec/aac.h |  1 +
 libavcodec/aacdec.c  | 67 
 libavcodec/aactab.c  | 36 
 libavcodec/aactab.h  |  3 +++
 libavcodec/version.h |  2 +-
 6 files changed, 105 insertions(+), 5 deletions(-)

diff --git a/Changelog b/Changelog
index c05f49e..18a3988 100644
--- a/Changelog
+++ b/Changelog
@@ -34,6 +34,7 @@ version 10:
   data read from an input file
 - incomplete Voxware MetaSound decoder
 - Error Resilient AAC syntax (ER AAC LC) decoding
+- Low Delay AAC (ER AAC LD) decoding
 
 
 version 9:
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index a7c9995..40e8dfb 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -289,6 +289,7 @@ typedef struct AACContext {
  */
 FFTContext mdct;
 FFTContext mdct_small;
+FFTContext mdct_ld;
 FFTContext mdct_ltp;
 FmtConvertContext fmt_conv;
 AVFloatDSPContext fdsp;
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 0f86b87..c18c5d9 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -817,6 +817,13 @@ static int decode_audio_specific_config(AACContext *ac,
m4ac->sampling_index);
 return AVERROR_INVALIDDATA;
 }
+if (m4ac->object_type == AOT_ER_AAC_LD &&
+(m4ac->sampling_index < 3 || m4ac->sampling_index > 7)) {
+av_log(avctx, AV_LOG_ERROR,
+   "invalid low delay sampling rate index %d\n",
+   m4ac->sampling_index);
+return AVERROR_INVALIDDATA;
+}
 
 skip_bits_long(&gb, i);
 
@@ -825,6 +832,7 @@ static int decode_audio_specific_config(AACContext *ac,
 case AOT_AAC_LC:
 case AOT_AAC_LTP:
 case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LD:
 if ((ret = decode_ga_specific_config(ac, avctx, &gb,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
@@ -985,12 +993,15 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 352);
 
 ff_mdct_init(&ac->mdct,   11, 1, 1.0 / (32768.0 * 1024.0));
+ff_mdct_init(&ac->mdct_ld,10, 1, 1.0 / (32768.0 * 512.0));
 ff_mdct_init(&ac->mdct_small,  8, 1, 1.0 / (32768.0 * 128.0));
 ff_mdct_init(&ac->mdct_ltp,   11, 0, -2.0 * 32768.0);
 // window initialization
 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+ff_kbd_window_init(ff_aac_kbd_long_512,  4.0, 512);
 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
 ff_init_ff_sine_windows(10);
+ff_init_ff_sine_windows( 9);
 ff_init_ff_sine_windows( 7);
 
 cbrt_tableinit();
@@ -1063,6 +1074,14 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 }
 ics->window_sequence[1] = ics->window_sequence[0];
 ics->window_sequence[0] = get_bits(gb, 2);
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD &&
+ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {
+av_log(ac->avctx, AV_LOG_ERROR,
+   "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
+   "window sequence %d found.\n", ics->window_sequence[0]);
+ics->window_sequence[0] = ONLY_LONG_SEQUENCE;
+return AVERROR_INVALIDDATA;
+}
 ics->use_kb_window[1]   = ics->use_kb_window[0];
 ics->use_kb_window[0]   = get_bits1(gb);
 ics->num_window_groups  = 1;
@@ -1086,8 +1105,15 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 } else {
 ics->max_sfb   = get_bits(gb, 6);
 ics->num_windows   = 1;
-ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD) {
+ics->swb_offset= 
ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
+ics->num_swb   =
ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
+if (!ics->num_swb || !ics->swb_offset)
+return AVERROR_BUG;
+} else {
+ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
+ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+}
 ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
 ics->predictor_present = get_bits1(gb);
 ics->predictor_reset_group = 0;
@@ -1102,6 +1128,11 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
"Prediction is not allowed in AAC-LC.\n");
 return AVERROR_INVALIDDATA;
 } else {
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD) {
+av_log(ac->avctx, AV_LOG_ERROR,
+   "LTP in ER AAC LD not yet implemented.\n");
+return AVERROR_PATCHWELCOME;
+}
 

[libav-devel] [PATCH 1/2] aacdec: Add support for Error Resilience syntax.

2013-09-17 Thread Alex Converse
This does not add support for any error resilience tools.
---
 Changelog   |   1 +
 libavcodec/aacdec.c | 112 +++-
 2 files changed, 103 insertions(+), 10 deletions(-)

diff --git a/Changelog b/Changelog
index 7e210a7..c05f49e 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version 10:
 - avconv -t option can now be used for inputs, to limit the duration of
   data read from an input file
 - incomplete Voxware MetaSound decoder
+- Error Resilient AAC syntax (ER AAC LC) decoding
 
 
 version 9:
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 62246b6..0f86b87 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -706,7 +706,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
  MPEG4AudioConfig *m4ac,
  int channel_config)
 {
-int extension_flag, ret;
+int extension_flag, ret, ep_config, res_flags;
 uint8_t layout_map[MAX_ELEM_ID*4][3];
 int tags = 0;
 
@@ -752,14 +752,30 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LTP:
 case AOT_ER_AAC_SCALABLE:
 case AOT_ER_AAC_LD:
-skip_bits(gb, 3);  /* aacSectionDataResilienceFlag
-* aacScalefactorDataResilienceFlag
-* aacSpectralDataResilienceFlag
-*/
+res_flags = get_bits(gb, 3);
+if (res_flags) {
+av_log(avctx, AV_LOG_ERROR,
+   "AAC data resilience not supported (flags %x)\n",
+   res_flags);
+return AVERROR_PATCHWELCOME;
+}
 break;
 }
 skip_bits1(gb);// extensionFlag3 (TBD in version 3)
 }
+switch (m4ac->object_type) {
+case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LTP:
+case AOT_ER_AAC_SCALABLE:
+case AOT_ER_AAC_LD:
+ep_config = get_bits(gb, 2);
+if (ep_config) {
+av_log(avctx, AV_LOG_ERROR,
+   "epConfig %d is not supported.\n",
+   ep_config);
+return AVERROR_PATCHWELCOME;
+}
+}
 return 0;
 }
 
@@ -808,6 +824,7 @@ static int decode_audio_specific_config(AACContext *ac,
 case AOT_AAC_MAIN:
 case AOT_AAC_LC:
 case AOT_AAC_LTP:
+case AOT_ER_AAC_LC:
 if ((ret = decode_ga_specific_config(ac, avctx, &gb,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
@@ -1079,7 +1096,8 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 if (decode_prediction(ac, ics, gb)) {
 return AVERROR_INVALIDDATA;
 }
-} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC) {
+} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC ||
+   ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC) {
 av_log(ac->avctx, AV_LOG_ERROR,
"Prediction is not allowed in AAC-LC.\n");
 return AVERROR_INVALIDDATA;
@@ -1701,7 +1719,7 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 TemporalNoiseShaping*tns = &sce->tns;
 IndividualChannelStream *ics = &sce->ics;
 float *out = sce->coeffs;
-int global_gain, pulse_present = 0;
+int global_gain, er_syntax, pulse_present = 0;
 int ret;
 
 /* This assignment is to silence a GCC warning about the variable being 
used
@@ -1724,6 +1742,9 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 return ret;
 
 pulse_present = 0;
+er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || 
+ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || 
+ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD;
 if (!scale_flag) {
 if ((pulse_present = get_bits1(gb))) {
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
@@ -1737,12 +1758,19 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 return AVERROR_INVALIDDATA;
 }
 }
-if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
-return AVERROR_INVALIDDATA;
+tns->present = get_bits1(gb);
+if (tns->present && !er_syntax)
+if (decode_tns(ac, tns, gb, ics) < 0)
+return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 avpriv_request_sample(ac->avctx, "SSR");
 return AVERROR_PATCHWELCOME;
 }
+// I see no textual basis in the spec for this occuring after SSR gain
+// control, but this is what both reference and real implmentations do
+if (tns->present && er_syntax)
+if (decode_tns(ac, tns, gb, ics) < 0)
+return AVERROR_INVALIDDATA;
 

Re: [libav-devel] [PATCH 1/2] aacdec: Add support for Error Resiliance syntax.

2013-09-16 Thread Alex Converse
On Mon, Sep 16, 2013 at 10:43 PM, Hendrik Leppkes  wrote:
>
> On Tue, Sep 17, 2013 at 1:02 AM, Alex Converse wrote:
>
> > This does not add support for any error resiliance tools.
> > ---
> >  Changelog   |   1 +
> >  libavcodec/aacdec.c | 116
> > +++-
> >  2 files changed, 107 insertions(+), 10 deletions(-)
> >
> > diff --git a/Changelog b/Changelog
> > index 7e210a7..5261c18 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -33,6 +33,7 @@ version 10:
> >  - avconv -t option can now be used for inputs, to limit the duration of
> >data read from an input file
> >  - incomplete Voxware MetaSound decoder
> > +- Error Resiliant AAC syntax (ER AAC LC) decoding
> >
> >
> >  version 9:
> > diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> > index 62246b6..4a18946 100644
> > --- a/libavcodec/aacdec.c
> > +++ b/libavcodec/aacdec.c
> > @@ -706,7 +706,7 @@ static int decode_ga_specific_config(AACContext *ac,
> > AVCodecContext *avctx,
> >   MPEG4AudioConfig *m4ac,
> >   int channel_config)
> >  {
> > -int extension_flag, ret;
> > +int extension_flag, ret, ep_config, res_flags;
> >  uint8_t layout_map[MAX_ELEM_ID*4][3];
> >  int tags = 0;
> >
> > @@ -752,14 +752,30 @@ static int decode_ga_specific_config(AACContext *ac,
> > AVCodecContext *avctx,
> >  case AOT_ER_AAC_LTP:
> >  case AOT_ER_AAC_SCALABLE:
> >  case AOT_ER_AAC_LD:
> > -skip_bits(gb, 3);  /* aacSectionDataResilienceFlag
> > -* aacScalefactorDataResilienceFlag
> > -* aacSpectralDataResilienceFlag
> > -*/
> > +res_flags = get_bits(gb, 3);
> > +if (res_flags) {
> > +av_log(avctx, AV_LOG_ERROR,
> > +   "AAC data resiliance not supported (flags %x)\n",
> > +   res_flags);
> > +return AVERROR_PATCHWELCOME;
> > +}
> >  break;
> >  }
> >  skip_bits1(gb);// extensionFlag3 (TBD in version 3)
> >
>
> Hm, does this happen in normal aac streams?
> The code previously completely ignored the flags, so whats the worst thing
> that can happen if the flags are set and you don't support it? Does it
> require completely bailing out and stopping decoding?
>

This change doesn't effect "normal" AAC streams. These flags are only read for
AOT_ER_AAC_LC, AOT_ER_AAC_LTP, AOT_ER_AAC_SCALABLE, and
AOT_ER_AAC_LD. Decoding for these ER AOTs currently fails in the caller
decode_audio_specific_config().

If these flags are set then various syntax elements are coded
differently from what
is currently supported and the decoder will spit out an (often
misleading) error nearly
every frame. In the rare chance the frame decodes without error output
is still wrong.

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


[libav-devel] [PATCH 2/2] aacdec: Add support for LD (Low Delay) AAC

2013-09-16 Thread Alex Converse
---
 Changelog   |  1 +
 libavcodec/aac.h|  1 +
 libavcodec/aacdec.c | 66 ++---
 libavcodec/aactab.c | 36 +
 libavcodec/aactab.h |  3 +++
 5 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 5261c18..4e818ce 100644
--- a/Changelog
+++ b/Changelog
@@ -34,6 +34,7 @@ version 10:
   data read from an input file
 - incomplete Voxware MetaSound decoder
 - Error Resiliant AAC syntax (ER AAC LC) decoding
+- Low Delay AAC (ER AAC LD) decoding
 
 
 version 9:
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index a7c9995..40e8dfb 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -289,6 +289,7 @@ typedef struct AACContext {
  */
 FFTContext mdct;
 FFTContext mdct_small;
+FFTContext mdct_ld;
 FFTContext mdct_ltp;
 FmtConvertContext fmt_conv;
 AVFloatDSPContext fdsp;
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 4a18946..7b28239 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -817,6 +817,13 @@ static int decode_audio_specific_config(AACContext *ac,
m4ac->sampling_index);
 return AVERROR_INVALIDDATA;
 }
+if (m4ac->object_type == AOT_ER_AAC_LD &&
+m4ac->sampling_index < 3 || m4ac->sampling_index > 7) {
+av_log(avctx, AV_LOG_ERROR,
+   "invalid low delay sampling rate index %d\n",
+   m4ac->sampling_index);
+return AVERROR_INVALIDDATA;
+}
 
 skip_bits_long(&gb, i);
 
@@ -825,6 +832,7 @@ static int decode_audio_specific_config(AACContext *ac,
 case AOT_AAC_LC:
 case AOT_AAC_LTP:
 case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LD:
 if ((ret = decode_ga_specific_config(ac, avctx, &gb,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
@@ -985,12 +993,15 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
 352);
 
 ff_mdct_init(&ac->mdct,   11, 1, 1.0 / (32768.0 * 1024.0));
+ff_mdct_init(&ac->mdct_ld,10, 1, 1.0 / (32768.0 * 512.0));
 ff_mdct_init(&ac->mdct_small,  8, 1, 1.0 / (32768.0 * 128.0));
 ff_mdct_init(&ac->mdct_ltp,   11, 0, -2.0 * 32768.0);
 // window initialization
 ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+ff_kbd_window_init(ff_aac_kbd_long_512,  4.0, 512);
 ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
 ff_init_ff_sine_windows(10);
+ff_init_ff_sine_windows( 9);
 ff_init_ff_sine_windows( 7);
 
 cbrt_tableinit();
@@ -1063,6 +1074,14 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 }
 ics->window_sequence[1] = ics->window_sequence[0];
 ics->window_sequence[0] = get_bits(gb, 2);
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD &&
+ics->window_sequence[0] != ONLY_LONG_SEQUENCE) {
+av_log(ac->avctx, AV_LOG_ERROR,
+   "AAC LD is only defined for ONLY_LONG_SEQUENCE but "
+   "window sequence %d found.\n", ics->window_sequence[0]);
+ics->window_sequence[0] = ONLY_LONG_SEQUENCE;
+return AVERROR_INVALIDDATA;
+}
 ics->use_kb_window[1]   = ics->use_kb_window[0];
 ics->use_kb_window[0]   = get_bits1(gb);
 ics->num_window_groups  = 1;
@@ -1086,8 +1105,15 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 } else {
 ics->max_sfb   = get_bits(gb, 6);
 ics->num_windows   = 1;
-ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
-ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD) {
+ics->swb_offset= 
ff_swb_offset_512[ac->oc[1].m4ac.sampling_index];
+ics->num_swb   =
ff_aac_num_swb_512[ac->oc[1].m4ac.sampling_index];
+if (!ics->num_swb || !ics->swb_offset)
+return AVERROR_BUG;
+} else {
+ics->swb_offset=
ff_swb_offset_1024[ac->oc[1].m4ac.sampling_index];
+ics->num_swb   =   
ff_aac_num_swb_1024[ac->oc[1].m4ac.sampling_index];
+}
 ics->tns_max_bands = 
ff_tns_max_bands_1024[ac->oc[1].m4ac.sampling_index];
 ics->predictor_present = get_bits1(gb);
 ics->predictor_reset_group = 0;
@@ -1102,6 +1128,11 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
"Prediction is not allowed in AAC-LC.\n");
 return AVERROR_INVALIDDATA;
 } else {
+if (ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD) {
+av_log(ac->avctx, AV_LOG_ERROR,
+   "LTP in ER AAC LD not yet implemented.\n");
+return AVERROR_PATCHWELCOME;
+}
 if ((ics->ltp.present = get_bits(

[libav-devel] [PATCH 1/2] aacdec: Add support for Error Resiliance syntax.

2013-09-16 Thread Alex Converse
This does not add support for any error resiliance tools.
---
 Changelog   |   1 +
 libavcodec/aacdec.c | 116 +++-
 2 files changed, 107 insertions(+), 10 deletions(-)

diff --git a/Changelog b/Changelog
index 7e210a7..5261c18 100644
--- a/Changelog
+++ b/Changelog
@@ -33,6 +33,7 @@ version 10:
 - avconv -t option can now be used for inputs, to limit the duration of
   data read from an input file
 - incomplete Voxware MetaSound decoder
+- Error Resiliant AAC syntax (ER AAC LC) decoding
 
 
 version 9:
diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 62246b6..4a18946 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -706,7 +706,7 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
  MPEG4AudioConfig *m4ac,
  int channel_config)
 {
-int extension_flag, ret;
+int extension_flag, ret, ep_config, res_flags;
 uint8_t layout_map[MAX_ELEM_ID*4][3];
 int tags = 0;
 
@@ -752,14 +752,30 @@ static int decode_ga_specific_config(AACContext *ac, 
AVCodecContext *avctx,
 case AOT_ER_AAC_LTP:
 case AOT_ER_AAC_SCALABLE:
 case AOT_ER_AAC_LD:
-skip_bits(gb, 3);  /* aacSectionDataResilienceFlag
-* aacScalefactorDataResilienceFlag
-* aacSpectralDataResilienceFlag
-*/
+res_flags = get_bits(gb, 3);
+if (res_flags) {
+av_log(avctx, AV_LOG_ERROR,
+   "AAC data resiliance not supported (flags %x)\n",
+   res_flags);
+return AVERROR_PATCHWELCOME;
+}
 break;
 }
 skip_bits1(gb);// extensionFlag3 (TBD in version 3)
 }
+switch (m4ac->object_type) {
+case AOT_ER_AAC_LC:
+case AOT_ER_AAC_LTP:
+case AOT_ER_AAC_SCALABLE:
+case AOT_ER_AAC_LD:
+ep_config = get_bits(gb, 2);
+if (ep_config) {
+av_log(avctx, AV_LOG_ERROR,
+   "epConfig %d is not supported.\n",
+   ep_config);
+return AVERROR_PATCHWELCOME;
+}
+}
 return 0;
 }
 
@@ -808,6 +824,7 @@ static int decode_audio_specific_config(AACContext *ac,
 case AOT_AAC_MAIN:
 case AOT_AAC_LC:
 case AOT_AAC_LTP:
+case AOT_ER_AAC_LC:
 if ((ret = decode_ga_specific_config(ac, avctx, &gb,
 m4ac, m4ac->chan_config)) < 0)
 return ret;
@@ -1079,7 +1096,8 @@ static int decode_ics_info(AACContext *ac, 
IndividualChannelStream *ics,
 if (decode_prediction(ac, ics, gb)) {
 return AVERROR_INVALIDDATA;
 }
-} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC) {
+} else if (ac->oc[1].m4ac.object_type == AOT_AAC_LC ||
+   ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC) {
 av_log(ac->avctx, AV_LOG_ERROR,
"Prediction is not allowed in AAC-LC.\n");
 return AVERROR_INVALIDDATA;
@@ -1701,7 +1719,7 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 TemporalNoiseShaping*tns = &sce->tns;
 IndividualChannelStream *ics = &sce->ics;
 float *out = sce->coeffs;
-int global_gain, pulse_present = 0;
+int global_gain, er_syntax, pulse_present = 0;
 int ret;
 
 /* This assignment is to silence a GCC warning about the variable being 
used
@@ -1724,6 +1742,9 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 return ret;
 
 pulse_present = 0;
+er_syntax = ac->oc[1].m4ac.object_type == AOT_ER_AAC_LC || 
+ac->oc[1].m4ac.object_type == AOT_ER_AAC_LTP || 
+ac->oc[1].m4ac.object_type == AOT_ER_AAC_LD;
 if (!scale_flag) {
 if ((pulse_present = get_bits1(gb))) {
 if (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) {
@@ -1737,12 +1758,19 @@ static int decode_ics(AACContext *ac, 
SingleChannelElement *sce,
 return AVERROR_INVALIDDATA;
 }
 }
-if ((tns->present = get_bits1(gb)) && decode_tns(ac, tns, gb, ics))
-return AVERROR_INVALIDDATA;
+tns->present = get_bits1(gb);
+if (tns->present && !er_syntax)
+if (decode_tns(ac, tns, gb, ics) < 0)
+   return AVERROR_INVALIDDATA;
 if (get_bits1(gb)) {
 avpriv_request_sample(ac->avctx, "SSR");
 return AVERROR_PATCHWELCOME;
 }
+// I see no textual basis in the spec for this occuring after SSR gain
+// control, but this is what both reference and real implmentations do
+if (tns->present && er_syntax)
+if (decode_tns(ac, tns, gb, ics) < 0)
+   return AVERROR_INVALIDDATA;
 }

[libav-devel] [PATCH] lavfi: Add the alength audio length filter.

2012-12-18 Thread Alex Converse
---
 Changelog|1 +
 doc/filters.texi |   34 
 libavfilter/Makefile |1 +
 libavfilter/af_alength.c |  210 ++
 libavfilter/allfilters.c |1 +
 libavfilter/version.h|2 +-
 6 files changed, 248 insertions(+), 1 deletions(-)
 create mode 100644 libavfilter/af_alength.c

diff --git a/Changelog b/Changelog
index b4a8e60..4c97276 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ version :
 - deprecated the avconv -vol option. the volume filter is to be used instead.
 - multi-channel ALAC encoding up to 7.1
 - TAK demuxer, parser, and decoder
+- add alength audio filter
 
 
 version 9_beta2:
diff --git a/doc/filters.texi b/doc/filters.texi
index 34db2f4..bb55435 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -133,6 +133,40 @@ For example to force the output to either unsigned 8-bit 
or signed 16-bit stereo
 aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
 @end example
 
+@section alength
+
+Shorten or optionally pad input audio to a target length.
+
+The filter accepts the following named parameters:
+@table @option
+
+@item length
+The target length in seconds
+
+@item pad
+A boolean that controls whether or not to pad output with silence to reach
+the target length.
+
+@item frame_size
+The size of silent frames to be generated.
+
+@end table
+
+For example to limit output audio to at most 10 seconds
+@example
+alength=length=10
+@end example
+
+To force output audio to be 10 seconds
+@example
+alength=length=10:pad=1
+@end example
+
+To pad or trim audio to match video length
+@example
+avconv -i INPUT -af alength=pad=1 -shortest OUTPUT
+@end example
+
 @section amix
 
 Mixes multiple audio inputs into a single output.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2559e8a..ac244d0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -26,6 +26,7 @@ OBJS = allfilters.o   
  \
 
 OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
+OBJS-$(CONFIG_ALENGTH_FILTER)+= af_alength.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_ASHOWINFO_FILTER)  += af_ashowinfo.o
diff --git a/libavfilter/af_alength.c b/libavfilter/af_alength.c
new file mode 100644
index 000..04c9ba7
--- /dev/null
+++ b/libavfilter/af_alength.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2012 Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that shortens or lengthens an audio stream.
+ */
+
+#include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct ALengthContext {
+const AVClass *class;
+AVRational sample_rate;
+int64_t next_pts;
+char *length;
+int64_t scaled_length;
+int64_t final_pts;
+int got_output;
+int pad;
+int frame_size;
+} ALengthContext;
+
+#define OFFSET(x) offsetof(ALengthContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption alength_options[] = {
+{ "length", "Target length in seconds",   OFFSET(length), 
AV_OPT_TYPE_STRING, { .str = "-1" }, .flags = A },
+{ "pad","Pad to length if too short", OFFSET(pad),
AV_OPT_TYPE_INT,   { 0 }, 0,   1, A },
+{ "frame_size", "frame_size", OFFSET(frame_size), 
AV_OPT_TYPE_INT,{ 1024 }, 0, INT_MAX, A },
+{ NULL }
+};
+
+static const AVClass alength_class = {
+.class_name = "alength filter",
+.item_name  = av_default_item_name,
+.option = alength_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int alength_init(AVFilterContext *ctx, const char *args)
+{
+ALengthContext *s = ctx->priv;
+int err;
+
+s->class = &alength_class;
+av_opt_set_defaults(s);
+
+if ((err = av_set_options_string(s, args, "=", ":")) < 0)
+return err;
+if (!strcmp(s->length, "-1"))
+s->scaled_length = AV_NOPT

Re: [libav-devel] [PATCH] aacdec: Fix an off-by-one overwrite when switching to LTP profile from MAIN.

2012-12-11 Thread Alex Converse
On Tue, Dec 11, 2012 at 6:42 PM, Luca Barbato  wrote:
> On 12/12/12 2:30 AM, Alex Converse wrote:
>>
>> Found-by: pawlkt
>> CC: libav-sta...@libav.org
>> ---
>>   libavcodec/aacdec.c |2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>
> Looks fine, do we have a sample for it?

It will be shareable soon.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] aacdec: Fix an off-by-one overwrite when switching to LTP profile from MAIN.

2012-12-11 Thread Alex Converse
Found-by: pawlkt
CC: libav-sta...@libav.org
---
 libavcodec/aacdec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index f3e9be4..d10a482 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -2003,7 +2003,7 @@ static void apply_tns(float coef[1024], 
TemporalNoiseShaping *tns,
 int w, filt, m, i;
 int bottom, top, order, start, end, size, inc;
 float lpc[TNS_MAX_ORDER];
-float tmp[TNS_MAX_ORDER];
+float tmp[TNS_MAX_ORDER + 1];
 
 for (w = 0; w < ics->num_windows; w++) {
 bottom = ics->num_swb;
-- 
1.7.7.3

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


[libav-devel] [PATCH] lavfi: Add the alength audio length filter.

2012-12-10 Thread Alex Converse
---
 Changelog|1 +
 doc/filters.texi |   33 +++
 libavfilter/Makefile |1 +
 libavfilter/af_alength.c |  213 ++
 libavfilter/allfilters.c |1 +
 5 files changed, 249 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/af_alength.c

diff --git a/Changelog b/Changelog
index b4a8e60..4c97276 100644
--- a/Changelog
+++ b/Changelog
@@ -8,6 +8,7 @@ version :
 - deprecated the avconv -vol option. the volume filter is to be used instead.
 - multi-channel ALAC encoding up to 7.1
 - TAK demuxer, parser, and decoder
+- add alength audio filter
 
 
 version 9_beta2:
diff --git a/doc/filters.texi b/doc/filters.texi
index 55e4468..89ce76c 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -133,6 +133,39 @@ For example to force the output to either unsigned 8-bit 
or signed 16-bit stereo
 aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
 @end example
 
+@section alength
+
+Shorten or optionally pad input audio to a target length.
+
+The filter accepts the following named parameters:
+@table @option
+
+@item length
+The target length in seconds
+
+@item pad
+A boolean that controls whether or not to pad output with silence to reach
+the target length.
+
+@item frame_size
+The size of silent frames to be generated.
+
+@end table
+
+For example to limit output audio to at most 10 seconds
+@example
+alength=length=10
+@end example
+
+To force output audio to be 10 seconds
+@example
+alength=length=10:pad=1
+@end example
+
+To pad or trim audio to match video length
+@example
+avconv -i INPUT -af alength=pad=1 -shortest OUTPUT
+@end example
 @section amix
 
 Mixes multiple audio inputs into a single output.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 2559e8a..ac244d0 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -26,6 +26,7 @@ OBJS = allfilters.o   
  \
 
 OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
+OBJS-$(CONFIG_ALENGTH_FILTER)+= af_alength.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_ASHOWINFO_FILTER)  += af_ashowinfo.o
diff --git a/libavfilter/af_alength.c b/libavfilter/af_alength.c
new file mode 100644
index 000..5ec0eea
--- /dev/null
+++ b/libavfilter/af_alength.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2012 Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that shortens or lengths and audio stream
+ */
+
+#include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct {
+const AVClass *class;
+AVRational sample_rate;
+AVRational time_base;
+int64_t next_pts;
+char *length;
+int64_t scaled_length;
+int64_t final_pts;
+int got_output;
+int pad;
+int frame_size;
+} ALengthContext;
+
+#define OFFSET(x) offsetof(ALengthContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption alength_options[] = {
+{ "length", "Target length in seconds", OFFSET(length), AV_OPT_TYPE_STRING, 
{.str="-1"}, .flags=A },
+{ "pad", "Pad to length if too short", OFFSET(pad), AV_OPT_TYPE_INT, { 0 }, 0, 
1, A },
+{ "frame_size", "frame_size", OFFSET(frame_size), AV_OPT_TYPE_INT, { 1024 }, 
0, INT_MAX, A },
+{ NULL }
+};
+
+static const AVClass alength_class = {
+.class_name = "alength filter",
+.item_name  = av_default_item_name,
+.option = alength_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int alength_init(AVFilterContext *ctx, const char *args)
+{
+ALengthContext *s = ctx->priv;
+int err;
+
+s->class = &alength_class;
+av_opt_set_defaults(s);
+
+if ((err = av_set_options_string(s, args, "=", ":")) < 0)
+return err;
+if (!strcmp(s->length, "-1")) {
+s->scaled_length = AV_NOPTS_VALUE;
+} else {
+   if ((err = av_parse_time(&s->scaled_length, s->length, 1)))
+   r

Re: [libav-devel] [PATCH] aacsbr: silence message for SBR extension "padding".

2012-12-10 Thread Alex Converse
On Mon, Dec 10, 2012 at 5:48 AM, Jindřich Makovička  wrote:
> Hi,
>
> this is a backport of a patch from FFMPEG, which silences error
> messages for AAC streams padded with zeros. These messages are emitted
> for each AAC packet and can easily make hundreds of megabytes per day
> if logged.
>
> A sample stream produced by an encoder from Cisco is available at
> geraldine.fjfi.cvut.cz/~makovicka/aac-sample.ts .
>

Any idea what function this padding is serving? They padding inside
the SBR layer with a reserved extension id rather than inside the AAC
layer where one is reserved explicitly for padding. It only ever seems
to have 6 to 9 bits (plus 2 for the extension type). If it is only
size calculation being one byte too large (SBR extensions are sized in
whole bytes, so the last fractional bytes is dropped automatically)
can we reflect that in the comment.

In my opinion, for these sorts of messages what we really need is an
av_log_once().

--- a/libavcodec/aacsbr.c
+++ b/libavcodec/aacsbr.c
@@ -926,7 +926,9 @@ static void read_sbr_extension(AACContext *ac,
SpectralBandReplication *sbr,
 }
 break;
 default:
-av_log_missing_feature(ac->avctx, "Reserved SBR extensions", 1);
+// some files contain 0-padding
+if (bs_extension_id || *num_bits_left > 16 || show_bits(gb,
*num_bits_left))

Can you explain

+av_log_missing_feature(ac->avctx, "Reserved SBR
extensions are", 1);
 skip_bits_long(gb, *num_bits_left); // bs_fill_bits
 *num_bits_left = 0;
 break;
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/1] svq3: check and reject negative slice types

2012-11-28 Thread Alex Converse
On Wed, Nov 28, 2012 at 1:32 PM, Janne Grunau  wrote:
>
> Fixes mov_svq3_aac__t_starcraft2_teasecinv2_h264.mov.SIGSEGV.d8a.664.
>
> CC: libav-sta...@libav.org
> ---
>  libavcodec/svq3.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
> index ac8d9c1..c905276 100644
> --- a/libavcodec/svq3.c
> +++ b/libavcodec/svq3.c
> @@ -786,7 +786,7 @@ static int svq3_decode_slice_header(AVCodecContext *avctx)
>  skip_bits_long(&s->gb, 0);
>  }
>
> -if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3) {
> +if ((i = svq3_get_ue_golomb(&s->gb)) == INVALID_VLC || i >= 3 || i < 0) {

Doesn't this make the INVALID_VLC comparison redundant?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/1] mov: use unsigned for stts atom data

2012-11-23 Thread Alex Converse
On Fri, Nov 23, 2012 at 6:30 AM, Hendrik Leppkes wrote:

> On Fri, Nov 23, 2012 at 1:43 PM, Janne Grunau 
> wrote:
> > Sample count and delta are in ISO 14496-12 clearly specified as
> > unsigned int.
> > Fixes an assert caused by negative avg_frame_rate deduced from a
> > negative duraton computed in mov_read_stts().
> > ---
> >  libavformat/isom.h | 4 ++--
> >  libavformat/mov.c  | 4 ++--
> >  2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavformat/isom.h b/libavformat/isom.h
> > index 932b1d0..f4a178b 100644
> > --- a/libavformat/isom.h
> > +++ b/libavformat/isom.h
> > @@ -43,8 +43,8 @@ int ff_mov_lang_to_iso639(unsigned code, char to[4]);
> >   */
> >
> >  typedef struct MOVStts {
> > -int count;
> > -int duration;
> > +unsigned count;
> > +unsigned duration;
> >  } MOVStts;
> >
> >  typedef struct MOVStsc {
> > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > index 35c07bd..a121aa5 100644
> > --- a/libavformat/mov.c
> > +++ b/libavformat/mov.c
> > @@ -1664,8 +1664,8 @@ static int mov_read_stts(MOVContext *c,
> AVIOContext *pb, MOVAtom atom)
> >  return AVERROR(ENOMEM);
> >
> >  for (i = 0; i < entries && !pb->eof_reached; i++) {
> > -int sample_duration;
> > -int sample_count;
> > +unsigned sample_duration;
> > +unsigned sample_count;
> >
> >  sample_count=avio_rb32(pb);
> >  sample_duration = avio_rb32(pb);
>
> I have a sample which only has a proper timeline when sample_duration
> is negative, and thus is required to be signed.
> I vote for fixing the logic that trips your assert, and not break this
> file.
>
> In case you are interested:
> http://files.1f0.de/samples/mp4-negative-stts-problem.mp4
>
> Admitedly, this file is not spec compliant, but breaking it seems like
> something that can be avoided.
>
>
I've run into files like this as well.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/4] aacdec: use float planar sample format for output

2012-11-19 Thread Alex Converse
This looks fine


On Wed, Nov 7, 2012 at 12:59 PM, Justin Ruggles wrote:

> On 10/29/2012 03:15 PM, Justin Ruggles wrote:
> > ---
> >  libavcodec/aac.h|7 ++-
> >  libavcodec/aacdec.c |  102
> ++
> >  libavcodec/aacsbr.c |6 +--
> >  3 files changed, 67 insertions(+), 48 deletions(-)
>
> ping.
>
> -Justin
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
>
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 05/11] mov: make enum MovChannelLayoutTag definition standards compliant

2012-10-29 Thread Alex Converse
On Mon, Oct 29, 2012 at 9:20 AM, Måns Rullgård  wrote:
> Alex Converse  writes:
>
>> On Fri, Oct 26, 2012 at 5:50 PM, Mans Rullgard  wrote:
>>> The C99 standard requires that "the expression that defines the value of
>>> an enumeration constant shall be an integer constant expression that has
>>> a value representable as an int."
>>>
>>> Signed-off-by: Mans Rullgard 
>>> ---
>>>  libavformat/mov_chan.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
>>> index 00a2a4b..d7eb528 100644
>>> --- a/libavformat/mov_chan.c
>>> +++ b/libavformat/mov_chan.c
>>> @@ -45,7 +45,7 @@
>>>   *do not specify a particular ordering of those channels."
>>>   */
>>>  enum MovChannelLayoutTag {
>>> -MOV_CH_LAYOUT_UNKNOWN   = 0x,
>>> +MOV_CH_LAYOUT_UNKNOWN   = ( -1 << 16),
>>
>> Your replacement is undefined:
>>
>> 6.5.7 Bitwise shift operators
>>
>> The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
>> bits are filled with zeros. If E1 has an unsigned type, the value of
>> the result is E1 × 2^E2 , reduced modulo one more than the maximum
>> value representable in the result type. If E1 has a signed type and
>> nonnegative value, and E1 × 2^E2 is representable in the result type,
>> then that is the resulting value; otherwise, the behavior is
>> undefined.
>
> We shift negative values all the time.
>

That may be the case, but this patch does not "make enum
MovChannelLayoutTag definition standards compliant".
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 05/11] mov: make enum MovChannelLayoutTag definition standards compliant

2012-10-29 Thread Alex Converse
On Fri, Oct 26, 2012 at 5:50 PM, Mans Rullgard  wrote:
> The C99 standard requires that "the expression that defines the value of
> an enumeration constant shall be an integer constant expression that has
> a value representable as an int."
>
> Signed-off-by: Mans Rullgard 
> ---
>  libavformat/mov_chan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
> index 00a2a4b..d7eb528 100644
> --- a/libavformat/mov_chan.c
> +++ b/libavformat/mov_chan.c
> @@ -45,7 +45,7 @@
>   *do not specify a particular ordering of those channels."
>   */
>  enum MovChannelLayoutTag {
> -MOV_CH_LAYOUT_UNKNOWN   = 0x,
> +MOV_CH_LAYOUT_UNKNOWN   = ( -1 << 16),


Your replacement is undefined:

6.5.7 Bitwise shift operators

The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
bits are filled with zeros. If E1 has an unsigned type, the value of
the result is E1 × 2^E2 , reduced modulo one more than the maximum
value representable in the result type. If E1 has a signed type and
nonnegative value, and E1 × 2^E2 is representable in the result type,
then that is the resulting value; otherwise, the behavior is
undefined.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 1/4] aacdec: use float planar sample format for output

2012-10-24 Thread Alex Converse
On Sun, Oct 14, 2012 at 2:40 PM, Justin Ruggles
 wrote:
> ---
>  libavcodec/aac.h|7 ++-
>  libavcodec/aacdec.c |  104 
> +++
>  libavcodec/aacsbr.c |6 +--
>  3 files changed, 69 insertions(+), 48 deletions(-)
>
> diff --git a/libavcodec/aac.h b/libavcodec/aac.h
> index 32baf9d..70470dd 100644
> --- a/libavcodec/aac.h
> +++ b/libavcodec/aac.h
> @@ -237,9 +237,10 @@ typedef struct SingleChannelElement {
>  uint8_t zeroes[128];///< band is not coded 
> (used by encoder)
>  DECLARE_ALIGNED(32, float,   coeffs)[1024]; ///< coefficients for 
> IMDCT
>  DECLARE_ALIGNED(32, float,   saved)[1024];  ///< overlap
> -DECLARE_ALIGNED(32, float,   ret)[2048];///< PCM output
> +DECLARE_ALIGNED(32, float,   ret_buf)[2048];///< PCM output buffer
>  DECLARE_ALIGNED(16, float,   ltp_state)[3072];  ///< time signal for LTP
>  PredictorState predictor_state[MAX_PREDICTORS];
> +float *ret; ///< PCM output
>  } SingleChannelElement;
>

[...]

> +static int frame_configure_elements(AVCodecContext *avctx, int get_new_frame)
> +{
> +AACContext *ac = avctx->priv_data;
> +int type, id;
> +
> +/* set channel pointers to internal buffers by default */
> +for (type = 0; type < 4; type++) {
> +for (id = 0; id < MAX_ELEM_ID; id++) {
> +ChannelElement *che = ac->che[type][id];
> +if (che) {
> +che->ch[0].ret = che->ch[0].ret_buf;
> +che->ch[1].ret = che->ch[1].ret_buf;
> +}
> +}
> +}
> +
> +if (get_new_frame) {
> +int ch, ret;
> +
> +/* get output buffer */
> +ac->frame.nb_samples = 2048;
> +if ((ret = avctx->get_buffer(avctx, &ac->frame)) < 0) {
> +av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> +return ret;
> +}
> +
> +/* map output channel pointers to AVFrame data */
> +for (ch = 0; ch < avctx->channels; ch++) {
> +if (ac->output_element[ch])
> +ac->output_element[ch]->ret = (float 
> *)ac->frame.extended_data[ch];
> +}
> +}
> +
> +return 0;
> +}
> +

I'm somewhat unclear on the case where we are actually decoding to the
internal buffers. output_configure() without get_new_frame only seems
to be called from header parsing code.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] mov: Do not apply dts shift from edit lists coming from data tracks.

2012-10-22 Thread Alex Converse
On Fri, Oct 12, 2012 at 4:07 AM, Måns Rullgård  wrote:
>
> Alex Converse  writes:
>
> > Some files in the wild have time code tracks with very negative initial
> > offsets.
>
> Do you have a sample?
>

I can't share the samples I have. I tried to make one but I don't
think I have a tool that can generate a timecode track.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] mov: Do not apply dts shift from edit lists coming from data tracks.

2012-10-11 Thread Alex Converse
Some files in the wild have time code tracks with very negative initial
offsets.
---
 libavformat/mov.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 63049f5..2a41dd5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1790,7 +1790,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 AVIndexEntry *mem;
 
 /* adjust first dts according to edit list */
-if (sc->time_offset && mov->time_scale > 0) {
+if (sc->time_offset && mov->time_scale > 0 && st->codec->codec_type != 
AVMEDIA_TYPE_DATA) {
 if (sc->time_offset < 0)
 sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, 
mov->time_scale);
 current_dts = -sc->time_offset;
-- 
1.7.7.3

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


Re: [libav-devel] [PATCH] pixdesc: Fix YUV 4:1:0 subsampling.

2012-09-19 Thread Alex Converse
On Wed, Sep 19, 2012 at 1:15 PM, Luca Barbato  wrote:
> On 09/19/2012 10:09 PM, Alex Converse wrote:
>> YUV 4:1:0 has 1 chroma sample for a 4x2 block so the vertical resolution
>> is 1/2 not 1/4.
>> ---
>>  libavutil/pixdesc.c |2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>
> Ok.

So the situation is more complicated than I initially thought. A bunch
of other software seems to think that a 4x4 block with one chrominance
sample is 4:1:0. Does anyone know why the name of this format breaks
the convention?

J:a:b
J: horizontal sampling reference (width of the conceptual region). Usually, 4.
a: number of chrominance samples (Cr, Cb) in the first row of J pixels.
b: number of (additional) chrominance samples (Cr, Cb) in the second
row of J pixels.

Wikipedia describes 4:1:0 as

This ratio is possible, and some codecs support it, but it is not
widely used. This ratio uses half of the vertical and one-fourth the
horizontal color resolutions, with only one-eighth of the bandwidth of
the maximum color resolutions used. Uncompressed video in this format
with 8-bit quantization uses 10 bytes for every macropixel (which is 4
x 2 pixels). It has the equivalent chrominance bandwidth of a PAL I
signal decoded with a delay line decoder, and still very much superior
to NTSC.

Mike's wiki describes it as:

YCbCr 4:1:0 indicates a planar YCbCr colorspace where a 4x4 block of
pixels in an image is represented by 16 Y samples, 1 for each pixel,
but all 16 pixels share a Cb sample and a Cr sample.

This article talks a bit about misidentification but doesn't do so for
4:1:0. http://dougkerr.net/pumpkin/articles/Subsampling.pdf
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] pixdesc: Fix YUV 4:1:0 subsampling.

2012-09-19 Thread Alex Converse
YUV 4:1:0 has 1 chroma sample for a 4x2 block so the vertical resolution
is 1/2 not 1/4.
---
 libavutil/pixdesc.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index 122072e..f49f327 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -198,7 +198,7 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] 
= {
 .name = "yuv410p",
 .nb_components = 3,
 .log2_chroma_w = 2,
-.log2_chroma_h = 2,
+.log2_chroma_h = 1,
 .comp = {
 { 0, 0, 1, 0, 7 },/* Y */
 { 1, 0, 1, 0, 7 },/* U */
-- 
1.7.7.3

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


[libav-devel] [PATCH 1/2] tiffenc: Simplify pixel format setup using AVPixFmtDescriptor.

2012-09-19 Thread Alex Converse
---
 libavcodec/tiffenc.c |   40 +---
 1 files changed, 17 insertions(+), 23 deletions(-)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 96a6f0b..4e64201 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -27,6 +27,7 @@
 
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
 
 #include "avcodec.h"
 #include "config.h"
@@ -219,6 +220,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 int is_yuv = 0;
 uint8_t *yuv_line = NULL;
 int shift_h, shift_v;
+const AVPixFmtDescriptor* pfd;
 
 s->avctx = avctx;
 
@@ -232,41 +234,35 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 s->subsampling[0] = 1;
 s->subsampling[1] = 1;
 
-s->bpp_tab_size = 0;
 switch (avctx->pix_fmt) {
 case PIX_FMT_RGB48LE:
-s->bpp = 48;
-s->photometric_interpretation = 2;
-s->bpp_tab_size = 3;
-for (i = 0; i < s->bpp_tab_size; i++) {
-bpp_tab[i] = 16;
-}
-break;
 case PIX_FMT_GRAY16LE:
-s->bpp = 16;
-s->photometric_interpretation = 1;
-s->bpp_tab_size = 1;
-bpp_tab[0] = 16;
-break;
 case PIX_FMT_RGB24:
-s->bpp = 24;
-s->photometric_interpretation = 2;
-break;
 case PIX_FMT_GRAY8:
-s->bpp = 8;
-s->photometric_interpretation = 1;
-break;
 case PIX_FMT_PAL8:
-s->bpp = 8;
-s->photometric_interpretation = 3;
+pfd = &av_pix_fmt_descriptors[avctx->pix_fmt];
+s->bpp = av_get_bits_per_pixel(pfd);
+if (pfd->flags & PIX_FMT_PAL) {
+s->photometric_interpretation = 3;
+} else if (pfd->flags & PIX_FMT_RGB) {
+s->photometric_interpretation = 2;
+} else {
+s->photometric_interpretation = 1;
+}
+s->bpp_tab_size = pfd->nb_components;
+for (i = 0; i < s->bpp_tab_size; i++) {
+bpp_tab[i] = s->bpp / s->bpp_tab_size;
+}
 break;
 case PIX_FMT_MONOBLACK:
 s->bpp = 1;
 s->photometric_interpretation = 1;
+s->bpp_tab_size = 0;
 break;
 case PIX_FMT_MONOWHITE:
 s->bpp = 1;
 s->photometric_interpretation = 0;
+s->bpp_tab_size = 0;
 break;
 case PIX_FMT_YUV420P:
 case PIX_FMT_YUV422P:
@@ -287,8 +283,6 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
"This colors format is not supported\n");
 return -1;
 }
-if (!s->bpp_tab_size)
-s->bpp_tab_size = (s->bpp >> 3);
 
 if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr 
== TIFF_LZW)
 //best choose for DEFLATE
-- 
1.7.7.3

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


[libav-devel] [PATCH 2/2] tiffenc: Check av_malloc() results.

2012-09-19 Thread Alex Converse
---
 libavcodec/tiffenc.c |   16 +++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 4e64201..e6fd6cf 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -316,6 +316,10 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 
 strip_sizes = av_mallocz(sizeof(*strip_sizes) * strips);
 strip_offsets = av_mallocz(sizeof(*strip_offsets) * strips);
+if (!strip_sizes || !strip_offsets) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 
 bytes_per_row = (((s->width - 1)/s->subsampling[0] + 1) * s->bpp
 * s->subsampling[0] * s->subsampling[1] + 7) >> 3;
@@ -323,6 +327,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 yuv_line = av_malloc(bytes_per_row);
 if (yuv_line == NULL){
 av_log(s->avctx, AV_LOG_ERROR, "Not enough memory\n");
+ret = AVERROR(ENOMEM);
 goto fail;
 }
 }
@@ -335,6 +340,10 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 
 zlen = bytes_per_row * s->rps;
 zbuf = av_malloc(zlen);
+if (!zbuf) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 strip_offsets[0] = ptr - pkt->data;
 zn = 0;
 for (j = 0; j < s->rps; j++) {
@@ -359,8 +368,13 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 } else
 #endif
 {
-if(s->compr == TIFF_LZW)
+if (s->compr == TIFF_LZW) {
 s->lzws = av_malloc(ff_lzw_encode_state_size);
+if (!s->lzws) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+}
 for (i = 0; i < s->height; i++) {
 if (strip_sizes[i / s->rps] == 0) {
 if(s->compr == TIFF_LZW){
-- 
1.7.7.3

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


[libav-devel] [PATCH 1/2] tiffenc: Add support for little endian RGB48 and GRAY16

2012-09-19 Thread Alex Converse
---
 libavcodec/tiffenc.c |   22 +++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 1bf7adc..96a6f0b 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -214,7 +214,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 uint32_t *strip_offsets = NULL;
 int bytes_per_row;
 uint32_t res[2] = { 72, 1 };// image resolution (72/1)
-static const uint16_t bpp_tab[] = { 8, 8, 8, 8 };
+uint16_t bpp_tab[] = { 8, 8, 8, 8 };
 int ret;
 int is_yuv = 0;
 uint8_t *yuv_line = NULL;
@@ -232,7 +232,22 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 s->subsampling[0] = 1;
 s->subsampling[1] = 1;
 
+s->bpp_tab_size = 0;
 switch (avctx->pix_fmt) {
+case PIX_FMT_RGB48LE:
+s->bpp = 48;
+s->photometric_interpretation = 2;
+s->bpp_tab_size = 3;
+for (i = 0; i < s->bpp_tab_size; i++) {
+bpp_tab[i] = 16;
+}
+break;
+case PIX_FMT_GRAY16LE:
+s->bpp = 16;
+s->photometric_interpretation = 1;
+s->bpp_tab_size = 1;
+bpp_tab[0] = 16;
+break;
 case PIX_FMT_RGB24:
 s->bpp = 24;
 s->photometric_interpretation = 2;
@@ -272,7 +287,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
"This colors format is not supported\n");
 return -1;
 }
-if (!is_yuv)
+if (!s->bpp_tab_size)
 s->bpp_tab_size = (s->bpp >> 3);
 
 if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr 
== TIFF_LZW)
@@ -474,7 +489,8 @@ AVCodec ff_tiff_encoder = {
 .priv_data_size = sizeof(TiffEncoderContext),
 .encode2= encode_frame,
 .pix_fmts   = (const enum PixelFormat[]) {
-PIX_FMT_RGB24, PIX_FMT_PAL8, PIX_FMT_GRAY8,
+PIX_FMT_RGB24, PIX_FMT_RGB48LE, PIX_FMT_PAL8,
+PIX_FMT_GRAY8, PIX_FMT_GRAY16LE,
 PIX_FMT_MONOBLACK, PIX_FMT_MONOWHITE,
 PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P,
 PIX_FMT_YUV410P, PIX_FMT_YUV411P,
-- 
1.7.7.3

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


[libav-devel] [PATCH 1/2] tiffenc: Add support for little endian RGB24 and GRAY16

2012-09-18 Thread Alex Converse
---
 libavcodec/tiffenc.c |   20 ++--
 1 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
index 1bf7adc..77b2236 100644
--- a/libavcodec/tiffenc.c
+++ b/libavcodec/tiffenc.c
@@ -214,7 +214,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 uint32_t *strip_offsets = NULL;
 int bytes_per_row;
 uint32_t res[2] = { 72, 1 };// image resolution (72/1)
-static const uint16_t bpp_tab[] = { 8, 8, 8, 8 };
+uint16_t bpp_tab[] = { 8, 8, 8, 8 };
 int ret;
 int is_yuv = 0;
 uint8_t *yuv_line = NULL;
@@ -232,7 +232,22 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
 s->subsampling[0] = 1;
 s->subsampling[1] = 1;
 
+s->bpp_tab_size = 0;
 switch (avctx->pix_fmt) {
+case PIX_FMT_RGB48LE:
+s->bpp = 48;
+s->photometric_interpretation = 2;
+s->bpp_tab_size = 3;
+for (i = 0; i < s->bpp_tab_size; i++) {
+bpp_tab[i] = 16;
+}
+break;
+case PIX_FMT_GRAY16LE:
+s->bpp = 16;
+s->photometric_interpretation = 1;
+s->bpp_tab_size = 1;
+bpp_tab[0] = 16;
+break;
 case PIX_FMT_RGB24:
 s->bpp = 24;
 s->photometric_interpretation = 2;
@@ -272,7 +287,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket 
*pkt,
"This colors format is not supported\n");
 return -1;
 }
-if (!is_yuv)
+if (!s->bpp_tab_size)
 s->bpp_tab_size = (s->bpp >> 3);
 
 if (s->compr == TIFF_DEFLATE || s->compr == TIFF_ADOBE_DEFLATE || s->compr 
== TIFF_LZW)
@@ -474,6 +489,7 @@ AVCodec ff_tiff_encoder = {
 .priv_data_size = sizeof(TiffEncoderContext),
 .encode2= encode_frame,
 .pix_fmts   = (const enum PixelFormat[]) {
+PIX_FMT_RGB48LE, PIX_FMT_GRAY16LE,
 PIX_FMT_RGB24, PIX_FMT_PAL8, PIX_FMT_GRAY8,
 PIX_FMT_MONOBLACK, PIX_FMT_MONOWHITE,
 PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_YUV444P,
-- 
1.7.7.3

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


[libav-devel] [PATCH 2/2] tiffdec: Add support for GRAY16LE.

2012-09-18 Thread Alex Converse
Tested with the GraphicsMagick TIFF archive and Libav generated files.
---
 libavcodec/tiff.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index f60c65e..2a48050 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -259,7 +259,7 @@ static int init_image(TiffContext *s)
 s->avctx->pix_fmt = PIX_FMT_RGB24;
 break;
 case 161:
-s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
+s->avctx->pix_fmt = s->le ? PIX_FMT_GRAY16LE : PIX_FMT_GRAY16BE;
 break;
 case 324:
 s->avctx->pix_fmt = PIX_FMT_RGBA;
-- 
1.7.7.3

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


Re: [libav-devel] [PATCH 3/3] aacsbr: silence bogus clang and gcc warning

2012-09-18 Thread Alex Converse
On Tue, Sep 18, 2012 at 10:08 AM, Benjamin Larsson
 wrote:
> On 09/18/2012 07:05 PM, Alex Converse wrote:
>>
>> On Mon, Sep 17, 2012 at 4:35 PM, Benjamin Larsson
>> wrote:
>>>
>>> gcc:
>>> libavcodec/aacsbr.c:399:8: warning: ‘max_qmf_subbands’ may be used
>>> uninitialized in this function [-Wuninitialized]
>>> libavcodec/aacsbr.c:326:24: note: ‘max_qmf_subbands’ was declared here
>>>
>>> clang:
>>> libavcodec/aacsbr.c:391:16: warning: variable 'max_qmf_subbands' is used
>>> uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
>>>  } else if (sbr->sample_rate>= 48000)
>>> ^
>>> libavcodec/aacsbr.c:394:33: note: uninitialized use occurs here
>>>  if (sbr->k[2] - sbr->k[0]>  max_qmf_subbands) {
>>>  ^~~~
>>>
>>> Reorder and change the if else block so that the max_qmf_subbands
>>> variable always will be set. This change is valid as the only allowed
>>> sample rate betwen 32000 and 48000 is 41000.
>>> ---
>>>   libavcodec/aacsbr.c |6 +++---
>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
>>> index 5eca115..35e7c72 100644
>>> --- a/libavcodec/aacsbr.c
>>> +++ b/libavcodec/aacsbr.c
>>> @@ -386,10 +386,10 @@ static int sbr_make_f_master(AACContext *ac,
>>> SpectralBandReplication *sbr,
>>>   // Requirements (14496-3 sp04 p205)
>>>   if (sbr->sample_rate<= 32000) {
>>>   max_qmf_subbands = 48;
>>> -} else if (sbr->sample_rate == 44100) {
>>> -max_qmf_subbands = 35;
>>> -} else if (sbr->sample_rate>= 48000)
>>> +} else if (sbr->sample_rate>= 48000) {
>>>   max_qmf_subbands = 32;
>>> +} else /*if (sbr->sample_rate == 44100) */
>>> +max_qmf_subbands = 35;
>>>
>> Is there a reason you are changing the order?
>
>
> To be able to change the 44100 else if block to an else.
>

why not just change the "else if (sbr->sample_rate>= 48000)" to an else?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 3/3] aacsbr: silence bogus clang and gcc warning

2012-09-18 Thread Alex Converse
On Mon, Sep 17, 2012 at 4:35 PM, Benjamin Larsson  wrote:
> gcc:
> libavcodec/aacsbr.c:399:8: warning: ‘max_qmf_subbands’ may be used 
> uninitialized in this function [-Wuninitialized]
> libavcodec/aacsbr.c:326:24: note: ‘max_qmf_subbands’ was declared here
>
> clang:
> libavcodec/aacsbr.c:391:16: warning: variable 'max_qmf_subbands' is used 
> uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> } else if (sbr->sample_rate >= 48000)
>^
> libavcodec/aacsbr.c:394:33: note: uninitialized use occurs here
> if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
> ^~~~
>
> Reorder and change the if else block so that the max_qmf_subbands
> variable always will be set. This change is valid as the only allowed
> sample rate betwen 32000 and 48000 is 41000.
> ---
>  libavcodec/aacsbr.c |6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/aacsbr.c b/libavcodec/aacsbr.c
> index 5eca115..35e7c72 100644
> --- a/libavcodec/aacsbr.c
> +++ b/libavcodec/aacsbr.c
> @@ -386,10 +386,10 @@ static int sbr_make_f_master(AACContext *ac, 
> SpectralBandReplication *sbr,
>  // Requirements (14496-3 sp04 p205)
>  if (sbr->sample_rate <= 32000) {
>  max_qmf_subbands = 48;
> -} else if (sbr->sample_rate == 44100) {
> -max_qmf_subbands = 35;
> -} else if (sbr->sample_rate >= 48000)
> +} else if (sbr->sample_rate >= 48000) {
>  max_qmf_subbands = 32;
> +} else /*if (sbr->sample_rate == 44100) */
> +max_qmf_subbands = 35;
>

Is there a reason you are changing the order?

>  if (sbr->k[2] - sbr->k[0] > max_qmf_subbands) {
>  av_log(ac->avctx, AV_LOG_ERROR,
> --
> 1.7.9.5
>
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 08/11] mpegaudioenc: use planar sample format

2012-09-10 Thread Alex Converse
On Mon, Sep 10, 2012 at 8:04 AM, Justin Ruggles
 wrote:
> On 08/25/2012 02:01 PM, Justin Ruggles wrote:
>> ---
>>  libavcodec/mpegaudioenc.c |   10 --
>>  1 files changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
>> index ab9e0fa..3ae90af 100644
>> --- a/libavcodec/mpegaudioenc.c
>> +++ b/libavcodec/mpegaudioenc.c
>> @@ -315,7 +315,7 @@ static void idct32(int *out, int *tab)
>>
>>  #define WSHIFT (WFRAC_BITS + 15 - FRAC_BITS)
>>
>> -static void filter(MpegAudioContext *s, int ch, const short *samples, int 
>> incr)
>> +static void filter(MpegAudioContext *s, int ch, const short *samples)
>>  {
>>  short *p, *q;
>>  int sum, offset, i, j;
>> @@ -328,8 +328,7 @@ static void filter(MpegAudioContext *s, int ch, const 
>> short *samples, int incr)
>>  for(j=0;j<36;j++) {
>>  /* 32 samples at once */
>>  for(i=0;i<32;i++) {
>> -s->samples_buf[ch][offset + (31 - i)] = samples[0];
>> -samples += incr;
>> +s->samples_buf[ch][offset + (31 - i)] = *samples++;
>>  }
>>
>>  /* filter */
>> @@ -736,13 +735,12 @@ static int MPA_encode_frame(AVCodecContext *avctx, 
>> AVPacket *avpkt,
>>  const AVFrame *frame, int *got_packet_ptr)
>>  {
>>  MpegAudioContext *s = avctx->priv_data;
>> -const int16_t *samples = (const int16_t *)frame->data[0];
>>  short smr[MPA_MAX_CHANNELS][SBLIMIT];
>>  unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT];
>>  int padding, i, ret;
>>
>>  for(i=0;inb_channels;i++) {
>> -filter(s, i, samples + i, s->nb_channels);
>> +filter(s, i, (const int16_t *)frame->data[i]);
>>  }
>>
>>  for(i=0;inb_channels;i++) {
>> @@ -792,7 +790,7 @@ AVCodec ff_mp2_encoder = {
>>  .init  = MPA_encode_init,
>>  .encode2   = MPA_encode_frame,
>>  .close = MPA_encode_close,
>> -.sample_fmts   = (const enum AVSampleFormat[]){ 
>> AV_SAMPLE_FMT_S16,
>> +.sample_fmts   = (const enum AVSampleFormat[]){ 
>> AV_SAMPLE_FMT_S16P,
>>  
>> AV_SAMPLE_FMT_NONE },
>>  .supported_samplerates = (const int[]){
>>  44100, 48000,  32000, 22050, 24000, 16000, 0
>
> ping
>

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


Re: [libav-devel] [PATCH 5/6] mp3enc: support MPEG-2 and MPEG-2.5 in Xing header.

2012-09-10 Thread Alex Converse
On Mon, Sep 10, 2012 at 6:47 AM, Anton Khirnov  wrote:
> From: Clément Bœsch 
>
> ---
>  libavformat/mp3enc.c |   24 +---
>  1 file changed, 17 insertions(+), 7 deletions(-)
>

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


Re: [libav-devel] [PATCH 2/6] lavf: cosmetics, reformat av_write_trailer().

2012-09-10 Thread Alex Converse
On Mon, Sep 10, 2012 at 6:47 AM, Anton Khirnov  wrote:
> ---
>  libavformat/utils.c |   16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
>

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


Re: [libav-devel] [PATCH 2/3] mp3enc: avoid truncating id3v1 tags by one byte.

2012-09-07 Thread Alex Converse
On Fri, Sep 7, 2012 at 3:09 PM, Måns Rullgård  wrote:
> Alex Converse  writes:
>
>> On Fri, Sep 7, 2012 at 2:55 PM, Måns Rullgård  wrote:
>>> Alex Converse  writes:
>>>
>>>> On Fri, Sep 7, 2012 at 2:45 PM, Måns Rullgård  wrote:
>>>>> Alex Converse  writes:
>>>>>
>>>>>> Avoid writing the trailing NUL byte for id3v1 tags if length reaches max 
>>>>>> length.
>>>>>>
>>>>>> Based on an idea by: Michael Niedermayer 
>>>>>> ---
>>>>>>  libavformat/mp3enc.c |6 --
>>>>>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>>>>>
>>>>>> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
>>>>>> index fac39d9..4bd2eed 100644
>>>>>> --- a/libavformat/mp3enc.c
>>>>>> +++ b/libavformat/mp3enc.c
>>>>>> @@ -37,8 +37,10 @@ static int id3v1_set_string(AVFormatContext *s, const 
>>>>>> char *key,
>>>>>>  uint8_t *buf, int buf_size)
>>>>>>  {
>>>>>>  AVDictionaryEntry *tag;
>>>>>> -if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
>>>>>> -av_strlcpy(buf, tag->value, buf_size);
>>>>>> +if ((tag = av_dict_get(s->metadata, key, NULL, 0))) {
>>>>>> +buf_size = FFMIN(buf_size, strlen(tag->value));
>>>>>> +memcpy(buf, tag->value, buf_size);
>>>>>> +}
>>>>>>  return !!tag;
>>>>>>  }
>>>>>>
>>>>>> --
>>>>>
>>>>> Or even simpler, use strncpy() and drop the initial memset().
>>>>>
>>>>
>>>> That won't compile,
>>>
>>> Why not?
>>>
>>
>> error: implicit declaration of function
>> ‘strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy’
>
> So drop that nonsense.  There is nothing more ridiculous than elaborate
> workarounds for self-imposed rules.
>

That fixed actual buffer overflows. If developers here were capable of
using strncpy() properly we wouldn't have had to ban it. The effects
of using strlcpy() where strncpy() is a better fit tend to be much
more innocuous (as seen here).
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/3] mp3enc: avoid truncating id3v1 tags by one byte.

2012-09-07 Thread Alex Converse
On Fri, Sep 7, 2012 at 2:55 PM, Måns Rullgård  wrote:
> Alex Converse  writes:
>
>> On Fri, Sep 7, 2012 at 2:45 PM, Måns Rullgård  wrote:
>>> Alex Converse  writes:
>>>
>>>> Avoid writing the trailing NUL byte for id3v1 tags if length reaches max 
>>>> length.
>>>>
>>>> Based on an idea by: Michael Niedermayer 
>>>> ---
>>>>  libavformat/mp3enc.c |6 --
>>>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
>>>> index fac39d9..4bd2eed 100644
>>>> --- a/libavformat/mp3enc.c
>>>> +++ b/libavformat/mp3enc.c
>>>> @@ -37,8 +37,10 @@ static int id3v1_set_string(AVFormatContext *s, const 
>>>> char *key,
>>>>  uint8_t *buf, int buf_size)
>>>>  {
>>>>  AVDictionaryEntry *tag;
>>>> -if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
>>>> -av_strlcpy(buf, tag->value, buf_size);
>>>> +if ((tag = av_dict_get(s->metadata, key, NULL, 0))) {
>>>> +buf_size = FFMIN(buf_size, strlen(tag->value));
>>>> +memcpy(buf, tag->value, buf_size);
>>>> +}
>>>>  return !!tag;
>>>>  }
>>>>
>>>> --
>>>
>>> Or even simpler, use strncpy() and drop the initial memset().
>>>
>>
>> That won't compile,
>
> Why not?
>

error: implicit declaration of function
‘strncpy_is_forbidden_due_to_security_issues_use_av_strlcpy’
[-Werror=implicit-function-declaration]
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 2/3] mp3enc: avoid truncating id3v1 tags by one byte.

2012-09-07 Thread Alex Converse
On Fri, Sep 7, 2012 at 2:45 PM, Måns Rullgård  wrote:
> Alex Converse  writes:
>
>> Avoid writing the trailing NUL byte for id3v1 tags if length reaches max 
>> length.
>>
>> Based on an idea by: Michael Niedermayer 
>> ---
>>  libavformat/mp3enc.c |6 --
>>  1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
>> index fac39d9..4bd2eed 100644
>> --- a/libavformat/mp3enc.c
>> +++ b/libavformat/mp3enc.c
>> @@ -37,8 +37,10 @@ static int id3v1_set_string(AVFormatContext *s, const 
>> char *key,
>>  uint8_t *buf, int buf_size)
>>  {
>>  AVDictionaryEntry *tag;
>> -if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
>> -av_strlcpy(buf, tag->value, buf_size);
>> +if ((tag = av_dict_get(s->metadata, key, NULL, 0))) {
>> +buf_size = FFMIN(buf_size, strlen(tag->value));
>> +memcpy(buf, tag->value, buf_size);
>> +}
>>  return !!tag;
>>  }
>>
>> --
>
> Or even simpler, use strncpy() and drop the initial memset().
>

That won't compile, and looking at all the crazy ways people had been
misusing strncpy() that's probably a good thing.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/3] mp3enc: avoid truncating id3v1 tags by one byte.

2012-09-07 Thread Alex Converse
Avoid writing the trailing NUL byte for id3v1 tags if length reaches max length.

Based on an idea by: Michael Niedermayer 
---
 libavformat/mp3enc.c |6 --
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index fac39d9..4bd2eed 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -37,8 +37,10 @@ static int id3v1_set_string(AVFormatContext *s, const char 
*key,
 uint8_t *buf, int buf_size)
 {
 AVDictionaryEntry *tag;
-if ((tag = av_dict_get(s->metadata, key, NULL, 0)))
-av_strlcpy(buf, tag->value, buf_size);
+if ((tag = av_dict_get(s->metadata, key, NULL, 0))) {
+buf_size = FFMIN(buf_size, strlen(tag->value));
+memcpy(buf, tag->value, buf_size);
+}
 return !!tag;
 }
 
-- 
1.7.7.3

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


[libav-devel] [PATCH 3/3] mp3enc: Import Xing tag improvements from FFmpeg.

2012-09-06 Thread Alex Converse
Size, toc, and low sample rates are now supported.

Imports work by: Peter Belkner ,
Michael Niedermayer ,
Clément Bœsch ,
Reimar Döffinger , and
Tobias Rapp 

Signed-off-by: Alex Converse 
---
 libavformat/mp3enc.c |  242 --
 1 files changed, 214 insertions(+), 28 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index fc741b9..a09879a 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -30,6 +30,10 @@
 #include "libavcodec/mpegaudiodecheader.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
+#include "libavcodec/mpegaudio.h"
+#include "libavcodec/mpegaudiodata.h"
+#include "libavcodec/mpegaudiodecheader.h"
+#include "libavformat/avio_internal.h"
 #include "libavutil/dict.h"
 #include "libavutil/avassert.h"
 
@@ -75,12 +79,23 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t 
*buf)
 return count;
 }
 
+#define VBR_NUM_BAGS 400
+#define VBR_TOC_SIZE 100
+
 typedef struct MP3Context {
 const AVClass *class;
 ID3v2EncContext id3;
 int id3v2_version;
 int write_id3v1;
 int64_t nb_frames_offset;
+int32_t frames;
+int32_t size;
+uint32_t want;
+uint32_t seen;
+uint32_t pos;
+uint64_t bag[VBR_NUM_BAGS];
+int initial_bitrate;
+int has_variable_bitrate;
 
 /* index of the audio stream */
 int audio_stream_idx;
@@ -91,53 +106,210 @@ typedef struct MP3Context {
 AVPacketList *queue, *queue_end;
 } MP3Context;
 
-/* insert a dummy frame containing number of frames */
+static const uint8_t xing_offtbl[2][2] = {{32, 17}, {17, 9}};
+
+/*
+ * Write an empty XING header and initialize respective data.
+ */
 static void mp3_write_xing(AVFormatContext *s)
 {
 MP3Context   *mp3 = s->priv_data;
-AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
-int   bitrate_idx = 1;// 32 kbps
-int64_t   xing_offset = (codec->channels == 2) ? 32 : 17;
-int32_theader;
-MPADecodeHeader  mpah;
-int srate_idx, i, channels;
+AVCodecContext   *codec = s->streams[mp3->audio_stream_idx]->codec;
+int  bitrate_idx;
+int  best_bitrate_idx = -1;
+int  best_bitrate_error= INT_MAX;
+int  xing_offset;
+int32_t  header, mask;
+MPADecodeHeader  c;
+int  srate_idx, ver = 0, i, channels;
+int  needed;
 
 if (!s->pb->seekable)
 return;
 
-for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++)
-if (avpriv_mpa_freq_tab[i] == codec->sample_rate) {
-srate_idx = i;
-break;
-}
+for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
+const uint16_t base_freq = avpriv_mpa_freq_tab[i];
+if  (codec->sample_rate == base_freq) ver = 0x3; // MPEG 1
+else if (codec->sample_rate == base_freq / 2) ver = 0x2; // MPEG 2
+else if (codec->sample_rate == base_freq / 4) ver = 0x0; // MPEG 2.5
+else continue;
+srate_idx = i;
+break;
+}
 if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
-av_log(s, AV_LOG_ERROR, "Unsupported sample rate.\n");
+av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing 
header.\n");
 return;
 }
 
 switch (codec->channels) {
 case 1:  channels = MPA_MONO;  
break;
 case 2:  channels = MPA_STEREO;
break;
-default: av_log(s, AV_LOG_ERROR, "Unsupported number of channels.\n"); 
return;
+default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, not 
writing Xing header.\n");
+ return;
 }
 
 /* dummy MPEG audio header */
 header  =  0xff  << 24; // sync
-header |= (0x7 << 5 | 0x3 << 3 | 0x1 << 1 | 0x1) << 16; // 
sync/mpeg-1/layer 3/no crc*/
-header |= (bitrate_idx << 4 | srate_idx << 2)<<  8;
+header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; // 
sync/audio-version/layer 3/no crc*/
+header |= (srate_idx << 2) <<  8;
 header |= channels << 6;
-avio_wb32(s->pb, header);
 
-avpriv_mpegaudio_decode_header(&mpah, header);
+for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
+int error;
+avpriv_mpegaudio_decode_header(&c, header | (bitrate_idx << (4+8)));
+error = FFABS(c.bit_rate - codec->bit_rate);
+if(error < best_bitrate_error){
+best_bitrate_error = error;
+best_bitrate_idx   = bitrate_idx;
+}
+}
+av_assert0(best_bitrate_idx >= 0);
+
+for (bitrat

[libav-devel] [PATCH 2/3] mp3enc: avoid truncating id3v1 tags by one byte

2012-09-06 Thread Alex Converse
From: Tobias Rapp 

Avoid writing the trailing null-byte for id3v1 tags if length reaches max 
length.

Signed-off-by: Michael Niedermayer 
Signed-off-by: Alex Converse 
---
 libavformat/mp3enc.c |   11 ++-
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index fac39d9..fc741b9 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -51,11 +51,12 @@ static int id3v1_create_tag(AVFormatContext *s, uint8_t 
*buf)
 buf[0] = 'T';
 buf[1] = 'A';
 buf[2] = 'G';
-count += id3v1_set_string(s, "TIT2",buf +  3, 30);   //title
-count += id3v1_set_string(s, "TPE1",buf + 33, 30);   
//author|artist
-count += id3v1_set_string(s, "TALB",buf + 63, 30);   //album
-count += id3v1_set_string(s, "TDRL",buf + 93,  4);   //date
-count += id3v1_set_string(s, "comment", buf + 97, 30);
+/* we knowingly overspecify each tag length by one byte to compensate for 
the mandatory null byte added by av_strlcpy */
+count += id3v1_set_string(s, "TIT2",buf +  3, 30 + 1);   //title
+count += id3v1_set_string(s, "TPE1",buf + 33, 30 + 1);   
//author|artist
+count += id3v1_set_string(s, "TALB",buf + 63, 30 + 1);   //album
+count += id3v1_set_string(s, "TDRL",buf + 93,  4 + 1);   //date
+count += id3v1_set_string(s, "comment", buf + 97, 30 + 1);
 if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track
 buf[125] = 0;
 buf[126] = atoi(tag->value);
-- 
1.7.7.3

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


[libav-devel] [PATCH 1/3] Do not assume timestamps for mp2 format.

2012-09-06 Thread Alex Converse
From: Carl Eugen Hoyos 

Signed-off-by: Alex Converse 
---
 libavformat/mp3enc.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/libavformat/mp3enc.c b/libavformat/mp3enc.c
index 9a54e01..fac39d9 100644
--- a/libavformat/mp3enc.c
+++ b/libavformat/mp3enc.c
@@ -197,6 +197,7 @@ AVOutputFormat ff_mp2_muxer = {
 .video_codec   = AV_CODEC_ID_NONE,
 .write_packet  = ff_raw_write_packet,
 .write_trailer = mp3_write_trailer,
+.flags = AVFMT_NOTIMESTAMPS,
 };
 #endif
 
-- 
1.7.7.3

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


Re: [libav-devel] [PATCH/RFC] movenc: Trim the audio codec delay using an edit list.

2012-09-01 Thread Alex Converse
On Fri, Aug 31, 2012 at 12:38 AM, Diego Biurrun  wrote:
>
> On Tue, Aug 28, 2012 at 11:47:46AM -0700, Thierry Foucu wrote:
> > On Wed, May 30, 2012 at 2:42 PM, Alex Converse 
> > wrote:
> > > --- a/libavformat/movenc.c
> > > +++ b/libavformat/movenc.c
> > > @@ -1464,10 +1464,15 @@ static int mov_write_edts_tag(AVIOContext *pb,
> > >
> > > I'm not 100% happy with this but it seems to solve 99% of the problem. In
> > > particular I don't like the pts == dts check and the equivalent
> > > track->cluster[0].cts check.
> > >
> > > For video files with delay we still see, e.g.
> > > ct = 1, dt = -1, trim = 1, empty edit = 0
> > > and with intentional additional output delay
> > > ct= 1, dt = 47, trim = 1, empty edit = 48
> > >
> > > For audio we used to see:
> > > ct = 0, dt = -1024, trim = 0, empty edit = 0
> > > and with intentional additional output delay:
> > > ct = 0, dt = 94976, trim = 0, empty edit = 94976.
> > >
> > > We now see:
> > > ct = 0, dt = -1024, trim = 1024, empty edit = 0
> > > and with intentional additional output delay:
> > > ct = 0, dt = 94976, trim = 0, empty edit = 94976
> > >
> > > The video case seems nicer in that we preserve codec delay independently 
> > > of
> > > presentation delay.
> >
> > Any updarte on this CL?
> >
> > Will be nice to remove audio encoder delay
>
> Alex?

I'm still waiting for review/feedback on the patch. In particular I'd
like to see Justin's opinion on this.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 01/19] fate: disable pcm audio in some video tests

2012-08-27 Thread Alex Converse
On Mon, Aug 27, 2012 at 3:23 AM, Diego Biurrun  wrote:
>
> On Tue, Aug 07, 2012 at 11:07:26PM +0200, Diego Biurrun wrote:
> > On Mon, May 14, 2012 at 08:42:18PM +0100, Måns Rullgård wrote:
> > > Alex Converse  writes:
> > > > On Fri, May 11, 2012 at 10:35 AM, Mans Rullgard 
> > > > wrote:
> > > >>
> > > >> These files all have pcm audio which is tested elsewhere.
> > > >>
> > > >> Signed-off-by: Mans Rullgard 
> > > >> ---
> > > >>  tests/fate/demux.mak |3 --
> > > >>  tests/fate/qt.mak|2 +-
> > > >>  tests/fate/screen.mak|4 +-
> > > >>  tests/fate/video.mak |   25 +
> > > >>  tests/ref/fate/8bps  |   24 -
> > > >>  tests/ref/fate/armovie-escape124 |5 --
> > > >>  tests/ref/fate/bethsoft-vid  |   72 -
> > > >>  tests/ref/fate/bfi   |   58 
> > > >>  tests/ref/fate/corepng   |   20 ---
> > > >>  tests/ref/fate/creatureshock-avs |   37 -
> > > >>  tests/ref/fate/cyberia-c93   |5 --
> > > >>  tests/ref/fate/dxtory|1 -
> > > >>  tests/ref/fate/id-cin-video  |   53 --
> > > >>  tests/ref/fate/siff  |4 --
> > > >>  tests/ref/fate/sp5x  |   10 
> > > >>  tests/ref/fate/tiertex-seq   |   78
> > > >> ---
> > > >>  tests/ref/fate/tmv   |  111
> > > >> --
> > > >>  tests/ref/fate/tscc-15bit|   16 --
> > > >>  tests/ref/fate/wc3movie-xan  |   36 -
> > > >>  19 files changed, 17 insertions(+), 547 deletions(-)
> > > >
> > > > This seems to substantially lower our coverage for demuxers. In
> > > > these
> > > > cases the code that demuxes the audio is still executed but now we
> > > > no
> > > > longer get to see the timestamps or that we are grabbing the correct
> > > > bytes for each audio frame. What's the motivation for this? I under
> > > > stand trying to test features in isolation, but "decoding" linear
> > > > PCM
> > > > audio isn't much more work than just copying, sometimes with a
> > > > byteswap.
> > >
> > > The ultimate goal is to make it possible to test even a very minimal
> > > configuration.  How about adding demux-only tests for those of these
> > > containers that are not fully covered otherwise?
> >
> > I'm with Mans here - the long-term goal is to be able to test any
> > config,
> > not just the full-featured ones.  This will require making changes like
> > this one here and there.  Sometimes you have to pass through a little
> > valley to reach the next summit.
>
> Can we revisit this please?  The patchset should go in, it will be
> long-term beneficial.
>

It still seems to decrease demuxer coverage. Why not split the tests
if you want to test minimal configurations?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavfi: Add the alength audio length filter.

2012-08-22 Thread Alex Converse
---
 Changelog|1 +
 doc/filters.texi |   33 +
 libavfilter/Makefile |1 +
 libavfilter/af_alength.c |  178 ++
 libavfilter/allfilters.c |1 +
 5 files changed, 214 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/af_alength.c

diff --git a/Changelog b/Changelog
index 4326c68..c94b28a 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ version :
 - Canopus Lossless Codec decoder
 - avconv -shortest option is now per-output file
 - Ut Video encoder
+- alength audio filter
 
 
 version 0.8:
diff --git a/doc/filters.texi b/doc/filters.texi
index e77256e..0932516 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -133,6 +133,39 @@ For example to force the output to either unsigned 8-bit 
or signed 16-bit stereo
 aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
 @end example
 
+@section alength
+
+Shorten or optionally pad input audio to a target length.
+
+The filter accepts the following named parameters:
+@table @option
+
+@item length
+The target length in samples
+
+@item pad
+A boolean that controls whether or not to pad output with silence to reach
+the target length.
+
+@item frame_size
+The size of silent frames to be generated.
+
+@end table
+
+For example to limit output audio to at most 48 samples
+@example
+alength=length=48
+@end example
+
+To force output audio to be 48 samples
+@example
+alength=length=48\,pad=1
+@end example
+
+To pad or trim audio to match video length
+@example
+avconv -i INPUT -af alength=pad=1 -shortest OUTPUT
+@end example
 @section amix
 
 Mixes multiple audio inputs into a single output.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 530aa57..74d57c9 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -26,6 +26,7 @@ OBJS = allfilters.o   
  \
 
 OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
+OBJS-$(CONFIG_ALENGTH_FILTER)+= af_alength.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
diff --git a/libavfilter/af_alength.c b/libavfilter/af_alength.c
new file mode 100644
index 000..2af934a
--- /dev/null
+++ b/libavfilter/af_alength.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2012 Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that shortens or lengths and audio stream
+ */
+
+#include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct {
+const AVClass *class;
+int64_t next_pts;
+int64_t length;
+int64_t final_pts;
+int got_output;
+int pad;
+int frame_size;
+} ALengthContext;
+
+#define OFFSET(x) offsetof(ALengthContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption alength_options[] = {
+{ "length", "Target length in samples", OFFSET(length), AV_OPT_TYPE_INT64, 
{.i64=INT64_MAX}, 0, INT64_MAX, A },
+{ "pad", "Pad to length if too short", OFFSET(pad), AV_OPT_TYPE_INT, { 0 }, 0, 
1, A },
+{ "frame_size", "frame_size", OFFSET(frame_size), AV_OPT_TYPE_INT, { 1024 }, 
0, INT_MAX, A },
+{ NULL }
+};
+
+static const AVClass alength_class = {
+.class_name = "alength filter",
+.item_name  = av_default_item_name,
+.option = alength_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int alength_init(AVFilterContext *ctx, const char *args)
+{
+ALengthContext *s = ctx->priv;
+int err;
+
+s->class = &alength_class;
+av_opt_set_defaults(s);
+
+if ((err = av_set_options_string(s, args, "=", ":")) < 0)
+return err;
+
+s->next_pts = AV_NOPTS_VALUE;
+s->final_pts = AV_NOPTS_VALUE;
+av_log(ctx, AV_LOG_VERBOSE, "length:%"PRId64" pad:%d frame_size:%d\n", 
s->length, s->pad, s->frame_size);
+
+return 0;
+}
+
+static int alength_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
+{
+AVFilterContext *ctx = inlink->dst;
+ALengthContext *s = ctx->pr

[libav-devel] [PATCH] lavfi: Add the alength audio length filter.

2012-08-21 Thread Alex Converse
---
 Changelog|1 +
 doc/filters.texi |   33 ++
 libavfilter/Makefile |1 +
 libavfilter/af_alength.c |  161 ++
 libavfilter/allfilters.c |1 +
 5 files changed, 197 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/af_alength.c

diff --git a/Changelog b/Changelog
index 4326c68..c94b28a 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ version :
 - Canopus Lossless Codec decoder
 - avconv -shortest option is now per-output file
 - Ut Video encoder
+- alength audio filter
 
 
 version 0.8:
diff --git a/doc/filters.texi b/doc/filters.texi
index e77256e..0932516 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -133,6 +133,39 @@ For example to force the output to either unsigned 8-bit 
or signed 16-bit stereo
 aformat=sample_fmts\=u8\,s16:channel_layouts\=stereo
 @end example
 
+@section alength
+
+Shorten or optionally pad input audio to a target length.
+
+The filter accepts the following named parameters:
+@table @option
+
+@item length
+The target length in samples
+
+@item pad
+A boolean that controls whether or not to pad output with silence to reach
+the target length.
+
+@item frame_size
+The size of silent frames to be generated.
+
+@end table
+
+For example to limit output audio to at most 48 samples
+@example
+alength=length=48
+@end example
+
+To force output audio to be 48 samples
+@example
+alength=length=48\,pad=1
+@end example
+
+To pad or trim audio to match video length
+@example
+avconv -i INPUT -af alength=pad=1 -shortest OUTPUT
+@end example
 @section amix
 
 Mixes multiple audio inputs into a single output.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 530aa57..74d57c9 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -26,6 +26,7 @@ OBJS = allfilters.o   
  \
 
 OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
+OBJS-$(CONFIG_ALENGTH_FILTER)+= af_alength.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
diff --git a/libavfilter/af_alength.c b/libavfilter/af_alength.c
new file mode 100644
index 000..a06bb07
--- /dev/null
+++ b/libavfilter/af_alength.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2012 Google, Inc.
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that shortens or lengths and audio stream
+ */
+
+#include "libavutil/audioconvert.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct {
+const AVClass *class;
+int64_t next_pts;
+int64_t length;
+int got_output;
+int pad;
+int frame_size;
+} ALengthContext;
+
+#define OFFSET(x) offsetof(ALengthContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption alength_options[] = {
+{ "length", "Target length in samples", OFFSET(length), AV_OPT_TYPE_INT64, { 
INT64_MAX }, 0, INT64_MAX, A },
+{ "pad", "Pad to length if too short", OFFSET(pad), AV_OPT_TYPE_INT, { 0 }, 0, 
1, A },
+{ "frame_size", "frame_size", OFFSET(frame_size), AV_OPT_TYPE_INT, { 1024 }, 
0, INT_MAX, A },
+{ NULL }
+};
+
+static const AVClass alength_class = {
+.class_name = "alength filter",
+.item_name  = av_default_item_name,
+.option = alength_options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int alength_init(AVFilterContext *ctx, const char *args)
+{
+ALengthContext *s = ctx->priv;
+int err;
+
+s->class = &alength_class;
+av_opt_set_defaults(s);
+
+if ((err = av_set_options_string(s, args, "=", ":")) < 0)
+return err;
+
+s->next_pts = AV_NOPTS_VALUE;
+av_log(ctx, AV_LOG_VERBOSE, "length:%"PRId64" pad:%d frame_size:%d\n", 
s->length, s->pad, s->frame_size);
+
+return 0;
+}
+
+static int alength_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
+{
+AVFilterContext *ctx = inlink->dst;
+ALengthContext *s = ctx->priv;
+AVFilterLink *outlink = ctx->outputs[0];
+int nb_

[libav-devel] [PATCH] lavfi: add asetnsamples audio filter

2012-08-21 Thread Alex Converse
From: Stefano Sabatini 

This filter changes the number of samples on single output operation.

Based on a patch by Andrey Utkin .

Signed-off-by: Alex Converse 
---
 Changelog |1 +
 doc/filters.texi  |   30 ++
 libavfilter/Makefile  |1 +
 libavfilter/af_asetnsamples.c |  210 +
 libavfilter/allfilters.c  |1 +
 5 files changed, 243 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/af_asetnsamples.c

diff --git a/Changelog b/Changelog
index 4326c68..35840dc 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ version :
 - Canopus Lossless Codec decoder
 - avconv -shortest option is now per-output file
 - Ut Video encoder
+- Set n samples (asetnsamples) audio filter
 
 
 version 0.8:
diff --git a/doc/filters.texi b/doc/filters.texi
index e77256e..364d664 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -175,6 +175,36 @@ stream ends. The default value is 2 seconds.
 
 Pass the audio source unchanged to the output.
 
+@section asetnsamples
+
+Set the number of samples per each output audio frame.
+
+The last output packet may contain a different number of samples, as
+the filter will flush all the remaining samples when the input audio
+signal its end.
+
+The filter accepts parameters as a list of @var{key}=@var{value} pairs,
+separated by ":".
+
+@table @option
+
+@item nb_out_samples, n
+Set the number of frames per each output audio frame. The number is
+intended as the number of samples @emph{per each channel}.
+Default value is 1024.
+
+@item pad, p
+If set to 1, the filter will pad the last audio frame with zeroes, so
+that the last frame will contain the same number of samples as the
+previous ones. Default value is 1.
+@end table
+
+For example, to set the number of per-frame samples to 1234 and
+disable padding for the last frame, use:
+@example
+asetnsamples=n=1234:p=0
+@end example
+
 @section asplit
 
 Split input audio into several identical outputs.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 530aa57..7be84ba 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -28,6 +28,7 @@ OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
+OBJS-$(CONFIG_ASETNSAMPLES_FILTER)   += af_asetnsamples.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASYNCTS_FILTER)+= af_asyncts.o
 OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o
diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c
new file mode 100644
index 000..cab7762
--- /dev/null
+++ b/libavfilter/af_asetnsamples.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2012 Andrey Utkin
+ * Copyright (c) 2012 Stefano Sabatini
+ *
+ * This file is part of Libav.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that changes number of samples on single output operation
+ */
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct {
+const AVClass *class;
+int nb_out_samples;  ///< how many samples to output
+AVAudioFifo *fifo;   ///< samples are queued here
+int64_t next_out_pts;
+int req_fullfilled;
+int pad;
+} ASNSContext;
+
+#define OFFSET(x) offsetof(ASNSContext, x)
+#define FLAGS AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption asetnsamples_options[] = {
+{ "pad", "pad last frame with silence", OFFSET(pad), AV_OPT_TYPE_INT, 
{.dbl=1}, 0, 1, FLAGS },
+{ "p",   "pad last frame with silence", OFFSET(pad), AV_OPT_TYPE_INT, 
{.dbl=1}, 0, 1, FLAGS },
+{ "nb_out_samples", "set the number of per-frame output samples", 
OFFSET(nb_out_samples), AV_OPT_TYPE_INT, {.dbl=1024}, 1, INT_MAX, FLAGS },
+{ "n",  "set the number of

Re: [libav-devel] [PATCH] lavfi: add asetnsamples audio filter

2012-08-21 Thread Alex Converse
On Tue, Aug 21, 2012 at 6:01 PM, Alex Converse  wrote:
> From: Stefano Sabatini 
>
> This filter changes the number of samples on single output operation.
>
> Based on a patch by Andrey Utkin .
>
> Signed-off-by: Alex Converse 

Sorry this was a missend of an untested version. (I removed class
oops). Sending the functional and tested version shortly.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavfi: add asetnsamples audio filter

2012-08-21 Thread Alex Converse
From: Stefano Sabatini 

This filter changes the number of samples on single output operation.

Based on a patch by Andrey Utkin .

Signed-off-by: Alex Converse 
---
 doc/filters.texi  |   30 ++
 libavfilter/Makefile  |1 +
 libavfilter/af_asetnsamples.c |  201 +
 libavfilter/allfilters.c  |1 +
 4 files changed, 233 insertions(+), 0 deletions(-)
 create mode 100644 libavfilter/af_asetnsamples.c

diff --git a/doc/filters.texi b/doc/filters.texi
index e77256e..364d664 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -175,6 +175,36 @@ stream ends. The default value is 2 seconds.
 
 Pass the audio source unchanged to the output.
 
+@section asetnsamples
+
+Set the number of samples per each output audio frame.
+
+The last output packet may contain a different number of samples, as
+the filter will flush all the remaining samples when the input audio
+signal its end.
+
+The filter accepts parameters as a list of @var{key}=@var{value} pairs,
+separated by ":".
+
+@table @option
+
+@item nb_out_samples, n
+Set the number of frames per each output audio frame. The number is
+intended as the number of samples @emph{per each channel}.
+Default value is 1024.
+
+@item pad, p
+If set to 1, the filter will pad the last audio frame with zeroes, so
+that the last frame will contain the same number of samples as the
+previous ones. Default value is 1.
+@end table
+
+For example, to set the number of per-frame samples to 1234 and
+disable padding for the last frame, use:
+@example
+asetnsamples=n=1234:p=0
+@end example
+
 @section asplit
 
 Split input audio into several identical outputs.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 530aa57..7be84ba 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -28,6 +28,7 @@ OBJS-$(CONFIG_AFIFO_FILTER)  += fifo.o
 OBJS-$(CONFIG_AFORMAT_FILTER)+= af_aformat.o
 OBJS-$(CONFIG_AMIX_FILTER)   += af_amix.o
 OBJS-$(CONFIG_ANULL_FILTER)  += af_anull.o
+OBJS-$(CONFIG_ASETNSAMPLES_FILTER)   += af_asetnsamples.o
 OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
 OBJS-$(CONFIG_ASYNCTS_FILTER)+= af_asyncts.o
 OBJS-$(CONFIG_CHANNELMAP_FILTER) += af_channelmap.o
diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c
new file mode 100644
index 000..6157886
--- /dev/null
+++ b/libavfilter/af_asetnsamples.c
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2012 Andrey Utkin
+ * Copyright (c) 2012 Stefano Sabatini
+ *
+ * This file is part of Libav.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Filter that changes number of samples on single output operation
+ */
+
+#include "libavutil/audio_fifo.h"
+#include "libavutil/audioconvert.h"
+#include "libavutil/avassert.h"
+#include "libavutil/common.h"
+#include "libavutil/opt.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "internal.h"
+#include "formats.h"
+
+typedef struct {
+int nb_out_samples;  ///< how many samples to output
+AVAudioFifo *fifo;   ///< samples are queued here
+int64_t next_out_pts;
+int req_fullfilled;
+int pad;
+} ASNSContext;
+
+#define OFFSET(x) offsetof(ASNSContext, x)
+#define FLAGS AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption asetnsamples_options[] = {
+{ "pad", "pad last frame with silence", OFFSET(pad), AV_OPT_TYPE_INT, 
{.dbl=1}, 0, 1, FLAGS },
+{ "p",   "pad last frame with silence", OFFSET(pad), AV_OPT_TYPE_INT, 
{.dbl=1}, 0, 1, FLAGS },
+{ "nb_out_samples", "set the number of per-frame output samples", 
OFFSET(nb_out_samples), AV_OPT_TYPE_INT, {.dbl=1024}, 1, INT_MAX, FLAGS },
+{ "n",  "set the number of per-frame output samples", 
OFFSET(nb_out_samples), AV_OPT_TYPE_INT, {.dbl=1024}, 1, INT_MAX, FLAGS },
+{ NULL }
+};
+
+static av_cold int asetnsamples_init(AVFilterContext *ctx, const char *args)
+{
+ASNSContext *asns = ctx->priv;
+int err;
+
+av_opt_set_defaults(asns);
+
+if ((err = av_set_options_string(asns, args, "=", &quo

Re: [libav-devel] [libav-commits] mpegvideo_enc: don't use deprecated avcodec_encode_video().

2012-08-18 Thread Alex Converse
On Fri, Aug 17, 2012 at 11:50 PM, Anton Khirnov  wrote:
>
> Module: libav
> Branch: master
> Commit: 7f9aaa499b8a5ce066cc17aac6ebbdf0111980b6
>
> Author:Anton Khirnov 
> Committer: Anton Khirnov 
> Date:  Wed Aug 15 09:35:18 2012 +0200
>
> mpegvideo_enc: don't use deprecated avcodec_encode_video().
>
> ---
>
>  libavcodec/mpegvideo_enc.c |   31 +++
>  1 files changed, 23 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
> index d527ace..65f2281 100644
> --- a/libavcodec/mpegvideo_enc.c
> +++ b/libavcodec/mpegvideo_enc.c
> @@ -1068,6 +1068,22 @@ static int skip_check(MpegEncContext *s, Picture
> *p, Picture *ref)
>  return 0;
>  }
>
> +static int encode_frame(AVCodecContext *c, AVFrame *frame)
> +{
> +AVPacket pkt = { 0 };
> +int ret, got_output;
> +
> +av_init_packet(&pkt);
> +av_init_packet(&pkt);

Why the double init?

> +ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
> +if (ret < 0)
> +return ret;
> +
> +ret = pkt.size;
> +av_free_packet(&pkt);
> +return ret;
> +}
> +
>  static int estimate_best_b_count(MpegEncContext *s)
>  {
>  AVCodec *codec= avcodec_find_encoder(s->avctx->codec_id);
> @@ -1075,8 +1091,6 @@ static int estimate_best_b_count(MpegEncContext *s)
>  AVFrame input[FF_MAX_B_FRAMES + 2];
>  const int scale = s->avctx->brd_scale;
>  int i, j, out_size, p_lambda, b_lambda, lambda2;
> -int outbuf_size  = s->width * s->height; // FIXME
> -uint8_t *outbuf  = av_malloc(outbuf_size);
>  int64_t best_rd  = INT64_MAX;
>  int best_b_count = -1;
>
> @@ -1153,8 +1167,9 @@ static int estimate_best_b_count(MpegEncContext *s)
>
>  input[0].pict_type = AV_PICTURE_TYPE_I;
>  input[0].quality   = 1 * FF_QP2LAMBDA;
> -out_size   = avcodec_encode_video(c, outbuf,
> -  outbuf_size,
> &input[0]);
> +
> +out_size = encode_frame(c, &input[0]);
> +
>  //rd += (out_size * lambda2) >> FF_LAMBDA_SHIFT;
>
>  for (i = 0; i < s->max_b_frames + 1; i++) {
> @@ -1163,14 +1178,15 @@ static int estimate_best_b_count(MpegEncContext
> *s)
>  input[i + 1].pict_type = is_p ?
>   AV_PICTURE_TYPE_P :
> AV_PICTURE_TYPE_B;
>  input[i + 1].quality   = is_p ? p_lambda : b_lambda;
> -out_size = avcodec_encode_video(c, outbuf, outbuf_size,
> -&input[i + 1]);
> +
> +out_size = encode_frame(c, &input[i + 1]);
> +
>  rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3);
>  }
>
>  /* get the delayed frames */
>  while (out_size) {
> -out_size = avcodec_encode_video(c, outbuf, outbuf_size,
> NULL);
> +out_size = encode_frame(c, NULL);
>  rd += (out_size * lambda2) >> (FF_LAMBDA_SHIFT - 3);
>  }
>
> @@ -1182,7 +1198,6 @@ static int estimate_best_b_count(MpegEncContext *s)
>  }
>  }
>
> -av_freep(&outbuf);
>  avcodec_close(c);
>  av_freep(&c);
>
>
> ___
> libav-commits mailing list
> libav-comm...@libav.org
> https://lists.libav.org/mailman/listinfo/libav-commits
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] aacdec: more verbose overread error message

2012-08-07 Thread Alex Converse
From: Michael Niedermayer 

Signed-off-by: Michael Niedermayer 
Signed-off-by: Alex Converse 
---
 libavcodec/aacdec.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 1c59ec5..291f3bd 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -112,7 +112,7 @@
 static VLC vlc_scalefactors;
 static VLC vlc_spectral[11];
 
-static const char overread_err[] = "Input buffer exhausted before END element 
found\n";
+#define overread_err "Input buffer exhausted before END element found\n"
 
 static int count_channels(uint8_t (*layout)[3], int tags)
 {
@@ -608,7 +608,7 @@ static int decode_pce(AVCodecContext *avctx, 
MPEG4AudioConfig *m4ac,
 /* comment field, first byte is length */
 comment_len = get_bits(gb, 8) * 8;
 if (get_bits_left(gb) < comment_len) {
-av_log(avctx, AV_LOG_ERROR, overread_err);
+av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err);
 return -1;
 }
 skip_bits_long(gb, comment_len);
@@ -908,7 +908,7 @@ static int skip_data_stream_element(AACContext *ac, 
GetBitContext *gb)
 align_get_bits(gb);
 
 if (get_bits_left(gb) < 8 * count) {
-av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+av_log(ac->avctx, AV_LOG_ERROR, "skip_data_stream_element: 
"overread_err);
 return -1;
 }
 skip_bits_long(gb, 8 * count);
@@ -1039,7 +1039,7 @@ static int decode_band_types(AACContext *ac, enum 
BandType band_type[120],
 sect_len_incr = get_bits(gb, bits);
 sect_end += sect_len_incr;
 if (get_bits_left(gb) < 0) {
-av_log(ac->avctx, AV_LOG_ERROR, overread_err);
+av_log(ac->avctx, AV_LOG_ERROR, "decode_band_types: 
"overread_err);
 return -1;
 }
 if (sect_end > ics->max_sfb) {
@@ -2440,7 +2440,7 @@ static int aac_decode_frame_int(AVCodecContext *avctx, 
void *data,
 if (elem_id == 15)
 elem_id += get_bits(gb, 8) - 1;
 if (get_bits_left(gb) < 8 * elem_id) {
-av_log(avctx, AV_LOG_ERROR, overread_err);
+av_log(avctx, AV_LOG_ERROR, "TYPE_FIL: "overread_err);
 err = -1;
 goto fail;
 }
-- 
1.7.7.3

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


[libav-devel] [PATCH 1/2] aacdec: Don't fall back to the old output configuration when no old configuration is present.

2012-08-07 Thread Alex Converse
Fixes MP4 files where the first frame is broken.
---
 libavcodec/aacdec.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 958c9d2..1c59ec5 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -365,7 +365,7 @@ static void push_output_configuration(AACContext *ac) {
  * configuration is unlocked.
  */
 static void pop_output_configuration(AACContext *ac) {
-if (ac->oc[1].status != OC_LOCKED) {
+if (ac->oc[1].status != OC_LOCKED && ac->oc[0].status != OC_NONE) {
 ac->oc[1] = ac->oc[0];
 ac->avctx->channels = ac->oc[1].channels;
 ac->avctx->channel_layout = ac->oc[1].channel_layout;
-- 
1.7.7.3

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


Re: [libav-devel] [PATCH] libx264: don't set framerate, set vfr_input.

2012-08-06 Thread Alex Converse
On Sun, Aug 5, 2012 at 11:30 PM, Anton Khirnov  wrote:
> There's no way for the encoder to know whether the input is CFR, so
> assume VFR.
> ---
>  libavcodec/libx264.c |5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index adda881..72fd390 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -381,8 +381,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  x4->params.i_height = avctx->height;
>  x4->params.vui.i_sar_width  = avctx->sample_aspect_ratio.num;
>  x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
> -x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
> -x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
> +x4->params.i_timebase_den = avctx->time_base.den;
> +x4->params.i_timebase_num = avctx->time_base.num;
> +x4->params.b_vfr_input= 1;
>

Is it possible to tell if we have a "vsync 1" filter present?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] VDD and FOMS 2012

2012-08-06 Thread Alex Converse
On Sat, Aug 4, 2012 at 10:58 AM, Diego Biurrun  wrote:
> So who else is going to attend the VideoLAN Dev Days?  I know that Luca,
> Mans, Kostya and myself will be there.  Register and come to Paris :)
>

I'll be there. It's been far too long since I've seen you all.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 04/10] idcin: set channel_layout

2012-08-01 Thread Alex Converse
On Wed, Aug 1, 2012 at 2:36 PM, Justin Ruggles  wrote:
> ---
>  libavformat/idcin.c |3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/idcin.c b/libavformat/idcin.c
> index 113c66e..c8b8225 100644
> --- a/libavformat/idcin.c
> +++ b/libavformat/idcin.c
> @@ -68,6 +68,7 @@
>   *   transmitting them to the video decoder
>   */
>
> +#include "libavutil/audioconvert.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/intreadwrite.h"
>  #include "avformat.h"
> @@ -204,6 +205,8 @@ static int idcin_read_header(AVFormatContext *s)
>  st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
>  st->codec->codec_tag = 1;
>  st->codec->channels = channels;
> +st->codec->channel_layout = channels > 1 ? AV_CH_LAYOUT_STEREO :
> +   AV_CH_LAYOUT_MONO;
>  st->codec->sample_rate = sample_rate;
>  st->codec->bits_per_coded_sample = bytes_per_sample * 8;
>  st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
> --
> 1.7.1

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


Re: [libav-devel] [PATCH] eval: add workaround for broken strtod() in MSVS.

2012-07-30 Thread Alex Converse
On Mon, Jul 30, 2012 at 10:07 AM, Ronald S. Bultje  wrote:
> Hi,
>
> On Wed, Jul 25, 2012 at 10:40 PM, Luca Barbato  wrote:
>> On 07/26/2012 05:37 AM, Ronald S. Bultje wrote:
>>> From: "Ronald S. Bultje" 
>>>
>>> ---
>>>  libavutil/eval.c |   35 +++
>>>  1 file changed, 35 insertions(+)
>>>
>>
>> As for the snprintf, I'd rather have those workaround in os_support,
>> move it to libavutil and have os_support.h included.
>>
>> I'd move this code to
>>
>> ff_strtod()
>>
>> and have #define strtod ff_strtod
>
> I'm a little bit concerned about having a function called ff_strtod()
> which is only called from a function called av_strtod().
>

What about avpriv_strtod_internal()

The longer name makes it less likely someone will use it accidentally
and the avpriv_ prefix should allow it to be used in all of the
libraries.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] eval: fix printing of NaN in eval fate test.

2012-07-25 Thread Alex Converse
On Wed, Jul 25, 2012 at 8:42 PM, Ronald S. Bultje  wrote:
>
> From: "Ronald S. Bultje" 
>
> This fixes "make fate-eval" on MSVC builds. Without this, the test outputs
> "-1.#NaN" instead of "nan" on MSVS 2010.
> ---
>  libavutil/eval.c |5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/libavutil/eval.c b/libavutil/eval.c
> index ef37ad8..6131263 100644
> --- a/libavutil/eval.c
> +++ b/libavutil/eval.c
> @@ -671,6 +671,11 @@ int main(int argc, char **argv)
>  av_expr_parse_and_eval(&d, *expr,
> const_names, const_values,
> NULL, NULL, NULL, NULL, NULL, 0, NULL);
> +#ifdef _MSC_VER
> +if (isnan(d))
> +printf("'%s' -> nan\n\n", *expr);
> +else
> +#endif
>  printf("'%s' -> %f\n\n", *expr, d);
>  }
>

Funny, when I proposed this without the MSC ifdef, you were wholly against it.

And once again I will state that a conformant libc has the freedom to
print "[-]nan(n-char-sequence)". So why not just drop the ifdef?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [libav-commits] rtmp: Move the CONFIG_ condition into the if conditions

2012-07-24 Thread Alex Converse
On Tue, Jul 24, 2012 at 5:57 AM, Samuel Pitoiset  wrote:
> Module: libav
> Branch: master
> Commit: f7bfb126cde36e15048273a0e346fe2ebdc27f57
>
> Author:Samuel Pitoiset 
> Committer: Martin Storsjö 
> Date:  Tue Jul 24 13:46:28 2012 +0200
>
> rtmp: Move the CONFIG_ condition into the if conditions
>
> This makes sure these calls are removed by dead code elimination
> even if optimization is disabled. This fixes building without
> crypto libraries without optimization.
>
> Signed-off-by: Martin Storsjö 
>
> ---
>
>  libavformat/rtmpproto.c |   15 +++
>  1 files changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> index f7ba7d5..1d25ae9 100644
> --- a/libavformat/rtmpproto.c
> +++ b/libavformat/rtmpproto.c
> @@ -729,7 +728,7 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
>  for (i = 9; i <= RTMP_HANDSHAKE_PACKET_SIZE; i++)
>  tosend[i] = av_lfg_get(&rnd) >> 24;
>
> -if (encrypted) {
> +if (rt->encrypted && CONFIG_FFRTMPCRYPT_PROTOCOL) {

FWIW to get this to DCE with clang/asan 3.1
CONFIG_FFRTMPCRYPT_PROTOCOL has to come first. But that seems pretty
broken, so I'm going to migrate my asan config to O1 with some stuff
turned off as is the current asan recommendation.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] libfdk-aacenc: add LATM/LOAS encapsulation support

2012-07-23 Thread Alex Converse
On Mon, Jul 23, 2012 at 9:20 AM, Kieran Kunhya  wrote:
>
> ---
>  libavcodec/libfdk-aacenc.c |   15 ++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
> index f2c3fbd..4d7aa7b 100644
> --- a/libavcodec/libfdk-aacenc.c
> +++ b/libavcodec/libfdk-aacenc.c
> @@ -33,6 +33,8 @@ typedef struct AACContext {
>  int afterburner;
>  int eld_sbr;
>  int signaling;
> +int latm;
> +int header_period;
>
>  AudioFrameQueue afq;
>  } AACContext;
> @@ -45,6 +47,8 @@ static const AVOption aac_enc_options[] = {
>  { "implicit", "Implicit backwards compatible signaling", 0,
> AV_OPT_TYPE_CONST, { 0 }, 0, 0, AV_OPT_FLAG_AUDIO_PARAM |
> AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
>  { "explicit_sbr", "Explicit SBR, implicit PS signaling", 0,
> AV_OPT_TYPE_CONST, { 1 }, 0, 0, AV_OPT_FLAG_AUDIO_PARAM |
> AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
>  { "explicit_hierarchical", "Explicit hierarchical signaling", 0,
> AV_OPT_TYPE_CONST, { 2 }, 0, 0, AV_OPT_FLAG_AUDIO_PARAM |
> AV_OPT_FLAG_ENCODING_PARAM, "signaling" },
> +{ "latm", "Output LATM/LOAS encapsulated data", offsetof(AACContext,
> latm), AV_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM |
> AV_OPT_FLAG_ENCODING_PARAM },
> +{ "header_period", "StreamMuxConfig and PCE repetition period (in
> frames)", offsetof(AACContext, header_period), AV_OPT_TYPE_INT, { 0 }, 0,
> 0x, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
>  { NULL }
>  };
>

Don't we use a separate codec id for LATM or is that for decoding only?
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] libopenjpeg: introduce lowres and lowqual private options

2012-07-19 Thread Alex Converse
On Thu, Jul 19, 2012 at 2:33 PM, Luca Barbato  wrote:
> On 07/19/2012 10:36 PM, Johan Andersson wrote:
>> On Thu, Jul 19, 2012 at 08:59:45PM +0200, Luca Barbato wrote:
>>> OpenJPEG can decode in lower resolution or decode only a number
>>> of enhancement layers.
>>
>> Didnt we remove lowres couple of month ago for some reason?
>
> It was a global option badly implemented on codec not really supporting it.
>
> Jpeg2k supports it and the result is decent.
>

I see no problem with this. The global lowres option was a maintenance
burden that didn't work well. This adds very little complexity to our
code and (has been claimed to) work well.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 34/39] alac: split element parsing into a separate function

2012-07-19 Thread Alex Converse
On Mon, Jul 9, 2012 at 2:24 PM, Justin Ruggles  wrote:
> This will make multi-channel implementation simpler.
> Based partially on a patch by Andrew D'Addesio .
> ---
>  libavcodec/alac.c |  121 +++-
>  1 files changed, 81 insertions(+), 40 deletions(-)
>

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


Re: [libav-devel] [PATCH 35/39] alac: multi-channel decoding support

2012-07-19 Thread Alex Converse
On Thu, Jul 19, 2012 at 8:22 AM, Justin Ruggles
 wrote:
>
> On 07/09/2012 05:24 PM, Justin Ruggles wrote:
> > From: Andrew D'Addesio 
> >
> > Signed-off-by: Justin Ruggles 
> > ---
> >  libavcodec/alac.c |   61
> > +---
> >  1 files changed, 43 insertions(+), 18 deletions(-)
>
> ping.
>

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


Re: [libav-devel] [PATCH 04/39] avformat: move 'chan' tag parsing to mov_chan.c to share with the CAF demuxer

2012-07-16 Thread Alex Converse
On Sun, Jul 15, 2012 at 7:57 PM, Justin Ruggles
 wrote:
>
> On 07/15/2012 10:56 PM, Justin Ruggles wrote:
> > @@ -491,8 +491,8 @@ uint32_t ff_mov_get_channel_label(uint32_t label)
> >  }
> >
> >  uint32_t ff_mov_get_channel_layout_tag(enum CodecID codec_id,
> > -   uint64_t channel_layout,
> > -   uint32_t *bitmap)
> > +   uint64_t channel_layout,
> > +   uint32_t *bitmap)
> >  {
> >  int i, j;
> >  uint32_t tag = 0;
>
> oops. stray cosmetics. fixed locally.
>

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


Re: [libav-devel] [PATCH] libfdk-aac: Allow setting the encoder bandwidth/cutoff frequency

2012-07-12 Thread Alex Converse
On Thu, Jul 12, 2012 at 11:29 AM, Martin Storsjö  wrote:
> ---
>  libavcodec/libfdk-aacenc.c |9 +
>  1 file changed, 9 insertions(+)
>

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


Re: [libav-devel] [PATCH 1/2] libavcodec: Add more AAC profiles

2012-07-11 Thread Alex Converse
On Wed, Jul 11, 2012 at 9:45 AM, Kieran Kunhya  wrote:
> On Wed, Jul 11, 2012 at 5:44 PM, Derek Buitenhuis
>  wrote:
>> On 11/07/2012 8:38 AM, Martin Storsjö wrote:
>>> TODO: Are the mpeg2 ones official or specific to the fraunhofer
>>> encoder?
>>

The MPEG-2 ones are "fake." The word profile means very different
things in MPEG-2 and MPEG-4. These are all profiles in the MPEG-2
sense of the word. In MPEG-4 these are audio object types (because it
wouldn't be MPEG-4 if it wasn't all objects and descriptors). MPEG-4
profiles combine lists of AOTs that can be used together. More modern
(and relevant) MPEG-4 profiles (The "AAC Profile" family) map to a
single object type (and 0 or more enhancement object types). The
MPEG-2 "AOTs" used by this encoder are just MPEG-4 AOTs shifted by
127.

They can either by implemented with FF_PROFILEs or with a private
option shifting us into MPEG-2 mode.

>>
>>>  #define FF_PROFILE_AAC_LOW  1
>>>  #define FF_PROFILE_AAC_SSR  2
>>>  #define FF_PROFILE_AAC_LTP  3
>>> +#define FF_PROFILE_AAC_HE   4
>>> +#define FF_PROFILE_AAC_HE_V2 28
>>> +#define FF_PROFILE_AAC_LD   22
>>> +#define FF_PROFILE_AAC_ELD  38
>>
>> Where these numbers come from is something that needs to
>> be answered before push.
>>
>
> AOT tables in ISO/IEC 14496-3

AOT minus 1, since MAIN is zero in MPEG-2 but in MPEG-4 NULL is zero
and MAIN is one.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH 33/39] alac: support a read sample size of up to 32

2012-07-10 Thread Alex Converse
On Tue, Jul 10, 2012 at 6:20 AM, Justin Ruggles
 wrote:
> Use get_bits_long() in decode_scalar().
> Use unsigned int for decoded value.
> ---
>  libavcodec/alac.c |   21 +++--
>  1 files changed, 11 insertions(+), 10 deletions(-)
>

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


Re: [libav-devel] [PATCH 33/39] alac: use get_bits_long() in decode_scalar()

2012-07-10 Thread Alex Converse
On Tue, Jul 10, 2012 at 4:24 AM, Justin Ruggles
 wrote:
> On 07/09/2012 07:14 PM, Alex Converse wrote:
>> On Mon, Jul 9, 2012 at 2:24 PM, Justin Ruggles  
>> wrote:
>>> allows for a larger sample size than MIN_CACHE_BITS
>>> ---
>>>  libavcodec/alac.c |9 ++---
>>>  1 files changed, 2 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/libavcodec/alac.c b/libavcodec/alac.c
>>> index 5f2c8a0..0e62adb 100644
>>> --- a/libavcodec/alac.c
>>> +++ b/libavcodec/alac.c
>>> @@ -84,7 +84,7 @@ static inline int decode_scalar(GetBitContext *gb, int k, 
>>> int readsamplesize)
>>>
>>>  if (x > 8) { /* RICE THRESHOLD */
>>>  /* use alternative encoding */
>>> -x = get_bits(gb, readsamplesize);
>>> +x = get_bits_long(gb, readsamplesize);
>>>  } else if (k != 1) {
>>>  int extrabits = show_bits(gb, k);
>>>
>>> @@ -294,6 +294,7 @@ static int alac_decode_frame(AVCodecContext *avctx, 
>>> void *data,
>>>  hassize = get_bits1(&alac->gb);
>>>
>>>  alac->extra_bits = get_bits(&alac->gb, 2) << 3;
>>> +readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
>>>
>>>  /* whether the frame is compressed */
>>>  is_compressed = !get_bits1(&alac->gb);
>>> @@ -321,12 +322,6 @@ static int alac_decode_frame(AVCodecContext *avctx, 
>>> void *data,
>>>  alac->output_samples_buffer[ch] = (int32_t 
>>> *)alac->frame.data[ch];
>>>  }
>>>
>>> -readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
>>> -if (readsamplesize > MIN_CACHE_BITS) {
>>> -av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", 
>>> readsamplesize);
>>> -return -1;
>>> -}
>>> -
>>
>> What about the case where sample_size = 32, channels = 6, and
>> extra_bits is 0? It seems possible and results in readsamplesize = 37
>> which is still too big.
>
> Yeah, I suppose we should check for that case. In practice it won't
> happen though. For one thing, channels cannot be 6 here. It's 1 or 2
> because it is per-element. The most it could be is 33. The reference
> alac encoder uses 16 extra bits for 32-bit, so it's really only a
> theoretical problem. I'll send an updated patch that handles the corner
> cases.
>

Just to be clear, I'm not proposing you need to handle cases where
it's more than 32 bits, only that you error out if the bitstream gives
you that value.

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


Re: [libav-devel] [PATCH 33/39] alac: use get_bits_long() in decode_scalar()

2012-07-09 Thread Alex Converse
On Mon, Jul 9, 2012 at 2:24 PM, Justin Ruggles  wrote:
> allows for a larger sample size than MIN_CACHE_BITS
> ---
>  libavcodec/alac.c |9 ++---
>  1 files changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/alac.c b/libavcodec/alac.c
> index 5f2c8a0..0e62adb 100644
> --- a/libavcodec/alac.c
> +++ b/libavcodec/alac.c
> @@ -84,7 +84,7 @@ static inline int decode_scalar(GetBitContext *gb, int k, 
> int readsamplesize)
>
>  if (x > 8) { /* RICE THRESHOLD */
>  /* use alternative encoding */
> -x = get_bits(gb, readsamplesize);
> +x = get_bits_long(gb, readsamplesize);
>  } else if (k != 1) {
>  int extrabits = show_bits(gb, k);
>
> @@ -294,6 +294,7 @@ static int alac_decode_frame(AVCodecContext *avctx, void 
> *data,
>  hassize = get_bits1(&alac->gb);
>
>  alac->extra_bits = get_bits(&alac->gb, 2) << 3;
> +readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
>
>  /* whether the frame is compressed */
>  is_compressed = !get_bits1(&alac->gb);
> @@ -321,12 +322,6 @@ static int alac_decode_frame(AVCodecContext *avctx, void 
> *data,
>  alac->output_samples_buffer[ch] = (int32_t 
> *)alac->frame.data[ch];
>  }
>
> -readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
> -if (readsamplesize > MIN_CACHE_BITS) {
> -av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", 
> readsamplesize);
> -return -1;
> -}
> -

What about the case where sample_size = 32, channels = 6, and
extra_bits is 0? It seems possible and results in readsamplesize = 37
which is still too big.


>  if (is_compressed) {
>  int16_t predictor_coef_table[MAX_CHANNELS][32];
>  int predictor_coef_num[MAX_CHANNELS];
> --
> 1.7.1
>
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] dvbsubdec: Always log into a context.

2012-07-09 Thread Alex Converse
---
 libavcodec/dvbsubdec.c |   29 -
 1 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index cc14622..f5fc7f2 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -318,7 +318,7 @@ static void delete_region_display_list(DVBSubContext *ctx, 
DVBSubRegion *region)
 
 }
 
-static void delete_state(DVBSubContext *ctx)
+static void delete_state(AVCodecContext *avctx, DVBSubContext *ctx)
 {
 DVBSubRegion *region;
 DVBSubCLUT *clut;
@@ -345,7 +345,7 @@ static void delete_state(DVBSubContext *ctx)
 
 /* Should already be null */
 if (ctx->object_list)
-av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n");
+av_log(avctx, AV_LOG_ERROR, "Memory deallocation error!\n");
 }
 
 static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
@@ -430,7 +430,7 @@ static av_cold int dvbsub_close_decoder(AVCodecContext 
*avctx)
 DVBSubContext *ctx = avctx->priv_data;
 DVBSubRegionDisplay *display;
 
-delete_state(ctx);
+delete_state(avctx, ctx);
 
 while (ctx->display_list) {
 display = ctx->display_list;
@@ -442,7 +442,8 @@ static av_cold int dvbsub_close_decoder(AVCodecContext 
*avctx)
 return 0;
 }
 
-static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len,
+static int dvbsub_read_2bit_string(AVCodecContext *avctx,
+   uint8_t *destbuf, int dbuf_len,
const uint8_t **srcbuf, int buf_size,
int non_mod, uint8_t *map_table)
 {
@@ -540,14 +541,15 @@ static int dvbsub_read_2bit_string(uint8_t *destbuf, int 
dbuf_len,
 }
 
 if (get_bits(&gb, 6))
-av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+av_log(avctx, AV_LOG_ERROR, "line overflow\n");
 
 (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
 
 return pixels_read;
 }
 
-static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len,
+static int dvbsub_read_4bit_string(AVCodecContext *avctx,
+   uint8_t *destbuf, int dbuf_len,
const uint8_t **srcbuf, int buf_size,
int non_mod, uint8_t *map_table)
 {
@@ -661,14 +663,15 @@ static int dvbsub_read_4bit_string(uint8_t *destbuf, int 
dbuf_len,
 }
 
 if (get_bits(&gb, 8))
-av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+av_log(avctx, AV_LOG_ERROR, "line overflow\n");
 
 (*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
 
 return pixels_read;
 }
 
-static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len,
+static int dvbsub_read_8bit_string(AVCodecContext *avctx,
+uint8_t *destbuf, int dbuf_len,
 const uint8_t **srcbuf, int buf_size,
 int non_mod, uint8_t *map_table)
 {
@@ -720,7 +723,7 @@ static int dvbsub_read_8bit_string(uint8_t *destbuf, int 
dbuf_len,
 }
 
 if (*(*srcbuf)++)
-av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+av_log(avctx, AV_LOG_ERROR, "line overflow\n");
 
 return pixels_read;
 }
@@ -785,7 +788,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext 
*avctx, DVBSubObjectDis
 else
 map_table = NULL;
 
-x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + 
x_pos,
+x_pos += dvbsub_read_2bit_string(avctx, pbuf + (y_pos * 
region->width) + x_pos,
 region->width - x_pos, &buf, 
buf_end - buf,
 non_mod, map_table);
 break;
@@ -800,7 +803,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext 
*avctx, DVBSubObjectDis
 else
 map_table = NULL;
 
-x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + 
x_pos,
+x_pos += dvbsub_read_4bit_string(avctx, pbuf + (y_pos * 
region->width) + x_pos,
 region->width - x_pos, &buf, 
buf_end - buf,
 non_mod, map_table);
 break;
@@ -810,7 +813,7 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext 
*avctx, DVBSubObjectDis
 return;
 }
 
-x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + 
x_pos,
+x_pos += dvbsub_read_8bit_string(avctx, pbuf + (y_pos * 
region->width) + x_pos,
 region->width - x_pos, &buf, 
buf_end - buf,
 non_mod, NULL);
 break;
@@ -1114,7 +1117,7 @@ static void dvbsub_parse_page_segment(AVCodecContext 
*avctx,
 av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
 
 if (page_state == 2) {
-delete

Re: [libav-devel] [PATCH 04/39] avformat: move 'chan' tag parsing to mov_chan.c to share with the CAF demuxer

2012-07-09 Thread Alex Converse
On Mon, Jul 9, 2012 at 2:23 PM, Justin Ruggles  wrote:
> ---
>  libavformat/cafdec.c   |6 ++
>  libavformat/mov.c  |   39 +--
>  libavformat/mov_chan.c |   44 
>  libavformat/mov_chan.h |   11 +++
>  4 files changed, 62 insertions(+), 38 deletions(-)
>

Some symbols (e.g. ff_mov_get_channel_label,
ff_mov_get_channel_layout_tag) could be made static. Although making
them static could be needless churn if we are planning on enhancing
support for chan in the muxer.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


  1   2   3   4   5   6   7   8   9   10   >