[FFmpeg-cvslog] avformat/segafilm - revert keyframe detection

2018-04-21 Thread Gyan Doshi
ffmpeg | branch: master | Gyan Doshi  | Sat Apr 21 13:02:12 
2018 +0530| [9f9f56e6791f6c44ac8e4b97a8da5816ed542332] | committer: James Almer

avformat/segafilm - revert keyframe detection

Keyframe detection was inverted in cfe1a9d311 in order to fix keyframe
flags set for the sample attached to trac #7091. However, that sample is
errantly muxed.

As noted at
https://web.archive.org/web/20020803104640/http://www.pcisys.net:80/~melanson/codecs/film-format.txt,
the original keyframe detection logic is correct, and this patch
restores it.

Signed-off-by: James Almer 

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

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

diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index e72c26b144..b0c6c419ce 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -239,7 +239,7 @@ static int film_read_header(AVFormatContext *s)
 } else {
 film->sample_table[i].stream = film->video_stream_index;
 film->sample_table[i].pts = AV_RB32([8]) & 0x7FFF;
-film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 
AVINDEX_KEYFRAME : 0;
+film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 
AVINDEX_KEYFRAME;
 video_frame_counter++;
 if (film->video_type)
 av_add_index_entry(s->streams[film->video_stream_index],

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


[FFmpeg-cvslog] avcodec/vc1_pred: set ref_field_type earlier

2018-04-21 Thread Jerome Borsboom
ffmpeg | branch: master | Jerome Borsboom  | Sat 
Apr 21 21:05:28 2018 +0200| [c0f154bba506e1cb609b1193632d452b89918a80] | 
committer: Paul B Mahol

avcodec/vc1_pred: set ref_field_type earlier

scaleforsame_y references ref_field_type. Therefore, it needs to be set
before scaleforsame is called.

Fixes #2557.

Signed-off-by: Jerome Borsboom 

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

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

diff --git a/libavcodec/vc1_pred.c b/libavcodec/vc1_pred.c
index 54712f6b7a..3a52a22bc6 100644
--- a/libavcodec/vc1_pred.c
+++ b/libavcodec/vc1_pred.c
@@ -341,6 +341,8 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int 
dmv_y,
 } else
 opposite = 0;
 if (opposite) {
+v->mv_f[dir][xy + v->blocks_off] = 1;
+v->ref_field_type[dir] = !v->cur_field_type;
 if (a_valid && !a_f) {
 field_predA[0] = scaleforopp(v, field_predA[0], 0, dir);
 field_predA[1] = scaleforopp(v, field_predA[1], 1, dir);
@@ -353,9 +355,9 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int 
dmv_y,
 field_predC[0] = scaleforopp(v, field_predC[0], 0, dir);
 field_predC[1] = scaleforopp(v, field_predC[1], 1, dir);
 }
-v->mv_f[dir][xy + v->blocks_off] = 1;
-v->ref_field_type[dir] = !v->cur_field_type;
 } else {
+v->mv_f[dir][xy + v->blocks_off] = 0;
+v->ref_field_type[dir] = v->cur_field_type;
 if (a_valid && a_f) {
 field_predA[0] = scaleforsame(v, n, field_predA[0], 0, dir);
 field_predA[1] = scaleforsame(v, n, field_predA[1], 1, dir);
@@ -368,8 +370,6 @@ void ff_vc1_pred_mv(VC1Context *v, int n, int dmv_x, int 
dmv_y,
 field_predC[0] = scaleforsame(v, n, field_predC[0], 0, dir);
 field_predC[1] = scaleforsame(v, n, field_predC[1], 1, dir);
 }
-v->mv_f[dir][xy + v->blocks_off] = 0;
-v->ref_field_type[dir] = v->cur_field_type;
 }
 
 if (a_valid) {

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


[FFmpeg-cvslog] lavf/qsv: clone the frame which may be managed by framework

2018-04-21 Thread Ruiling Song
ffmpeg | branch: master | Ruiling Song  | Tue Apr  3 
09:50:20 2018 +0800| [d865783b6c8d4f96f5094ed72eff0f5a4a4908af] | committer: 
Mark Thompson

lavf/qsv: clone the frame which may be managed by framework

For filters based on framesync, the input frame was managed
by framesync, so we should not directly keep and destroy it,
instead we make a clone of it here, or else double-free will occur.
But for other filters not based on framesync, we still need to
free the input frame inside filter_frame.

Signed-off-by: Ruiling Song 

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

 libavfilter/qsvvpp.c | 4 ++--
 libavfilter/vf_vpp_qsv.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 732cf56a6a..2c01295628 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -296,7 +296,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_log(ctx, AV_LOG_ERROR, "QSVVPP gets a wrong frame.\n");
 return NULL;
 }
-qsv_frame->frame   = picref;
+qsv_frame->frame   = av_frame_clone(picref);
 qsv_frame->surface = (mfxFrameSurface1 *)qsv_frame->frame->data[3];
 } else {
 /* make a copy if the input is not padded as libmfx requires */
@@ -318,7 +318,7 @@ static QSVFrame *submit_frame(QSVVPPContext *s, 
AVFilterLink *inlink, AVFrame *p
 av_frame_copy_props(qsv_frame->frame, picref);
 av_frame_free();
 } else
-qsv_frame->frame = picref;
+qsv_frame->frame = av_frame_clone(picref);
 
 if (map_frame_to_surface(qsv_frame->frame,
 _frame->surface_internal) < 0) {
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 6be7098ae9..41a9f38962 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -341,9 +341,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*picref)
 VPPContext   *vpp = inlink->dst->priv;
 AVFilterLink *outlink = ctx->outputs[0];
 
-if (vpp->qsv)
+if (vpp->qsv) {
 ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
-else {
+av_frame_free();
+} else {
 if (picref->pts != AV_NOPTS_VALUE)
 picref->pts = av_rescale_q(picref->pts, inlink->time_base, 
outlink->time_base);
 ret = ff_filter_frame(outlink, picref);

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


[FFmpeg-cvslog] avfilter: add deblock filter

2018-04-21 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Apr 17 17:33:00 
2018 +0200| [21da248b5fee28cee4a160edb415e0caa446806c] | committer: Paul B Mahol

avfilter: add deblock filter

Signed-off-by: Paul B Mahol 

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

 Changelog|   4 +
 doc/filters.texi |  59 +++
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/version.h|   2 +-
 libavfilter/vf_deblock.c | 413 +++
 6 files changed, 479 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 7df4513e2d..3ed4874b09 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,10 @@ Entries are sorted chronologically from oldest to youngest 
within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- deblock filter
+
+
+version 4.0:
 - Bitstream filters for editing metadata in H.264, HEVC and MPEG-2 streams
 - Dropped support for OpenJPEG versions 2.0 and below. Using OpenJPEG now
   requires 2.1 (or later) and pkg-config.
diff --git a/doc/filters.texi b/doc/filters.texi
index 77a1d49520..c4318c5b6f 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7078,6 +7078,65 @@ e.g. banding detection threshold is triggered for all 
color components.
 The default is disabled.
 @end table
 
+@section deblock
+
+Remove blocking artifacts from input video.
+
+The filter accepts the following options:
+
+@table @option
+@item filter
+Set filter type, can be @var{weak} or @var{strong}. Default is @var{strong}.
+This controls what kind of deblocking is applied.
+
+@item block
+Set size of block, allowed range is from 4 to 512. Default is @var{8}.
+
+@item alpha
+@item beta
+@item gamma
+@item delta
+Set blocking detection thresholds. Allowed range is 0 to 1.
+Defaults are: @var{0.098} for @var{alpha} and @var{0.05} for the rest.
+Using higher threshold gives more deblocking strength.
+Setting @var{alpha} controls threshold detection at exact edge of block.
+Remaining options controls threshold detection near the edge. Each one for
+below/above or left/right. Setting any of those to @var{0} disables
+deblocking.
+
+@item planes
+Set planes to filter. Default is to filter all available planes.
+@end table
+
+@subsection Examples
+
+@itemize
+@item
+Deblock using weak filter and block size of 4 pixels.
+@example
+deblock=filter=weak:block=4
+@end example
+
+@item
+Deblock using strong filter, block size of 4 pixels and custom thresholds for
+deblocking more edges.
+@example
+deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05
+@end example
+
+@item
+Similar as above, but filter only first plane.
+@example
+deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=1
+@end example
+
+@item
+Similar as above, but filter only second and third plane.
+@example
+deblock=filter=strong:block=4:alpha=0.12:beta=0.07:gamma=0.06:delta=0.05:planes=6
+@end example
+@end itemize
+
 @anchor{decimate}
 @section decimate
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 7fc3de3bb2..0cd964ee6f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -173,6 +173,7 @@ OBJS-$(CONFIG_CURVES_FILTER) += vf_curves.o
 OBJS-$(CONFIG_DATASCOPE_FILTER)  += vf_datascope.o
 OBJS-$(CONFIG_DCTDNOIZ_FILTER)   += vf_dctdnoiz.o
 OBJS-$(CONFIG_DEBAND_FILTER) += vf_deband.o
+OBJS-$(CONFIG_DEBLOCK_FILTER)+= vf_deblock.o
 OBJS-$(CONFIG_DECIMATE_FILTER)   += vf_decimate.o
 OBJS-$(CONFIG_DECONVOLVE_FILTER) += vf_convolve.o framesync.o
 OBJS-$(CONFIG_DEFLATE_FILTER)+= vf_neighbor.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index bd55463bfc..643eec287d 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -165,6 +165,7 @@ extern AVFilter ff_vf_curves;
 extern AVFilter ff_vf_datascope;
 extern AVFilter ff_vf_dctdnoiz;
 extern AVFilter ff_vf_deband;
+extern AVFilter ff_vf_deblock;
 extern AVFilter ff_vf_decimate;
 extern AVFilter ff_vf_deconvolve;
 extern AVFilter ff_vf_deflate;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 1b37eb6535..625e95dd4c 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  18
+#define LIBAVFILTER_VERSION_MINOR  19
 #define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_deblock.c b/libavfilter/vf_deblock.c
new file mode 100644
index 00..229770908a
--- /dev/null
+++ b/libavfilter/vf_deblock.c
@@ -0,0 +1,413 @@
+/*
+ * Copyright (c) 2018 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the