[FFmpeg-cvslog] wmavoice: move wmavoice_flush() up.

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Tue Dec 20 
17:03:46 2016 -0500| [992cb15e671332650ddd5020c00cf08a40bb7cf0] | committer: 
Ronald S. Bultje

wmavoice: move wmavoice_flush() up.

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

 libavcodec/wmavoice.c | 56 +--
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index ceac61f..4b3ab43 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -337,6 +337,34 @@ static av_cold void wmavoice_init_static_data(AVCodec 
*codec)
 bits, 1, 1, codes, 2, 2, 132);
 }
 
+static av_cold void wmavoice_flush(AVCodecContext *ctx)
+{
+WMAVoiceContext *s = ctx->priv_data;
+int n;
+
+s->postfilter_agc= 0;
+s->sframe_cache_size = 0;
+s->skip_bits_next= 0;
+for (n = 0; n < s->lsps; n++)
+s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0);
+memset(s->excitation_history, 0,
+   sizeof(*s->excitation_history) * MAX_SIGNAL_HISTORY);
+memset(s->synth_history,  0,
+   sizeof(*s->synth_history)  * MAX_LSPS);
+memset(s->gain_pred_err,  0,
+   sizeof(s->gain_pred_err));
+
+if (s->do_apf) {
+memset(&s->synth_filter_out_buf[MAX_LSPS_ALIGN16 - s->lsps], 0,
+   sizeof(*s->synth_filter_out_buf) * s->lsps);
+memset(s->dcf_mem,  0,
+   sizeof(*s->dcf_mem)  * 2);
+memset(s->zero_exc_pf,  0,
+   sizeof(*s->zero_exc_pf)  * s->history_nsamples);
+memset(s->denoise_filter_cache, 0, sizeof(s->denoise_filter_cache));
+}
+}
+
 /**
  * Set up decoder with parameters from demuxer (extradata etc.).
  */
@@ -2046,34 +2074,6 @@ static av_cold int wmavoice_decode_end(AVCodecContext 
*ctx)
 return 0;
 }
 
-static av_cold void wmavoice_flush(AVCodecContext *ctx)
-{
-WMAVoiceContext *s = ctx->priv_data;
-int n;
-
-s->postfilter_agc= 0;
-s->sframe_cache_size = 0;
-s->skip_bits_next= 0;
-for (n = 0; n < s->lsps; n++)
-s->prev_lsps[n] = M_PI * (n + 1.0) / (s->lsps + 1.0);
-memset(s->excitation_history, 0,
-   sizeof(*s->excitation_history) * MAX_SIGNAL_HISTORY);
-memset(s->synth_history,  0,
-   sizeof(*s->synth_history)  * MAX_LSPS);
-memset(s->gain_pred_err,  0,
-   sizeof(s->gain_pred_err));
-
-if (s->do_apf) {
-memset(&s->synth_filter_out_buf[MAX_LSPS_ALIGN16 - s->lsps], 0,
-   sizeof(*s->synth_filter_out_buf) * s->lsps);
-memset(s->dcf_mem,  0,
-   sizeof(*s->dcf_mem)  * 2);
-memset(s->zero_exc_pf,  0,
-   sizeof(*s->zero_exc_pf)  * s->history_nsamples);
-memset(s->denoise_filter_cache, 0, sizeof(s->denoise_filter_cache));
-}
-}
-
 AVCodec ff_wmavoice_decoder = {
 .name = "wmavoice",
 .long_name= NULL_IF_CONFIG_SMALL("Windows Media Audio Voice"),

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


[FFmpeg-cvslog] checkasm/vp9: benchmark all sub-IDCTs (but not WHT or ADST).

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Thu Nov 17 
16:08:20 2016 -0500| [1c8fbd7b90469f69fe3a3f78ba7886195d97c34f] | committer: 
Ronald S. Bultje

checkasm/vp9: benchmark all sub-IDCTs (but not WHT or ADST).

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

 tests/checkasm/vp9dsp.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/tests/checkasm/vp9dsp.c b/tests/checkasm/vp9dsp.c
index 441041c..f32b97c 100644
--- a/tests/checkasm/vp9dsp.c
+++ b/tests/checkasm/vp9dsp.c
@@ -331,15 +331,20 @@ static void check_itxfm(void)
 int n_txtps = tx < TX_32X32 ? N_TXFM_TYPES : 1;
 
 for (txtp = 0; txtp < n_txtps; txtp++) {
-if (check_func(dsp.itxfm_add[tx][txtp], 
"vp9_inv_%s_%dx%d_add_%d",
-   tx == 4 ? "wht_wht" : txtp_types[txtp], sz, sz,
-   bit_depth)) {
-randomize_buffers();
-ftx(coef, tx, txtp, sz, bit_depth);
-
-for (sub = (txtp == 0) ? 1 : 2; sub <= sz; sub <<= 1) {
+// skip testing sub-IDCTs for WHT or ADST since they don't
+// implement it in any of the SIMD functions. If they do,
+// consider changing this to ensure we have complete test
+// coverage
+for (sub = (txtp == 0 && tx < 4) ? 1 : sz; sub <= sz; sub <<= 
1) {
+if (check_func(dsp.itxfm_add[tx][txtp],
+   "vp9_inv_%s_%dx%d_sub%d_add_%d",
+   tx == 4 ? "wht_wht" : txtp_types[txtp],
+   sz, sz, sub, bit_depth)) {
 int eob;
 
+randomize_buffers();
+ftx(coef, tx, txtp, sz, bit_depth);
+
 if (sub < sz) {
 eob = copy_subcoefs(subcoef0, coef, tx, txtp,
 sz, sub, bit_depth);
@@ -357,8 +362,9 @@ static void check_itxfm(void)
 !iszero(subcoef0, sz * sz * SIZEOF_COEF) ||
 !iszero(subcoef1, sz * sz * SIZEOF_COEF))
 fail();
+
+bench_new(dst, sz * SIZEOF_PIXEL, coef, eob);
 }
-bench_new(dst, sz * SIZEOF_PIXEL, coef, sz * sz);
 }
 }
 }

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


[FFmpeg-cvslog] wmavoice: disable bitstream checking.

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Tue Dec 20 
17:14:26 2016 -0500| [3deb4b54a24f8cddce463d9f5751b01efeb976af] | committer: 
Ronald S. Bultje

wmavoice: disable bitstream checking.

The checked bitstream reader does that already. To allow parsing of
superframes split over a packet boundary, we always decode the last
superframe in each packet at the start of the next packet, even if
theoretically we could have decoded it. The last superframe in the
last packet is decoded using AV_CODEC_CAP_DELAY.

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

 libavcodec/wmavoice.c | 144 ++
 1 file changed, 29 insertions(+), 115 deletions(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 4b3ab43..ae100fb 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -251,6 +251,7 @@ typedef struct WMAVoiceContext {
 
 int frame_cntr;   ///< current frame index [0 - 0xFFFE]; is
   ///< only used for comfort noise in #pRNG()
+int nb_superframes;   ///< number of superframes in current packet
 float gain_pred_err[6];   ///< cache for gain prediction
 float excitation_history[MAX_SIGNAL_HISTORY];
   ///< cache of the signal of previous
@@ -875,7 +876,6 @@ static void dequant_lsps(double *lsps, int num,
 /**
  * @name LSP dequantization routines
  * LSP dequantization routines, for 10/16LSPs and independent/residual coding.
- * @note we assume enough bits are available, caller should check.
  * lsp10i() consumes 24 bits; lsp10r() consumes an additional 24 bits;
  * lsp16i() consumes 34 bits; lsp16r() consumes an additional 26 bits.
  * @{
@@ -1419,7 +1419,6 @@ static void synth_block_fcb_acb(WMAVoiceContext *s, 
GetBitContext *gb,
 
 /**
  * Parse data in a single block.
- * @note we assume enough bits are available, caller should check.
  *
  * @param s WMA Voice decoding context private data
  * @param gb bit I/O context
@@ -1463,7 +1462,6 @@ static void synth_block(WMAVoiceContext *s, GetBitContext 
*gb,
 
 /**
  * Synthesize output samples for a single frame.
- * @note we assume enough bits are available, caller should check.
  *
  * @param ctx WMA Voice decoder context
  * @param gb bit I/O context (s->gb or one for cross-packet superframes)
@@ -1682,83 +1680,6 @@ static void stabilize_lsps(double *lsps, int num)
 }
 
 /**
- * Test if there's enough bits to read 1 superframe.
- *
- * @param orig_gb bit I/O context used for reading. This function
- *does not modify the state of the bitreader; it
- *only uses it to copy the current stream position
- * @param s WMA Voice decoding context private data
- * @return < 0 on error, 1 on not enough bits or 0 if OK.
- */
-static int check_bits_for_superframe(GetBitContext *orig_gb,
- WMAVoiceContext *s)
-{
-GetBitContext s_gb, *gb = &s_gb;
-int n, need_bits, bd_idx;
-const struct frame_type_desc *frame_desc;
-
-/* initialize a copy */
-init_get_bits(gb, orig_gb->buffer, orig_gb->size_in_bits);
-skip_bits_long(gb, get_bits_count(orig_gb));
-av_assert1(get_bits_left(gb) == get_bits_left(orig_gb));
-
-/* superframe header */
-if (get_bits_left(gb) < 14)
-return 1;
-if (!get_bits1(gb))
-return AVERROR(ENOSYS);   // WMAPro-in-WMAVoice superframe
-if (get_bits1(gb)) skip_bits(gb, 12); // number of  samples in superframe
-if (s->has_residual_lsps) {   // residual LSPs (for all frames)
-if (get_bits_left(gb) < s->sframe_lsp_bitsize)
-return 1;
-skip_bits_long(gb, s->sframe_lsp_bitsize);
-}
-
-/* frames */
-for (n = 0; n < MAX_FRAMES; n++) {
-int aw_idx_is_ext = 0;
-
-if (!s->has_residual_lsps) { // independent LSPs (per-frame)
-   if (get_bits_left(gb) < s->frame_lsp_bitsize) return 1;
-   skip_bits_long(gb, s->frame_lsp_bitsize);
-}
-bd_idx = s->vbm_tree[get_vlc2(gb, frame_type_vlc.table, 6, 3)];
-if (bd_idx < 0)
-return AVERROR_INVALIDDATA; // invalid frame type VLC code
-frame_desc = &frame_descs[bd_idx];
-if (frame_desc->acb_type == ACB_TYPE_ASYMMETRIC) {
-if (get_bits_left(gb) < s->pitch_nbits)
-return 1;
-skip_bits_long(gb, s->pitch_nbits);
-}
-if (frame_desc->fcb_type == FCB_TYPE_SILENCE) {
-skip_bits(gb, 8);
-} else if (frame_desc->fcb_type == FCB_TYPE_AW_PULSES) {
-int tmp = get_bits(gb, 6);
-if (tmp >= 0x36) {
-skip_bits(gb, 2);
-aw_idx_is_ext = 1;
-}
-}
-
-/* blocks */
-if (frame_desc->acb_type == ACB_TYPE_HAMMING) {
-need_bits = s->block_pitch_nbits +
-(frame_desc->n_blocks - 1

[FFmpeg-cvslog] wmavoice: reindent.

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Tue Dec 20 
17:14:41 2016 -0500| [b011bb5f8b2ce5f21bc4f07f50a56a26310383af] | committer: 
Ronald S. Bultje

wmavoice: reindent.

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

 libavcodec/wmavoice.c | 72 +--
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index ae100fb..f31c9d2 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -1915,29 +1915,29 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, 
void *data,
 /* If the packet header specifies a s->spillover_nbits, then we want
  * to push out all data of the previous packet (+ spillover) before
  * continuing to parse new superframes in the current packet. */
-if (s->sframe_cache_size > 0) {
-int cnt = get_bits_count(gb);
-copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
-flush_put_bits(&s->pb);
-s->sframe_cache_size += s->spillover_nbits;
-if ((res = synth_superframe(ctx, data, got_frame_ptr)) == 0 &&
-*got_frame_ptr) {
-cnt += s->spillover_nbits;
-s->skip_bits_next = cnt & 7;
-res = cnt >> 3;
-if (res > avpkt->size) {
-av_log(ctx, AV_LOG_ERROR,
-   "Trying to skip %d bytes in packet of size 
%d\n",
-   res, avpkt->size);
-return AVERROR_INVALIDDATA;
-}
-return res;
-} else
-skip_bits_long (gb, s->spillover_nbits - cnt +
-get_bits_count(gb)); // resync
-} else if (s->spillover_nbits) {
-skip_bits_long(gb, s->spillover_nbits);  // resync
-}
+if (s->sframe_cache_size > 0) {
+int cnt = get_bits_count(gb);
+copy_bits(&s->pb, avpkt->data, size, gb, s->spillover_nbits);
+flush_put_bits(&s->pb);
+s->sframe_cache_size += s->spillover_nbits;
+if ((res = synth_superframe(ctx, data, got_frame_ptr)) == 0 &&
+*got_frame_ptr) {
+cnt += s->spillover_nbits;
+s->skip_bits_next = cnt & 7;
+res = cnt >> 3;
+if (res > avpkt->size) {
+av_log(ctx, AV_LOG_ERROR,
+   "Trying to skip %d bytes in packet of size %d\n",
+   res, avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+return res;
+} else
+skip_bits_long (gb, s->spillover_nbits - cnt +
+get_bits_count(gb)); // resync
+} else if (s->spillover_nbits) {
+skip_bits_long(gb, s->spillover_nbits);  // resync
+}
 } else if (s->skip_bits_next)
 skip_bits(gb, s->skip_bits_next);
 
@@ -1949,20 +1949,20 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, 
void *data,
 *got_frame_ptr = 0;
 return size;
 } else if (s->nb_superframes > 0) {
-if ((res = synth_superframe(ctx, data, got_frame_ptr)) < 0) {
-return res;
-} else if (*got_frame_ptr) {
-int cnt = get_bits_count(gb);
-s->skip_bits_next = cnt & 7;
-res = cnt >> 3;
-if (res > avpkt->size) {
-av_log(ctx, AV_LOG_ERROR,
-   "Trying to skip %d bytes in packet of size %d\n",
-   res, avpkt->size);
-return AVERROR_INVALIDDATA;
+if ((res = synth_superframe(ctx, data, got_frame_ptr)) < 0) {
+return res;
+} else if (*got_frame_ptr) {
+int cnt = get_bits_count(gb);
+s->skip_bits_next = cnt & 7;
+res = cnt >> 3;
+if (res > avpkt->size) {
+av_log(ctx, AV_LOG_ERROR,
+   "Trying to skip %d bytes in packet of size %d\n",
+   res, avpkt->size);
+return AVERROR_INVALIDDATA;
+}
+return res;
 }
-return res;
-}
 } else if ((s->sframe_cache_size = pos) > 0) {
 /* ... cache it for spillover in next packet */
 init_put_bits(&s->pb, s->sframe_cache, SFRAME_CACHE_MAXSIZE);

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


[FFmpeg-cvslog] wmavoice: protect against zero-energy in adaptive gain control.

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Tue Dec 20 
18:01:05 2016 -0500| [33d7f822f8ed2d1870babc1d04d4d48cf8b6f240] | committer: 
Ronald S. Bultje

wmavoice: protect against zero-energy in adaptive gain control.

Otherwise the scale factor becomes NaN, resulting in corrupt output.
Fixes #5426.

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

 libavcodec/wmavoice.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 90dfe20..cd5958c 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -512,7 +512,8 @@ static void adaptive_gain_control(float *out, const float 
*in,
 speech_energy += fabsf(speech_synth[i]);
 postfilter_energy += fabsf(in[i]);
 }
-gain_scale_factor = (1.0 - alpha) * speech_energy / postfilter_energy;
+gain_scale_factor = postfilter_energy == 0.0 ? 0.0 :
+(1.0 - alpha) * speech_energy / postfilter_energy;
 
 for (i = 0; i < size; i++) {
 mem = alpha * mem + gain_scale_factor;

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


[FFmpeg-cvslog] wmavoice: move overflow handling to common code.

2016-12-27 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Tue Dec 20 
17:10:33 2016 -0500| [7b27dd5c16de785297ce4de4b88afa0b6685f61d] | committer: 
Ronald S. Bultje

wmavoice: move overflow handling to common code.

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

 libavcodec/wmavoice.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index f31c9d2..90dfe20 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -1800,6 +1800,11 @@ static int synth_superframe(AVCodecContext *ctx, AVFrame 
*frame,
 skip_bits(gb, 10 * (res + 1));
 }
 
+if (get_bits_left(gb) < 0) {
+wmavoice_flush(ctx);
+return AVERROR_INVALIDDATA;
+}
+
 *got_frame_ptr = 1;
 
 /* Update history */
@@ -1925,12 +1930,6 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, 
void *data,
 cnt += s->spillover_nbits;
 s->skip_bits_next = cnt & 7;
 res = cnt >> 3;
-if (res > avpkt->size) {
-av_log(ctx, AV_LOG_ERROR,
-   "Trying to skip %d bytes in packet of size %d\n",
-   res, avpkt->size);
-return AVERROR_INVALIDDATA;
-}
 return res;
 } else
 skip_bits_long (gb, s->spillover_nbits - cnt +
@@ -1955,12 +1954,6 @@ static int wmavoice_decode_packet(AVCodecContext *ctx, 
void *data,
 int cnt = get_bits_count(gb);
 s->skip_bits_next = cnt & 7;
 res = cnt >> 3;
-if (res > avpkt->size) {
-av_log(ctx, AV_LOG_ERROR,
-   "Trying to skip %d bytes in packet of size %d\n",
-   res, avpkt->size);
-return AVERROR_INVALIDDATA;
-}
 return res;
 }
 } else if ((s->sframe_cache_size = pos) > 0) {

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


[FFmpeg-cvslog] MAINTAINERS: update

2016-12-27 Thread Christophe Gisquet
ffmpeg | branch: master | Christophe Gisquet  | 
Tue Dec 27 09:18:51 2016 +| [e3312b3746ef364c3101381bada57f8ef75f175a] | 
committer: Michael Niedermayer

MAINTAINERS: update

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

 MAINTAINERS | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index e718463..cb9516d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -176,7 +176,7 @@ Codecs:
   h263* Michael Niedermayer
   h264* Loren Merritt, Michael Niedermayer
   hap*  Tom Butterworth
-  huffyuv*  Michael Niedermayer, Christophe Gisquet
+  huffyuv*  Michael Niedermayer
   idcinvideo.c  Mike Melanson
   interplayvideo.c  Mike Melanson
   jni*, ffjni*  Matthieu Bouron
@@ -223,7 +223,6 @@ Codecs:
   rpza.cRoberto Togni
   rtjpeg.c, rtjpeg.hReimar Doeffinger
   rv10.cMichael Niedermayer
-  rv4*  Christophe Gisquet
   s3tc* Ivo van Poorten
   smc.c Mike Melanson
   smvjpegdec.c  Ash Hughes
@@ -237,7 +236,6 @@ Codecs:
   tta.c Alex Beregszaszi, Jaikrishnan Menon
   ttaenc.c  Paul B Mahol
   txd.c Ivo van Poorten
-  vc1*  Christophe Gisquet
   vc2*  Rostislav Pehlivanov
   vcr1.cMichael Niedermayer
   vda_h264_dec.cXidorn Quan

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


[FFmpeg-cvslog] lavfi/transpose: add missing const options flags

2016-12-27 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Tue Dec 27 09:36:18 
2016 +0100| [571a36015738b081dea1893fd7e5f193a51d6438] | committer: Clément 
Bœsch

lavfi/transpose: add missing const options flags

Fixes ffmpeg -h filter=transpose

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

 libavfilter/vf_transpose.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 28226c3..75b4dda 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -260,10 +260,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
 static const AVOption transpose_options[] = {
 { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = 
TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
-{ "cclock_flip", "rotate counter-clockwise with vertical flip", 0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .unit = "dir" },
-{ "clock",   "rotate clockwise",0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK   }, .unit = "dir" },
-{ "cclock",  "rotate counter-clockwise",0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK  }, .unit = "dir" },
-{ "clock_flip",  "rotate clockwise with vertical flip", 0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP  }, .unit = "dir" },
+{ "cclock_flip", "rotate counter-clockwise with vertical flip", 0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = 
"dir" },
+{ "clock",   "rotate clockwise",0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK   }, .flags=FLAGS, .unit = 
"dir" },
+{ "cclock",  "rotate counter-clockwise",0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK  }, .flags=FLAGS, .unit = 
"dir" },
+{ "clock_flip",  "rotate clockwise with vertical flip", 0, 
AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = 
"dir" },
 
 { "passthrough", "do not apply transposition if the input matches the 
specified geometry",
   OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE},  0, 
INT_MAX, FLAGS, "passthrough" },

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


[FFmpeg-cvslog] lavfi/selectivecolor: simplify crazy mid val computations

2016-12-27 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Tue Dec 27 23:43:59 
2016 +0100| [afaaf8db1847ddd7d291c218edcba5cd4bf2441e] | committer: Clément 
Bœsch

lavfi/selectivecolor: simplify crazy mid val computations

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

 libavfilter/vf_selectivecolor.c | 33 +++--
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/libavfilter/vf_selectivecolor.c b/libavfilter/vf_selectivecolor.c
index a5cb533..26fd8eb 100644
--- a/libavfilter/vf_selectivecolor.c
+++ b/libavfilter/vf_selectivecolor.c
@@ -28,6 +28,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
+#include "libavcodec/mathops.h" // for mid_pred(), which is a macro so no link 
dependency
 #include "avfilter.h"
 #include "drawutils.h"
 #include "formats.h"
@@ -112,42 +113,14 @@ static const AVOption selectivecolor_options[] = {
 
 AVFILTER_DEFINE_CLASS(selectivecolor);
 
-static inline int get_mid_val(int r, int g, int b)
-{
-if ((r < g && r > b) || (r < b && r > g)) return r;
-if ((g < r && g > b) || (g < b && g > r)) return g;
-if ((b < r && b > g) || (b < g && b > r)) return b;
-return -1;
-}
-
 static int get_rgb_adjust_range(int r, int g, int b, int min_val, int max_val)
 {
-// max - mid
-const int mid_val = get_mid_val(r, g, b);
-if (mid_val == -1) {
-// XXX: can be simplified
-if ((r != min_val && g == min_val && b == min_val) ||
-(r == min_val && g != min_val && b == min_val) ||
-(r == min_val && g == min_val && b != min_val))
-return max_val - min_val;
-return 0;
-}
-return max_val - mid_val;
+return max_val - mid_pred(r, g, b);
 }
 
 static int get_cmy_adjust_range(int r, int g, int b, int min_val, int max_val)
 {
-// mid - min
-const int mid_val = get_mid_val(r, g, b);
-if (mid_val == -1) {
-// XXX: refactor with rgb
-if ((r != max_val && g == max_val && b == max_val) ||
-(r == max_val && g != max_val && b == max_val) ||
-(r == max_val && g == max_val && b != max_val))
-return max_val - min_val;
-return 0;
-}
-return mid_val - min_val;
+return mid_pred(r, g, b) - min_val;
 }
 
 #define DECLARE_ADJUST_RANGE_FUNCS(nbits)  
 \

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