[FFmpeg-cvslog] libopenh264enc: Handle sample_aspect_ratio

2018-11-05 Thread Valery Kot
ffmpeg | branch: master | Valery Kot  | Thu Nov  1 
14:15:11 2018 +0100| [be827e1d38cbaaa55c969d87b3650118ee1e6fb3] | committer: 
Mark Thompson

libopenh264enc: Handle sample_aspect_ratio

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

 libavcodec/libopenh264enc.c | 41 +
 1 file changed, 41 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 83c3f0ce20..5baa423433 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -164,6 +164,47 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.sSpatialLayers[0].iSpatialBitrate = param.iTargetBitrate;
 param.sSpatialLayers[0].iMaxSpatialBitrate  = param.iMaxBitrate;
 
+#if OPENH264_VER_AT_LEAST(1, 7)
+if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den) {
+// Table E-1.
+static const AVRational sar_idc[] = {
+{   0,  0 }, // Unspecified (never written here).
+{   1,  1 }, {  12, 11 }, {  10, 11 }, {  16, 11 },
+{  40, 33 }, {  24, 11 }, {  20, 11 }, {  32, 11 },
+{  80, 33 }, {  18, 11 }, {  15, 11 }, {  64, 33 },
+{ 160, 99 }, // Last 3 are unknown to openh264: {   4,  3 }, {   
3,  2 }, {   2,  1 },
+};
+static const ESampleAspectRatio asp_idc[] = {
+ASP_UNSPECIFIED,
+ASP_1x1,  ASP_12x11,   ASP_10x11,   ASP_16x11,
+ASP_40x33,ASP_24x11,   ASP_20x11,   ASP_32x11,
+ASP_80x33,ASP_18x11,   ASP_15x11,   ASP_64x33,
+ASP_160x99,
+};
+int num, den, i;
+
+av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
+  avctx->sample_aspect_ratio.den, 65535);
+
+for (i = 1; i < FF_ARRAY_ELEMS(sar_idc); i++) {
+if (num == sar_idc[i].num &&
+den == sar_idc[i].den)
+break;
+}
+if (i == FF_ARRAY_ELEMS(sar_idc)) {
+param.sSpatialLayers[0].eAspectRatio = ASP_EXT_SAR;
+param.sSpatialLayers[0].sAspectRatioExtWidth = num;
+param.sSpatialLayers[0].sAspectRatioExtHeight = den;
+} else {
+param.sSpatialLayers[0].eAspectRatio = asp_idc[i];
+}
+param.sSpatialLayers[0].bAspectRatioPresent = true;
+}
+else {
+param.sSpatialLayers[0].bAspectRatioPresent = false;
+}
+#endif
+
 if ((avctx->slices > 1) && (s->max_nal_size)) {
 av_log(avctx, AV_LOG_ERROR,
"Invalid combination -slices %d and -max_nal_size %d.\n",

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


[FFmpeg-cvslog] avcodec/openh264enc.c: generate IDR frame in response to I frame pict_type

2018-04-05 Thread Valery Kot
ffmpeg | branch: master | Valery Kot  | Fri Mar 16 
14:50:34 2018 +0100| [67fd8df4197e50720223f9715594a1fa31f48b54] | committer: 
James Almer

avcodec/openh264enc.c: generate IDR frame in response to I frame pict_type

Signed-off-by: Valery Kot 

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

 libavcodec/libopenh264enc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index fdadb101f5..83c3f0ce20 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -246,6 +246,10 @@ static int svc_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 sp.iPicWidth  = avctx->width;
 sp.iPicHeight = avctx->height;
 
+if (frame->pict_type == AV_PICTURE_TYPE_I) {
+(*s->encoder)->ForceIntraFrame(s->encoder, true);
+}
+
 encoded = (*s->encoder)->EncodeFrame(s->encoder, &sp, &fbi);
 if (encoded != cmResultSuccess) {
 av_log(avctx, AV_LOG_ERROR, "EncodeFrame failed\n");

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


[FFmpeg-cvslog] avfilter/vf_edgedetect: properly implement double_threshold()

2020-07-06 Thread Valery Kot
ffmpeg | branch: master | Valery Kot  | Mon Jun 22 
17:29:21 2020 +0200| [855d51bf481dddf425f9a82e4d1aa2cdc93c22f8] | committer: 
Andriy Gelman

avfilter/vf_edgedetect: properly implement double_threshold()

Important part of this algorithm is the double threshold step: pixels
above "high" threshold being kept, pixels below "low" threshold dropped,
pixels in between (weak edges) are kept if they are neighboring "high"
pixels.

The weak edge check uses a neighboring context and should not be applied
on the plane's border. The condition was incorrect and has been fixed in
the commit.

Signed-off-by: Andriy Gelman 
Reviewed-by: Andriy Gelman 

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

 libavfilter/vf_edgedetect.c   | 2 +-
 tests/ref/fate/filter-edgedetect  | 2 +-
 tests/ref/fate/filter-edgedetect-colormix | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_edgedetect.c b/libavfilter/vf_edgedetect.c
index a5614ea63b..df8afbd532 100644
--- a/libavfilter/vf_edgedetect.c
+++ b/libavfilter/vf_edgedetect.c
@@ -294,7 +294,7 @@ static void double_threshold(int low, int high, int w, int 
h,
 continue;
 }
 
-if ((!i || i == w - 1 || !j || j == h - 1) &&
+if (!(!i || i == w - 1 || !j || j == h - 1) &&
 src[i] > low &&
 (src[-src_linesize + i-1] > high ||
  src[-src_linesize + i  ] > high ||
diff --git a/tests/ref/fate/filter-edgedetect b/tests/ref/fate/filter-edgedetect
index 23c9953e61..e49639afac 100644
--- a/tests/ref/fate/filter-edgedetect
+++ b/tests/ref/fate/filter-edgedetect
@@ -1 +1 @@
-edgedetect  93ceace33f6636bcdbeb037317c65745
+edgedetect  04ff46bb35edff3dbad4102391516d25
diff --git a/tests/ref/fate/filter-edgedetect-colormix 
b/tests/ref/fate/filter-edgedetect-colormix
index e828c6bd19..0df17344bc 100644
--- a/tests/ref/fate/filter-edgedetect-colormix
+++ b/tests/ref/fate/filter-edgedetect-colormix
@@ -1 +1 @@
-edgedetect-colormix 1b8658252e2f03fbae30e6d63dd24c7c
+edgedetect-colormix 9f50c5586f899a8f5a10059154d64bde

___
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".