Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-29 Thread Sun, Jing A
On Thursday, March 28, 2019 5:20 AM, Mark Thompson wrote:

>Looking at what the highDynamicRangeInput field actually does 
>,
> I don't think it makes sense for this external "hdr" option at exist at all.

>From the point of view of a user looking at the external options, they might 
>expect that on setting this option some conversion takes place to actually 
>create an HDR output.  In fact, that's not what it does - it just marks the 
>output with some very specific colour properties, and any stream which doesn't 
>actually have exactly those properties will then have incorrect metadata for 
>display (possibly conflicting with container metadata, if the container has 
>better support for colour properties than this encoder).

>Perhaps to avoid confusion about what is actually happening the option could 
>be removed and this check replaced with something like:

>if (avctx->colorspace == AVCOL_SPC_BT2020_NCL &&
>avctx->color_primaries == AVCOL_PRI_BT2020 &&
>avctx->color_trc == AVCOL_TRC_SMPTE2084 &&
>avctx->color_range == AVCOL_RANGE_MPEG &&
>avctx->chroma_sample_location == AVCHROMA_LOC_TOPLEFT) {
>param->highDynamicRangeInput = 1;
>} else {
>param->highDynamicRangeInput = 0;
>// Maybe also a warning here in some cases?
>}

>- Mark

Since SVT-HEVC's HDR is not ready, I just removed the interface and I will add 
it back when it's fully supported with color properties preserving. Please 
review v10 and thanks a lot.

- Jing

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

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

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-27 Thread Mark Thompson
On 27/03/2019 17:13, Vittorio Giovara wrote:
> On Tue, Mar 26, 2019 at 10:47 PM Jing Sun  wrote:
> 
>> Signed-off-by: Zhengxu Huang 
>> Signed-off-by: Hassene Tmar 
>> Signed-off-by: Jun Zhao 
>> Signed-off-by: Jing Sun 
>> ---
>>  configure|   4 +
>>  libavcodec/Makefile  |   1 +
>>  libavcodec/allcodecs.c   |   1 +
>>  libavcodec/libsvt_hevc.c | 502
>> +++
>>  4 files changed, 508 insertions(+)
>>  create mode 100644 libavcodec/libsvt_hevc.c
>>
>> ...
>> +if (svt_enc->hdr) {
>> +svt_enc->vui_info = 1;
>> +param->highDynamicRangeInput = svt_enc->hdr;
>> +}
>>
> 
> Where is the warning that notifies the lack of color properties support?

Looking at what the highDynamicRangeInput field actually does 
,
 I don't think it makes sense for this external "hdr" option at exist at all.

From the point of view of a user looking at the external options, they might 
expect that on setting this option some conversion takes place to actually 
create an HDR output.  In fact, that's not what it does - it just marks the 
output with some very specific colour properties, and any stream which doesn't 
actually have exactly those properties will then have incorrect metadata for 
display (possibly conflicting with container metadata, if the container has 
better support for colour properties than this encoder).

Perhaps to avoid confusion about what is actually happening the option could be 
removed and this check replaced with something like:

if (avctx->colorspace == AVCOL_SPC_BT2020_NCL &&
avctx->color_primaries == AVCOL_PRI_BT2020 &&
avctx->color_trc == AVCOL_TRC_SMPTE2084 &&
avctx->color_range == AVCOL_RANGE_MPEG &&
avctx->chroma_sample_location == AVCHROMA_LOC_TOPLEFT) {
param->highDynamicRangeInput = 1;
} else {
param->highDynamicRangeInput = 0;
// Maybe also a warning here in some cases?
}

That would then do the right thing for all streams which actually have the 
given properties, while not forcing incorrect display of anything else.

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

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

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-27 Thread Vittorio Giovara
On Tue, Mar 26, 2019 at 10:47 PM Jing Sun  wrote:

> Signed-off-by: Zhengxu Huang 
> Signed-off-by: Hassene Tmar 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Jing Sun 
> ---
>  configure|   4 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libsvt_hevc.c | 502
> +++
>  4 files changed, 508 insertions(+)
>  create mode 100644 libavcodec/libsvt_hevc.c
>
> +
> +if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
> +av_log(avctx, AV_LOG_DEBUG , "Encoder 10 bits depth input\n");
> +
> +// SVT-HEVC's compressed 10-bit format is to supported,
> +// without which it works well functionally but with a
> +// slight performance penalty caused by the extra conv
> +// step from yuv420p10le to that format.
> +
> +param->compressedTenBitFormat = 0;
> +param->encoderBitDepth= 10;
> +}
>

So what is happening in this case? The encoder is slower because it
converts from 10 to 8 bit internally? And then the output encode is 8 bit
right now? If that is the case, I'd rather have this functionality removed
since the conversion can happen directly within ffmpeg. Having the
conversion performed by the encoder is guaranteed to be slower and less
precise, and if the output is not 10 bit it is very surprising too.

At the same time the comment in the code is useless because users will
never read something buried deep in the code, I'd suggest printing
something at the warning level so that it will be shown during the
conversion (and please have it proofread by a native English-speaking
person).


> +param->encoderColorFormat = EB_YUV420;
> +
> +// Update param from options
> +param->hierarchicalLevels = svt_enc->hierarchical_level - 1;
> +param->encMode= svt_enc->enc_mode;
> +param->profile= svt_enc->profile;
> +param->tier   = svt_enc->tier;
> +param->level  = svt_enc->level;
> +param->rateControlMode= svt_enc->rc_mode;
> +param->sceneChangeDetection   = svt_enc->scd;
> +param->tune   = svt_enc->tune;
> +param->baseLayerSwitchMode= svt_enc->base_layer_switch_mode;
> +param->qp = svt_enc->qp;
> +param->accessUnitDelimiter= svt_enc->aud;
> +
> +param->targetBitRate  = avctx->bit_rate;
> +if (avctx->gop_size > 0)
> +param->intraPeriodLength  = avctx->gop_size - 1;
> +
> +if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
> +param->frameRateNumerator = avctx->framerate.num;
> +param->frameRateDenominator   = avctx->framerate.den *
> avctx->ticks_per_frame;
> +} else {
> +param->frameRateNumerator = avctx->time_base.den;
> +param->frameRateDenominator   = avctx->time_base.num *
> avctx->ticks_per_frame;
> +}
> +
> +if (param->rateControlMode) {
> +param->maxQpAllowed   = avctx->qmax;
> +param->minQpAllowed   = avctx->qmin;
> +}
> +
> +param->intraRefreshType   =
> +!!(avctx->flags & AV_CODEC_FLAG_CLOSED_GOP) + 1;
> +
> +// is it repeat headers for MP4 or Annex-b
> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)
> +param->codeVpsSpsPps  = 0;
> +else
> +param->codeVpsSpsPps  = 1;
> +
> +param->codeEosNal = 1;
>

nit: excessive whitespace alignment

+
> +if (svt_enc->hdr) {
> +svt_enc->vui_info = 1;
> +param->highDynamicRangeInput = svt_enc->hdr;
> +}
>

Where is the warning that notifies the lack of color properties support?


> +
> +avctx->extradata_size = header_ptr->nFilledLen;
> +avctx->extradata = av_mallocz(avctx->extradata_size +
> AV_INPUT_BUFFER_PADDING_SIZE);
> +if (!avctx->extradata) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "Cannot allocate HEVC header of size %d.\n",
> avctx->extradata_size);
> +svt_ret = EB_ErrorInsufficientResources;
> +goto failed_init_enc;
> +}
>

initialize extradata_size only in case of success, some code may rely on it

+#define OFFSET(x) offsetof(SvtContext, x)
> +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
> +static const AVOption options[] = {
> +{ "vui", "Enable vui info", OFFSET(vui_info),
> +  AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, VE },
> +
> +{ "aud", "Include AUD", OFFSET(aud),
> +  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>

IMO these options help text could be improved.

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

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

[FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-26 Thread Jing Sun
Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jun Zhao 
Signed-off-by: Jing Sun 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 502 +++
 4 files changed, 508 insertions(+)
 create mode 100644 libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 938ff10..2aabac4 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
+  --enable-libsvthevc  enable HEVC encoding via svt [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -1784,6 +1785,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3173,6 +3175,7 @@ libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
 libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
+libsvt_hevc_encoder_deps="libsvthevc"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
@@ -6209,6 +6212,7 @@ enabled libsoxr   && require libsoxr soxr.h 
soxr_create -lsoxr
 enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
sftp_init
 enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
speex_decoder_init
 enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
srt/srt.h srt_socket
+enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc EbApi.h 
EbInitHandle
 enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
TF_Version -ltensorflow
 enabled libtesseract  && require_pkg_config libtesseract tesseract 
tesseract/capi.h TessBaseAPICreate
 enabled libtheora && require libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 15c43a8..c93e545 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
libopus.o \
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b26aeca..e93f66f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -703,6 +703,7 @@ extern AVCodec ff_librsvg_decoder;
 extern AVCodec ff_libshine_encoder;
 extern AVCodec ff_libspeex_encoder;
 extern AVCodec ff_libspeex_decoder;
+extern AVCodec ff_libsvt_hevc_encoder;
 extern AVCodec ff_libtheora_encoder;
 extern AVCodec ff_libtwolame_encoder;
 extern AVCodec ff_libvo_amrwbenc_encoder;
diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
new file mode 100644
index 000..ca6e37b
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,502 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2018 Intel Corporation
+*
+* 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 this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "EbErrorCodes.h"
+#include "EbTime.h"
+#include "EbApi.h"
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/opt.h"
+
+#include "internal.h"
+#include "avcodec.h"
+
+typedef enum eos_status {
+EOS_NOT_REACHED = 0,
+EOS_REACHED,
+EOS_TOTRIGGER
+}EOS_STATUS;
+
+typedef struct SvtContext {
+AVClass *class;
+
+EB_H265_ENC_CONFIGURATION enc_params;
+EB_COMPONENTTYPE *svt_handle;
+EB_BUFFERHEADERTYPE in_buf;
+EOS_STATUS eos_flag;
+
+// User options.
+int vui_info;
+   

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-26 Thread Carl Eugen Hoyos
2019-03-25 6:42 GMT+01:00, Sun, Jing A :
> Friday, March 22, 2019 5:54 PM, Carl Eugen Hoyos:
>
>>What I meant is:
>>I don't understand the comment (and your mail), it says above the
>> functionality has to be disabled but you write it works fine.
>>The comment is (still) unclear imo.
>
>>Carl Eugen
>
> Hi Carl, it works functionally, but there is something that can be done, and
> will be done in the further, to improve its performance a little.

Then my suggestion would be add "which adds a performance penalty"
(or similar) to the comment.
I do understand it now but it seems difficult to parse without the
extra information.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-24 Thread Sun, Jing A
Friday, March 22, 2019 5:54 PM, Carl Eugen Hoyos:

>What I meant is:
>I don't understand the comment (and your mail), it says above the 
>functionality has to be disabled but you write it works fine.
>The comment is (still) unclear imo.

>Carl Eugen

Hi Carl, it works functionally, but there is something that can be done, and 
will be done in the further, to improve its performance a little.

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

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

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-21 Thread Sun, Jing A
Friday, March 22, 2019 7:52 AM, Carl Eugen:

> +if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
> +av_log(avctx, AV_LOG_DEBUG , "Encoder 10 bits depth 
> + input\n");
> +
> +// Encoding the source frames of the compressed 10-bit format
> +// supported by SVT-HEVC requires an extra conversion operation
> +// from yuv420p10le to that format. Disable it for now in ffmpeg.
>Sorry for the misunderstanding:
>What happens now (with this patch) if the user provides AV_PIX_FMT_YUV420P10LE 
>to this FFmpeg encoder?
>And what should ideally happen?

It works fine functionally. And we will save the extra step's cost time a 
little after we figures out how to and where to add the compressed format 
support in ffmpeg later.

> +
> +param->compressedTenBitFormat = 0;
> +ten_bits = 1;
> +}
>Why doesn't this block set param->encoderBitDepth?

Modified. Thanks for the good catch.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with 
subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-21 Thread Jing Sun
Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jun Zhao 
Signed-off-by: Jing Sun 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 501 +++
 4 files changed, 507 insertions(+)
 create mode 100644 libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 938ff10..2aabac4 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
+  --enable-libsvthevc  enable HEVC encoding via svt [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -1784,6 +1785,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3173,6 +3175,7 @@ libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
 libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
+libsvt_hevc_encoder_deps="libsvthevc"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
@@ -6209,6 +6212,7 @@ enabled libsoxr   && require libsoxr soxr.h 
soxr_create -lsoxr
 enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
sftp_init
 enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
speex_decoder_init
 enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
srt/srt.h srt_socket
+enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc EbApi.h 
EbInitHandle
 enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
TF_Version -ltensorflow
 enabled libtesseract  && require_pkg_config libtesseract tesseract 
tesseract/capi.h TessBaseAPICreate
 enabled libtheora && require libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 15c43a8..c93e545 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
libopus.o \
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b26aeca..e93f66f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -703,6 +703,7 @@ extern AVCodec ff_librsvg_decoder;
 extern AVCodec ff_libshine_encoder;
 extern AVCodec ff_libspeex_encoder;
 extern AVCodec ff_libspeex_decoder;
+extern AVCodec ff_libsvt_hevc_encoder;
 extern AVCodec ff_libtheora_encoder;
 extern AVCodec ff_libtwolame_encoder;
 extern AVCodec ff_libvo_amrwbenc_encoder;
diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
new file mode 100644
index 000..819979a
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,501 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2018 Intel Corporation
+*
+* 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 this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "EbErrorCodes.h"
+#include "EbTime.h"
+#include "EbApi.h"
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/opt.h"
+
+#include "internal.h"
+#include "avcodec.h"
+
+typedef enum eos_status {
+EOS_NOT_REACHED = 0,
+EOS_REACHED,
+EOS_TOTRIGGER
+}EOS_STATUS;
+
+typedef struct SvtContext {
+AVClass *class;
+
+EB_H265_ENC_CONFIGURATION enc_params;
+EB_COMPONENTTYPE *svt_handle;
+EB_BUFFERHEADERTYPE in_buf;
+EOS_STATUS eos_flag;
+
+// User options.
+int vui_info;
+   

Re: [FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-21 Thread Carl Eugen Hoyos
2019-03-21 5:10 GMT+01:00, Jing Sun :

> +if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
> +av_log(avctx, AV_LOG_DEBUG , "Encoder 10 bits depth input\n");
> +
> +// Encoding the source frames of the compressed 10-bit format
> +// supported by SVT-HEVC requires an extra conversion operation
> +// from yuv420p10le to that format. Disable it for now in ffmpeg.

Sorry for the misunderstanding:
What happens now (with this patch) if the user provides
AV_PIX_FMT_YUV420P10LE to this FFmpeg encoder?
And what should ideally happen?

> +
> +param->compressedTenBitFormat = 0;
> +ten_bits = 1;
> +}

Why doesn't this block set param->encoderBitDepth?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

[FFmpeg-devel] [PATCH v9 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-20 Thread Jing Sun
Signed-off-by: Zhengxu Huang 
Signed-off-by: Hassene Tmar 
Signed-off-by: Jun Zhao 
Signed-off-by: Jing Sun 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 505 +++
 4 files changed, 511 insertions(+)
 create mode 100644 libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 938ff10..2aabac4 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ External library support:
   --enable-libspeexenable Speex de/encoding via libspeex [no]
   --enable-libsrt  enable Haivision SRT protocol via libsrt [no]
   --enable-libssh  enable SFTP protocol via libssh [no]
+  --enable-libsvthevc  enable HEVC encoding via svt [no]
   --enable-libtensorflow   enable TensorFlow as a DNN module backend
for DNN based filters like sr [no]
   --enable-libtesseractenable Tesseract, needed for ocr filter [no]
@@ -1784,6 +1785,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3173,6 +3175,7 @@ libshine_encoder_select="audio_frame_queue"
 libspeex_decoder_deps="libspeex"
 libspeex_encoder_deps="libspeex"
 libspeex_encoder_select="audio_frame_queue"
+libsvt_hevc_encoder_deps="libsvthevc"
 libtheora_encoder_deps="libtheora"
 libtwolame_encoder_deps="libtwolame"
 libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
@@ -6209,6 +6212,7 @@ enabled libsoxr   && require libsoxr soxr.h 
soxr_create -lsoxr
 enabled libssh&& require_pkg_config libssh libssh libssh/sftp.h 
sftp_init
 enabled libspeex  && require_pkg_config libspeex speex speex/speex.h 
speex_decoder_init
 enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0" 
srt/srt.h srt_socket
+enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc EbApi.h 
EbInitHandle
 enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h 
TF_Version -ltensorflow
 enabled libtesseract  && require_pkg_config libtesseract tesseract 
tesseract/capi.h TessBaseAPICreate
 enabled libtheora && require libtheora theora/theoraenc.h th_info_init 
-ltheoraenc -ltheoradec -logg
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 15c43a8..c93e545 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)+= libopusenc.o 
libopus.o \
 OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
 OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
 OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
+OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
 OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
 OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
 OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index b26aeca..e93f66f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -703,6 +703,7 @@ extern AVCodec ff_librsvg_decoder;
 extern AVCodec ff_libshine_encoder;
 extern AVCodec ff_libspeex_encoder;
 extern AVCodec ff_libspeex_decoder;
+extern AVCodec ff_libsvt_hevc_encoder;
 extern AVCodec ff_libtheora_encoder;
 extern AVCodec ff_libtwolame_encoder;
 extern AVCodec ff_libvo_amrwbenc_encoder;
diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c
new file mode 100644
index 000..9c958f5
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,505 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2018 Intel Corporation
+*
+* 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 this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+#include "EbErrorCodes.h"
+#include "EbTime.h"
+#include "EbApi.h"
+
+#include "libavutil/common.h"
+#include "libavutil/frame.h"
+#include "libavutil/opt.h"
+
+#include "internal.h"
+#include "avcodec.h"
+
+typedef enum eos_status {
+EOS_NOT_REACHED = 0,
+EOS_REACHED,
+EOS_TOTRIGGER
+}EOS_STATUS;
+
+typedef struct SvtContext {
+AVClass *class;
+
+EB_H265_ENC_CONFIGURATION enc_params;
+EB_COMPONENTTYPE *svt_handle;
+EB_BUFFERHEADERTYPE in_buf;
+EOS_STATUS eos_flag;
+
+// User options.
+int vui_info;
+