[FFmpeg-devel] [PATCH 2/2] lavc/audiotoolboxdec: add eac3 decoder

2016-03-30 Thread Rodger Combs
This is added in 10.11, so we add a #define when building against older SDKs.

The decoder actually supports 7.1-channel eac3, but since the parser only
reports 6 channels, we end up decoding the 5.1 downmix (same as the internal
decoder) for now.
---
 configure| 1 +
 libavcodec/Makefile  | 1 +
 libavcodec/allcodecs.c   | 1 +
 libavcodec/audiotoolboxdec.c | 7 +++
 4 files changed, 10 insertions(+)

diff --git a/configure b/configure
index e550547..f984a13 100755
--- a/configure
+++ b/configure
@@ -2650,6 +2650,7 @@ ac3_at_decoder_deps="audiotoolbox"
 adpcm_ima_qt_at_decoder_deps="audiotoolbox"
 alac_at_decoder_deps="audiotoolbox"
 amr_nb_at_decoder_deps="audiotoolbox"
+eac3_at_decoder_deps="audiotoolbox"
 gsm_ms_at_decoder_deps="audiotoolbox"
 ilbc_at_decoder_deps="audiotoolbox"
 mp1_at_decoder_deps="audiotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 8c14268..801cccd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -806,6 +806,7 @@ OBJS-$(CONFIG_AC3_AT_DECODER) += 
audiotoolboxdec.o
 OBJS-$(CONFIG_ADPCM_IMA_QT_AT_DECODER)+= audiotoolboxdec.o
 OBJS-$(CONFIG_ALAC_AT_DECODER)+= audiotoolboxdec.o
 OBJS-$(CONFIG_AMR_NB_AT_DECODER)  += audiotoolboxdec.o
+OBJS-$(CONFIG_EAC3_AT_DECODER)+= audiotoolboxdec.o
 OBJS-$(CONFIG_GSM_MS_AT_DECODER)  += audiotoolboxdec.o
 OBJS-$(CONFIG_ILBC_AT_DECODER)+= audiotoolboxdec.o
 OBJS-$(CONFIG_MP1_AT_DECODER) += audiotoolboxdec.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index f498041..0bbf7d3 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -568,6 +568,7 @@ void avcodec_register_all(void)
 REGISTER_DECODER(ADPCM_IMA_QT_AT,   adpcm_ima_qt_at);
 REGISTER_ENCDEC (ALAC_AT,   alac_at);
 REGISTER_DECODER(AMR_NB_AT, amr_nb_at);
+REGISTER_DECODER(EAC3_AT,   eac3_at);
 REGISTER_DECODER(GSM_MS_AT, gsm_ms_at);
 REGISTER_ENCDEC (ILBC_AT,   ilbc_at);
 REGISTER_DECODER(MP1_AT,mp1_at);
diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index 4ff46ea..f840a6b 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -30,6 +30,10 @@
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 
+#ifndef __MAC_10_11
+#define kAudioFormatEnhancedAC3 'ec-3'
+#endif
+
 typedef struct ATDecodeContext {
 AVClass *av_class;
 
@@ -58,6 +62,8 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int 
profile)
 return kAudioFormatAppleLossless;
 case AV_CODEC_ID_AMR_NB:
 return kAudioFormatAMR;
+case AV_CODEC_ID_EAC3:
+return kAudioFormatEnhancedAC3;
 case AV_CODEC_ID_GSM_MS:
 return kAudioFormatMicrosoftGSM;
 case AV_CODEC_ID_ILBC:
@@ -512,6 +518,7 @@ FFAT_DEC(ac3,  AV_CODEC_ID_AC3)
 FFAT_DEC(adpcm_ima_qt, AV_CODEC_ID_ADPCM_IMA_QT)
 FFAT_DEC(alac, AV_CODEC_ID_ALAC)
 FFAT_DEC(amr_nb,   AV_CODEC_ID_AMR_NB)
+FFAT_DEC(eac3, AV_CODEC_ID_EAC3)
 FFAT_DEC(gsm_ms,   AV_CODEC_ID_GSM_MS)
 FFAT_DEC(ilbc, AV_CODEC_ID_ILBC)
 FFAT_DEC(mp1,  AV_CODEC_ID_MP1)
-- 
2.7.3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavc/audiotoolboxdec: fix a number of config and timestamp issues

2016-03-30 Thread Rodger Combs
- ADTS-formatted AAC didn't work
- Channel layouts were never exported
- Channel mappings were incorrect beyond stereo
- Channel counts weren't updated after packets were decoded
- Timestamps were exported incorrectly
---
 libavcodec/audiotoolboxdec.c | 286 +--
 1 file changed, 221 insertions(+), 65 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index 1fa6f16..4ff46ea 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -38,8 +38,9 @@ typedef struct ATDecodeContext {
 AVPacket in_pkt;
 AVPacket new_in_pkt;
 AVBitStreamFilterContext *bsf;
+char *decoded_data;
+int channel_map[64];
 
-unsigned pkt_size;
 int64_t last_pts;
 int eof;
 } ATDecodeContext;
@@ -81,20 +82,127 @@ static UInt32 ffat_get_format_id(enum AVCodecID codec, int 
profile)
 }
 }
 
-static void ffat_update_ctx(AVCodecContext *avctx)
+static int ffat_get_channel_id(AudioChannelLabel label)
+{
+if (label == 0)
+return -1;
+else if (label <= kAudioChannelLabel_LFEScreen)
+return label - 1;
+else if (label <= kAudioChannelLabel_RightSurround)
+return label + 4;
+else if (label <= kAudioChannelLabel_CenterSurround)
+return label + 1;
+else if (label <= kAudioChannelLabel_RightSurroundDirect)
+return label + 23;
+else if (label <= kAudioChannelLabel_TopBackRight)
+return label - 1;
+else if (label < kAudioChannelLabel_RearSurroundLeft)
+return -1;
+else if (label <= kAudioChannelLabel_RearSurroundRight)
+return label - 29;
+else if (label <= kAudioChannelLabel_RightWide)
+return label - 4;
+else if (label == kAudioChannelLabel_LFE2)
+return ff_ctzll(AV_CH_LOW_FREQUENCY_2);
+else if (label == kAudioChannelLabel_Mono)
+return ff_ctzll(AV_CH_FRONT_CENTER);
+else
+return -1;
+}
+
+static int ffat_compare_channel_descriptions(const void* a, const void* b)
+{
+const AudioChannelDescription* da = a;
+const AudioChannelDescription* db = b;
+return ffat_get_channel_id(da->mChannelLabel) - 
ffat_get_channel_id(db->mChannelLabel);
+}
+
+static AudioChannelLayout *ffat_convert_layout(AudioChannelLayout *layout, 
UInt32* size)
+{
+AudioChannelLayoutTag tag = layout->mChannelLayoutTag;
+AudioChannelLayout *new_layout;
+if (tag == kAudioChannelLayoutTag_UseChannelDescriptions)
+return layout;
+else if (tag == kAudioChannelLayoutTag_UseChannelBitmap)
+AudioFormatGetPropertyInfo(kAudioFormatProperty_ChannelLayoutForBitmap,
+   sizeof(UInt32), >mChannelBitmap, 
size);
+else
+AudioFormatGetPropertyInfo(kAudioFormatProperty_ChannelLayoutForTag,
+   sizeof(AudioChannelLayoutTag), , size);
+new_layout = av_malloc(*size);
+if (!new_layout) {
+av_free(layout);
+return NULL;
+}
+if (tag == kAudioChannelLayoutTag_UseChannelBitmap)
+AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutForBitmap,
+   sizeof(UInt32), >mChannelBitmap, size, 
new_layout);
+else
+AudioFormatGetProperty(kAudioFormatProperty_ChannelLayoutForTag,
+   sizeof(AudioChannelLayoutTag), , size, 
new_layout);
+new_layout->mChannelLayoutTag = 
kAudioChannelLayoutTag_UseChannelDescriptions;
+av_free(layout);
+return new_layout;
+}
+
+static int ffat_update_ctx(AVCodecContext *avctx)
 {
 ATDecodeContext *at = avctx->priv_data;
-AudioStreamBasicDescription in_format;
-UInt32 size = sizeof(in_format);
+AudioStreamBasicDescription format;
+UInt32 size = sizeof(format);
 if (!AudioConverterGetProperty(at->converter,

kAudioConverterCurrentInputStreamDescription,
-   , _format)) {
-avctx->channels = in_format.mChannelsPerFrame;
-at->pkt_size = in_format.mFramesPerPacket;
+   , )) {
+if (format.mSampleRate)
+avctx->sample_rate = format.mSampleRate;
+avctx->channels = format.mChannelsPerFrame;
+avctx->channel_layout = av_get_default_channel_layout(avctx->channels);
+avctx->frame_size = format.mFramesPerPacket;
+}
+
+if (!AudioConverterGetProperty(at->converter,
+   
kAudioConverterCurrentOutputStreamDescription,
+   , )) {
+format.mSampleRate = avctx->sample_rate;
+format.mChannelsPerFrame = avctx->channels;
+AudioConverterSetProperty(at->converter,
+  
kAudioConverterCurrentOutputStreamDescription,
+  size, );
+}
+
+if (!AudioConverterGetPropertyInfo(at->converter, 
kAudioConverterOutputChannelLayout,
+   , NULL) 

Re: [FFmpeg-devel] [PATCH] avformat/latmenc: automatically insert aac_adtstoasc bitstream filter when needed

2016-03-30 Thread James Almer
On 3/30/2016 9:14 PM, Ronald S. Bultje wrote:
> Hi,
> 
> On Sat, Mar 26, 2016 at 12:45 AM, James Almer  wrote:
> 
>> Signed-off-by: James Almer 
>> ---
>>  libavformat/latmenc.c | 20 +++-
>>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> 
> lgtm.
> 
> Ronald

Pushed, thanks.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: new colorspace conversion filter.

2016-03-30 Thread Michael Niedermayer
On Wed, Mar 30, 2016 at 04:35:18PM -0400, Ronald S. Bultje wrote:
> The intent here is similar to colormatrix, but it's LGPLv2.1-or-later
> (instead of GPLv2.0) and supports gamma/chromaticity correction.
> ---
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/colorspacedsp.c  | 130 ++
>  libavfilter/colorspacedsp.h  |  51 +++
>  libavfilter/colorspacedsp_template.c | 256 
>  libavfilter/vf_colorspace.c  | 773 
> +++
>  6 files changed, 1212 insertions(+)
>  create mode 100644 libavfilter/colorspacedsp.c
>  create mode 100644 libavfilter/colorspacedsp.h
>  create mode 100644 libavfilter/colorspacedsp_template.c
>  create mode 100644 libavfilter/vf_colorspace.c

It would be better if all colorspace and pixel convert code would be
in the same lib.
Especially for automatic convertion

swscale since last GSoC applies the individual scale and convert steps
through a more generic system, and should be possible to add this
in there. Quite possibly that would be more work and require some more
changes and cleanup in swscale.
swscale also supports spliting convertions into multiple swscalers,
so you could easily have a swscale that uses this as a special
converter connected to a 2nd swscale that does all the rest.

Also iam sure pedro would help and awnser any questions as his time
permits about the improvments added in last GSoC.

anyway thats not a objection, i just think this isnt the best way
to implement this

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

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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


Re: [FFmpeg-devel] [PATCH] avformat/latmenc: automatically insert aac_adtstoasc bitstream filter when needed

2016-03-30 Thread Ronald S. Bultje
Hi,

On Sat, Mar 26, 2016 at 12:45 AM, James Almer  wrote:

> Signed-off-by: James Almer 
> ---
>  libavformat/latmenc.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)


lgtm.

Ronald
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/aacenc_quantization: Fix undefined behavior and instead detect and print an error

2016-03-30 Thread Claudio Freire
On Wed, Mar 30, 2016 at 10:15 AM, Claudio Freire  wrote:
> On Wed, Mar 30, 2016 at 8:33 AM, Michael Niedermayer
>  wrote:
>> On Wed, Mar 30, 2016 at 02:04:20AM -0300, Claudio Freire wrote:
>>> On Wed, Mar 30, 2016 at 1:18 AM, Claudio Freire  
>>> wrote:
>>> > On Tue, Mar 29, 2016 at 10:51 PM, Michael Niedermayer
>>> >  wrote:
>>> >> This is a hotfix and not a real fix of the underlaying bug
>>> >> The underlaying bug is ATM not fully understood
>>> >>
>>> >> iam not sure if we should apply this or not
>>> >>
>>> >> Signed-off-by: Michael Niedermayer 
>>> >> ---
>>> >>  libavcodec/aacenc_quantization.h |   13 +++--
>>> >>  1 file changed, 11 insertions(+), 2 deletions(-)
>>> >>
>>> >> diff --git a/libavcodec/aacenc_quantization.h 
>>> >> b/libavcodec/aacenc_quantization.h
>>> >> index 4250407..d367be0 100644
>>> >> --- a/libavcodec/aacenc_quantization.h
>>> >> +++ b/libavcodec/aacenc_quantization.h
>>> >> @@ -141,8 +141,17 @@ static av_always_inline float 
>>> >> quantize_and_encode_band_cost_template(
>>> >>  if (BT_ESC) {
>>> >>  for (j = 0; j < 2; j++) {
>>> >>  if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 
>>> >> 64.0f) {
>>> >> -int coef = av_clip_uintp2(quant(fabsf(in[i+j]), 
>>> >> Q, ROUNDING), 13);
>>> >> -int len = av_log2(coef);
>>> >> +float a = fabsf(in[i+j]) * Q;
>>> >> +double f = sqrtf(a * sqrtf(a)) + ROUNDING;
>>> >> +int coef, len;
>>> >> +
>>> >> +if (f > INT_MAX || f < 16) {
>>> >> +av_log(NULL, AV_LOG_ERROR, "f %f is out of 
>>> >> range this is a internal error\n", f);
>>> >> +f = INT_MAX;
>>> >> +}
>>> >> +
>>> >> +coef = av_clip_uintp2(f, 13);
>>> >> +len = av_log2(coef);
>>> >>
>>> >>  put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) 
>>> >> - 2);
>>> >>  put_sbits(pb, len, coef);
>>> >
>>> > Actually I just understood the underlying bug and am testing a fix.
>>> >
>>> > Basically, scalefactors need to be bound by (roughly)
>>> > coef2minsf(maxval), which isn't being done atm, and some signals
>>> > prompt the encoder to pick lower and lower scalefactors trying to
>>> > consume unspent bits that cannot really be consumed.
>>>
>>> Try the attached diff instead (I'm not able to reproduce the issue with gcc)
>>
>> seems to fix it (with gcc didnt try clang but fate will once its
>> pushed)
>>
>> Thanks
>
>
> Pushed

In case anyone is worrying about the latest related breakage, don't.
I've got a fix for that one too, I just cannot push it from where I am
ATM. Will do ASAP when I get to my computer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/latmenc: automatically insert aac_adtstoasc bitstream filter when needed

2016-03-30 Thread James Almer
On 3/26/2016 1:45 AM, James Almer wrote:
> Signed-off-by: James Almer 
> ---
>  libavformat/latmenc.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 

Ping.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 06/10] swscale/arm/yuv2rgb: only process one line at a time for the yuv420p and nv{12, 21} formats

2016-03-30 Thread Benoit Fouet

Hi,

Le 26/03/2016 13:05, Matthieu Bouron a écrit :

On Sat, Mar 26, 2016 at 2:09 AM, Michael Niedermayer wrote:
>On Fri, Mar 25, 2016 at 11:46:01PM +0100, Matthieu Bouron wrote:

> >From: Matthieu Bouron
> >
> >---
> >  libswscale/arm/yuv2rgb_neon.S | 89

>---

> >  1 file changed, 24 insertions(+), 65 deletions(-)

>
>breaks build
>
>  make distclean ; ../configure --cross-prefix=/usr/arm-linux-gnueabi/bin/
>--cc='ccache arm-linux-gnueabi-gcc-4.5' --extra-cflags='-mfpu=neon
>-mfloat-abi=softfp' --cpu=cortex-a8 --arch=armv7 --target-os=linux
>--enable-cross-compile && make -j12
>
>CC  libavutil/arm/float_dsp_init_arm.o
>src/libswscale/arm/yuv2rgb_neon.S: Assembler messages:
>src/libswscale/arm/yuv2rgb_neon.S:269: Error: thumb conditional
>instruction should be in IT block -- `subeq r6,r6,r0'
>src/libswscale/arm/yuv2rgb_neon.S:269: Error: thumb conditional
>instruction should be in IT block -- `addne r6,r7'
>

[...]

Patch updated with the relevant it instructions added. It still does build
on my rpi2 setup but is not tested on the same setup as yours.
Can you confirm it builds/works on your setup ?

If it works, i will send an updated version of the next patch (07/10) to
resolve the conflicts.

Matthieu

0006-swscale-arm-yuv2rgb-only-process-one-line-at-a-time-.patch


 From 7b3a405b2b483fb16f549b69ce6f21d8a946 Mon Sep 17 00:00:00 2001
From: Matthieu Bouron
Date: Wed, 23 Mar 2016 11:26:13 +
Subject: [PATCH 06/10] swscale/arm/yuv2rgb: only process one line at a time
  for the yuv420p and nv{12,21} formats

---
  libswscale/arm/yuv2rgb_neon.S | 92 +--
  1 file changed, 27 insertions(+), 65 deletions(-)

diff --git a/libswscale/arm/yuv2rgb_neon.S b/libswscale/arm/yuv2rgb_neon.S
index ef7b0a6..6aeccae 100644
--- a/libswscale/arm/yuv2rgb_neon.S
+++ b/libswscale/arm/yuv2rgb_neon.S
@@ -105,16 +105,6 @@
  compute_16pxr2, d14, d15, \ofmt
  .endm
  
-.macro process_2l_16px ofmt

-compute_premult d28, d29, d30, d31
-
-vld1.8  {q7}, [r4]!@ first 
line of luma
-compute_16pxr2, d14, d15, \ofmt
-
-vld1.8  {q7}, [r12]!   @ 
second line of luma
-compute_16pxr11, d14, d15, \ofmt
-.endm
-
  .macro load_args_nvx
  push{r4-r12, lr}
  vpush   {q4-q7}
@@ -127,13 +117,9 @@
  ldr r10,[sp, #128] @ r10 
= y_coeff
  vdup.16 d0, r10@ d0  
= y_coeff
  vld1.16 {d1}, [r8] @ d1  
= *table
-add r11, r2, r3@ r11 = 
dst + linesize (dst2)
-add r12, r4, r5@ r12 = 
srcY + linesizeY (srcY2)


Nit: this lets r11 and r12 unused by the NV conversions. It should be 
possible not to push/pop them
If not (which I would certainly understand), what would you think about 
moving the registers save out of the 'load_args_*' macro?
It seems weird to have all the push/vpush that are not factored, and the 
pop/vpop that is done in only one place, at the end of each function.


[snip]

Looks good to me anyway (as well as the remainder of the series).

--
Ben

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 02/10] swscale/arm/yuv2rgb: fix comments and factorize lsl in load_args_yuv422p

2016-03-30 Thread Benoit Fouet

Hi,

Le 25/03/2016 23:45, Matthieu Bouron a écrit :

From: Matthieu Bouron

---
  libswscale/arm/yuv2rgb_neon.S | 9 -
  1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libswscale/arm/yuv2rgb_neon.S b/libswscale/arm/yuv2rgb_neon.S
index f40327b..aac0773 100644
--- a/libswscale/arm/yuv2rgb_neon.S
+++ b/libswscale/arm/yuv2rgb_neon.S
@@ -172,11 +172,10 @@
  vdup.16 d0, r10@ d0  
= y_coeff
  vld1.16 {d1}, [r8] @ d1  
= *table
  add r11, r2, r3@ r11 
= dst + linesize (dst2)
-lsl r8, r0, #2
-sub r3, r3, r8 @ r3 = 
linesize  * 2 - width * 4 (padding)
-sub r5, r5, r0 @ r5 = 
linesizeY * 2 - width (paddingY)
-sub r7, r7, r0, lsr #1 @ r7 = 
linesizeU - width / 2 (paddingU)
-sub r12,r12,r0, lsr #1 @ r12 = 
linesizeV- width / 2 (paddingV)
+sub r3, r3, r0, lsl #2 @ r3  = 
linesize  - width * 4 (padding)
+sub r5, r5, r0 @ r5  = 
linesizeY - width (paddingY)
+sub r7, r7, r0, lsr #1 @ r7  = 
linesizeU - width / 2 (paddingU)
+sub r12,r12,r0, lsr #1 @ r12 = 
linesizeV - width / 2 (paddingV)
  ldr r10,[sp, #120] @ r10 
= srcV
  .endm
  


nit: it would be cool to split: one for the comments and the other one 
for the lsl factorization.


--
Ben

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] fate: Add filter-metadata-cropdetect

2016-03-30 Thread Michael Niedermayer
On Thu, Mar 24, 2016 at 06:05:33PM +0100, Michael Niedermayer wrote:
> Signed-off-by: Michael Niedermayer 
> ---
>  tests/fate/filter-video.mak   |6 ++
>  tests/ref/fate/filter-metadata-cropdetect |   32 
> +
>  2 files changed, 38 insertions(+)
>  create mode 100644 tests/ref/fate/filter-metadata-cropdetect

applied

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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


Re: [FFmpeg-devel] [PATCHv2] add signature filter for MPEG7 video signature

2016-03-30 Thread Gerion Entrup
On Mittwoch, 30. März 2016 22:57:47 CEST Gerion Entrup wrote:
> Add improved patch.

Rebased to master.

>From 9646ed6f0cf78356cf2914a60705c98d8f21fe8a Mon Sep 17 00:00:00 2001
From: Gerion Entrup 
Date: Sun, 20 Mar 2016 11:10:31 +0100
Subject: [PATCH] add signature filter for MPEG7 video signature

This filter does not implement all features of MPEG7. Missing features:
- compression of signature files
- work only on (cropped) parts of the video
---
 Changelog  |   1 +
 configure  |   1 +
 doc/filters.texi   |  70 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/signature.h| 554 ++
 libavfilter/signature_lookup.c | 550 ++
 libavfilter/version.h  |   4 +-
 libavfilter/vf_signature.c | 741 +
 9 files changed, 1921 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/signature.h
 create mode 100644 libavfilter/signature_lookup.c
 create mode 100644 libavfilter/vf_signature.c

diff --git a/Changelog b/Changelog
index 7b0187d..8a2b7fd 100644
--- a/Changelog
+++ b/Changelog
@@ -18,6 +18,7 @@ version :
 - coreimage filter (GPU based image filtering on OSX)
 - libdcadec removed
 - bitstream filter for extracting DTS core
+- MPEG-7 Video Signature filter
 
 version 3.0:
 - Common Encryption (CENC) MP4 encoding and decoding support
diff --git a/configure b/configure
index e550547..fe29827 100755
--- a/configure
+++ b/configure
@@ -2979,6 +2979,7 @@ showspectrum_filter_deps="avcodec"
 showspectrum_filter_select="fft"
 showspectrumpic_filter_deps="avcodec"
 showspectrumpic_filter_select="fft"
+signature_filter_deps="gpl avcodec avformat"
 smartblur_filter_deps="gpl swscale"
 sofalizer_filter_deps="netcdf avcodec"
 sofalizer_filter_select="fft"
diff --git a/doc/filters.texi b/doc/filters.texi
index 5d6cf52..a95f5a7 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11559,6 +11559,76 @@ saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
 @end example
 @end itemize
 
+@anchor{signature}
+@section signature
+
+Calculates the MPEG-7 Video Signature. The filter could handle more than one
+input. In this case the matching between the inputs could be calculated. The
+filter passthrough the first input. The output is written in XML.
+
+It accepts the following options:
+
+@table @option
+@item mode
+Enable the calculation of the matching. The option value must be 0 (to disable
+or 1 (to enable). Optionally you can set the mode to 2. Then the detection ends,
+if the first matching sequence it reached. This should be slightly faster.
+Per default the detection is disabled.
+
+@item nb_inputs
+Set the number of inputs. The option value must be a non negative interger.
+Default value is 1.
+
+@item filename
+Set the path to witch the output is written. If there is more than one input,
+the path must be a prototype, i.e. must contain %d or %0nd (where n is a positive
+integer), that will be replaced with the input number. If no filename is
+specified, no output will be written. This is the default.
+
+@item xml
+Choose the output format. If set to 1 the filter will write XML, if set to 0
+the filter will write binary output. The default is 0.
+
+@item th_d
+Set threshold to detect one word as similar. The option value must be an integer
+greater than zero. The default value is 9000.
+
+@item th_dc
+Set threshold to detect all words as similar. The option value must be an integer
+greater than zero. The default value is 6.
+
+@item th_xh
+Set threshold to detect frames as similar. The option value must be an integer
+greater than zero. The default value is 116.
+
+@item th_di
+Set the minimum length of a sequence in frames to recognize it as matching
+sequence. The option value must be a non negative integer value.
+The default value is 0.
+
+@item th_it
+Set the minimum relation, that matching frames to all frames must have.
+The option value must be a double value between 0 and 1. The default value is 0.5.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+To calculate the signature of an input video and store it in signature.xml:
+@example
+ffmpeg -i input.mkv -vf signature=filename=signature.xml -map 0:v -c rawvideo -f null -
+@end example
+
+@item
+To detect whether two videos matches and store the signatures in
+signature0.xml and signature1.xml:
+@example
+ffmpeg -i input1.mkv -i input2.mkv -filter_complex "[0:0][1:0] signature=nb_inputs=2:detectmode=1signature%d.xml" -map 0:v -map 1:v -c rawvideo -f null -
+@end example
+
+@end itemize
+
 @anchor{smartblur}
 @section smartblur
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b6e1999..9cd0d22 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -246,6 +246,7 @@ OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
 OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  += 

Re: [FFmpeg-devel] [PATCHv2] add signature filter for MPEG7 video signature

2016-03-30 Thread Gerion Entrup
On Mittwoch, 30. März 2016 15:29:27 CEST Michael Niedermayer wrote:
> On Wed, Mar 30, 2016 at 01:57:24PM +0200, Gerion Entrup wrote:
> > Attached improved version of patch.
> > 
> > Differences to last time:
> > - reduce amount of errors in the signature (the last patch included some int
> > foo = a/b). This version replaces this with a rational.
> > - implement binary output.
> > - fixes in configure, some typos
> > 
> > I have found the conformance testfiles [1]. Both the binary and the xml 
> > output
> > passes the conformance test but are not bitexact. I wrote some python script
> > to prove this (see attachment). I don't see why this happens. If someone 
> > want
> > to help, the correspondent reference code is in the file
> > "ExtractionUtilities/VideoSignatureExtraction.cpp" beginning with line 1615,
> > that could be found here [2].
> > 
> > Then a few questions:
> > - The timebase of the testfiles is 9. In the binary output 
> > unfortunately there
> > is only place for a 16 bit number, so this don't fit. Currently the code 
> > simply crop
> > remaining bits. Is there a better solution (devide with some number etc)?
> > 
> > - I try to use put_bits32 where it is possible, because I thought is is 
> > faster. Then
> > I saw it internally uses put_bits as well. Does it have a performance 
> > impact to
> > replace it with put_bits(..., 8, ...) (would simplify the code a lot)?
> > 
> > Gerion
> > 
> > [1] 
> > http://standards.iso.org/ittf/PubliclyAvailableStandards/c057047_ISO_IEC_15938-7_2003_Amd_6_2011_Conformance_Testing.zip
> > [2] 
> > http://standards.iso.org/ittf/PubliclyAvailableStandards/c056735_ISO_IEC_15938-6_2003_Amd_4_2011_Electronic_inserts.zip
> 
> >  Changelog  |1 
> >  configure  |1 
> >  doc/filters.texi   |   70 +++
> >  libavfilter/Makefile   |1 
> >  libavfilter/allfilters.c   |1 
> >  libavfilter/signature.h|  574 ++
> >  libavfilter/signature_lookup.c |  527 +++
> >  libavfilter/version.h  |4 
> >  libavfilter/vf_signature.c |  774 
> > +
> >  9 files changed, 1951 insertions(+), 2 deletions(-)
> > 18a73574782a4e5e576bed3857fd283a009ff532  
> > 0001-add-signature-filter-for-MPEG7-video-signature.patch
> > From c81db6a999694f01335ee0d88483f276f2d10d3f Mon Sep 17 00:00:00 2001
> > From: Gerion Entrup 
> > Date: Sun, 20 Mar 2016 11:10:31 +0100
> > Subject: [PATCH] add signature filter for MPEG7 video signature
> > 
> > This filter does not implement all features of MPEG7. Missing features:
> > - compression of signature files
> > - work only on (cropped) parts of the video
> > ---
> >  Changelog  |   1 +
> >  configure  |   1 +
> >  doc/filters.texi   |  70 
> >  libavfilter/Makefile   |   1 +
> >  libavfilter/allfilters.c   |   1 +
> >  libavfilter/signature.h| 574 ++
> >  libavfilter/signature_lookup.c | 527 
> >  libavfilter/version.h  |   4 +-
> >  libavfilter/vf_signature.c | 774 
> > +
> >  9 files changed, 1951 insertions(+), 2 deletions(-)
> >  create mode 100644 libavfilter/signature.h
> >  create mode 100644 libavfilter/signature_lookup.c
> >  create mode 100644 libavfilter/vf_signature.c
> > 
> > diff --git a/Changelog b/Changelog
> > index 1f57f5e..5b76607 100644
> > --- a/Changelog
> > +++ b/Changelog
> > @@ -12,6 +12,7 @@ version :
> >  - ciescope filter
> >  - protocol blacklisting API
> >  - MediaCodec H264 decoding
> > +- MPEG-7 Video Signature filter
> >  
> >  
> >  version 3.0:
> [...]
> 
> > +typedef struct {
> > +int x;
> > +int y;
> > +} Point;
> > +
> > +typedef struct {
> > +Point up;
> > +Point to;
> > +} Block;
> 
> these are used for tables of small values, int which is 32bit
> would waste quite some space, can uint8_t be used too ?
Yes, all Points are < 32 .

> 
> 
> [...]
> > +/* bitcount[index] = amount of ones in (binary) index */
> > +static const int bitcount[256] =
> > +{
> > +  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
> > +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> > +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> > +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> > +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> > +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,

[FFmpeg-devel] [PATCH] lavfi: new colorspace conversion filter.

2016-03-30 Thread Ronald S. Bultje
The intent here is similar to colormatrix, but it's LGPLv2.1-or-later
(instead of GPLv2.0) and supports gamma/chromaticity correction.
---
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/colorspacedsp.c  | 130 ++
 libavfilter/colorspacedsp.h  |  51 +++
 libavfilter/colorspacedsp_template.c | 256 
 libavfilter/vf_colorspace.c  | 773 +++
 6 files changed, 1212 insertions(+)
 create mode 100644 libavfilter/colorspacedsp.c
 create mode 100644 libavfilter/colorspacedsp.h
 create mode 100644 libavfilter/colorspacedsp_template.c
 create mode 100644 libavfilter/vf_colorspace.c

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index b6e1999..9b7546d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -131,6 +131,7 @@ OBJS-$(CONFIG_COLORCHANNELMIXER_FILTER)  += 
vf_colorchannelmixer.o
 OBJS-$(CONFIG_COLORKEY_FILTER)   += vf_colorkey.o
 OBJS-$(CONFIG_COLORLEVELS_FILTER)+= vf_colorlevels.o
 OBJS-$(CONFIG_COLORMATRIX_FILTER)+= vf_colormatrix.o
+OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspacedsp.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)+= vf_convolution.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
 OBJS-$(CONFIG_COREIMAGE_FILTER)  += vf_coreimage.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 5c18fd1..3fc450f 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -152,6 +152,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(COLORKEY,   colorkey,   vf);
 REGISTER_FILTER(COLORLEVELS,colorlevels,vf);
 REGISTER_FILTER(COLORMATRIX,colormatrix,vf);
+REGISTER_FILTER(COLORSPACE, colorspace, vf);
 REGISTER_FILTER(CONVOLUTION,convolution,vf);
 REGISTER_FILTER(COPY,   copy,   vf);
 REGISTER_FILTER(COREIMAGE,  coreimage,  vf);
diff --git a/libavfilter/colorspacedsp.c b/libavfilter/colorspacedsp.c
new file mode 100644
index 000..e71bf1f
--- /dev/null
+++ b/libavfilter/colorspacedsp.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2016 Ronald S. Bultje 
+ *
+ * This file is part of FFmpeg.
+ *
+ * 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
+ */
+
+#include "colorspacedsp.h"
+
+#define SS_W 0
+#define SS_H 0
+
+#define BIT_DEPTH 8
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 10
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 12
+#include "colorspacedsp_template.c"
+
+#undef SS_W
+#undef SS_H
+
+#define SS_W 1
+#define SS_H 0
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 8
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 10
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 12
+#include "colorspacedsp_template.c"
+
+#undef SS_W
+#undef SS_H
+
+#define SS_W 1
+#define SS_H 1
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 8
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 10
+#include "colorspacedsp_template.c"
+
+#undef BIT_DEPTH
+#define BIT_DEPTH 12
+#include "colorspacedsp_template.c"
+
+static void multiply3x3_c(int16_t *buf[3], ptrdiff_t stride,
+  int w, int h, const int16_t m[3][3][8])
+{
+int y, x;
+int16_t *buf0 = buf[0], *buf1 = buf[1], *buf2 = buf[2];
+
+for (y = 0; y < h; y++) {
+for (x = 0; x < w; x++) {
+int v0 = buf0[x], v1 = buf1[x], v2 = buf2[x];
+
+buf0[x] = av_clip_int16((m[0][0][0] * v0 + m[0][1][0] * v1 +
+ m[0][2][0] * v2 + 8192) >> 14);
+buf1[x] = av_clip_int16((m[1][0][0] * v0 + m[1][1][0] * v1 +
+ m[1][2][0] * v2 + 8192) >> 14);
+buf2[x] = av_clip_int16((m[2][0][0] * v0 + m[2][1][0] * v1 +
+ m[2][2][0] * v2 + 8192) >> 14);
+}
+
+buf0 += stride;
+buf1 += stride;
+buf2 += stride;
+}
+}
+
+void ff_colorspacedsp_init(ColorSpaceDSPContext *dsp)
+{
+dsp->yuv2rgb[0][0] = yuv2rgb_444_8_c;
+dsp->yuv2rgb[0][1] = yuv2rgb_422_8_c;
+dsp->yuv2rgb[0][2] = yuv2rgb_420_8_c;
+

Re: [FFmpeg-devel] [PATCH 6/6] lavc/audiotoolboxdec: fix a number of config and timestamp issues

2016-03-30 Thread Rodger Combs

> On Mar 30, 2016, at 04:57, pon pon  
> wrote:
> 
> not a regression. this have happened since the first patch.
> i use osx1095. does this issue depend on os versions? your version?
> i have attached samples. samples other than ticket #5369 are made from
> ticket #5369, using ffmpeg.
> 
> if that helps, we can know differences of apis of os versions in the below.
> https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_11/index.html#//apple_ref/doc/uid/TP40016197
> https://developer.apple.com/library/mac/releasenotes/MacOSX/WhatsNewInOSX/WhatsNewInOSX.html#//apple_ref/doc/uid/TP40001812
> 
> ponpon
> 
> http://speedy.sh/rqZ4x/test-stereo.mkv
> http://speedy.sh/3F59z/test-stereo.ac3
> http://speedy.sh/DpxAu/test.ac3
> http://speedy.sh/vZzKQ/test.mkv
> 

It's possible your OSX version just doesn't have the relevant decoder. Could 
you try using `afplay` to play the raw ac3 files? If that fails, then it's an 
OS issue and not a lavc bug, so this result is expected.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] fate: add demux test for TS with AC3 (Ticket 4864)

2016-03-30 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 tests/fate/demux.mak|3 +++
 tests/ref/fate/ts-demux |   23 +++
 2 files changed, 26 insertions(+)
 create mode 100644 tests/ref/fate/ts-demux

diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index d6508c2..dad77ec 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -126,6 +126,9 @@ fate-xmv-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/xmv/logos1p.fmv -vcodec copy
 FATE_SAMPLES_DEMUX-$(CONFIG_XWMA_DEMUXER) += fate-xwma-demux
 fate-xwma-demux: CMD = crc -i $(TARGET_SAMPLES)/xwma/ergon.xwma -acodec copy
 
+FATE_SAMPLES_DEMUX-$(CONFIG_MPEGTS_DEMUXER) += fate-ts-demux
+fate-ts-demux: CMD = framecrc -i $(TARGET_SAMPLES)/ac3/mp3ac325-4864-small.ts 
-codec copy
+
 FATE_SAMPLES_DEMUX += $(FATE_SAMPLES_DEMUX-yes)
 FATE_SAMPLES_FFMPEG += $(FATE_SAMPLES_DEMUX)
 fate-demux: $(FATE_SAMPLES_DEMUX)
diff --git a/tests/ref/fate/ts-demux b/tests/ref/fate/ts-demux
new file mode 100644
index 000..1d867b3
--- /dev/null
+++ b/tests/ref/fate/ts-demux
@@ -0,0 +1,23 @@
+#extradata 0:  150, 0xb4192fb9
+#tb 0: 1/9
+#tb 1: 1/9
+1,  0,  0, 2880, 1536, 0x773ffeea, S=1,1, 
0x00bd00bd
+1,   2880,   2880, 2880, 1536, 0x6dc10748
+1,   5760,   5760, 2880, 1536, 0xbab5129c
+1,   8640,   8640, 2880, 1536, 0x602f034b
+1,  11520,  11520, 2880,  906, 0x69cdcbcd
+0,  32037,  36541, 1501,   114336, 0x37a215a8, S=1,1, 
0x00e000e0
+0,  33538,  33538, 1501,12560, 0xb559a3d4, F=0x0, S=1,
1, 0x00e000e0
+0,  35040,  35040, 1501,12704, 0x2614adf4, F=0x0, S=1,
1, 0x00e000e0
+0,  36541,  41046, 1501,51976, 0x9ff1dbfe, F=0x0, S=1,
1, 0x00e000e0
+0,  38043,  38043, 1501,13096, 0x4ff9ea23, F=0x0, S=1,
1, 0x00e000e0
+0,  39544,  39544, 1501,13744, 0xf2b2402a, F=0x0, S=1,
1, 0x00e000e0
+0,  41046,  45550, 1501,56568, 0x65f5aee1, F=0x0, S=1,
1, 0x00e000e0
+0,  42547,  42547, 1501,14720, 0x8855866c, F=0x0, S=1,
1, 0x00e000e0
+0,  44049,  44049, 1501,15216, 0x83cbc4fc, F=0x0, S=1,
1, 0x00e000e0
+0,  45550,  50055, 1501,61720, 0xecda6b05, F=0x0, S=1,
1, 0x00e000e0
+0,  47052,  47052, 1501,17416, 0xdf480c6d, F=0x0, S=1,
1, 0x00e000e0
+0,  48553,  48553, 1501,18144, 0x1950624c, F=0x0, S=1,
1, 0x00e000e0
+0,  50055,  54559, 1501,56848, 0xd4f315be, F=0x0, S=1,
1, 0x00e000e0
+0,  51556,  51556, 1501,16296, 0xd391a1d0, F=0x0, S=1,
1, 0x00e000e0
+0,  53058,  53058, 1501, 4944, 0x4d88640e, F=0x0
-- 
1.7.9.5

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Implement hdcd filtering

2016-03-30 Thread Michael Niedermayer
On Wed, Mar 30, 2016 at 11:42:47AM +0200, Benjamin St wrote:
> >
> > fails make fate
> 
> It's due to the copyright header. I still don't know how to handle this
> correct as this filter is based on https://github.com/kode54/foo_hdcd/,
> which contains:
> 
> > 1. Redistributions of source code must retain the above copyright
> > notice, this list of conditions and the following disclaimer.

if the license is compatible with the LGPL then you could be added to
the exceptions

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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


Re: [FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c

2016-03-30 Thread Michael Niedermayer
On Wed, Mar 30, 2016 at 10:12:29AM +, Petru Rares Sincraian wrote:
> Hi,
> 
> I solved the problems with swscale_license() and alloc_gamma_tbl() functions. 
> I am working to solve alphaless_fmt() function in a different way.
> 
> 
> From: ffmpeg-devel  on behalf of Michael 
> Niedermayer 
> Sent: Sunday, March 27, 2016 9:43 PM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c
> 
> On Sun, Mar 27, 2016 at 04:39:39PM +, Petru Rares Sincraian wrote:
> >
> >   - Added test for: swscale_license()
> >   - Added test for: alphaless_fmt()
> >   - Added test for: alloc_gamma_tbl()
> [...]
> 
> > +static void test_alloc_gamma_tbl(void)
> > +{
> > +uint16_t *tbl = alloc_gamma_tbl(1.);
> > +int i;
> > +
> > +// print only 32 elements
> > +printf("e = 1.0\n");
> > +for (i = 0; i < 65536; i += 2048)
> > +printf("it: %d\t value: %d\n", i, tbl[i]);
> > +
> > +tbl = alloc_gamma_tbl(0.75);
> > +printf("\ne = 0.75\n");
> > +for (i = 0; i < 65536; i += 2048)
> > +printf("it: %d\t value: %d\n", i, tbl[i]);
> > +
> > +tbl = alloc_gamma_tbl(2.8);
> > +printf("\ne = 2.8\n");
> > +for (i = 0; i < 65536; i += 2048)
> > +printf("it: %d\t value: %d\n", i, tbl[i]);
> 
> this leaks memory
> 
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
> 
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope

>  libswscale/Makefile   |1 
>  libswscale/utils.c|   49 +
>  tests/Makefile|1 
>  tests/fate/libswscale.mak |6 ++
>  tests/ref/fate/utils  |  105 
> ++
>  5 files changed, 162 insertions(+)
> f3e7cf692c31bf2df982eeeb97fc6fef8e3ec736  
> 0001-Added-more-tests-to-libswscale-utils.c.patch
> From ebefe53b13c878d50f5a388022c894d2b2c5ee96 Mon Sep 17 00:00:00 2001
> From: Petru Rares Sincraian 
> Date: Thu, 24 Mar 2016 18:46:02 +0100
> Subject: [PATCH] Added more tests to libswscale/utils.c
> 
>   - Added test for: swscale_license()
>   - Added test for: alloc_gamma_tbl()
> ---
>  libswscale/Makefile   |   1 +
>  libswscale/utils.c|  49 ++
>  tests/Makefile|   1 +
>  tests/fate/libswscale.mak |   6 +++
>  tests/ref/fate/utils  | 105 
> ++
>  5 files changed, 162 insertions(+)
>  create mode 100644 tests/fate/libswscale.mak
>  create mode 100644 tests/ref/fate/utils
> 
> diff --git a/libswscale/Makefile b/libswscale/Makefile
> index a9f9e03..a6ae81d 100644
> --- a/libswscale/Makefile
> +++ b/libswscale/Makefile
> @@ -27,3 +27,4 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
>  
>  TESTPROGS = colorspace  \
>  swscale \
> +utils   \
> diff --git a/libswscale/utils.c b/libswscale/utils.c
> index ba409d6..b572a11 100644
> --- a/libswscale/utils.c
> +++ b/libswscale/utils.c
> @@ -2410,3 +2410,52 @@ struct SwsContext *sws_getCachedContext(struct 
> SwsContext *context, int srcW,
>  }
>  return context;
>  }
> +
> +#ifdef TEST
> +

> +static void test_swscale_license(void)
> +{
> +const char *license = swscale_license();
> +if (!strcmp(FFMPEG_LICENSE, license))
> +printf("License OK\n");
> +else
> +printf("License don't match.\nExpect: %s\nGiven: %s\n",
> +FFMPEG_LICENSE, license);
> +}


> +
> +static void test_alloc_gamma_tbl(void)
> +{
> +uint16_t *tbl;
> +int i;
> +
> +// print only 32 elements
> +tbl = alloc_gamma_tbl(1.);
> +printf("e = 1.0\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);
> +av_free(tbl);
> +
> +tbl = alloc_gamma_tbl(0.75);
> +printf("\ne = 0.75\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);
> +av_free(tbl);
> +
> +tbl = alloc_gamma_tbl(2.8);
> +printf("\ne = 2.8\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);
> +av_free(tbl);
> +
> +}

missing malloc failure checks
also a better way to test matematical tables is to check how close
they are to the ideal double precission values
dumping all values to a file would detect changes but not give
any information about if the changes are better or worse so printing
the sum of squared differences or something should be more usefull


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes


signature.asc

Re: [FFmpeg-devel] [PATCHv2] add signature filter for MPEG7 video signature

2016-03-30 Thread Michael Niedermayer
On Wed, Mar 30, 2016 at 01:57:24PM +0200, Gerion Entrup wrote:
> Attached improved version of patch.
> 
> Differences to last time:
> - reduce amount of errors in the signature (the last patch included some int
> foo = a/b). This version replaces this with a rational.
> - implement binary output.
> - fixes in configure, some typos
> 
> I have found the conformance testfiles [1]. Both the binary and the xml output
> passes the conformance test but are not bitexact. I wrote some python script
> to prove this (see attachment). I don't see why this happens. If someone want
> to help, the correspondent reference code is in the file
> "ExtractionUtilities/VideoSignatureExtraction.cpp" beginning with line 1615,
> that could be found here [2].
> 
> Then a few questions:
> - The timebase of the testfiles is 9. In the binary output unfortunately 
> there
> is only place for a 16 bit number, so this don't fit. Currently the code 
> simply crop
> remaining bits. Is there a better solution (devide with some number etc)?
> 
> - I try to use put_bits32 where it is possible, because I thought is is 
> faster. Then
> I saw it internally uses put_bits as well. Does it have a performance impact 
> to
> replace it with put_bits(..., 8, ...) (would simplify the code a lot)?
> 
> Gerion
> 
> [1] 
> http://standards.iso.org/ittf/PubliclyAvailableStandards/c057047_ISO_IEC_15938-7_2003_Amd_6_2011_Conformance_Testing.zip
> [2] 
> http://standards.iso.org/ittf/PubliclyAvailableStandards/c056735_ISO_IEC_15938-6_2003_Amd_4_2011_Electronic_inserts.zip

>  Changelog  |1 
>  configure  |1 
>  doc/filters.texi   |   70 +++
>  libavfilter/Makefile   |1 
>  libavfilter/allfilters.c   |1 
>  libavfilter/signature.h|  574 ++
>  libavfilter/signature_lookup.c |  527 +++
>  libavfilter/version.h  |4 
>  libavfilter/vf_signature.c |  774 
> +
>  9 files changed, 1951 insertions(+), 2 deletions(-)
> 18a73574782a4e5e576bed3857fd283a009ff532  
> 0001-add-signature-filter-for-MPEG7-video-signature.patch
> From c81db6a999694f01335ee0d88483f276f2d10d3f Mon Sep 17 00:00:00 2001
> From: Gerion Entrup 
> Date: Sun, 20 Mar 2016 11:10:31 +0100
> Subject: [PATCH] add signature filter for MPEG7 video signature
> 
> This filter does not implement all features of MPEG7. Missing features:
> - compression of signature files
> - work only on (cropped) parts of the video
> ---
>  Changelog  |   1 +
>  configure  |   1 +
>  doc/filters.texi   |  70 
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/signature.h| 574 ++
>  libavfilter/signature_lookup.c | 527 
>  libavfilter/version.h  |   4 +-
>  libavfilter/vf_signature.c | 774 
> +
>  9 files changed, 1951 insertions(+), 2 deletions(-)
>  create mode 100644 libavfilter/signature.h
>  create mode 100644 libavfilter/signature_lookup.c
>  create mode 100644 libavfilter/vf_signature.c
> 
> diff --git a/Changelog b/Changelog
> index 1f57f5e..5b76607 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -12,6 +12,7 @@ version :
>  - ciescope filter
>  - protocol blacklisting API
>  - MediaCodec H264 decoding
> +- MPEG-7 Video Signature filter
>  
>  
>  version 3.0:
[...]

> +typedef struct {
> +int x;
> +int y;
> +} Point;
> +
> +typedef struct {
> +Point up;
> +Point to;
> +} Block;

these are used for tables of small values, int which is 32bit
would waste quite some space, can uint8_t be used too ?


[...]
> +/* bitcount[index] = amount of ones in (binary) index */
> +static const int bitcount[256] =
> +{
> +  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
> +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> +  1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> +  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
> +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> +  3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
> +  4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
> +};

av_popcount()
that also does 4 bytes at a time


[...]
> +static int get_l1dist(AVFilterContext *ctx, SignatureContext *sc, uint8_t 
> *first, uint8_t *second)
> +{
> +unsigned int i;
> +int dist = 0;
> +int f,s;
> +
> 

Re: [FFmpeg-devel] [PATCH] avcodec/aacenc_quantization: Fix undefined behavior and instead detect and print an error

2016-03-30 Thread Claudio Freire
On Wed, Mar 30, 2016 at 8:33 AM, Michael Niedermayer
 wrote:
> On Wed, Mar 30, 2016 at 02:04:20AM -0300, Claudio Freire wrote:
>> On Wed, Mar 30, 2016 at 1:18 AM, Claudio Freire  
>> wrote:
>> > On Tue, Mar 29, 2016 at 10:51 PM, Michael Niedermayer
>> >  wrote:
>> >> This is a hotfix and not a real fix of the underlaying bug
>> >> The underlaying bug is ATM not fully understood
>> >>
>> >> iam not sure if we should apply this or not
>> >>
>> >> Signed-off-by: Michael Niedermayer 
>> >> ---
>> >>  libavcodec/aacenc_quantization.h |   13 +++--
>> >>  1 file changed, 11 insertions(+), 2 deletions(-)
>> >>
>> >> diff --git a/libavcodec/aacenc_quantization.h 
>> >> b/libavcodec/aacenc_quantization.h
>> >> index 4250407..d367be0 100644
>> >> --- a/libavcodec/aacenc_quantization.h
>> >> +++ b/libavcodec/aacenc_quantization.h
>> >> @@ -141,8 +141,17 @@ static av_always_inline float 
>> >> quantize_and_encode_band_cost_template(
>> >>  if (BT_ESC) {
>> >>  for (j = 0; j < 2; j++) {
>> >>  if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 
>> >> 64.0f) {
>> >> -int coef = av_clip_uintp2(quant(fabsf(in[i+j]), 
>> >> Q, ROUNDING), 13);
>> >> -int len = av_log2(coef);
>> >> +float a = fabsf(in[i+j]) * Q;
>> >> +double f = sqrtf(a * sqrtf(a)) + ROUNDING;
>> >> +int coef, len;
>> >> +
>> >> +if (f > INT_MAX || f < 16) {
>> >> +av_log(NULL, AV_LOG_ERROR, "f %f is out of 
>> >> range this is a internal error\n", f);
>> >> +f = INT_MAX;
>> >> +}
>> >> +
>> >> +coef = av_clip_uintp2(f, 13);
>> >> +len = av_log2(coef);
>> >>
>> >>  put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 
>> >> 2);
>> >>  put_sbits(pb, len, coef);
>> >
>> > Actually I just understood the underlying bug and am testing a fix.
>> >
>> > Basically, scalefactors need to be bound by (roughly)
>> > coef2minsf(maxval), which isn't being done atm, and some signals
>> > prompt the encoder to pick lower and lower scalefactors trying to
>> > consume unspent bits that cannot really be consumed.
>>
>> Try the attached diff instead (I'm not able to reproduce the issue with gcc)
>
> seems to fix it (with gcc didnt try clang but fate will once its
> pushed)
>
> Thanks


Pushed
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCHv2] add signature filter for MPEG7 video signature

2016-03-30 Thread Gerion Entrup
Attached improved version of patch.

Differences to last time:
- reduce amount of errors in the signature (the last patch included some int
foo = a/b). This version replaces this with a rational.
- implement binary output.
- fixes in configure, some typos

I have found the conformance testfiles [1]. Both the binary and the xml output
passes the conformance test but are not bitexact. I wrote some python script
to prove this (see attachment). I don't see why this happens. If someone want
to help, the correspondent reference code is in the file
"ExtractionUtilities/VideoSignatureExtraction.cpp" beginning with line 1615,
that could be found here [2].

Then a few questions:
- The timebase of the testfiles is 9. In the binary output unfortunately 
there
is only place for a 16 bit number, so this don't fit. Currently the code simply 
crop
remaining bits. Is there a better solution (devide with some number etc)?

- I try to use put_bits32 where it is possible, because I thought is is faster. 
Then
I saw it internally uses put_bits as well. Does it have a performance impact to
replace it with put_bits(..., 8, ...) (would simplify the code a lot)?

Gerion

[1] 
http://standards.iso.org/ittf/PubliclyAvailableStandards/c057047_ISO_IEC_15938-7_2003_Amd_6_2011_Conformance_Testing.zip
[2] 
http://standards.iso.org/ittf/PubliclyAvailableStandards/c056735_ISO_IEC_15938-6_2003_Amd_4_2011_Electronic_inserts.zip>From c81db6a999694f01335ee0d88483f276f2d10d3f Mon Sep 17 00:00:00 2001
From: Gerion Entrup 
Date: Sun, 20 Mar 2016 11:10:31 +0100
Subject: [PATCH] add signature filter for MPEG7 video signature

This filter does not implement all features of MPEG7. Missing features:
- compression of signature files
- work only on (cropped) parts of the video
---
 Changelog  |   1 +
 configure  |   1 +
 doc/filters.texi   |  70 
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/signature.h| 574 ++
 libavfilter/signature_lookup.c | 527 
 libavfilter/version.h  |   4 +-
 libavfilter/vf_signature.c | 774 +
 9 files changed, 1951 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/signature.h
 create mode 100644 libavfilter/signature_lookup.c
 create mode 100644 libavfilter/vf_signature.c

diff --git a/Changelog b/Changelog
index 1f57f5e..5b76607 100644
--- a/Changelog
+++ b/Changelog
@@ -12,6 +12,7 @@ version :
 - ciescope filter
 - protocol blacklisting API
 - MediaCodec H264 decoding
+- MPEG-7 Video Signature filter
 
 
 version 3.0:
diff --git a/configure b/configure
index e5de306..372b847 100755
--- a/configure
+++ b/configure
@@ -2953,6 +2953,7 @@ showspectrum_filter_deps="avcodec"
 showspectrum_filter_select="fft"
 showspectrumpic_filter_deps="avcodec"
 showspectrumpic_filter_select="fft"
+signature_filter_deps="gpl avcodec avformat"
 smartblur_filter_deps="gpl swscale"
 sofalizer_filter_deps="netcdf avcodec"
 sofalizer_filter_select="fft"
diff --git a/doc/filters.texi b/doc/filters.texi
index c093927..feb9c7a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -11444,6 +11444,76 @@ saturation maximum: %@{metadata:lavfi.signalstats.SATMAX@}
 @end example
 @end itemize
 
+@anchor{signature}
+@section signature
+
+Calculates the MPEG-7 Video Signature. The filter could handle more than one
+input. In this case the matching between the inputs could be calculated. The
+filter passthrough the first input. The output is written in XML.
+
+It accepts the following options:
+
+@table @option
+@item mode
+Enable the calculation of the matching. The option value must be 0 (to disable
+or 1 (to enable). Optionally you can set the mode to 2. Then the detection ends,
+if the first matching sequence it reached. This should be slightly faster.
+Per default the detection is disabled.
+
+@item nb_inputs
+Set the number of inputs. The option value must be a non negative interger.
+Default value is 1.
+
+@item filename
+Set the path to witch the output is written. If there is more than one input,
+the path must be a prototype, i.e. must contain %d or %0nd (where n is a positive
+integer), that will be replaced with the input number. If no filename is
+specified, no output will be written. This is the default.
+
+@item xml
+Choose the output format. If set to 1 the filter will write XML, if set to 0
+the filter will write binary output. The default is 0.
+
+@item th_d
+Set threshold to detect one word as similar. The option value must be an integer
+greater than zero. The default value is 9000.
+
+@item th_dc
+Set threshold to detect all words as similar. The option value must be an integer
+greater than zero. The default value is 6.
+
+@item th_xh
+Set threshold to detect frames as similar. The option value must be an integer
+greater than zero. The default value is 116.
+
+@item th_di
+Set the 

Re: [FFmpeg-devel] [PATCH] avcodec/aacenc_quantization: Fix undefined behavior and instead detect and print an error

2016-03-30 Thread Michael Niedermayer
On Wed, Mar 30, 2016 at 02:04:20AM -0300, Claudio Freire wrote:
> On Wed, Mar 30, 2016 at 1:18 AM, Claudio Freire  
> wrote:
> > On Tue, Mar 29, 2016 at 10:51 PM, Michael Niedermayer
> >  wrote:
> >> This is a hotfix and not a real fix of the underlaying bug
> >> The underlaying bug is ATM not fully understood
> >>
> >> iam not sure if we should apply this or not
> >>
> >> Signed-off-by: Michael Niedermayer 
> >> ---
> >>  libavcodec/aacenc_quantization.h |   13 +++--
> >>  1 file changed, 11 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavcodec/aacenc_quantization.h 
> >> b/libavcodec/aacenc_quantization.h
> >> index 4250407..d367be0 100644
> >> --- a/libavcodec/aacenc_quantization.h
> >> +++ b/libavcodec/aacenc_quantization.h
> >> @@ -141,8 +141,17 @@ static av_always_inline float 
> >> quantize_and_encode_band_cost_template(
> >>  if (BT_ESC) {
> >>  for (j = 0; j < 2; j++) {
> >>  if (ff_aac_codebook_vectors[cb-1][curidx*2+j] == 
> >> 64.0f) {
> >> -int coef = av_clip_uintp2(quant(fabsf(in[i+j]), 
> >> Q, ROUNDING), 13);
> >> -int len = av_log2(coef);
> >> +float a = fabsf(in[i+j]) * Q;
> >> +double f = sqrtf(a * sqrtf(a)) + ROUNDING;
> >> +int coef, len;
> >> +
> >> +if (f > INT_MAX || f < 16) {
> >> +av_log(NULL, AV_LOG_ERROR, "f %f is out of 
> >> range this is a internal error\n", f);
> >> +f = INT_MAX;
> >> +}
> >> +
> >> +coef = av_clip_uintp2(f, 13);
> >> +len = av_log2(coef);
> >>
> >>  put_bits(pb, len - 4 + 1, (1 << (len - 4 + 1)) - 
> >> 2);
> >>  put_sbits(pb, len, coef);
> >
> > Actually I just understood the underlying bug and am testing a fix.
> >
> > Basically, scalefactors need to be bound by (roughly)
> > coef2minsf(maxval), which isn't being done atm, and some signals
> > prompt the encoder to pick lower and lower scalefactors trying to
> > consume unspent bits that cannot really be consumed.
> 
> Try the attached diff instead (I'm not able to reproduce the issue with gcc)

seems to fix it (with gcc didnt try clang but fate will once its
pushed)

Thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


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


Re: [FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c

2016-03-30 Thread Petru Rares Sincraian
Hi,

I solved the problems with swscale_license() and alloc_gamma_tbl() functions. I 
am working to solve alphaless_fmt() function in a different way.


From: ffmpeg-devel  on behalf of Michael 
Niedermayer 
Sent: Sunday, March 27, 2016 9:43 PM
To: FFmpeg development discussions and patches
Subject: Re: [FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c

On Sun, Mar 27, 2016 at 04:39:39PM +, Petru Rares Sincraian wrote:
>
>   - Added test for: swscale_license()
>   - Added test for: alphaless_fmt()
>   - Added test for: alloc_gamma_tbl()
[...]

> +static void test_alloc_gamma_tbl(void)
> +{
> +uint16_t *tbl = alloc_gamma_tbl(1.);
> +int i;
> +
> +// print only 32 elements
> +printf("e = 1.0\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);
> +
> +tbl = alloc_gamma_tbl(0.75);
> +printf("\ne = 0.75\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);
> +
> +tbl = alloc_gamma_tbl(2.8);
> +printf("\ne = 2.8\n");
> +for (i = 0; i < 65536; i += 2048)
> +printf("it: %d\t value: %d\n", i, tbl[i]);

this leaks memory

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

In a rich man's house there is no place to spit but his face.
-- Diogenes of SinopeFrom ebefe53b13c878d50f5a388022c894d2b2c5ee96 Mon Sep 17 00:00:00 2001
From: Petru Rares Sincraian 
Date: Thu, 24 Mar 2016 18:46:02 +0100
Subject: [PATCH] Added more tests to libswscale/utils.c

	- Added test for: swscale_license()
	- Added test for: alloc_gamma_tbl()
---
 libswscale/Makefile   |   1 +
 libswscale/utils.c|  49 ++
 tests/Makefile|   1 +
 tests/fate/libswscale.mak |   6 +++
 tests/ref/fate/utils  | 105 ++
 5 files changed, 162 insertions(+)
 create mode 100644 tests/fate/libswscale.mak
 create mode 100644 tests/ref/fate/utils

diff --git a/libswscale/Makefile b/libswscale/Makefile
index a9f9e03..a6ae81d 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -27,3 +27,4 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
 
 TESTPROGS = colorspace  \
 swscale \
+utils   \
diff --git a/libswscale/utils.c b/libswscale/utils.c
index ba409d6..b572a11 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -2410,3 +2410,52 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context, int srcW,
 }
 return context;
 }
+
+#ifdef TEST
+
+static void test_swscale_license(void)
+{
+const char *license = swscale_license();
+if (!strcmp(FFMPEG_LICENSE, license))
+printf("License OK\n");
+else
+printf("License don't match.\nExpect: %s\nGiven: %s\n",
+FFMPEG_LICENSE, license);
+}
+
+static void test_alloc_gamma_tbl(void)
+{
+uint16_t *tbl;
+int i;
+
+// print only 32 elements
+tbl = alloc_gamma_tbl(1.);
+printf("e = 1.0\n");
+for (i = 0; i < 65536; i += 2048)
+printf("it: %d\t value: %d\n", i, tbl[i]);
+av_free(tbl);
+
+tbl = alloc_gamma_tbl(0.75);
+printf("\ne = 0.75\n");
+for (i = 0; i < 65536; i += 2048)
+printf("it: %d\t value: %d\n", i, tbl[i]);
+av_free(tbl);
+
+tbl = alloc_gamma_tbl(2.8);
+printf("\ne = 2.8\n");
+for (i = 0; i < 65536; i += 2048)
+printf("it: %d\t value: %d\n", i, tbl[i]);
+av_free(tbl);
+
+}
+
+int main(void)
+{
+printf("Testing swscale_license()\n");
+test_swscale_license();
+
+printf("\nTesting alloc_gamma_tbl()\n");
+test_alloc_gamma_tbl();
+}
+
+#endif
diff --git a/tests/Makefile b/tests/Makefile
index 6fef0cd..4e82a69 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -140,6 +140,7 @@ include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavresample.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
+include $(SRC_PATH)/tests/fate/libswscale.mak
 include $(SRC_PATH)/tests/fate/lossless-audio.mak
 include $(SRC_PATH)/tests/fate/lossless-video.mak
 include $(SRC_PATH)/tests/fate/microsoft.mak
diff --git a/tests/fate/libswscale.mak b/tests/fate/libswscale.mak
new file mode 100644
index 000..2bd7139
--- /dev/null
+++ b/tests/fate/libswscale.mak
@@ -0,0 +1,6 @@
+FATE_LIBAVSWSCALE += fate-utils
+fate-utils: libswscale/utils-test$(EXESUF)
+fate-utils: CMD = run libswscale/utils-test
+
+FATE-$(CONFIG_SWSCALE) += $(FATE_LIBAVSWSCALE)
+fate-libavswscale: $(FATE_LIBAVSWSCALE)
diff --git a/tests/ref/fate/utils b/tests/ref/fate/utils
new file mode 100644
index 000..3743b82
--- /dev/null
+++ b/tests/ref/fate/utils
@@ -0,0 +1,105 

Re: [FFmpeg-devel] [PATCH 6/6] lavc/audiotoolboxdec: fix a number of config and timestamp issues

2016-03-30 Thread pon pon
2016-03-30 6:00 GMT+09:00 Rodger Combs :

>
>
> Is this a regression in these patches, or did this already happen?
> I haven't seen this issue in my local tests with AC3 streams; can you
> provide a sample?
>

not a regression. this have happened since the first patch.
i use osx1095. does this issue depend on os versions? your version?
i have attached samples. samples other than ticket #5369 are made from
ticket #5369, using ffmpeg.

if that helps, we can know differences of apis of os versions in the below.
https://developer.apple.com/library/mac/releasenotes/General/APIDiffsMacOSX10_11/index.html#//apple_ref/doc/uid/TP40016197
https://developer.apple.com/library/mac/releasenotes/MacOSX/WhatsNewInOSX/WhatsNewInOSX.html#//apple_ref/doc/uid/TP40001812

ponpon

http://speedy.sh/rqZ4x/test-stereo.mkv
http://speedy.sh/3F59z/test-stereo.ac3
http://speedy.sh/DpxAu/test.ac3
http://speedy.sh/vZzKQ/test.mkv


2016-03-30 6:00 GMT+09:00 Rodger Combs :

>
> > On Mar 28, 2016, at 00:39, pon pon 
> wrote:
> >
> > 2016-03-28 2:20 GMT+09:00 Rodger Combs :
> >
> >> - ADTS-formatted AAC didn't work
> >> - Channel layouts were never exported
> >> - Channel mappings were incorrect beyond stereo
> >> - Channel counts weren't updated after packets were decoded
> >> - Timestamps were exported incorrectly
> >> ---
> >>
> >>
> >
> > patching is fixed and all errors of encoding are fixed but there are
> errors
> > of ac3 decoding.
> > logs are attached
>
> Is this a regression in these patches, or did this already happen?
> I haven't seen this issue in my local tests with AC3 streams; can you
> provide a sample?
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Implement hdcd filtering

2016-03-30 Thread Benjamin St
>
> fails make fate

It's due to the copyright header. I still don't know how to handle this
correct as this filter is based on https://github.com/kode54/foo_hdcd/,
which contains:

> 1. Redistributions of source code must retain the above copyright
> notice, this list of conditions and the following disclaimer.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mpegtsenc: Allow DVB stream_type for mp2 audio

2016-03-30 Thread Carl Eugen Hoyos
On Tuesday 29 March 2016 04:31:53 pm Carl Eugen Hoyos wrote:
> Hi!
>
> Could attached maybe fix ticket #5388?

New patch attached that should improve conformance.

Please comment, Carl Eugen
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 51677ea..29bccb5 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -318,7 +318,12 @@ static int mpegts_write_pmt(AVFormatContext *s, 
MpegTSService *service)
 break;
 case AV_CODEC_ID_MP2:
 case AV_CODEC_ID_MP3:
-stream_type = STREAM_TYPE_AUDIO_MPEG1;
+if (   st->codec->sample_rate > 0
+&& st->codec->sample_rate < 32000) {
+stream_type = STREAM_TYPE_AUDIO_MPEG2;
+} else {
+stream_type = STREAM_TYPE_AUDIO_MPEG1;
+}
 break;
 case AV_CODEC_ID_AAC:
 stream_type = (ts->flags & MPEGTS_FLAG_AAC_LATM)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Demux the PixelCrop* values

2016-03-30 Thread Steve Lhomme
On Tue, Mar 29, 2016 at 2:46 PM, Dave Rice  wrote:
> Hi,
>
>> On Mar 29, 2016, at 4:23 AM, wm4  wrote:
>>
>> On Sat, 26 Mar 2016 16:56:55 -0600
>> Nic Wolfe  wrote:
>>
>>> The Matroska spec defines PixelCropTop, PixelCropBottom, PixelCropLeft,
>>> and PixelCropRight elements: 
>>> https://www.matroska.org/technical/specs/index.html
>>>
>>> This commit adds support for demuxing these values so that
>>> applications using libav*
>>> are able to use them when playing the stream. They're added to the 
>>> AVStream's
>>> metadata if they are set to something non-zero.
>>>
>>>
>>> My official patch is base64 encoded and attached but I will also
>>> include the diff below for (hopefully) convenience.
>>>
>>
>> To elaborate on why this change is bad (in its current state):
>>
>> - It's not clearly defined what the pixelcrop fields mean. Do they
>>  operate before or after aspect rasto is applied? Do they affect
>>  aspect ratio calculation? What if aspect ratio or video size change
>>  later? Does it get applied after h264 bitstream cropping, does it
>>  override it? AFAIK these issues were also discussed on the cellar
>>  mailing list, but I didn't follow it.
>
> It was discussed on CELLAR but not patched yet. At the moment, the best 
> clarification is from Steve Lhomme in this post 
> https://mailarchive.ietf.org/arch/search/?email_list=cellar=display+area+question:
>  "Yes, the cropping happens on the pixels, the display size are just how to 
> display those remaining pixels.” So the pixelcrop is applied before the 
> aspect ratio.

Given in the past pixel cropping was done in parallel to the codec one
(ie redefining the ones already implied by the codec like 1088 MPEG2)
and there is a need to allow different cropping that the internal
codec one, we might need some extra flags to cover both cases. Since
they could be both needed, we might need a set of extra UserPixelCrop.
I think mkvmerge (at least) copies the codec crop into the current
PixelCrop, which would become CodecPixelCrop in the documentation.

> AFAIK there is no determination as to how h264 bitstream cropping and 
> Matroska cropping should be prioritized (cc’ing CELLAR on this).
>
> I think the PixelCrop documentation also needs to consider handling in video 
> stereo modes.
>
>> - There should generally be a concept at least in libavformat's API how
>>  to handle cropping. For example, it could be some sort of well-defined
>>  AVStream side data. (Personally I'd be a fan of adding it to AVFrame
>>  too. There's no way around if it should work for hw decoding.)
>> - Worst of all: it's exported as generic metadata. This means that:
>>  - API users could start interpreting the same metadata fields for
>>other formats than Matroska too
>>  - Transcoders like ffmpeg CLI will copy the crop metadata to other
>>containers (as normal metadata).
>>  - Non-Matroska files might be created that contain the "made
>>up" libavformat Matroska demuxer metadata, and the creator of the
>>file expects that programs respect it.
>>  (Something like this almost happened with the "old" libavformat
>>  rotation metadata, which is also exported as normal metadata.)
>>
>> While just adding a "hack" to export metadata for essentially 1 API
>> user might be acceptable if adding "proper" API is too hard for now, at
>> least the last point needs to be fixed.
>
> I also support a demuxer option to allow pixelcrop to be ignored.
> Best Regards,
> Dave Rice
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel