Re: [FFmpeg-devel] avcodec/libopenh264enc.c

2018-10-12 Thread Valery Kot
I sent a (hopefully valid) patch along with a proper commit message.
It resulted in a new thread, sorry.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avcodec/libopenh264enc.c

2018-10-11 Thread Moritz Barsnick
On Thu, Oct 11, 2018 at 16:45:02 +0200, Timo Rothenpieler wrote:
> This patch is corrupted, also needs a more meaningful commit message.

Valery previously sent the patch as an attachment, which looked okay.
(Perhaps needed a better commit message nevertheless.)

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


Re: [FFmpeg-devel] avcodec/libopenh264enc.c

2018-10-11 Thread Timo Rothenpieler

This patch is corrupted, also needs a more meaningful commit message.



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] avcodec/libopenh264enc.c

2018-10-11 Thread Valery Kot
When using libx264 (GPL) encoder, sample aspect ratio gets stored on
both container and frame levels. For libopenh264 (LGPL), aspect ratio
on codec/frame level currently is ignored, which results in weird
display aspect ratio for non-square pixels on some players.

Proposed patch fixes that, if FFmpeg being build against libopenh264
1.7 or newer.

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

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 83c3f0ce20..6d4d9e6192 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -164,6 +164,32 @@ 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 == 0 ||
avctx->sample_aspect_ratio.den == 0)
+param.sSpatialLayers[0].bAspectRatioPresent = false;
+else {
+param.sSpatialLayers[0].bAspectRatioPresent = true;
+if  (!av_cmp_q(av_make_q( 1,  1),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_1x1;
+else if (!av_cmp_q(av_make_q(12, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_12x11;
+else if (!av_cmp_q(av_make_q(10, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_10x11;
+else if (!av_cmp_q(av_make_q(16, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_16x11;
+else if (!av_cmp_q(av_make_q(40, 33),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_40x33;
+else if (!av_cmp_q(av_make_q(24, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_24x11;
+else if (!av_cmp_q(av_make_q(20, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_20x11;
+else if (!av_cmp_q(av_make_q(32, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_32x11;
+else if (!av_cmp_q(av_make_q(80, 33),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_80x33;
+else if (!av_cmp_q(av_make_q(18, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_18x11;
+else if (!av_cmp_q(av_make_q(15, 11),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_15x11;
+else if (!av_cmp_q(av_make_q(64, 33),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_64x33;
+else if (!av_cmp_q(av_make_q(160,99),
avctx->sample_aspect_ratio))  param.sSpatialLayers[0].eAspectRatio =
ASP_160x99;
+else {
+param.sSpatialLayers[0].eAspectRatio = ASP_EXT_SAR;
+param.sSpatialLayers[0].sAspectRatioExtWidth =
avctx->sample_aspect_ratio.num;
+param.sSpatialLayers[0].sAspectRatioExtHeight =
avctx->sample_aspect_ratio.den;
+}
+}
+#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",
-- 
2.15.1.windows.2
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] avcodec/libopenh264enc.c

2018-10-11 Thread Valery Kot
When using libx264 (GPL) encoder, sample aspect ratio gets stored on
both container and frame levels. For libopenh264 (LGPL), aspect ratio
on codec/frame level currently is ignored, which results in weird
display aspect ratio for non-square pixels on some players.

Proposed patch fixes that, if FFmpeg being build against libopenh264
1.7 or newer.


0001-Set-sample-aspect-ratio-in-libopenh264-encoder.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel