[FFmpeg-cvslog] avcodec/adpcm_psx: ignore unknown flag bits

2021-05-12 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Mon May  3 
21:20:30 2021 +1000| [d1c28c6c780514b12db761db5cde178725b165f0] | committer: 
Zane van Iperen

avcodec/adpcm_psx: ignore unknown flag bits

As per documentation.

Signed-off-by: Zane van Iperen 

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

 libavcodec/adpcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 09ea062027..94e1fade28 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -2002,7 +2002,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void 
*data,
 filter = filter >> 4;
 if (filter >= FF_ARRAY_ELEMS(xa_adpcm_table))
 return AVERROR_INVALIDDATA;
-flag   = bytestream2_get_byteu(&gb);
+flag   = bytestream2_get_byteu(&gb) & 0x7;
 
 /* Decode 28 samples.  */
 for (n = 0; n < 28; n++) {

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat: add Argonaut Games CVG demuxer

2021-05-12 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Mon May  3 
21:20:35 2021 +1000| [9789ea59d08d39cc21a72c2d97f6dae9660a3f3b] | committer: 
Zane van Iperen

avformat: add Argonaut Games CVG demuxer

Signed-off-by: Zane van Iperen 

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

 Changelog|   1 +
 MAINTAINERS  |   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/argo_cvg.c   | 245 +++
 libavformat/version.h|   4 +-
 6 files changed, 251 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index c38c5d63a0..04d23c7e16 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@ version :
 - ADPCM IMA Westwood encoder
 - Westwood AUD muxer
 - ADPCM IMA Acorn Replay decoder
+- Argonaut Games CVG demuxer
 
 
 version 4.4:
diff --git a/MAINTAINERS b/MAINTAINERS
index ed8eddb317..dcac46003e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -399,6 +399,7 @@ Muxers/Demuxers:
   apngdec.c Benoit Fouet
   argo_asf.cZane van Iperen
   argo_brp.cZane van Iperen
+  argo_cvg.cZane van Iperen
   ass*  Aurelien Jacobs
   astdec.c  Paul B Mahol
   astenc.c  James Almer
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 85b5d8e7eb..0dca1ffd77 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -107,6 +107,7 @@ OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o 
subtitles.o
 OBJS-$(CONFIG_ARGO_ASF_DEMUXER)  += argo_asf.o
 OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o
 OBJS-$(CONFIG_ARGO_BRP_DEMUXER)  += argo_brp.o argo_asf.o
+OBJS-$(CONFIG_ARGO_CVG_DEMUXER)  += argo_cvg.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
 OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0c672ad8c8..923af3f649 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -66,6 +66,7 @@ extern const AVInputFormat  ff_aqtitle_demuxer;
 extern const AVInputFormat  ff_argo_asf_demuxer;
 extern const AVOutputFormat ff_argo_asf_muxer;
 extern const AVInputFormat  ff_argo_brp_demuxer;
+extern const AVInputFormat  ff_argo_cvg_demuxer;
 extern const AVInputFormat  ff_asf_demuxer;
 extern const AVOutputFormat ff_asf_muxer;
 extern const AVInputFormat  ff_asf_o_demuxer;
diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
new file mode 100644
index 00..2851c1649f
--- /dev/null
+++ b/libavformat/argo_cvg.c
@@ -0,0 +1,245 @@
+/*
+ * Argonaut Games CVG demuxer
+ *
+ * Copyright (C) 2021 Zane van Iperen (z...@zanevaniperen.com)
+ *
+ * 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 "avformat.h"
+#include "internal.h"
+#include "libavutil/intreadwrite.h"
+
+/*
+ * .CVG files are essentially PSX ADPCM wrapped with a size and checksum.
+ * Found in the PSX versions of the game.
+ */
+
+#define ARGO_CVG_HEADER_SIZE12
+#define ARGO_CVG_BLOCK_ALIGN0x10
+#define ARGO_CVG_NB_BLOCKS  32
+#define ARGO_CVG_SAMPLES_PER_BLOCK  28
+
+typedef struct ArgoCVGHeader {
+uint32_t size; /*< File size -8 (this + trailing checksum) */
+uint32_t unk1; /*< Unknown. Always seems to be 0 or 1. */
+uint32_t unk2; /*< Unknown. Always seems to be 0 or 1. */
+} ArgoCVGHeader;
+
+typedef struct ArgoCVGOverride {
+const char*name;
+ArgoCVGHeader header;
+uint32_t  checksum;
+int   sample_rate;
+} ArgoCVGOverride;
+
+typedef struct ArgoCVGDemuxContext {
+ArgoCVGHeader header;
+uint32_t  checksum;
+uint32_t  num_blocks;
+uint32_t  blocks_read;
+} ArgoCVGDemuxContext;
+
+/* "Special" files that are played at a different rate. */
+static ArgoCVGOverride overrides[] = {
+{ "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */
+{ "REDCRY88.CVG", { 38280, 0, 1 }, 4134848, 88200 }, /* Beta */
+{ "DANLOOP1.CVG", { 54744, 1, 0 }, 5684641, 37

[FFmpeg-cvslog] avcodec/adpcm_psx: always fetch next byte irregardless of flag

2021-05-12 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Mon May  3 
21:20:26 2021 +1000| [a845e6daa9aba4cbed024de8cbefccaa6c40f4bb] | committer: 
Zane van Iperen

avcodec/adpcm_psx: always fetch next byte irregardless of flag

Even though all samples are meant to be zero (if flag == 0x07),
doesn't mean that they aren't there. See No$PSX docs [1].

[1]: https://problemkaputt.de/psx-spx.htm#spuadpcmsamples

Signed-off-by: Zane van Iperen 

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

 libavcodec/adpcm.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 8fe43b5720..09ea062027 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -2008,14 +2008,14 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 for (n = 0; n < 28; n++) {
 int sample = 0, scale;
 
-if (flag < 0x07) {
-if (n & 1) {
-scale = sign_extend(byte >> 4, 4);
-} else {
-byte  = bytestream2_get_byteu(&gb);
-scale = sign_extend(byte, 4);
-}
+if (n & 1) {
+scale = sign_extend(byte >> 4, 4);
+} else {
+byte  = bytestream2_get_byteu(&gb);
+scale = sign_extend(byte, 4);
+}
 
+if (flag < 0x07) {
 scale  = scale * (1 << 12);
 sample = (int)((scale >> shift) + 
(c->status[channel].sample1 * xa_adpcm_table[filter][0] + 
c->status[channel].sample2 * xa_adpcm_table[filter][1]) / 64);
 }

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat: add Argonaut Games CVG muxer

2021-05-12 Thread Zane van Iperen
ffmpeg | branch: master | Zane van Iperen  | Mon May  3 
21:20:39 2021 +1000| [dcb285d2b7d126c80fad6079400a904e813442c1] | committer: 
Zane van Iperen

avformat: add Argonaut Games CVG muxer

Signed-off-by: Zane van Iperen 

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

 Changelog|   1 +
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/argo_cvg.c   | 149 ++-
 libavformat/version.h|   2 +-
 5 files changed, 152 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 04d23c7e16..b9d5188cf6 100644
--- a/Changelog
+++ b/Changelog
@@ -6,6 +6,7 @@ version :
 - Westwood AUD muxer
 - ADPCM IMA Acorn Replay decoder
 - Argonaut Games CVG demuxer
+- Argonaut Games CVG muxer
 
 
 version 4.4:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 0dca1ffd77..c9ef564523 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -108,6 +108,7 @@ OBJS-$(CONFIG_ARGO_ASF_DEMUXER)  += argo_asf.o
 OBJS-$(CONFIG_ARGO_ASF_MUXER)+= argo_asf.o
 OBJS-$(CONFIG_ARGO_BRP_DEMUXER)  += argo_brp.o argo_asf.o
 OBJS-$(CONFIG_ARGO_CVG_DEMUXER)  += argo_cvg.o
+OBJS-$(CONFIG_ARGO_CVG_MUXER)+= argo_cvg.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec_f.o asf.o asfcrypt.o \
 avlanguage.o
 OBJS-$(CONFIG_ASF_O_DEMUXER) += asfdec_o.o asf.o asfcrypt.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 923af3f649..111ca3cbf0 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -67,6 +67,7 @@ extern const AVInputFormat  ff_argo_asf_demuxer;
 extern const AVOutputFormat ff_argo_asf_muxer;
 extern const AVInputFormat  ff_argo_brp_demuxer;
 extern const AVInputFormat  ff_argo_cvg_demuxer;
+extern const AVOutputFormat ff_argo_cvg_muxer;
 extern const AVInputFormat  ff_asf_demuxer;
 extern const AVOutputFormat ff_asf_muxer;
 extern const AVInputFormat  ff_asf_o_demuxer;
diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
index 2851c1649f..73db777199 100644
--- a/libavformat/argo_cvg.c
+++ b/libavformat/argo_cvg.c
@@ -1,5 +1,5 @@
 /*
- * Argonaut Games CVG demuxer
+ * Argonaut Games CVG (de)muxer
  *
  * Copyright (C) 2021 Zane van Iperen (z...@zanevaniperen.com)
  *
@@ -21,6 +21,7 @@
  */
 #include "avformat.h"
 #include "internal.h"
+#include "libavutil/opt.h"
 #include "libavutil/intreadwrite.h"
 
 /*
@@ -53,6 +54,14 @@ typedef struct ArgoCVGDemuxContext {
 uint32_t  blocks_read;
 } ArgoCVGDemuxContext;
 
+typedef struct ArgoCVGMuxContext {
+const AVClass *class;
+int   skip_rate_check;
+uint32_t  checksum;
+size_tsize;
+} ArgoCVGMuxContext;
+
+#if CONFIG_ARGO_CVG_DEMUXER
 /* "Special" files that are played at a different rate. */
 static ArgoCVGOverride overrides[] = {
 { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */
@@ -243,3 +252,141 @@ const AVInputFormat ff_argo_cvg_demuxer = {
 .read_packet= argo_cvg_read_packet,
 .read_seek  = argo_cvg_seek,
 };
+#endif
+
+#if CONFIG_ARGO_CVG_MUXER
+static int argo_cvg_write_init(AVFormatContext *s)
+{
+ArgoCVGMuxContext *ctx = s->priv_data;
+const AVCodecParameters *par;
+
+if (s->nb_streams != 1) {
+av_log(s, AV_LOG_ERROR, "CVG files have exactly one stream\n");
+return AVERROR(EINVAL);
+}
+
+par = s->streams[0]->codecpar;
+
+if (par->codec_id != AV_CODEC_ID_ADPCM_PSX) {
+av_log(s, AV_LOG_ERROR, "%s codec not supported\n",
+   avcodec_get_name(par->codec_id));
+return AVERROR(EINVAL);
+}
+
+if (par->channels != 1) {
+av_log(s, AV_LOG_ERROR, "CVG files only support 1 channel\n");
+return AVERROR(EINVAL);
+}
+
+if (par->block_align != ARGO_CVG_BLOCK_ALIGN)
+return AVERROR(EINVAL);
+
+if (!ctx->skip_rate_check && par->sample_rate != 22050) {
+av_log(s, AV_LOG_ERROR, "Sample rate must be 22050\n");
+return AVERROR(EINVAL);
+}
+
+if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL)) {
+av_log(s, AV_LOG_ERROR, "Stream not seekable, unable to write output 
file\n");
+return AVERROR(EINVAL);
+}
+
+return 0;
+}
+
+static int argo_cvg_write_header(AVFormatContext *s)
+{
+ArgoCVGMuxContext *ctx = s->priv_data;
+
+avio_wl32(s->pb, 0); /* Size, fixed later. */
+avio_wl32(s->pb, 0);
+avio_wl32(s->pb, 1);
+
+ctx->checksum = 1;
+ctx->size = 8;
+return 0;
+}
+
+static int argo_cvg_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ArgoCVGMuxContext *ctx = s->priv_data;
+AVCodecParameters *par = s->streams[0]->codecpar;
+
+if (pkt->size % par->block_align != 0)
+return AVERROR_INVALIDDATA;
+
+avio_write(s->pb, pkt->data, pkt->size);
+
+ctx->size += pkt->size;
+
+if (ctx->size > UINT32_MAX)
+  

[FFmpeg-cvslog] lavf/flvdec: normalize exporting date metadata

2021-05-12 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Mon May 10 
09:15:29 2021 +0200| [6a9a4f34bd4ab10726d43f8961edfd99a5c47647] | committer: 
Anton Khirnov

lavf/flvdec: normalize exporting date metadata

Export them in UTC, not the local timezone. This way the output is
the same everywhere. The timezone information stored in the file is
still ignored, since there seems to be no simple way to export it
correctly.

Format them according to ISO 8601, which we generally use for exporting
dates.

Fixes fate-flv-demux, which was broken since
958bea5248f87116b0dd080461aa70c14ea86cf0 on some platforms.

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

 libavformat/flvdec.c | 7 +--
 tests/ref/fate/flv-demux | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index e6c2877a74..ddaceaafe4 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -686,8 +686,11 @@ static int amf_parse_object(AVFormatContext *s, AVStream 
*astream,
 struct tm t;
 char datestr[128];
 time =  date.milliseconds / 1000; // to seconds
-localtime_r(&time, &t);
-strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S %z", &t);
+gmtime_r(&time, &t);
+
+// timezone is ignored, since there is no easy way to offset the 
UTC
+// timestamp into the specified timezone
+strftime(datestr, sizeof(datestr), "%Y-%m-%dT%H:%M:%SZ", &t);
 
 av_dict_set(&s->metadata, key, datestr, 0);
 }
diff --git a/tests/ref/fate/flv-demux b/tests/ref/fate/flv-demux
index 30435adeb9..827b56ea09 100644
--- a/tests/ref/fate/flv-demux
+++ b/tests/ref/fate/flv-demux
@@ -605,4 +605,4 @@ 
packet|codec_type=audio|stream_index=1|pts=11656|pts_time=11.656000|dts=11656|dt
 
packet|codec_type=video|stream_index=0|pts=11678|pts_time=11.678000|dts=11678|dts_time=11.678000|duration=33|duration_time=0.033000|size=1190|pos=510794|flags=__|data_hash=CRC32:a0206c90
 
stream|index=0|codec_name=h264|profile=77|codec_type=video|codec_tag_string=[0][0][0][0]|codec_tag=0x|width=426|height=240|coded_width=426|coded_height=240|closed_captions=0|has_b_frames=1|sample_aspect_ratio=1:1|display_aspect_ratio=71:40|pix_fmt=yuv420p|level=21|color_range=unknown|color_space=unknown|color_transfer=unknown|color_primaries=unknown|chroma_location=left|field_order=progressive|refs=1|is_avc=true|nal_length_size=4|id=N/A|r_frame_rate=3/1001|avg_frame_rate=30/1|time_base=1/1000|start_pts=0|start_time=0.00|duration_ts=N/A|duration=N/A|bit_rate=393929|max_bit_rate=N/A|bits_per_raw_sample=8|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=351|extradata_hash=CRC32:07b85ca9|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnail
 
s=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
 
stream|index=1|codec_name=aac|profile=1|codec_type=audio|codec_tag_string=[0][0][0][0]|codec_tag=0x|sample_fmt=fltp|sample_rate=22050|channels=2|channel_layout=stereo|bits_per_sample=0|id=N/A|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/1000|start_pts=0|start_time=0.00|duration_ts=N/A|duration=N/A|bit_rate=67874|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=252|extradata_hash=CRC32:d039c029|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
-format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.00|duration=210.20|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332|tag:hasAudio=true|tag:audiodelay=0|tag:videosize=10176110|tag:metadatadate=Sun,
 27 Feb 2011 12:00:33 +0100|tag:metadatacreator=inlet media FLVTool2 v1.0.6 - 
http://www.inlet-media.de/flvtool2|tag:hasCuePoints=false
+format|filename=Enigma_Principles_of_Lust-part.flv|nb_streams=2|nb_programs=0|format_name=flv|start_time=0.00|duration=210.20|size=512000|bit_rate=19485|probe_score=100|tag:hasKeyframes=true|tag:hasMetadata=true|tag:datasize=11970544|tag:hasVideo=true|tag:canSeekToEnd=false|tag:lasttimestamp=210|tag:lastkeyframetimestamp=210|tag:audiosize=1791332

[FFmpeg-cvslog] avutil/imgutils: don't add offsets to NULL pointers

2021-05-12 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed May 12 00:33:45 
2021 -0300| [fc99d595531c0742aae8fe088fc5aad519035f2a] | committer: James Almer

avutil/imgutils: don't add offsets to NULL pointers

Signed-off-by: James Almer 

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

 libavutil/imgutils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 53faad889a..6c32a71cc5 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -165,6 +165,9 @@ int av_image_fill_pointers(uint8_t *data[4], enum 
AVPixelFormat pix_fmt, int hei
 ret += sizes[i];
 }
 
+if (!ptr)
+return ret;
+
 data[0] = ptr;
 for (i = 1; i < 4 && sizes[i]; i++)
 data[i] = data[i - 1] + sizes[i - 1];

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/utils: Use 64bit earlier in r_frame_rate check

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 12 22:33:06 2021 +0200| [578633fc1ac8c02a36a706bd71f775550412d1e1] | 
committer: Michael Niedermayer

avformat/utils: Use 64bit earlier in r_frame_rate check

Fixes: signed integer overflow: 1406796319 * 2 cannot be represented in type 
'int'
Fixes: 
32777/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-5632576913014784

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 9228313a00..492e08562e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3988,7 +3988,7 @@ int avformat_find_stream_info(AVFormatContext *ic, 
AVDictionary **options)
 
 if (!st->r_frame_rate.num) {
 if (avctx->time_base.den * (int64_t) st->time_base.num
-<= avctx->time_base.num * avctx->ticks_per_frame * 
(uint64_t) st->time_base.den) {
+<= avctx->time_base.num * (uint64_t)avctx->ticks_per_frame 
* st->time_base.den) {
 av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,
   avctx->time_base.den, 
(int64_t)avctx->time_base.num * avctx->ticks_per_frame, INT_MAX);
 } else {

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tools/target_dec_fuzzer: Adjust threshold for jpeg2000

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 12 22:47:02 2021 +0200| [537d402d56c012d136c54936f12e89109b9635c4] | 
committer: Michael Niedermayer

tools/target_dec_fuzzer: Adjust threshold for jpeg2000

Fixes: Timeout (25->4sec)
Fixes: 
32780/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6017852583837696

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 tools/target_dec_fuzzer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 2bdf9ea8d5..7034e556fb 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -173,6 +173,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_IFF_ILBM:maxpixels  /= 128;   break;
 case AV_CODEC_ID_INDEO4:  maxpixels  /= 128;   break;
 case AV_CODEC_ID_INTERPLAY_ACM: maxsamples /= 16384;  break;
+case AV_CODEC_ID_JPEG2000:maxpixels  /= 16;break;
 case AV_CODEC_ID_LAGARITH:maxpixels  /= 1024;  break;
 case AV_CODEC_ID_LSCR:maxpixels  /= 16;break;
 case AV_CODEC_ID_MOTIONPIXELS:maxpixels  /= 256;   break;

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/mov: Ignore duplicate CoLL

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 13:37:26 2021 +0200| [9548dc74d8db2bc002e1195dbd076f621f5c3ea1] | 
committer: Michael Niedermayer

avformat/mov: Ignore duplicate CoLL

Fixes: memleak
Fixes: 
32146/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5377612845285376

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 3ee15ff3dc..c088c9f515 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5444,6 +5444,11 @@ static int mov_read_coll(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 }
 avio_skip(pb, 3); /* flags */
 
+if (sc->coll){
+av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate COLL\n");
+return 0;
+}
+
 sc->coll = av_content_light_metadata_alloc(&sc->coll_size);
 if (!sc->coll)
 return AVERROR(ENOMEM);

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avformat/mov: Limit nb_chapter_tracks to input size

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 13:30:17 2021 +0200| [299a56c9006b2eb8807c3e3efefb91a78fe6b3b2] | 
committer: Michael Niedermayer

avformat/mov: Limit nb_chapter_tracks to input size

Fixes: Timeout (15k loop iterations instead of 400m)
Fixes: 
31368/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6601583174483968

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavformat/mov.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index f67bb2441f..3ee15ff3dc 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4656,6 +4656,8 @@ static int mov_read_chap(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 for (i = 0; i < num && !pb->eof_reached; i++)
 c->chapter_tracks[i] = avio_rb32(pb);
 
+c->nb_chapter_tracks = i;
+
 return 0;
 }
 

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/vc1: Check remaining bits in ff_vc1_parse_frame_header()

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 15:50:43 2021 +0200| [38c47615880357314ba30727a85bf7b00989706a] | 
committer: Michael Niedermayer

avcodec/vc1: Check remaining bits in ff_vc1_parse_frame_header()

Fixes: Timeout
Fixes: 
33156/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV3_fuzzer-6259655027326976

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/vc1.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index b7140c089c..40e2b4d692 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -672,6 +672,8 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* 
gb)
 if (v->s.pict_type == AV_PICTURE_TYPE_P)
 v->rnd ^= 1;
 
+if (get_bits_left(gb) < 5)
+return AVERROR_INVALIDDATA;
 /* Quantizer stuff */
 pqindex = get_bits(gb, 5);
 if (!pqindex)
@@ -764,6 +766,9 @@ int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext* 
gb)
 av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: "
"Imode: %i, Invert: %i\n", status>>1, status&1);
 
+if (get_bits_left(gb) < 4)
+return AVERROR_INVALIDDATA;
+
 /* Hopefully this is correct for P-frames */
 v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables
 v->cbptab = get_bits(gb, 2);

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/adpcm: Set vqa_version before use in init

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 16:20:55 2021 +0200| [7a403da0cb8e5fe308fe307b7ed219110f7021e0] | 
committer: Michael Niedermayer

avcodec/adpcm: Set vqa_version before use in init

Fixes: null pointer dereference
Fixes: 
33172/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_WS_fuzzer-5200164273913856

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/adpcm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 94e1fade28..5e0a654caf 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -193,6 +193,8 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
 avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
 break;
 case AV_CODEC_ID_ADPCM_IMA_WS:
+if (avctx->extradata && avctx->extradata_size >= 2)
+c->vqa_version = AV_RL16(avctx->extradata);
 avctx->sample_fmt = c->vqa_version == 3 ? AV_SAMPLE_FMT_S16P :
   AV_SAMPLE_FMT_S16;
 break;

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] tools/target_dec_fuzzer: Adjust threshold for TAK

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 16:42:25 2021 +0200| [e4be734e4fd7e9a8e30462f2e026185765ddc4ba] | 
committer: Michael Niedermayer

tools/target_dec_fuzzer: Adjust threshold for TAK

Fixes: Timeout
Fixes: 
33346/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-4715352157192192

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 tools/target_dec_fuzzer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c
index 7034e556fb..0f4d4f1bed 100644
--- a/tools/target_dec_fuzzer.c
+++ b/tools/target_dec_fuzzer.c
@@ -193,6 +193,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t 
size) {
 case AV_CODEC_ID_SCREENPRESSO:maxpixels  /= 64;break;
 case AV_CODEC_ID_SMACKVIDEO:  maxpixels  /= 64;break;
 case AV_CODEC_ID_SNOW:maxpixels  /= 128;   break;
+case AV_CODEC_ID_TAK: maxsamples /= 1024;  break;
 case AV_CODEC_ID_TGV: maxpixels  /= 32;break;
 case AV_CODEC_ID_THEORA:  maxpixels  /= 1024;  break;
 case AV_CODEC_ID_TRUEMOTION2: maxpixels  /= 1024;  break;

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/clearvideo: Check for 0 tile_shift

2021-05-12 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Mon 
Apr 19 16:46:08 2021 +0200| [63e75e09aef5836330a2786f0a9229ed82239e6b] | 
committer: Michael Niedermayer

avcodec/clearvideo: Check for 0 tile_shift

Fixes: shift exponent -1 is negative
Fixes: 
33401/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CLEARVIDEO_fuzzer-5908683596890112

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

 libavcodec/clearvideo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index e5e33d3313..5c79376c64 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -722,8 +722,8 @@ static av_cold int clv_decode_init(AVCodecContext *avctx)
 }
 
 c->tile_shift = av_log2(c->tile_size);
-if (1U << c->tile_shift != c->tile_size) {
-av_log(avctx, AV_LOG_ERROR, "Tile size: %d, is not power of 2.\n", 
c->tile_size);
+if (1U << c->tile_shift != c->tile_size || c->tile_shift < 1) {
+av_log(avctx, AV_LOG_ERROR, "Tile size: %d, is not power of 2 > 1\n", 
c->tile_size);
 return AVERROR_INVALIDDATA;
 }
 

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] fix broken links to msdn documentation

2021-05-12 Thread Peter Ross
ffmpeg | branch: master | Peter Ross  | Tue Apr 20 16:38:45 
2021 +1000| [b5ea0980c5c78df25277f9a1baf640b60184ab61] | committer: Peter Ross

fix broken links to msdn documentation

Signed-off-by: Peter Ross 

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

 compat/msvcrt/snprintf.c | 2 +-
 libavformat/mmst.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/compat/msvcrt/snprintf.c b/compat/msvcrt/snprintf.c
index c64653fe82..43f5c3bb39 100644
--- a/compat/msvcrt/snprintf.c
+++ b/compat/msvcrt/snprintf.c
@@ -59,7 +59,7 @@ int avpriv_vsnprintf(char *s, size_t n, const char *fmt,
  * recommends to provide _snprintf/_vsnprintf() a buffer size that
  * is one less than the actual buffer, and zero it before calling
  * _snprintf/_vsnprintf() to workaround this problem.
- * See http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx */
+ * See 
https://web.archive.org/web/20151214111935/http://msdn.microsoft.com/en-us/library/1kt27hek(v=vs.80).aspx
 */
 memset(s, 0, n);
 va_copy(ap_copy, ap);
 ret = _vsnprintf(s, n - 1, fmt, ap_copy);
diff --git a/libavformat/mmst.c b/libavformat/mmst.c
index 377323fe27..fa6e86ac26 100644
--- a/libavformat/mmst.c
+++ b/libavformat/mmst.c
@@ -25,7 +25,7 @@
  * MMS protocol specification:
  *  [1]http://msdn.microsoft.com/en-us/library/cc234711(PROT.10).aspx
  * ASF specification. Revision 01.20.03.
- *  [2]http://msdn.microsoft.com/en-us/library/bb643323.aspx
+ *  
[2]http://web.archive.org/web/20131203084402/http://msdn.microsoft.com/en-us/library/bb643323.aspx
  */
 
 #include "avformat.h"

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

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] GSoC: Support fast guided filter.

2021-05-12 Thread Xuewei Meng
ffmpeg | branch: master | Xuewei Meng  | Mon May 10 
21:42:31 2021 +0800| [43d70feb788318b124418c5c666f2120ee5ca930] | committer: 
Steven Liu

GSoC: Support fast guided filter.

Two modes are supported in guided filter, basic mode and fast mode.
Basic mode is the initial pushed guided filter without optimization.
Fast mode is implemented based on the basic one by sub-sampling method.
The sub-sampling ratio which can be defined by users controls the
algorithm complexity. The larger the sub-sampling ratio, the lower
the algorithm complexity.

Signed-off-by: Xuewei Meng 
Reviewed-by: Steven Liu 

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

 doc/filters.texi|  20 +++---
 libavfilter/vf_guided.c | 104 
 2 files changed, 85 insertions(+), 39 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 22d02c38f7..b574334bea 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12963,12 +12963,22 @@ Apply guided filter for edge-preserving smoothing, 
dehazing and so on.
 The filter accepts the following options:
 @table @option
 @item radius
-Set the radius in pixels.
+Set the box radius in pixels.
 Allowed range is 1 to 20. Default is 3.
 
 @item eps
-Set regularization parameter.
-Allowed range is 0 to 1. Default is 0.1.
+Set regularization parameter (with square).
+Allowed range is 0 to 1. Default is 0.01.
+
+@item mode
+Set filter mode. Can be @code{basic} or @code{fast}.
+Default is @code{basic}.
+
+@item sub
+Set subsampling ratio.
+Allowed range is 1 to 64.
+Default is always 1 for @code{basic} value of @var{mode} option,
+and 4 for @code{fast} value of @var{mode} option.
 
 @item planes
 Set planes to filter. Default is first only.
@@ -12987,8 +12997,8 @@ ffmpeg -i in.png -i in.png -filter_complex guided 
out.png
 
 @item
 Dehazing, structure-transferring filtering, detail enhancement with guided 
filter.
-For the generation of guidance image,
-see @url{http://kaiminghe.com/publications/pami12guidedfilter.pdf}.
+For the generation of guidance image, refer to paper "Guided Image Filtering".
+See: @url{http://kaiminghe.com/publications/pami12guidedfilter.pdf}.
 @example
 ffmpeg -i in.png -i guidance.png -filter_complex guided out.png
 @end example
diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c
index 20c142337a..e7c689e7be 100644
--- a/libavfilter/vf_guided.c
+++ b/libavfilter/vf_guided.c
@@ -27,12 +27,20 @@
 #include "internal.h"
 #include "video.h"
 
+enum FilterModes {
+BASIC,
+FAST,
+NB_MODES,
+};
+
 typedef struct GuidedContext {
 const AVClass *class;
 FFFrameSync fs;
 
 int radius;
 float eps;
+int mode;
+int sub;
 
 int planes;
 
@@ -51,9 +59,13 @@ typedef struct GuidedContext {
 #define FLAGS 
AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 
 static const AVOption guided_options[] = {
-{ "radius", "set the box radius",   OFFSET(radius), 
AV_OPT_TYPE_INT,   {.i64=3},   1,  20, FLAGS },
-{ "eps","set the regularization parameter (with square)",  
OFFSET(eps),AV_OPT_TYPE_FLOAT, {.dbl=0.01  }, 0.0,   1, FLAGS },
-{ "planes", "set planes to filter", OFFSET(planes), AV_OPT_TYPE_INT,   
{.i64=1},   0, 0xF, FLAGS },
+{ "radius", "set the box radius",   
OFFSET(radius), AV_OPT_TYPE_INT,   {.i64 = 3},   1,   20, FLAGS },
+{ "eps","set the regularization parameter (with square)",   
OFFSET(eps),AV_OPT_TYPE_FLOAT, {.dbl = 0.01 }, 0.0,1, FLAGS },
+{ "mode",   "set filtering mode (0: basic mode; 1: fast mode)", 
OFFSET(mode),   AV_OPT_TYPE_INT,   {.i64 = BASIC},   0, NB_MODES - 1, FLAGS, 
"mode" },
+{ "basic",  "basic guided filter",  0, 
 AV_OPT_TYPE_CONST, {.i64 = BASIC},   0,0, FLAGS, "mode" },
+{ "fast",   "fast guided filter",   0, 
 AV_OPT_TYPE_CONST, {.i64 = FAST },   0,0, FLAGS, "mode" },
+{ "sub","subsampling ratio",
OFFSET(sub),AV_OPT_TYPE_INT,   {.i64 = 1},   1,   64, FLAGS },
+{ "planes", "set planes to filter", 
OFFSET(planes), AV_OPT_TYPE_INT,   {.i64=1  },   0,  0xF, FLAGS },
 { NULL }
 };
 
@@ -147,6 +159,26 @@ static int config_input(AVFilterLink *inlink)
 return AVERROR(EINVAL);
 }
 
+if (s->mode == BASIC) {
+if (s->sub != 1) {
+av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is 1 in basic 
mode.\n");
+s->sub = 1;
+}
+}
+else if (s->mode == FAST) {
+if (s->sub == 1) {
+av_log(ctx, AV_LOG_WARNING, "Subsampling ratio is larger than 1 in 
fast mode.\n");
+s->sub = 4;
+}
+if (s->radius >= s->sub)
+s->radius = s->radius / s->sub;
+