Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
On 05/03/2019 07:43, Jing SUN wrote: > From: Jing Sun > > base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC > > V4: - Fix the build error with new API in PR#52 > - Fix the encoding hang issue by API change in PR#52 > - Fix the last frame dropping issue > - Fix the invalid parameter causing segmentation fault issue > - Add the support to svt hevc and av1 plugins coexistance > - Add the VMAF optimized mode to "-tune" > - Add the "-hdr" parameter > > V3: - Fix the build error with new API > > V2: - Change the config options (didn't need to enable-gpl for BSD+Patent, > it's can compatible with LGPL2+, thanks Xavier correct this part), > now just need to "--enable-libsvthevc" option > - Add force_idr option > - Remove default GoP size setting in the wrapper, SVT-HEVC will calc > the the GoP size internal > - Refine the code as the FFmpeg community's comments > (https://patchwork.ffmpeg.org/patch/11347/) > > V1: - base on patch by Huang, Zhengxu, then refine some code. > > Change-Id: If0dcc5044ab9effd6847a8f48797b985d02b0816 > Signed-off-by: Huang, Zhengxu > Signed-off-by: hassene > Signed-off-by: Jun Zhao > Signed-off-by: Jing Sun > --- > configure| 4 + > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libsvt_hevc.c | 546 > +++ > 4 files changed, 552 insertions(+) > create mode 100644 libavcodec/libsvt_hevc.c > > ... > > diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c new > file mode 100644 index 000..97bd204 > --- /dev/null > +++ b/libavcodec/libsvt_hevc.c > @@ -0,0 +1,546 @@ > +/* > +* 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 "svt-hevc/EbErrorCodes.h" > +#include "svt-hevc/EbTime.h" > +#include "svt-hevc/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; This structure appears have exactly the same lifetime as the encoder itself - can you just put it directly in the SvtContext rather than allocating/freeing it separately? [SUN, Jing] To be modified in v7. > +int raw_size; This variable seems to be write-only. [SUN, Jing] To be modified in v7. > + > +EOS_STATUS eos_flag; > + > +// User options. > +int vui_info; > +int hierarchical_level; > +int la_depth; > +int enc_mode; > +int rc_mode; > +int scd; > +int tune; > +int qp; > +int hdr; > + > +int forced_idr; > + > +int aud; > + > +int profile; > +int tier; > +int level; > + > +int base_layer_switch_mode; > +} SvtContext; > + > +static int error_mapping(EB_ERRORTYPE svt_ret) { > +int err; > + > +switch (svt_ret) { > +case EB_ErrorInsufficientResources: > +err = AVERROR(ENOMEM); > +break; > + > +case EB_ErrorUndefined: > +case EB_ErrorInvalidComponent: > +case EB_ErrorBadParameter: > +err = AVERROR(EINVAL); > +break; > + > +case EB_ErrorDestroyThreadFailed: > +case EB_ErrorSemaphoreUnresponsive: > +case EB_ErrorDestroySemaphoreFailed: > +case EB_ErrorCreateMutexFailed: > +case EB_ErrorMutexUnresponsive: > +case EB_ErrorDestroyMutexFailed: > +err = AVERROR_EXTERNAL; > +break; > + > +case EB_NoErrorEmptyQueue: > +err = AVERROR(EAGAIN); > + > +case EB_ErrorNone: > +err = 0; > +break; > + > +default: > +err = AVERROR_UNKNOWN; > +} > + > +return err; > +} > + > +static void free_buffer(SvtContext *svt_enc) { > +if (svt_enc->in_buf) { > +EB_H265_ENC_INPUT *in_data = (EB_H265_ENC_INPUT >
Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
2019-03-05 8:43 GMT+01:00, Jing SUN : > +enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc > svt-hevc/EbApi.h EbInitHandle What funny optional dependencies does this library have that justifies requiring pkg_config? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
On 05/03/2019 07:43, Jing SUN wrote: > From: Jing Sun > > base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC > > V4: - Fix the build error with new API in PR#52 > - Fix the encoding hang issue by API change in PR#52 > - Fix the last frame dropping issue > - Fix the invalid parameter causing segmentation fault issue > - Add the support to svt hevc and av1 plugins coexistance > - Add the VMAF optimized mode to "-tune" > - Add the "-hdr" parameter > > V3: - Fix the build error with new API > > V2: - Change the config options (didn't need to enable-gpl for BSD+Patent, > it's can compatible with LGPL2+, thanks Xavier correct this part), > now just need to "--enable-libsvthevc" option > - Add force_idr option > - Remove default GoP size setting in the wrapper, SVT-HEVC will calc > the the GoP size internal > - Refine the code as the FFmpeg community's comments > (https://patchwork.ffmpeg.org/patch/11347/) > > V1: - base on patch by Huang, Zhengxu, then refine some code. > > Change-Id: If0dcc5044ab9effd6847a8f48797b985d02b0816 > Signed-off-by: Huang, Zhengxu > Signed-off-by: hassene > Signed-off-by: Jun Zhao > Signed-off-by: Jing Sun > --- > configure| 4 + > libavcodec/Makefile | 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libsvt_hevc.c | 546 > +++ > 4 files changed, 552 insertions(+) > create mode 100644 libavcodec/libsvt_hevc.c > > ... > > diff --git a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c > new file mode 100644 > index 000..97bd204 > --- /dev/null > +++ b/libavcodec/libsvt_hevc.c > @@ -0,0 +1,546 @@ > +/* > +* 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 "svt-hevc/EbErrorCodes.h" > +#include "svt-hevc/EbTime.h" > +#include "svt-hevc/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; This structure appears have exactly the same lifetime as the encoder itself - can you just put it directly in the SvtContext rather than allocating/freeing it separately? > +int raw_size; This variable seems to be write-only. > + > +EOS_STATUS eos_flag; > + > +// User options. > +int vui_info; > +int hierarchical_level; > +int la_depth; > +int enc_mode; > +int rc_mode; > +int scd; > +int tune; > +int qp; > +int hdr; > + > +int forced_idr; > + > +int aud; > + > +int profile; > +int tier; > +int level; > + > +int base_layer_switch_mode; > +} SvtContext; > + > +static int error_mapping(EB_ERRORTYPE svt_ret) > +{ > +int err; > + > +switch (svt_ret) { > +case EB_ErrorInsufficientResources: > +err = AVERROR(ENOMEM); > +break; > + > +case EB_ErrorUndefined: > +case EB_ErrorInvalidComponent: > +case EB_ErrorBadParameter: > +err = AVERROR(EINVAL); > +break; > + > +case EB_ErrorDestroyThreadFailed: > +case EB_ErrorSemaphoreUnresponsive: > +case EB_ErrorDestroySemaphoreFailed: > +case EB_ErrorCreateMutexFailed: > +case EB_ErrorMutexUnresponsive: > +case EB_ErrorDestroyMutexFailed: > +err = AVERROR_EXTERNAL; > +break; > + > +case EB_NoErrorEmptyQueue: > +err = AVERROR(EAGAIN); > + > +case EB_ErrorNone: > +err = 0; > +break; > + > +default: > +err = AVERROR_UNKNOWN; > +} > + > +return err; > +} > + > +static void free_buffer(SvtContext *svt_enc) > +{ > +if (svt_enc->in_buf) { > +EB_H265_ENC_INPUT *in_data = (EB_H265_ENC_INPUT > *)svt_enc->in_buf->pBuffer; > +av_freep(_data); > +
Re: [FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
On Tue, Mar 5, 2019 at 1:45 AM Jing SUN wrote: > From: Jing Sun > > base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC > > V4: - Fix the build error with new API in PR#52 > - Fix the encoding hang issue by API change in PR#52 > - Fix the last frame dropping issue > - Fix the invalid parameter causing segmentation fault issue > - Add the support to svt hevc and av1 plugins coexistance > - Add the VMAF optimized mode to "-tune" > - Add the "-hdr" parameter > Is there any way to preserve the color matrix/primary/transfer properties during encoding? -- Vittorio ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v6 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper.
From: Jing Sun base on patch by Huang, Zhengxu from https://github.com/intel/SVT-HEVC V4: - Fix the build error with new API in PR#52 - Fix the encoding hang issue by API change in PR#52 - Fix the last frame dropping issue - Fix the invalid parameter causing segmentation fault issue - Add the support to svt hevc and av1 plugins coexistance - Add the VMAF optimized mode to "-tune" - Add the "-hdr" parameter V3: - Fix the build error with new API V2: - Change the config options (didn't need to enable-gpl for BSD+Patent, it's can compatible with LGPL2+, thanks Xavier correct this part), now just need to "--enable-libsvthevc" option - Add force_idr option - Remove default GoP size setting in the wrapper, SVT-HEVC will calc the the GoP size internal - Refine the code as the FFmpeg community's comments (https://patchwork.ffmpeg.org/patch/11347/) V1: - base on patch by Huang, Zhengxu, then refine some code. Change-Id: If0dcc5044ab9effd6847a8f48797b985d02b0816 Signed-off-by: Huang, Zhengxu Signed-off-by: hassene Signed-off-by: Jun Zhao Signed-off-by: Jing Sun --- configure| 4 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/libsvt_hevc.c | 546 +++ 4 files changed, 552 insertions(+) create mode 100644 libavcodec/libsvt_hevc.c diff --git a/configure b/configure index dcead3a..36bc8c1 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 svt-hevc/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..97bd204 --- /dev/null +++ b/libavcodec/libsvt_hevc.c @@ -0,0 +1,546 @@ +/* +* 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