[FFmpeg-cvslog] avfilter/af_tremolo: make it bit-exact with sox effect of same name

2015-09-24 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Sep 23 23:03:35 
2015 +0200| [964a9badcc0368c528562f61be35050a04779f41] | committer: Paul B Mahol

avfilter/af_tremolo: make it bit-exact with sox effect of same name

Signed-off-by: Paul B Mahol 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=964a9badcc0368c528562f61be35050a04779f41
---

 libavfilter/Makefile |2 +-
 libavfilter/af_tremolo.c |   45 ++---
 2 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 7054275..c70887e 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -85,7 +85,7 @@ OBJS-$(CONFIG_SILENCEREMOVE_FILTER)  += 
af_silenceremove.o
 OBJS-$(CONFIG_STEREOTOOLS_FILTER)+= af_stereotools.o
 OBJS-$(CONFIG_STEREOWIDEN_FILTER)+= af_stereowiden.o
 OBJS-$(CONFIG_TREBLE_FILTER) += af_biquads.o
-OBJS-$(CONFIG_TREMOLO_FILTER)+= af_tremolo.o 
generate_wave_table.o
+OBJS-$(CONFIG_TREMOLO_FILTER)+= af_tremolo.o
 OBJS-$(CONFIG_VOLUME_FILTER) += af_volume.o
 OBJS-$(CONFIG_VOLUMEDETECT_FILTER)   += af_volumedetect.o
 
diff --git a/libavfilter/af_tremolo.c b/libavfilter/af_tremolo.c
index 6335401..0ae7a7c 100644
--- a/libavfilter/af_tremolo.c
+++ b/libavfilter/af_tremolo.c
@@ -22,15 +22,13 @@
 #include "avfilter.h"
 #include "internal.h"
 #include "audio.h"
-#include "generate_wave_table.h"
 
 typedef struct TremoloContext {
 const AVClass *class;
 double freq;
 double depth;
-double *wave_table;
-int wave_table_index;
-int sample_rate;
+double *table;
+int index;
 } TremoloContext;
 
 #define OFFSET(x) offsetof(TremoloContext, x)
@@ -44,20 +42,11 @@ static const AVOption tremolo_options[] = {
 
 AVFILTER_DEFINE_CLASS(tremolo);
 
-static double trem_env(AVFilterContext *ctx)
-{
-TremoloContext *s = ctx->priv;
-double env = s->wave_table[s->wave_table_index];
-s->wave_table_index++;
-if (s->wave_table_index >= s->sample_rate / s->freq)
-s->wave_table_index = 0;
-return 1.0 - (s->depth * env);
-}
-
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
 AVFilterContext *ctx = inlink->dst;
 AVFilterLink *outlink = ctx->outputs[0];
+TremoloContext *s = ctx->priv;
 const double *src = (const double *)in->data[0];
 const int channels = inlink->channels;
 const int nb_samples = in->nb_samples;
@@ -78,12 +67,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 dst = (double *)out->data[0];
 
 for (n = 0; n < nb_samples; n++) {
-const double env = trem_env(ctx);
-
 for (c = 0; c < channels; c++)
-dst[c] = src[c] * env;
+dst[c] = src[c] * s->table[s->index];
 dst += channels;
 src += channels;
+s->index++;
+if (s->index >= inlink->sample_rate)
+s->index = 0;
 }
 
 if (in != out)
@@ -125,21 +115,30 @@ static int query_formats(AVFilterContext *ctx)
 static av_cold void uninit(AVFilterContext *ctx)
 {
 TremoloContext *s = ctx->priv;
-av_freep(&s->wave_table);
+av_freep(&s->table);
 }
 
 static int config_input(AVFilterLink *inlink)
 {
 AVFilterContext *ctx = inlink->dst;
 TremoloContext *s = ctx->priv;
+const double offset = 1. - s->depth / 2.;
+int i;
 
-s->sample_rate = inlink->sample_rate;
-s->wave_table = av_malloc_array(s->sample_rate / s->freq, 
sizeof(*s->wave_table));
-if (!s->wave_table)
+s->table = av_malloc_array(inlink->sample_rate, sizeof(*s->table));
+if (!s->table)
 return AVERROR(ENOMEM);
 
-ff_generate_wave_table(WAVE_SIN, AV_SAMPLE_FMT_DBL, s->wave_table, 
s->sample_rate / s->freq, 0.0, 1.0, 0.0);
-s->wave_table_index = 0;
+for (i = 0; i < inlink->sample_rate; i++) {
+double env = s->freq * i / inlink->sample_rate;
+
+env = sin(2 * M_PI * fmod(env + 0.25, 1.0));
+
+s->table[i] = env * (1 - fabs(offset)) + offset;
+}
+
+s->index = 0;
+
 return 0;
 }
 

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


[FFmpeg-cvslog] avfilter/generate_wave_table: clean up extra newlines

2015-09-24 Thread Kyle Swanson
ffmpeg | branch: master | Kyle Swanson  | Thu Sep 24 09:34:42 2015 
-0500| [435d000eb59ab974520bcfb3e77ddfa2473331f8] | committer: Paul B Mahol

avfilter/generate_wave_table: clean up extra newlines

Signed-off-by: Kyle Swanson 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=435d000eb59ab974520bcfb3e77ddfa2473331f8
---

 libavfilter/generate_wave_table.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/libavfilter/generate_wave_table.c 
b/libavfilter/generate_wave_table.c
index bee9c00..6cd8022 100644
--- a/libavfilter/generate_wave_table.c
+++ b/libavfilter/generate_wave_table.c
@@ -80,5 +80,3 @@ void ff_generate_wave_table(enum WaveType wave_type,
 }
 }
 }
-
-

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


[FFmpeg-cvslog] tests/checkasm/vp9dsp: Revert first hunk of bddcf758d3a68ac0bcc3bc4fc4aa7156e05245d4

2015-09-24 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Sep 24 18:33:11 2015 +0200| [5ba40c3c712fdd44b6eecd5499799fe96225a01b] | 
committer: Michael Niedermayer

tests/checkasm/vp9dsp: Revert first hunk of 
bddcf758d3a68ac0bcc3bc4fc4aa7156e05245d4

The change was wrong, also add a comment explaining it

Found-by: BBB
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ba40c3c712fdd44b6eecd5499799fe96225a01b
---

 tests/checkasm/vp9dsp.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/checkasm/vp9dsp.c b/tests/checkasm/vp9dsp.c
index e94daf3..eb9228a 100644
--- a/tests/checkasm/vp9dsp.c
+++ b/tests/checkasm/vp9dsp.c
@@ -102,7 +102,9 @@ static void check_ipred(void)
 ((uint16_t *)buf0)[(a) + (b) * jstride] = c; \
 } \
 } while (0)
-#define setdx(a,b,c,d) setpx(a,b,(c)-(d)+(rnd()%((d)*2+1)))
+
+// c can be an assignment and must not be put under ()
+#define setdx(a,b,c,d) setpx(a,b,c-(d)+(rnd()%((d)*2+1)))
 #define setsx(a,b,c,d) setdx(a,b,c,(d) << (bit_depth - 8))
 #define randomize_buffers(bidx, lineoff, str) \
 do { \

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


[FFmpeg-cvslog] Return EOF for ICO when the end is reached

2015-09-24 Thread Michael Bradshaw
ffmpeg | branch: master | Michael Bradshaw  | Fri Aug 21 
07:46:16 2015 -0700| [244184217c3e560ff1f30c072edd745fa42a604c] | committer: 
Carl Eugen Hoyos

Return EOF for ICO when the end is reached

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=244184217c3e560ff1f30c072edd745fa42a604c
---

 libavformat/icodec.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 847f0ee..22e2099 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -124,7 +124,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 int ret;
 
 if (ico->current_image >= ico->nb_images)
-return AVERROR(EIO);
+return AVERROR_EOF;
 
 image = &ico->images[ico->current_image];
 

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


[FFmpeg-cvslog] avcodec/ffv1: seperate slice_count from max_slice_count

2015-09-24 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Sep 24 23:49:30 2015 +0200| [aa6c43f3fdec8a7518534b9dab20c9eb4be11568] | 
committer: Michael Niedermayer

avcodec/ffv1: seperate slice_count from max_slice_count

Fix segfault with too large slice_count
Fixes Ticket4879

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aa6c43f3fdec8a7518534b9dab20c9eb4be11568
---

 libavcodec/ffv1.c|   14 +++---
 libavcodec/ffv1.h|1 +
 libavcodec/ffv1dec.c |8 +---
 libavcodec/ffv1enc.c |4 +++-
 4 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 6bcdf7c..13d3be2 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -101,7 +101,7 @@ av_cold int ff_ffv1_init_slice_state(FFV1Context *f, 
FFV1Context *fs)
 av_cold int ff_ffv1_init_slices_state(FFV1Context *f)
 {
 int i, ret;
-for (i = 0; i < f->slice_count; i++) {
+for (i = 0; i < f->max_slice_count; i++) {
 FFV1Context *fs = f->slice_context[i];
 if ((ret = ff_ffv1_init_slice_state(f, fs)) < 0)
 return AVERROR(ENOMEM);
@@ -113,10 +113,10 @@ av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f)
 {
 int i;
 
-f->slice_count = f->num_h_slices * f->num_v_slices;
-av_assert0(f->slice_count > 0);
+f->max_slice_count = f->num_h_slices * f->num_v_slices;
+av_assert0(f->max_slice_count > 0);
 
-for (i = 0; i < f->slice_count; i++) {
+for (i = 0; i < f->max_slice_count; i++) {
 int sx  = i % f->num_h_slices;
 int sy  = i / f->num_h_slices;
 int sxs = f->avctx->width  *  sx  / f->num_h_slices;
@@ -210,7 +210,7 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
 ff_thread_release_buffer(avctx, &s->last_picture);
 av_frame_free(&s->last_picture.f);
 
-for (j = 0; j < s->slice_count; j++) {
+for (j = 0; j < s->max_slice_count; j++) {
 FFV1Context *fs = s->slice_context[j];
 for (i = 0; i < s->plane_count; i++) {
 PlaneContext *p = &fs->plane[i];
@@ -224,14 +224,14 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
 av_freep(&avctx->stats_out);
 for (j = 0; j < s->quant_table_count; j++) {
 av_freep(&s->initial_states[j]);
-for (i = 0; i < s->slice_count; i++) {
+for (i = 0; i < s->max_slice_count; i++) {
 FFV1Context *sf = s->slice_context[i];
 av_freep(&sf->rc_stat2[j]);
 }
 av_freep(&s->rc_stat2[j]);
 }
 
-for (i = 0; i < s->slice_count; i++)
+for (i = 0; i < s->max_slice_count; i++)
 av_freep(&s->slice_context[i]);
 
 return 0;
diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 9526b16..b68ed2c 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -118,6 +118,7 @@ typedef struct FFV1Context {
 
 struct FFV1Context *slice_context[MAX_SLICES];
 int slice_count;
+int max_slice_count;
 int num_v_slices;
 int num_h_slices;
 int slice_width;
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 557b1a0..fbb85d6 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -775,6 +775,7 @@ static int read_header(FFV1Context *f)
 av_log(f->avctx, AV_LOG_ERROR, "read_quant_table error\n");
 return AVERROR_INVALIDDATA;
 }
+f->slice_count = f->max_slice_count;
 } else if (f->version < 3) {
 f->slice_count = get_symbol(c, state, 0);
 } else {
@@ -789,8 +790,8 @@ static int read_header(FFV1Context *f)
 p -= size + trailer;
 }
 }
-if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0) {
-av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid\n", 
f->slice_count);
+if (f->slice_count > (unsigned)MAX_SLICES || f->slice_count <= 0 || 
f->slice_count > f->max_slice_count) {
+av_log(f->avctx, AV_LOG_ERROR, "slice count %d is invalid (max=%d)\n", 
f->slice_count, f->max_slice_count);
 return AVERROR_INVALIDDATA;
 }
 
@@ -1016,6 +1017,7 @@ static int init_thread_copy(AVCodecContext *avctx)
 f->picture.f  = NULL;
 f->last_picture.f = NULL;
 f->sample_buffer  = NULL;
+f->max_slice_count = 0;
 f->slice_count = 0;
 
 for (i = 0; i < f->quant_table_count; i++) {
@@ -1091,7 +1093,7 @@ static int update_thread_context(AVCodecContext *dst, 
const AVCodecContext *src)
 av_assert0(!fdst->sample_buffer);
 }
 
-av_assert1(fdst->slice_count == fsrc->slice_count);
+av_assert1(fdst->max_slice_count == fsrc->max_slice_count);
 
 
 ff_thread_release_buffer(dst, &fdst->picture);
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index 338cc4e..5bd93fb 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -982,6 +982,7 @@ slices_ok:
 
 if ((ret = ff_ffv1_init_slice_contexts(s)) < 0)
 return ret;
+s->slice_count = s->max_slice_count;
 if ((ret = ff_ffv1_init_slices