Re: [FFmpeg-devel] [PATCH] udp: ignore UDP packets without payload

2017-05-25 Thread Daniel Kučera
2017-05-24 9:02 GMT+02:00 Nicolas George :
> Le quartidi 4 prairial, an CCXXV, Daniel Kucera a écrit :
>> Time to time some devices send UDP packets without payload.
>> ffmpeg previously exited on receiving such packet, this patch
>> fixes this behaviour.
>>
>> Signed-off-by: Daniel Kucera 
>> ---
>>  libavformat/udp.c | 6 +-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> I do not think this is correct: UDP is a packetized protocol, packet
> with empty payload are still packets, and meaningful for some protocols.
>
> Regards,
>
> --
>   Nicolas George

If we return 0, then it is considered as EOF by calling functions
(e.g. avio_read). So returning 0 means: "this is end of stream" and
not: "we received zero length packet, but more data may be coming" and
thus the stream processing ends. I need to fix this behavior, example
errors are described here:
https://blog.danman.eu/new-version-of-lenkeng-hdmi-over-ip-extender-lkv373a/#comment-478

S pozdravom / Best regards
Daniel Kucera.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] frame_thread_encoder: extend critical code covered by finished_task_mutex.

2017-05-25 Thread Michael Niedermayer
On Wed, May 24, 2017 at 12:59:58PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On May 24, 2017 12:51 PM, "Clément Bœsch"  wrote:
> 
> On Wed, May 24, 2017 at 12:15:05PM -0400, Ronald S. Bultje wrote:
> > Should fix tsan errors in utvideoenc_rgb_left and related tests.
> > ---
> >  libavcodec/frame_thread_encoder.c | 13 ++---
> >  1 file changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_
> encoder.c
> > index 27ae356..2746964 100644
> > --- a/libavcodec/frame_thread_encoder.c
> > +++ b/libavcodec/frame_thread_encoder.c
> > @@ -273,14 +273,21 @@ int ff_thread_video_encode_frame(AVCodecContext
> *avctx, AVPacket *pkt, const AVF
> >
> >  c->task_index = (c->task_index+1) % BUFFER_SIZE;
> >
> > -if(!c->finished_tasks[c->finished_task_index].outdata &&
> (c->task_index - c->finished_task_index) % BUFFER_SIZE <=
> avctx->thread_count)
> > +pthread_mutex_lock(&c->finished_task_mutex);
> > +if(!c->finished_tasks[c->finished_task_index].outdata &&
> > +   (c->task_index - c->finished_task_index) % BUFFER_SIZE <=
> avctx->thread_count) {
> > +pthread_mutex_unlock(&c->finished_task_mutex);
> >  return 0;
> > +}
> > +} else {
> > +pthread_mutex_lock(&c->finished_task_mutex);
> >  }
> >
> > -if(c->task_index == c->finished_task_index)
> > +if(c->task_index == c->finished_task_index) {
> > +pthread_mutex_unlock(&c->finished_task_mutex);
> >  return 0;
> > +}
> >
> > -pthread_mutex_lock(&c->finished_task_mutex);
> >  while (!c->finished_tasks[c->finished_task_index].outdata) {
> >  pthread_cond_wait(&c->finished_task_cond,
> &c->finished_task_mutex);
> >  }
> 
> 
> LGTM
> 
> alternatively you could do sth like the following (totally untested) to
> reduce the pthread spaghettis:
> 
> 
> Yes, I initially wrote it like that but considered the spaghetti too much
> for the edge case benefit it brings to flushing only.
> 
> But if people prefer that, I can do that too. What do others think?

I like ubitux version

thanks

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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


[FFmpeg-devel] [PATCH] frame_thread_encoder: extend critical code covered by finished_task_mutex.

2017-05-25 Thread Ronald S. Bultje
Should fix tsan errors in utvideoenc_rgb_left and related tests.
---
 libavcodec/frame_thread_encoder.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/libavcodec/frame_thread_encoder.c 
b/libavcodec/frame_thread_encoder.c
index 27ae356..6cf1a68 100644
--- a/libavcodec/frame_thread_encoder.c
+++ b/libavcodec/frame_thread_encoder.c
@@ -272,15 +272,16 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt, const AVF
 pthread_mutex_unlock(&c->task_fifo_mutex);
 
 c->task_index = (c->task_index+1) % BUFFER_SIZE;
-
-if(!c->finished_tasks[c->finished_task_index].outdata && 
(c->task_index - c->finished_task_index) % BUFFER_SIZE <= avctx->thread_count)
-return 0;
 }
 
-if(c->task_index == c->finished_task_index)
-return 0;
-
 pthread_mutex_lock(&c->finished_task_mutex);
+if (c->task_index == c->finished_task_index ||
+(frame && !c->finished_tasks[c->finished_task_index].outdata &&
+ (c->task_index - c->finished_task_index) % BUFFER_SIZE <= 
avctx->thread_count)) {
+pthread_mutex_unlock(&c->finished_task_mutex);
+return 0;
+}
+
 while (!c->finished_tasks[c->finished_task_index].outdata) {
 pthread_cond_wait(&c->finished_task_cond, &c->finished_task_mutex);
 }
-- 
2.8.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/tscc2: Skip duplicate frames

2017-05-25 Thread Michael Niedermayer
On Sun, May 21, 2017 at 03:34:21PM +0200, Michael Niedermayer wrote:
> This turns CFR duplicated frames into skiped frames
> 
> Fixes: Timeout
> Fixes: 1719/clusterfuzz-testcase-minimized-6375090079924224
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/tscc2.c   | 13 +
>  tests/ref/fate/tscc2-avi |  8 
>  2 files changed, 5 insertions(+), 16 deletions(-)

applied

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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/wavpack: Fix: runtime error: signed integer overflow: 3 * -2147483648 cannot be represented in type 'int'

2017-05-25 Thread Michael Niedermayer
On Wed, May 24, 2017 at 12:21:20AM +0200, Michael Niedermayer wrote:
> Fixes: 1776/clusterfuzz-testcase-minimized-6191258231898112
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/wavpack.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

patchset applied

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

No great genius has ever existed without some touch of madness. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH] frame_thread_encoder: extend critical code covered by finished_task_mutex.

2017-05-25 Thread Michael Niedermayer
On Thu, May 25, 2017 at 08:20:46AM -0400, Ronald S. Bultje wrote:
> Should fix tsan errors in utvideoenc_rgb_left and related tests.
> ---
>  libavcodec/frame_thread_encoder.c | 13 +++--
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/frame_thread_encoder.c 
> b/libavcodec/frame_thread_encoder.c
> index 27ae356..6cf1a68 100644
> --- a/libavcodec/frame_thread_encoder.c
> +++ b/libavcodec/frame_thread_encoder.c
> @@ -272,15 +272,16 @@ int ff_thread_video_encode_frame(AVCodecContext *avctx, 
> AVPacket *pkt, const AVF
>  pthread_mutex_unlock(&c->task_fifo_mutex);
>  
>  c->task_index = (c->task_index+1) % BUFFER_SIZE;
> -
> -if(!c->finished_tasks[c->finished_task_index].outdata && 
> (c->task_index - c->finished_task_index) % BUFFER_SIZE <= avctx->thread_count)
> -return 0;
>  }
>  
> -if(c->task_index == c->finished_task_index)
> -return 0;
> -
>  pthread_mutex_lock(&c->finished_task_mutex);
> +if (c->task_index == c->finished_task_index ||
> +(frame && !c->finished_tasks[c->finished_task_index].outdata &&
> + (c->task_index - c->finished_task_index) % BUFFER_SIZE <= 
> avctx->thread_count)) {
> +pthread_mutex_unlock(&c->finished_task_mutex);
> +return 0;
> +}
> +
>  while (!c->finished_tasks[c->finished_task_index].outdata) {
>  pthread_cond_wait(&c->finished_task_cond, &c->finished_task_mutex);
>  }

LGTM

thx

[...]

--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


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


[FFmpeg-devel] [PATCH] avcodec/fft_template: Fix multiple runtime error: signed integer overflow: -1943918714 - 1935113003 cannot be represented in type 'int'

2017-05-25 Thread Michael Niedermayer
Fixes: 1735/clusterfuzz-testcase-minimized-5350472347025408

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/fft_template.c | 50 +++
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
index 480557f49f..e3a37e5d69 100644
--- a/libavcodec/fft_template.c
+++ b/libavcodec/fft_template.c
@@ -249,7 +249,7 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
 
 int nbits, i, n, num_transforms, offset, step;
 int n4, n2, n34;
-FFTSample tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
+SUINT tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
 FFTComplex *tmpz;
 const int fft_size = (1 << s->nbits);
 int64_t accu;
@@ -260,14 +260,14 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
 offset = ff_fft_offsets_lut[n] << 2;
 tmpz = z + offset;
 
-tmp1 = tmpz[0].re + tmpz[1].re;
-tmp5 = tmpz[2].re + tmpz[3].re;
-tmp2 = tmpz[0].im + tmpz[1].im;
-tmp6 = tmpz[2].im + tmpz[3].im;
-tmp3 = tmpz[0].re - tmpz[1].re;
-tmp8 = tmpz[2].im - tmpz[3].im;
-tmp4 = tmpz[0].im - tmpz[1].im;
-tmp7 = tmpz[2].re - tmpz[3].re;
+tmp1 = tmpz[0].re + (SUINT)tmpz[1].re;
+tmp5 = tmpz[2].re + (SUINT)tmpz[3].re;
+tmp2 = tmpz[0].im + (SUINT)tmpz[1].im;
+tmp6 = tmpz[2].im + (SUINT)tmpz[3].im;
+tmp3 = tmpz[0].re - (SUINT)tmpz[1].re;
+tmp8 = tmpz[2].im - (SUINT)tmpz[3].im;
+tmp4 = tmpz[0].im - (SUINT)tmpz[1].im;
+tmp7 = tmpz[2].re - (SUINT)tmpz[3].re;
 
 tmpz[0].re = tmp1 + tmp5;
 tmpz[2].re = tmp1 - tmp5;
@@ -288,19 +288,19 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
 offset = ff_fft_offsets_lut[n] << 3;
 tmpz = z + offset;
 
-tmp1 = tmpz[4].re + tmpz[5].re;
-tmp3 = tmpz[6].re + tmpz[7].re;
-tmp2 = tmpz[4].im + tmpz[5].im;
-tmp4 = tmpz[6].im + tmpz[7].im;
+tmp1 = tmpz[4].re + (SUINT)tmpz[5].re;
+tmp3 = tmpz[6].re + (SUINT)tmpz[7].re;
+tmp2 = tmpz[4].im + (SUINT)tmpz[5].im;
+tmp4 = tmpz[6].im + (SUINT)tmpz[7].im;
 tmp5 = tmp1 + tmp3;
 tmp7 = tmp1 - tmp3;
 tmp6 = tmp2 + tmp4;
 tmp8 = tmp2 - tmp4;
 
-tmp1 = tmpz[4].re - tmpz[5].re;
-tmp2 = tmpz[4].im - tmpz[5].im;
-tmp3 = tmpz[6].re - tmpz[7].re;
-tmp4 = tmpz[6].im - tmpz[7].im;
+tmp1 = tmpz[4].re - (SUINT)tmpz[5].re;
+tmp2 = tmpz[4].im - (SUINT)tmpz[5].im;
+tmp3 = tmpz[6].re - (SUINT)tmpz[7].re;
+tmp4 = tmpz[6].im - (SUINT)tmpz[7].im;
 
 tmpz[4].re = tmpz[0].re - tmp5;
 tmpz[0].re = tmpz[0].re + tmp5;
@@ -311,13 +311,13 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
 tmpz[6].im = tmpz[2].im + tmp7;
 tmpz[2].im = tmpz[2].im - tmp7;
 
-accu = (int64_t)Q31(M_SQRT1_2)*(tmp1 + tmp2);
+accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp1 + tmp2);
 tmp5 = (int32_t)((accu + 0x4000) >> 31);
-accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 - tmp4);
+accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 - tmp4);
 tmp7 = (int32_t)((accu + 0x4000) >> 31);
-accu = (int64_t)Q31(M_SQRT1_2)*(tmp2 - tmp1);
+accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp2 - tmp1);
 tmp6 = (int32_t)((accu + 0x4000) >> 31);
-accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 + tmp4);
+accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 + tmp4);
 tmp8 = (int32_t)((accu + 0x4000) >> 31);
 tmp1 = tmp5 + tmp7;
 tmp3 = tmp5 - tmp7;
@@ -348,10 +348,10 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
 offset = ff_fft_offsets_lut[n] << nbits;
 tmpz = z + offset;
 
-tmp5 = tmpz[ n2].re + tmpz[n34].re;
-tmp1 = tmpz[ n2].re - tmpz[n34].re;
-tmp6 = tmpz[ n2].im + tmpz[n34].im;
-tmp2 = tmpz[ n2].im - tmpz[n34].im;
+tmp5 = tmpz[ n2].re + (SUINT)tmpz[n34].re;
+tmp1 = tmpz[ n2].re - (SUINT)tmpz[n34].re;
+tmp6 = tmpz[ n2].im + (SUINT)tmpz[n34].im;
+tmp2 = tmpz[ n2].im - (SUINT)tmpz[n34].im;
 
 tmpz[ n2].re = tmpz[ 0].re - tmp5;
 tmpz[  0].re = tmpz[ 0].re + tmp5;
-- 
2.13.0

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


[FFmpeg-devel] [PATCH 1/2] avcodec/audiotoolboxdec: always use a copy of the AVCodecContext extradata

2017-05-25 Thread James Almer
Fixes memleaks introduced by 954e2b3d34b7c2d82871254f07e2f8a39bc451cb

Signed-off-by: James Almer 
---
Untested.

 libavcodec/audiotoolboxdec.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index a8655f0421..d499a0afc8 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -399,8 +399,13 @@ static av_cold int ffat_create_decoder(AVCodecContext 
*avctx, AVPacket *pkt)
 static av_cold int ffat_init_decoder(AVCodecContext *avctx)
 {
 ATDecodeContext *at = avctx->priv_data;
-at->extradata = avctx->extradata;
-at->extradata_size = avctx->extradata_size;
+if (avctx->extradata_size) {
+at->extradata = av_mallocz(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
+if (!at->extradata)
+return AVERROR(ENOMEM);
+at->extradata_size = avctx->extradata_size;
+memcpy(at->extradata, avctx->extradata, avctx->extradata_size);
+}
 
 if ((avctx->channels && avctx->sample_rate) || 
ffat_usable_extradata(avctx))
 return ffat_create_decoder(avctx, NULL);
@@ -599,6 +604,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx)
 av_packet_unref(&at->new_in_pkt);
 av_packet_unref(&at->in_pkt);
 av_free(at->decoded_data);
+av_free(at->extradata);
 return 0;
 }
 
-- 
2.12.1

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


[FFmpeg-devel] [PATCH 2/2] avcodec/audiotoolboxdec: add FF_CODEC_CAP_INIT_CLEANUP to the decoder capabilities

2017-05-25 Thread James Almer
Extradata may be allocated and the AudioConverterRef may be created during 
init(),
which in case of a failure would not be freed as close() isn't called 
afterwards.

Signed-off-by: James Almer 
---
Untested.

The documentation for AudioConverterDispose() didn't say if it could handle 
NULL as
argument, so i added a check just in case.
If anyone can confirm NULL is a valid argument i'll remove that chunk.

 libavcodec/audiotoolboxdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index d499a0afc8..c30817778f 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -599,7 +599,8 @@ static av_cold void ffat_decode_flush(AVCodecContext *avctx)
 static av_cold int ffat_close_decoder(AVCodecContext *avctx)
 {
 ATDecodeContext *at = avctx->priv_data;
-AudioConverterDispose(at->converter);
+if (at->converter)
+AudioConverterDispose(at->converter);
 av_bsf_free(&at->bsf);
 av_packet_unref(&at->new_in_pkt);
 av_packet_unref(&at->in_pkt);
@@ -628,7 +629,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx)
 .flush  = ffat_decode_flush, \
 .priv_class = &ffat_##NAME##_dec_class, \
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, \
-.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE, \
+.caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_INIT_CLEANUP, \
 };
 
 FFAT_DEC(aac,  AV_CODEC_ID_AAC)
-- 
2.12.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/fft_template: Fix multiple runtime error: signed integer overflow: -1943918714 - 1935113003 cannot be represented in type 'int'

2017-05-25 Thread Rostislav Pehlivanov
On 25 May 2017 at 15:10, Michael Niedermayer  wrote:

> Fixes: 1735/clusterfuzz-testcase-minimized-5350472347025408
>
> Found-by: continuous fuzzing process https://github.com/google/oss-
> fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/fft_template.c | 50 +++---
> -
>  1 file changed, 25 insertions(+), 25 deletions(-)
>
> diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
> index 480557f49f..e3a37e5d69 100644
> --- a/libavcodec/fft_template.c
> +++ b/libavcodec/fft_template.c
> @@ -249,7 +249,7 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
>
>  int nbits, i, n, num_transforms, offset, step;
>  int n4, n2, n34;
> -FFTSample tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
> +SUINT tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
>  FFTComplex *tmpz;
>  const int fft_size = (1 << s->nbits);
>  int64_t accu;
> @@ -260,14 +260,14 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> {
>  offset = ff_fft_offsets_lut[n] << 2;
>  tmpz = z + offset;
>
> -tmp1 = tmpz[0].re + tmpz[1].re;
> -tmp5 = tmpz[2].re + tmpz[3].re;
> -tmp2 = tmpz[0].im + tmpz[1].im;
> -tmp6 = tmpz[2].im + tmpz[3].im;
> -tmp3 = tmpz[0].re - tmpz[1].re;
> -tmp8 = tmpz[2].im - tmpz[3].im;
> -tmp4 = tmpz[0].im - tmpz[1].im;
> -tmp7 = tmpz[2].re - tmpz[3].re;
> +tmp1 = tmpz[0].re + (SUINT)tmpz[1].re;
> +tmp5 = tmpz[2].re + (SUINT)tmpz[3].re;
> +tmp2 = tmpz[0].im + (SUINT)tmpz[1].im;
> +tmp6 = tmpz[2].im + (SUINT)tmpz[3].im;
> +tmp3 = tmpz[0].re - (SUINT)tmpz[1].re;
> +tmp8 = tmpz[2].im - (SUINT)tmpz[3].im;
> +tmp4 = tmpz[0].im - (SUINT)tmpz[1].im;
> +tmp7 = tmpz[2].re - (SUINT)tmpz[3].re;
>
>  tmpz[0].re = tmp1 + tmp5;
>  tmpz[2].re = tmp1 - tmp5;
> @@ -288,19 +288,19 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> {
>  offset = ff_fft_offsets_lut[n] << 3;
>  tmpz = z + offset;
>
> -tmp1 = tmpz[4].re + tmpz[5].re;
> -tmp3 = tmpz[6].re + tmpz[7].re;
> -tmp2 = tmpz[4].im + tmpz[5].im;
> -tmp4 = tmpz[6].im + tmpz[7].im;
> +tmp1 = tmpz[4].re + (SUINT)tmpz[5].re;
> +tmp3 = tmpz[6].re + (SUINT)tmpz[7].re;
> +tmp2 = tmpz[4].im + (SUINT)tmpz[5].im;
> +tmp4 = tmpz[6].im + (SUINT)tmpz[7].im;
>  tmp5 = tmp1 + tmp3;
>  tmp7 = tmp1 - tmp3;
>  tmp6 = tmp2 + tmp4;
>  tmp8 = tmp2 - tmp4;
>
> -tmp1 = tmpz[4].re - tmpz[5].re;
> -tmp2 = tmpz[4].im - tmpz[5].im;
> -tmp3 = tmpz[6].re - tmpz[7].re;
> -tmp4 = tmpz[6].im - tmpz[7].im;
> +tmp1 = tmpz[4].re - (SUINT)tmpz[5].re;
> +tmp2 = tmpz[4].im - (SUINT)tmpz[5].im;
> +tmp3 = tmpz[6].re - (SUINT)tmpz[7].re;
> +tmp4 = tmpz[6].im - (SUINT)tmpz[7].im;
>
>  tmpz[4].re = tmpz[0].re - tmp5;
>  tmpz[0].re = tmpz[0].re + tmp5;
> @@ -311,13 +311,13 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> {
>  tmpz[6].im = tmpz[2].im + tmp7;
>  tmpz[2].im = tmpz[2].im - tmp7;
>
> -accu = (int64_t)Q31(M_SQRT1_2)*(tmp1 + tmp2);
> +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp1 + tmp2);
>  tmp5 = (int32_t)((accu + 0x4000) >> 31);
> -accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 - tmp4);
> +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 - tmp4);
>  tmp7 = (int32_t)((accu + 0x4000) >> 31);
> -accu = (int64_t)Q31(M_SQRT1_2)*(tmp2 - tmp1);
> +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp2 - tmp1);
>  tmp6 = (int32_t)((accu + 0x4000) >> 31);
> -accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 + tmp4);
> +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 + tmp4);
>  tmp8 = (int32_t)((accu + 0x4000) >> 31);
>  tmp1 = tmp5 + tmp7;
>  tmp3 = tmp5 - tmp7;
> @@ -348,10 +348,10 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> {
>  offset = ff_fft_offsets_lut[n] << nbits;
>  tmpz = z + offset;
>
> -tmp5 = tmpz[ n2].re + tmpz[n34].re;
> -tmp1 = tmpz[ n2].re - tmpz[n34].re;
> -tmp6 = tmpz[ n2].im + tmpz[n34].im;
> -tmp2 = tmpz[ n2].im - tmpz[n34].im;
> +tmp5 = tmpz[ n2].re + (SUINT)tmpz[n34].re;
> +tmp1 = tmpz[ n2].re - (SUINT)tmpz[n34].re;
> +tmp6 = tmpz[ n2].im + (SUINT)tmpz[n34].im;
> +tmp2 = tmpz[ n2].im - (SUINT)tmpz[n34].im;
>
>  tmpz[ n2].re = tmpz[ 0].re - tmp5;
>  tmpz[  0].re = tmpz[ 0].re + tmp5;
> --
> 2.13.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


libavcodec/avfft.h:typedef float FFTSample

[FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi  |  27 ++
 libavfilter/Makefile  |   1 +
 libavfilter/af_surround.c | 853 ++
 libavfilter/allfilters.c  |   1 +
 4 files changed, 882 insertions(+)
 create mode 100644 libavfilter/af_surround.c

diff --git a/doc/filters.texi b/doc/filters.texi
index a0ab2fb..19e4bfe 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3792,6 +3792,33 @@ channels. Default is 0.3.
 Set level of input signal of original channel. Default is 0.8.
 @end table
 
+@section surround
+Apply audio surround upmix filter.
+
+This filter allows to produce multichannel output from stereo audio stream.
+
+The filter accepts the following options:
+
+@table @option
+@item chl_out
+Set output channel layout. By default is @var{5.1}.
+
+@item level_in
+Set input volume level. By default is @var{1}.
+
+@item level_out
+Set output volume level. By default is @var{1}.
+
+@item lfe
+Enable LFE channel output if output channel layout have it. By default is 
enabled.
+
+@item lfe_low
+Set LFE low cut off frequency. By default is @var{128} Hz.
+
+@item lfe_high
+Set LFE high cut off frequency. By default is @var{256} Hz.
+@end table
+
 @section treble
 
 Boost or cut treble (upper) frequencies of the audio using a two-pole
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 434a989..c88dfb3 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -108,6 +108,7 @@ OBJS-$(CONFIG_SILENCEREMOVE_FILTER)  += 
af_silenceremove.o
 OBJS-$(CONFIG_SOFALIZER_FILTER)  += af_sofalizer.o
 OBJS-$(CONFIG_STEREOTOOLS_FILTER)+= af_stereotools.o
 OBJS-$(CONFIG_STEREOWIDEN_FILTER)+= af_stereowiden.o
+OBJS-$(CONFIG_SURROUND_FILTER)   += af_surround.o
 OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o
 OBJS-$(CONFIG_TREMOLO_FILTER)+= af_tremolo.o
 OBJS-$(CONFIG_VIBRATO_FILTER)+= af_vibrato.o 
generate_wave_table.o
diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
new file mode 100644
index 000..310b8d7
--- /dev/null
+++ b/libavfilter/af_surround.c
@@ -0,0 +1,853 @@
+/*
+ * Copyright (c) 2017 Paul B Mahol
+ *
+ * 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 "libavutil/audio_fifo.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "libavcodec/avfft.h"
+#include "avfilter.h"
+#include "audio.h"
+#include "formats.h"
+
+typedef struct AudioSurroundContext {
+const AVClass *class;
+
+char *out_channel_layout_str;
+float level_in;
+float level_out;
+int output_lfe;
+int lowcutf;
+int highcutf;
+
+float lowcut;
+float highcut;
+
+uint64_t out_channel_layout;
+int nb_in_channels;
+int nb_out_channels;
+
+AVFrame *input;
+AVFrame *output;
+AVFrame *overlap_buffer;
+
+int buf_size;
+int hop_size;
+AVAudioFifo *fifo;
+RDFTContext **rdft, **irdft;
+float *window_func_lut;
+
+int64_t pts;
+
+void (*upmix)(AVFilterContext *ctx,
+  float l_phase,
+  float r_phase,
+  float c_phase,
+  float mag_total,
+  float x, float y,
+  int n);
+} AudioSurroundContext;
+
+static int query_formats(AVFilterContext *ctx)
+{
+AudioSurroundContext *s = ctx->priv;
+AVFilterFormats *formats = NULL;
+AVFilterChannelLayouts *layouts = NULL;
+int ret;
+
+ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP);
+if (ret)
+return ret;
+ret = ff_set_common_formats(ctx, formats);
+if (ret)
+return ret;
+
+layouts = NULL;
+ret = ff_add_channel_layout(&layouts, s->out_channel_layout);
+if (ret)
+return ret;
+
+ret = ff_channel_layouts_ref(layouts, 
&ctx->outputs[0]->in_channel_layouts);
+if (ret)
+return ret;
+
+layouts = NULL;
+ret = ff_add_channel_layout(&layouts, AV_CH_LAYOUT_STEREO);
+if (ret)
+return ret;
+
+ret = ff_channel_layouts_ref(layouts, 
&ctx->inputs[0]->out_channel_layouts);
+if (ret)
+return ret;
+
+formats = ff_all_samplerates();
+if (!formats)
+return AVERROR(ENOMEM);
+return ff_set_comm

[FFmpeg-devel] [PATCH] lavc/aarch64: add a few SIMD function for AAC PS

2017-05-25 Thread Clément Bœsch
---

This is still not benchmarked (written and verified with qemu).

I typically wrote an alternative implementation for
stereo_interpolate[0] which needs to be compared with the current one:

function ff_ps_stereo_interpolate_neon, export=1
ld1 {v0.4S}, [x2]
ld1 {v1.4S}, [x3]
1:
ld1 {v2.2S}, [x0]
ld1 {v3.2S}, [x1]
faddv0.4S, v0.4S, v1.4S
fmulv4.2S, v2.2S, v0.S[0]
fmulv5.2S, v2.2S, v0.S[1]
fmlav4.2S, v3.2S, v0.S[2]
fmlav5.2S, v3.2S, v0.S[3]
st1 {v4.2S}, [x0], #8
st1 {v5.2S}, [x1], #8
subsw4, w4, #1
b.gt1b
ret
endfunc

I don't know which is faster. For now, the current version follows the
logic I used in stereo_interpolate[1] (the ipdopd one). It's doing less
mult operations, but more shuffling.

A 3rd alternative would be possible if it was possible to assume len % 2
was always true (allowing overreading and overwriting by one more entry
basically). Currently, this is not the case.

Speaking of ipdopd, the factors table and the ext may be clumsy.
---
 libavcodec/aacpsdsp.h  |   1 +
 libavcodec/aacpsdsp_template.c |   2 +
 libavcodec/aarch64/Makefile|   2 +
 libavcodec/aarch64/aacpsdsp_init_aarch64.c |  44 +
 libavcodec/aarch64/aacpsdsp_neon.S | 101 +
 5 files changed, 150 insertions(+)
 create mode 100644 libavcodec/aarch64/aacpsdsp_init_aarch64.c
 create mode 100644 libavcodec/aarch64/aacpsdsp_neon.S

diff --git a/libavcodec/aacpsdsp.h b/libavcodec/aacpsdsp.h
index ad9bbb81bd..3714a08052 100644
--- a/libavcodec/aacpsdsp.h
+++ b/libavcodec/aacpsdsp.h
@@ -51,6 +51,7 @@ typedef struct PSDSPContext {
 
 void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s);
 void ff_psdsp_init_arm(PSDSPContext *s);
+void ff_psdsp_init_aarch64(PSDSPContext *s);
 void ff_psdsp_init_mips(PSDSPContext *s);
 void ff_psdsp_init_x86(PSDSPContext *s);
 
diff --git a/libavcodec/aacpsdsp_template.c b/libavcodec/aacpsdsp_template.c
index 3049ce8b79..158160b246 100644
--- a/libavcodec/aacpsdsp_template.c
+++ b/libavcodec/aacpsdsp_template.c
@@ -222,6 +222,8 @@ av_cold void AAC_RENAME(ff_psdsp_init)(PSDSPContext *s)
 #if !USE_FIXED
 if (ARCH_ARM)
 ff_psdsp_init_arm(s);
+if (ARCH_AARCH64)
+ff_psdsp_init_aarch64(s);
 if (ARCH_MIPS)
 ff_psdsp_init_mips(s);
 if (ARCH_X86)
diff --git a/libavcodec/aarch64/Makefile b/libavcodec/aarch64/Makefile
index 104bc67802..d440b1b18a 100644
--- a/libavcodec/aarch64/Makefile
+++ b/libavcodec/aarch64/Makefile
@@ -11,6 +11,7 @@ OBJS-$(CONFIG_NEON_CLOBBER_TEST)+= aarch64/neontest.o
 OBJS-$(CONFIG_VIDEODSP) += aarch64/videodsp_init.o
 
 # decoders/encoders
+OBJS-$(CONFIG_AAC_DECODER)  += aarch64/aacpsdsp_init_aarch64.o
 OBJS-$(CONFIG_DCA_DECODER)  += aarch64/synth_filter_init.o
 OBJS-$(CONFIG_RV40_DECODER) += aarch64/rv40dsp_init_aarch64.o
 OBJS-$(CONFIG_VC1DSP)   += aarch64/vc1dsp_init_aarch64.o
@@ -42,6 +43,7 @@ NEON-OBJS-$(CONFIG_MDCT)+= aarch64/mdct_neon.o
 NEON-OBJS-$(CONFIG_MPEGAUDIODSP)+= aarch64/mpegaudiodsp_neon.o
 
 # decoders/encoders
+NEON-OBJS-$(CONFIG_AAC_DECODER) += aarch64/aacpsdsp_neon.o
 NEON-OBJS-$(CONFIG_DCA_DECODER) += aarch64/synth_filter_neon.o
 NEON-OBJS-$(CONFIG_VORBIS_DECODER)  += aarch64/vorbisdsp_neon.o
 NEON-OBJS-$(CONFIG_VP9_DECODER) += aarch64/vp9itxfm_16bpp_neon.o   
\
diff --git a/libavcodec/aarch64/aacpsdsp_init_aarch64.c 
b/libavcodec/aarch64/aacpsdsp_init_aarch64.c
new file mode 100644
index 00..9c9e5db851
--- /dev/null
+++ b/libavcodec/aarch64/aacpsdsp_init_aarch64.c
@@ -0,0 +1,44 @@
+/*
+ * 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 "config.h"
+
+#include "libavutil/aarch64/cpu.h"
+#include "libavcodec/aacpsdsp.h"
+
+void ff_ps_add_squares_neon(float *dst, const float (*src)[2], int n);
+void ff_ps_mul_pair_single_neon(float (*dst)[2], float (*src0)[2],
+float *src1, int n);
+void ff_ps_stereo_interpolate_neon(float (*l)[2], float (*r)[2]

Re: [FFmpeg-devel] [PATCH] lavc/aarch64: add a few SIMD function for AAC PS

2017-05-25 Thread James Almer
On 5/25/2017 12:50 PM, Clément Bœsch wrote:
> ---
> 
> This is still not benchmarked (written and verified with qemu).
> 
> I typically wrote an alternative implementation for
> stereo_interpolate[0] which needs to be compared with the current one:
> 
> function ff_ps_stereo_interpolate_neon, export=1
> ld1 {v0.4S}, [x2]
> ld1 {v1.4S}, [x3]
> 1:
> ld1 {v2.2S}, [x0]
> ld1 {v3.2S}, [x1]
> faddv0.4S, v0.4S, v1.4S
> fmulv4.2S, v2.2S, v0.S[0]
> fmulv5.2S, v2.2S, v0.S[1]
> fmlav4.2S, v3.2S, v0.S[2]
> fmlav5.2S, v3.2S, v0.S[3]
> st1 {v4.2S}, [x0], #8
> st1 {v5.2S}, [x1], #8
> subsw4, w4, #1
> b.gt1b
> ret
> endfunc
> 
> I don't know which is faster. For now, the current version follows the
> logic I used in stereo_interpolate[1] (the ipdopd one). It's doing less
> mult operations, but more shuffling.
> 
> A 3rd alternative would be possible if it was possible to assume len % 2
> was always true (allowing overreading and overwriting by one more entry
> basically). Currently, this is not the case.
> 
> Speaking of ipdopd, the factors table and the ext may be clumsy.
> ---

[...]

> +function ff_ps_stereo_interpolate_ipdopd_neon, export=1
> +movrel  x5, ipdopd_factors
> +ld1 {v20.4S}, [x5]
> +ld1 {v0.4S,v1.4S}, [x2]
> +ld1 {v6.4S,v7.4S}, [x3]
> +1:
> +ld1 {v2.2S}, [x0]
> +ld1 {v3.2S}, [x1]
> +dup v2.2D, v2.D[0]
> +dup v3.2D, v3.D[0]
> +faddv0.4S, v0.4S, v6.4S
> +faddv1.4S, v1.4S, v7.4S
> +zip1v16.4S, v0.4S, v0.4S
> +zip2v17.4S, v0.4S, v0.4S
> +zip1v18.4S, v1.4S, v1.4S
> +zip2v19.4S, v1.4S, v1.4S
> +fmulv4.4S, v2.4S, v16.4S
> +fmlav4.4S, v3.4S, v17.4S
> +ext v2.16B, v2.16B, v2.16B, #4
> +ext v3.16B, v3.16B, v3.16B, #4

> +fmulv5.4S, v2.4S, v18.4S
> +fmlav5.4S, v3.4S, v19.4S
> +fmlav4.4S, v5.4S, v20.4S

You could make ipdopd_factors be 0, INT32_MIN, 0, INT32_MIN then replace
the fmla with eor + fadd.
No idea if that will actually be faster, though.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] avcodec/audiotoolboxdec: switch to the new generic filtering mechanism

2017-05-25 Thread James Almer
Signed-off-by: James Almer 
---
Again, untested.

 libavcodec/audiotoolboxdec.c | 73 
 1 file changed, 20 insertions(+), 53 deletions(-)

diff --git a/libavcodec/audiotoolboxdec.c b/libavcodec/audiotoolboxdec.c
index c30817778f..97514368bf 100644
--- a/libavcodec/audiotoolboxdec.c
+++ b/libavcodec/audiotoolboxdec.c
@@ -43,7 +43,6 @@ typedef struct ATDecodeContext {
 AudioStreamPacketDescription pkt_desc;
 AVPacket in_pkt;
 AVPacket new_in_pkt;
-AVBSFContext *bsf;
 char *decoded_data;
 int channel_map[64];
 
@@ -478,42 +477,15 @@ static int ffat_decode(AVCodecContext *avctx, void *data,
 ATDecodeContext *at = avctx->priv_data;
 AVFrame *frame = data;
 int pkt_size = avpkt->size;
-AVPacket filtered_packet = {0};
 OSStatus ret;
 AudioBufferList out_buffers;
 
-if (avctx->codec_id == AV_CODEC_ID_AAC && avpkt->size > 2 &&
-(AV_RB16(avpkt->data) & 0xfff0) == 0xfff0) {
-AVPacket filter_pkt = {0};
-if (!at->bsf) {
-const AVBitStreamFilter *bsf = av_bsf_get_by_name("aac_adtstoasc");
-if(!bsf)
-return AVERROR_BSF_NOT_FOUND;
-if ((ret = av_bsf_alloc(bsf, &at->bsf)))
-return ret;
-if (((ret = avcodec_parameters_from_context(at->bsf->par_in, 
avctx)) < 0) ||
-((ret = av_bsf_init(at->bsf)) < 0)) {
-av_bsf_free(&at->bsf);
-return ret;
-}
-}
-
-if ((ret = av_packet_ref(&filter_pkt, avpkt)) < 0)
-return ret;
-
-if ((ret = av_bsf_send_packet(at->bsf, &filter_pkt)) < 0) {
-av_packet_unref(&filter_pkt);
-return ret;
-}
-
-if ((ret = av_bsf_receive_packet(at->bsf, &filtered_packet)) < 0)
-return ret;
-
+if (avctx->codec_id == AV_CODEC_ID_AAC) {
 if (!at->extradata_size) {
 uint8_t *side_data;
 int side_data_size = 0;
 
-side_data = av_packet_get_side_data(&filtered_packet, 
AV_PKT_DATA_NEW_EXTRADATA,
+side_data = av_packet_get_side_data(avpkt, 
AV_PKT_DATA_NEW_EXTRADATA,
 &side_data_size);
 if (side_data_size) {
 at->extradata = av_mallocz(side_data_size + 
AV_INPUT_BUFFER_PADDING_SIZE);
@@ -523,13 +495,10 @@ static int ffat_decode(AVCodecContext *avctx, void *data,
 memcpy(at->extradata, side_data, side_data_size);
 }
 }
-
-avpkt = &filtered_packet;
 }
 
 if (!at->converter) {
 if ((ret = ffat_create_decoder(avctx, avpkt)) < 0) {
-av_packet_unref(&filtered_packet);
 return ret;
 }
 }
@@ -548,9 +517,7 @@ static int ffat_decode(AVCodecContext *avctx, void *data,
 av_packet_unref(&at->new_in_pkt);
 
 if (avpkt->size) {
-if (filtered_packet.data) {
-at->new_in_pkt = filtered_packet;
-} else if ((ret = av_packet_ref(&at->new_in_pkt, avpkt)) < 0) {
+if ((ret = av_packet_ref(&at->new_in_pkt, avpkt)) < 0) {
 return ret;
 }
 } else {
@@ -601,7 +568,6 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx)
 ATDecodeContext *at = avctx->priv_data;
 if (at->converter)
 AudioConverterDispose(at->converter);
-av_bsf_free(&at->bsf);
 av_packet_unref(&at->new_in_pkt);
 av_packet_unref(&at->in_pkt);
 av_free(at->decoded_data);
@@ -615,7 +581,7 @@ static av_cold int ffat_close_decoder(AVCodecContext *avctx)
 .version= LIBAVUTIL_VERSION_INT, \
 };
 
-#define FFAT_DEC(NAME, ID) \
+#define FFAT_DEC(NAME, ID, bsf_name) \
 FFAT_DEC_CLASS(NAME) \
 AVCodec ff_##NAME##_at_decoder = { \
 .name   = #NAME "_at", \
@@ -628,22 +594,23 @@ static av_cold int ffat_close_decoder(AVCodecContext 
*avctx)
 .decode = ffat_decode, \
 .flush  = ffat_decode_flush, \
 .priv_class = &ffat_##NAME##_dec_class, \
+.bsfs   = bsf_name, \
 .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, \
 .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | 
FF_CODEC_CAP_INIT_CLEANUP, \
 };
 
-FFAT_DEC(aac,  AV_CODEC_ID_AAC)
-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)
-FFAT_DEC(mp2,  AV_CODEC_ID_MP2)
-FFAT_DEC(mp3,  AV_CODEC_ID_MP3)
-FFAT_DEC(pcm_alaw, AV_CODEC_ID_PCM_ALAW)
-FFAT_DEC(pcm_mulaw,AV_CODEC_ID_PCM_MULAW)
-FFAT_DEC(qdmc, AV_CODEC_ID_QDMC)
-FFAT_DEC(qdm2, AV_CODEC_ID_QDM2)
+FFAT_DEC(aac,  AV_CODEC_ID_AAC, "aac_adtstoasc")
+FFAT_DEC(

[FFmpeg-devel] [PATCH] avcodec/htmlsubtitles: Be a bit more picky on syntax

2017-05-25 Thread Michael Niedermayer
This reduces the number of strstr() calls per byte

Fixes timeout
Fixes: 1817/clusterfuzz-testcase-minimized-5104230530547712

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/htmlsubtitles.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/htmlsubtitles.c b/libavcodec/htmlsubtitles.c
index 16295daa0c..e69681f31c 100644
--- a/libavcodec/htmlsubtitles.c
+++ b/libavcodec/htmlsubtitles.c
@@ -92,7 +92,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, const 
char *in)
 case '<':
 tag_close = in[1] == '/';
 len = 0;
-if (sscanf(in+tag_close+1, "%127[^>]>%n", buffer, &len) >= 1 && 
len > 0) {
+if (sscanf(in+tag_close+1, "%127[^<>]>%n", buffer, &len) >= 1 && 
len > 0) {
 const char *tagname = buffer;
 while (*tagname == ' ')
 tagname++;
@@ -149,7 +149,7 @@ int ff_htmlmarkup_to_ass(void *log_ctx, AVBPrint *dst, 
const char *in)
 }
 } else if (tagname[0] && !tagname[1] && strspn(tagname, 
"bisu") == 1) {
 av_bprintf(dst, "{\\%c%d}", tagname[0], !tag_close);
-} else {
+} else if (*tagname) {
 unknown = 1;
 snprintf(tmp, sizeof(tmp), "", tagname);
 }
-- 
2.13.0

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


Re: [FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Carl Eugen Hoyos
2017-05-25 16:45 GMT+02:00 Paul B Mahol :

> +@section surround
> +Apply audio surround upmix filter.
> +
> +This filter allows to produce multichannel output from
> stereo audio stream.

Does this work on Pro Logic-encoded files (ticket #4085)
or does this filter use a different algorithm?
Does a filter have advantages over an implementation in
libswresample?

Iirc, our Pro Logic downmixer has an issue with "phase shift"
(ticket 3455 / 4175): Does this filter give expected output
for FFmpeg-encoded files or original Pro Logic files (or is
there no difference on upmixing)?

Thank you, I believe this is a very important feature,
Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] zscale: Add pixdesc-API compatible color names to filter options

2017-05-25 Thread Vittorio Giovara
Reviewed-by: Paul B Mahol 
Signed-off-by: Vittorio Giovara 
---
 libavfilter/vf_zscale.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 1675278935..8ef5cab320 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -713,6 +713,9 @@ static const AVOption zscale_options[] = {
 { "input",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 0, FLAGS, "range" },
 { "limited",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, "range" },
 { "full", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RANGE_FULL},0, 0, FLAGS, "range" },
+{ "unknown",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 0, FLAGS, "range" },
+{ "tv",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RANGE_LIMITED}, 0, 0, FLAGS, "range" },
+{ "pc",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RANGE_FULL},0, 0, FLAGS, "range" },
 { "primaries", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_PRIMARIES_ST432_1, FLAGS, "primaries" },
 { "p", "set color primaries", OFFSET(primaries), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_PRIMARIES_ST432_1, FLAGS, "primaries" },
 { "input",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 0, FLAGS, "primaries" },
@@ -721,6 +724,11 @@ static const AVOption zscale_options[] = {
 { "170m", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_170M},0, 0, FLAGS, "primaries" },
 { "240m", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_240M},0, 0, FLAGS, "primaries" },
 { "2020", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_2020},0, 0, FLAGS, "primaries" },
+{ "unknown",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_UNSPECIFIED}, 0, 0, FLAGS, "primaries" },
+{ "bt709",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_709}, 0, 0, FLAGS, "primaries" },
+{ "smpte170m",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_170M},0, 0, FLAGS, "primaries" },
+{ "smpte240m",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_240M},0, 0, FLAGS, "primaries" },
+{ "bt2020",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_2020},0, 0, FLAGS, "primaries" },
 { "smpte432", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_PRIMARIES_ST432_1}, 0, 0, FLAGS, "primaries" },
 { "transfer", "set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_TRANSFER_ARIB_B67, FLAGS, "transfer" },
 { "t","set transfer characteristic", OFFSET(trc), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_TRANSFER_ARIB_B67, FLAGS, "transfer" },
@@ -731,6 +739,12 @@ static const AVOption zscale_options[] = {
 { "linear",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_LINEAR},  0, 0, FLAGS, "transfer" },
 { "2020_10",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, "transfer" },
 { "2020_12",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, "transfer" },
+{ "unknown",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, "transfer" },
+{ "bt470m",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, "transfer" },
+{ "bt709",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_709}, 0, 0, FLAGS, "transfer" },
+{ "linear",   0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_LINEAR},  0, 0, FLAGS, "transfer" },
+{ "bt2020-10",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, "transfer" },
+{ "bt2020-12",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, "transfer" },
 { "smpte2084",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_ST2084},  0, 0, FLAGS, "transfer" },
 { "iec61966-2-1", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_IEC_61966_2_1},0, 0, FLAGS, "transfer" },
 { "arib-std-b67", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_TRANSFER_ARIB_B67},

Re: [FFmpeg-devel] [PATCH] zscale: Add pixdesc-API compatible color names to filter options

2017-05-25 Thread Vittorio Giovara
On Thu, May 25, 2017 at 2:53 PM, Vittorio Giovara
 wrote:
> Reviewed-by: Paul B Mahol 
> Signed-off-by: Vittorio Giovara 
> ---
>  libavfilter/vf_zscale.c | 22 +-
>  1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
> index 1675278935..8ef5cab320 100644
> --- a/libavfilter/vf_zscale.c
> +++ b/libavfilter/vf_zscale.c
>  { "t","set transfer characteristic", OFFSET(trc), 
> AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_TRANSFER_ARIB_B67, FLAGS, "transfer" },
> @@ -731,6 +739,12 @@ static const AVOption zscale_options[] = {
>  { "linear",   0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_TRANSFER_LINEAR},  0, 0, FLAGS, "transfer" },
>  { "2020_10",  0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_TRANSFER_2020_10}, 0, 0, FLAGS, "transfer" },
>  { "2020_12",  0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_TRANSFER_2020_12}, 0, 0, FLAGS, "transfer" },
> +{ "unknown",  0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_TRANSFER_UNSPECIFIED}, 0, 0, FLAGS, "transfer" },
> +{ "bt470m",   0,   0, AV_OPT_TYPE_CONST, 
> {.i64 = ZIMG_TRANSFER_601}, 0, 0, FLAGS, "transfer" },

sorry this should read as "smpte170m"
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Paul B Mahol
On 5/25/17, Carl Eugen Hoyos  wrote:
> 2017-05-25 16:45 GMT+02:00 Paul B Mahol :
>
>> +@section surround
>> +Apply audio surround upmix filter.
>> +
>> +This filter allows to produce multichannel output from
>> stereo audio stream.
>
> Does this work on Pro Logic-encoded files (ticket #4085)
> or does this filter use a different algorithm?

It works with sample from that ticket.
It uses own algorithm.

> Does a filter have advantages over an implementation in
> libswresample?

libswresample doesnt do this.

>
> Iirc, our Pro Logic downmixer has an issue with "phase shift"
> (ticket 3455 / 4175): Does this filter give expected output
> for FFmpeg-encoded files or original Pro Logic files (or is
> there no difference on upmixing)?

FFmpeg downmixing, while certainly not correct, is giving reasonable
output when used with this filter.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Moritz Barsnick
The same questions as Carl Eugen posted came to mind, furthermore:

On Thu, May 25, 2017 at 16:45:46 +0200, Paul B Mahol wrote:

> +Set output channel layout. By default is @var{5.1}.

The grammar of the second sentence here (and all the following
descriptions) should either by:
"By default, this is @var{}."
or
"Default is @var{}."

Regarding the channel layout: Could you please link to the section
describing the supported layouts? As such:

"See @ref{channel layout syntax,,the Channel Layout section in the 
ffmpeg-utils(1) manual,ffmpeg-utils}
for the required syntax."
 
> +@item lfe
> +Enable LFE channel output if output channel layout have it. By default is 
> enabled.

"has it"

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


Re: [FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Paul B Mahol
On 5/25/17, Moritz Barsnick  wrote:
> The same questions as Carl Eugen posted came to mind, furthermore:
>
> On Thu, May 25, 2017 at 16:45:46 +0200, Paul B Mahol wrote:
>
>> +Set output channel layout. By default is @var{5.1}.
>
> The grammar of the second sentence here (and all the following
> descriptions) should either by:
> "By default, this is @var{}."
> or
> "Default is @var{}."
>
> Regarding the channel layout: Could you please link to the section
> describing the supported layouts? As such:
>
> "See @ref{channel layout syntax,,the Channel Layout section in the
> ffmpeg-utils(1) manual,ffmpeg-utils}
> for the required syntax."
>
>> +@item lfe
>> +Enable LFE channel output if output channel layout have it. By default is
>> enabled.
>
> "has it"
>
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


[FFmpeg-devel] [PATCH] zscale: Add range options aliases to match scale ones

2017-05-25 Thread Vittorio Giovara
---
 libavfilter/vf_zscale.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 594de179f4..d7b1612f3c 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -708,6 +708,7 @@ static const AVOption zscale_options[] = {
 { "spline16", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RESIZE_SPLINE16}, 0, 0, FLAGS, "filter" },
 { "spline36", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RESIZE_SPLINE36}, 0, 0, FLAGS, "filter" },
 { "lanczos",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_RESIZE_LANCZOS},  0, 0, FLAGS, "filter" },
+{ "out_range", "set color range",  OFFSET(range), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "range", "set color range",  OFFSET(range), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "r", "set color range",  OFFSET(range), AV_OPT_TYPE_INT, 
{.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "input",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = -1}, 0, 0, FLAGS, "range" },
@@ -764,6 +765,7 @@ static const AVOption zscale_options[] = {
 { "ycgco",0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_MATRIX_YCGCO},   0, 0, FLAGS, "matrix" },
 { "bt2020nc", 0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_MATRIX_2020_NCL},0, 0, FLAGS, "matrix" },
 { "bt2020c",  0,   0, AV_OPT_TYPE_CONST, 
{.i64 = ZIMG_MATRIX_2020_CL}, 0, 0, FLAGS, "matrix" },
+{ "in_range", "set input color range", OFFSET(range_in),
AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "rangein", "set input color range", OFFSET(range_in), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "rin", "set input color range", OFFSET(range_in), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_RANGE_FULL, FLAGS, "range" },
 { "primariesin", "set input color primaries", OFFSET(primaries_in), 
AV_OPT_TYPE_INT, {.i64 = -1}, -1, ZIMG_PRIMARIES_ST432_1, FLAGS, "primaries" },
-- 
2.12.0

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


Re: [FFmpeg-devel] [PATCH] avfilter: add audio surround upmixer

2017-05-25 Thread Carl Eugen Hoyos
2017-05-25 22:39 GMT+02:00 Paul B Mahol :
> On 5/25/17, Carl Eugen Hoyos  wrote:
>> 2017-05-25 16:45 GMT+02:00 Paul B Mahol :
>>
>>> +@section surround
>>> +Apply audio surround upmix filter.
>>> +
>>> +This filter allows to produce multichannel output from
>>> stereo audio stream.
>>
>> Does this work on Pro Logic-encoded files (ticket #4085)
>> or does this filter use a different algorithm?
>
> It works with sample from that ticket.

> It uses own algorithm.

Is it related to one of the algorithms listed here?
https://en.wikipedia.org/wiki/Matrix_decoder
It may make sense to mention the used algorithm in the
documentation (or the source code).

>> Does a filter have advantages over an implementation in
>> libswresample?
>
> libswresample doesnt do this.

Yes.
My question was if your implementation shouldn't be
part of libswresample, or rather what would be the
disadvantage.

>> Iirc, our Pro Logic downmixer has an issue with "phase shift"
>> (ticket 3455 / 4175): Does this filter give expected output
>> for FFmpeg-encoded files or original Pro Logic files (or is
>> there no difference on upmixing)?
>
> FFmpeg downmixing, while certainly not correct, is giving
> reasonable output when used with this filter.

But it works better for Pro Logic files?

Thanks, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/fft_template: Fix multiple runtime error: signed integer overflow: -1943918714 - 1935113003 cannot be represented in type 'int'

2017-05-25 Thread Michael Niedermayer
On Thu, May 25, 2017 at 03:29:59PM +0100, Rostislav Pehlivanov wrote:
> On 25 May 2017 at 15:10, Michael Niedermayer  wrote:
> 
> > Fixes: 1735/clusterfuzz-testcase-minimized-5350472347025408
> >
> > Found-by: continuous fuzzing process https://github.com/google/oss-
> > fuzz/tree/master/projects/ffmpeg
> > Signed-off-by
> > :
> > Michael Niedermayer 
> > ---
> >  libavcodec/fft_template.c | 50 +++---
> > -
> >  1 file changed, 25 insertions(+), 25 deletions(-)
> >
> > diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
> > index 480557f49f..e3a37e5d69 100644
> > --- a/libavcodec/fft_template.c
> > +++ b/libavcodec/fft_template.c
> > @@ -249,7 +249,7 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z) {
> >
> >  int nbits, i, n, num_transforms, offset, step;
> >  int n4, n2, n34;
> > -FFTSample tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
> > +SUINT tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8;
> >  FFTComplex *tmpz;
> >  const int fft_size = (1 << s->nbits);
> >  int64_t accu;
> > @@ -260,14 +260,14 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> > {
> >  offset = ff_fft_offsets_lut[n] << 2;
> >  tmpz = z + offset;
> >
> > -tmp1 = tmpz[0].re + tmpz[1].re;
> > -tmp5 = tmpz[2].re + tmpz[3].re;
> > -tmp2 = tmpz[0].im + tmpz[1].im;
> > -tmp6 = tmpz[2].im + tmpz[3].im;
> > -tmp3 = tmpz[0].re - tmpz[1].re;
> > -tmp8 = tmpz[2].im - tmpz[3].im;
> > -tmp4 = tmpz[0].im - tmpz[1].im;
> > -tmp7 = tmpz[2].re - tmpz[3].re;
> > +tmp1 = tmpz[0].re + (SUINT)tmpz[1].re;
> > +tmp5 = tmpz[2].re + (SUINT)tmpz[3].re;
> > +tmp2 = tmpz[0].im + (SUINT)tmpz[1].im;
> > +tmp6 = tmpz[2].im + (SUINT)tmpz[3].im;
> > +tmp3 = tmpz[0].re - (SUINT)tmpz[1].re;
> > +tmp8 = tmpz[2].im - (SUINT)tmpz[3].im;
> > +tmp4 = tmpz[0].im - (SUINT)tmpz[1].im;
> > +tmp7 = tmpz[2].re - (SUINT)tmpz[3].re;
> >
> >  tmpz[0].re = tmp1 + tmp5;
> >  tmpz[2].re = tmp1 - tmp5;
> > @@ -288,19 +288,19 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> > {
> >  offset = ff_fft_offsets_lut[n] << 3;
> >  tmpz = z + offset;
> >
> > -tmp1 = tmpz[4].re + tmpz[5].re;
> > -tmp3 = tmpz[6].re + tmpz[7].re;
> > -tmp2 = tmpz[4].im + tmpz[5].im;
> > -tmp4 = tmpz[6].im + tmpz[7].im;
> > +tmp1 = tmpz[4].re + (SUINT)tmpz[5].re;
> > +tmp3 = tmpz[6].re + (SUINT)tmpz[7].re;
> > +tmp2 = tmpz[4].im + (SUINT)tmpz[5].im;
> > +tmp4 = tmpz[6].im + (SUINT)tmpz[7].im;
> >  tmp5 = tmp1 + tmp3;
> >  tmp7 = tmp1 - tmp3;
> >  tmp6 = tmp2 + tmp4;
> >  tmp8 = tmp2 - tmp4;
> >
> > -tmp1 = tmpz[4].re - tmpz[5].re;
> > -tmp2 = tmpz[4].im - tmpz[5].im;
> > -tmp3 = tmpz[6].re - tmpz[7].re;
> > -tmp4 = tmpz[6].im - tmpz[7].im;
> > +tmp1 = tmpz[4].re - (SUINT)tmpz[5].re;
> > +tmp2 = tmpz[4].im - (SUINT)tmpz[5].im;
> > +tmp3 = tmpz[6].re - (SUINT)tmpz[7].re;
> > +tmp4 = tmpz[6].im - (SUINT)tmpz[7].im;
> >
> >  tmpz[4].re = tmpz[0].re - tmp5;
> >  tmpz[0].re = tmpz[0].re + tmp5;
> > @@ -311,13 +311,13 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> > {
> >  tmpz[6].im = tmpz[2].im + tmp7;
> >  tmpz[2].im = tmpz[2].im - tmp7;
> >
> > -accu = (int64_t)Q31(M_SQRT1_2)*(tmp1 + tmp2);
> > +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp1 + tmp2);
> >  tmp5 = (int32_t)((accu + 0x4000) >> 31);
> > -accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 - tmp4);
> > +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 - tmp4);
> >  tmp7 = (int32_t)((accu + 0x4000) >> 31);
> > -accu = (int64_t)Q31(M_SQRT1_2)*(tmp2 - tmp1);
> > +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp2 - tmp1);
> >  tmp6 = (int32_t)((accu + 0x4000) >> 31);
> > -accu = (int64_t)Q31(M_SQRT1_2)*(tmp3 + tmp4);
> > +accu = (int64_t)Q31(M_SQRT1_2)*(int)(tmp3 + tmp4);
> >  tmp8 = (int32_t)((accu + 0x4000) >> 31);
> >  tmp1 = tmp5 + tmp7;
> >  tmp3 = tmp5 - tmp7;
> > @@ -348,10 +348,10 @@ static void fft_calc_c(FFTContext *s, FFTComplex *z)
> > {
> >  offset = ff_fft_offsets_lut[n] << nbits;
> >  tmpz = z + offset;
> >
> > -tmp5 = tmpz[ n2].re + tmpz[n34].re;
> > -tmp1 = tmpz[ n2].re - tmpz[n34].re;
> > -tmp6 = tmpz[ n2].im + tmpz[n34].im;
> > -tmp2 = tmpz[ n2].im - tmpz[n34].im;
> > +tmp5 = tmpz[ n2].re + (SUINT)tmpz[n34].re;
> > +tmp1 = tmpz[ n2].re - (SUINT)tmpz[n34].re;
> > +tmp6 = tmpz[ n2].im + (SUINT)tmpz[n34].im;
> > +tmp2 = tmpz[ n2].im - (SUINT)tmpz[n34].im;
> >
> >  tmp

[FFmpeg-devel] [PATCH] lavc/golomb: Fix UE golomb overwrite issue.

2017-05-25 Thread Jun Zhao
From eabcbf3d41e83f24623e6195d4a0ff86e4d95a80 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Fri, 26 May 2017 09:02:29 +0800
Subject: [PATCH] lavc/golomb: Fix UE golomb overwrite issue.

put_bits just support write up to 31 bits, when write 32 bit in
put_bits, it's will overwrite the bit buffer, because the default
assert level is 0, the av_assert2(n <= 31 && value < (1U << n))
in put_bits can not be trigger runtime.

Signed-off-by: Jun Zhao 
---
 libavcodec/golomb.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
index 0833aff468..2c5a969ac1 100644
--- a/libavcodec/golomb.h
+++ b/libavcodec/golomb.h
@@ -468,7 +468,10 @@ static inline void set_ue_golomb(PutBitContext *pb, int i)
 put_bits(pb, ff_ue_golomb_len[i], i + 1);
 else {
 int e = av_log2(i + 1);
-put_bits(pb, 2 * e + 1, i + 1);
+if (e < 16)
+put_bits(pb, 2 * e + 1, i + 1);
+else
+put_bits32(pb, i + 1);
 }
 }
 
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] minterpolate: added codec_me_mode

2017-05-25 Thread Michael Niedermayer
On Mon, May 08, 2017 at 07:40:25PM +, Davinder Singh wrote:
> hi,
> 
> On Mon, Apr 24, 2017 at 9:43 PM Paul B Mahol  wrote:
> 
> > On 4/24/17, Davinder Singh  wrote:
> > > Patch attached.
> > >
> >
> > So this encodes video frames to generate motion vectors?
> >
> 
> yes. it significantly improves the frame quality. can please you test it?
> 
> the filter will be made independent of libavcodec.

In the absence of further comments, i intend to apply this patch
(unless i spot some issue)

thx

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

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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