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

2019-08-18 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Monday, August 19, 2019 1:55 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v17 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

Fixed memleak.

Regards,
Sun, 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 v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-05 Thread Sun, Jing A
This update corrected the rc_mode assignment position. It should get assigned 
before the if().

264a265,269
> +if (param->rateControlMode) {
> +param->maxQpAllowed = avctx->qmax;
> +param->minQpAllowed = avctx->qmin;
> +}
> +
277,281d281
< +if (param->rateControlMode) {
< +param->maxQpAllowed = avctx->qmax;
< +param->minQpAllowed = avctx->qmin;
< +}
< + 
___
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 v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

[Patch content]

This update removed the code line below:
+{ "flags", "+cgop" },

For the "forced_idr" parameter is controlling this, but not the 
AV_CODEC_FLAG_CLOSED_GOP flag. Thanks Li Zhong for catching it.

Regards,
Sun, 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".

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

2019-08-01 Thread Sun, Jing A
Sun, Jing A would like to recall the message, "[PATCH v16 1/2] lavc/svt_hevc: 
add libsvt hevc encoder wrapper".
___
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 v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-08-01 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

[Patch content]

This update removed the code line below:
+{ "flags", "+cgop" },

For the "forced_idr" parameter is controlling this, but not the 
AV_CODEC_FLAG_CLOSED_GOP flag. Thanks Li Zhong for catching it.

Regards,
Sun, Jing


-----Original Message-
From: Sun, Jing A 
Sent: Thursday, August 1, 2019 3:53 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v16 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

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 | 500 +++
 libavcodec/version.h |   2 +-
 5 files changed, 507 insertions(+), 1 deletion(-)  create mode 100644 
libavcodec/libsvt_hevc.c

diff --git a/configure b/configure
index 5a4f507..3a6cab7 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]
@@ -1788,6 +1789,7 @@ EXTERNAL_LIBRARY_LIST="
 libspeex
 libsrt
 libssh
+libsvthevc
 libtensorflow
 libtesseract
 libtheora
@@ -3183,6 +3185,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"
@@ -6230,6 +6233,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 3cd73fb..d39f568 
100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -991,6 +991,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 
d2f9a39..d8788a7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -707,6 +707,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..b0e21a36
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,500 @@
+/*
+* Scalable Video Technology for HEVC encoder library plugin
+*
+* Copyright (c) 2019 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 

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

2019-07-31 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Wednesday, July 31, 2019 11:40 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

> Simply remove the void* cast in the memset() line. "avctx->extradata +
> avctx->extradata_size" is acceptable as an argument.

Thanks James! It's modified and submitted as V16.

Regards,
Sun, 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 v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-31 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Li, 
Zhong
Sent: Wednesday, July 31, 2019 11:33 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper
 
> > > > +AVCodec ff_libsvt_hevc_encoder = {
> > > > +.name   = "libsvt_hevc",
> > > > +.long_name  =
> > NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> > > Video Technology for HEVC) encoder"),
> > > > +.priv_data_size = sizeof(SvtContext),
> > > > +.type   = AVMEDIA_TYPE_VIDEO,
> > > > +.id = AV_CODEC_ID_HEVC,
> > > > +.init   = eb_enc_init,
> > > > +.encode2= eb_encode_frame,
> > > > +.close  = eb_enc_close,
> > > > +.capabilities   = AV_CODEC_CAP_DELAY |
> > > AV_CODEC_CAP_AUTO_THREADS,
> > >
> > > The code don't support to configure thread_count, so I think you'll 
> > > get the same result without AV_CODEC_CAP_AUTO_THREADS.
> > 
> > > This was pointed out by Mark Thompson on patch V4.
> > > It is a problem how comment can be well addressed and avoid to be
> > pointed out again and again.
> > 
> > I got started based on V5 and V6 is my first submission. Thanks for 
> > showing me the information. I am looking into it.
>It was also mentioned in svt-av1 patch 
>https://patchwork.ffmpeg.org/patch/13912/:
>* Expose threads setting since AV_CODEC_CAP_AUTO_THREADS declared 
>___



I checked out the history in https://patchwork.ffmpeg.org/patch/11347/:

Mark's remarks:
> +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AUTO_THREADS,
Threads aren't actually mentioned at all above.  Does that mean the encoder 
will always make as many threads as it wants, and the user has no separate 
control?

And from the macro definition:
/**
 * Codec supports avctx->thread_count == 0 (auto).
 */
#define AV_CODEC_CAP_AUTO_THREADS(1 << 15)

static void validate_thread_parameters(AVCodecContext *avctx)
{
...
} else if (!(avctx->codec->capabilities & AV_CODEC_CAP_AUTO_THREADS)) {
avctx->thread_count   = 1;
avctx->active_thread_type = 0;
}
...
}

I think it's right to declare the codec with that capability as long as the 
codec indeed supports the auto thread count. It's not wrong that we have 
declared that. And to Mark's question, the answer is "Yes, the SVT HEVC encoder 
always makes as many threads as it wants". It checks the CPU cores and decides 
the count of working threads based on the number of cores to ensure the best 
performance, and by now users have no separate control on it.

We have been considering if we shall add such a controlling interface to SVT 
HEVC lib and how. The code lines of handling avctx->thread_count in this 
avcodec is possible to get added in the future. Right now, adding an empty 
interface without implementation supported by SVT HEVC lib makes no sense.
 
Regards,
Sun, 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 v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Limin 
Wang
Sent: Wednesday, July 31, 2019 7:05 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

On Tue, Jul 30, 2019 at 07:48:43PM +0200, Carl Eugen Hoyos wrote:
> Am Di., 30. Juli 2019 um 15:20 Uhr schrieb James Almer :
> >
> > On 7/30/2019 2:59 AM, Limin Wang wrote:
> > >> +if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
> > >> +EB_BUFFERHEADERTYPE *header_ptr = NULL;
> > >> +
> > >> +svt_ret = EbH265EncStreamHeader(svt_enc->svt_handle, 
> > >> _ptr);
> > >> +if (svt_ret != EB_ErrorNone) {
> > >> +av_log(avctx, AV_LOG_ERROR, "Failed to build stream 
> > >> header\n");
> > >> +goto failed_init_encoder;
> > >> +}
> > >> +
> > >> +avctx->extradata_size = header_ptr->nFilledLen;
> > >> +avctx->extradata = av_malloc(avctx->extradata_size + 
> > >> + AV_INPUT_BUFFER_PADDING_SIZE);
> > > It's preferalbe to use av_mallocz
> >
> > He was asked to do it this way as it's faster. No need to zero the 
> > whole buffer if it's going to be written to immediately afterwards. 
> > Only the trailing padding bytes needs to be zeroed.
> 
> In this case I suspect there is an unneeded cast in the next line.

> It's very confusing to allocate with extra padding size, then memcpy the 
> actual data size, then zero the padding data.

> IMO, the padding size is used for the bitstream optimized buffer read(32 or 
> 64 bit for minimal at least). If it's memcpy, do we need malloc with extra 
> AV_INPUT_BUFFER_PADDING_SIZE?

Thanks for everyone's advices and I am considering on how to make this not 
confusing. Will update the patch later.
BTW, it's a "she" :-).

Regards,
Sun, 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 v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Li, 
Zhong
Sent: Tuesday, July 30, 2019 3:49 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

> > +AVCodec ff_libsvt_hevc_encoder = {
> > +.name   = "libsvt_hevc",
> > +.long_name  = NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> Video Technology for HEVC) encoder"),
> > +.priv_data_size = sizeof(SvtContext),
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.id = AV_CODEC_ID_HEVC,
> > +.init   = eb_enc_init,
> > +.encode2= eb_encode_frame,
> > +.close  = eb_enc_close,
> > +.capabilities   = AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_AUTO_THREADS,
> 
> The code don't support to configure thread_count, so I think you'll 
> get the same result without AV_CODEC_CAP_AUTO_THREADS.

> This was pointed out by Mark Thompson on patch V4. 
> It is a problem how comment can be well addressed and avoid to be pointed out 
> again and again. 

I got started based on V5 and V6 is my first submission. Thanks for showing me 
the information. I am looking into it. 

Regards,
Sun, 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 v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-29 Thread Sun, Jing A
The just updated one fixed such typo:
  .pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_YUV420P10,
  AV_PIX_FMT_YUV422P,
- AV_PIX_FMT_YUV420P10,
+AV_PIX_FMT_YUV422P10,
  AV_PIX_FMT_YUV444P,
  AV_PIX_FMT_YUV444P10,
  AV_PIX_FMT_NONE },

Regards,
Sun, 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] lavc: Add libsvt-av1 encoder wrapper

2019-07-14 Thread Sun, Jing A
-Original Message-
From: Li, Zhong 
Sent: Saturday, July 13, 2019 1:23 AM
To: Sun, Jing A ; ffmpeg-devel@ffmpeg.org
Cc: Daryl Seah ; Tang, Zhizhen 
Subject: RE: [PATCH] lavc: Add libsvt-av1 encoder wrapper

> I prefer to contribute on FFmpeg mainline instead of a forked branch. 
> However, once get aligned in the community, of course I can contribute to the 
> branch as well.
> (Many SVT core library and API patches hold on my hand will also be sent out 
> after my leave of next 2~3 weeks)
> And let me provide more detail about the purposes:
> 1. SVT encoders (01.org/svt ) show very impressive performance benefit and 
> get much attention . 
  Let's collect some feedback as early as possible, this patch is not call for 
merge bug call for feedback, comments. Not only collect feedback of SVT FFmpeg 
wrapper, but also feedback of SVT core libraries and APIs.

SVT AV1 GitHub is not a forked branch, but a project every SVT developer is 
working together on. When you have any changes you would like to make to its 
FFmpeg plugin, you'd better submit those to the SVT AV1 Github first, so that 
the SVT maintainers and other plugin authors could review them before making 
them public.

>  e.g : SVT-AV1 reused libaom. If you enable both libsvt-av1 and libaom as 
> static link, then will have name conflict. 
>  Such issue is not easily found if you keep wrapper patch on 
> https://github.com/OpenVisualCloud/SVT-AV1/tree/master/ffmpeg_plugin ,
> But will easily found if works on FFmpeg mainline. 

That's a known issue: https://github.com/OpenVisualCloud/SVT-AV1/issues/119, 
which was submitted by me at Feb. Please look into it.

> 2. Many review comments from community (including mine) haven't been well 
> addressed in SVT-HEVC wrapper patch. 
  This patch is just to address them, probably it can be a reference of 
SVT-HEVC wrapper too. 

Which one is not addressed?

> 3. As mentioned in the patch annotation, this wrapper patch is a response of 
> ticket #7914, though it is not quite mature.
___
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] lavc: Add libsvt-av1 encoder wrapper

2019-07-12 Thread Sun, Jing A
-Original Message-
From: Li, Zhong 
Sent: Friday, July 12, 2019 6:32 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Daryl Seah ; Li, Zhong ; Daryl; 
Seah; Sun, Jing A ; Tang, Zhizhen 
Subject: [PATCH] lavc: Add libsvt-av1 encoder wrapper

From: Daryl Seah 

Signed-off-by: Daryl Seah
Signed-off-by: Jing SUN 
Signed-off-by: ZhiZhen Tang 
Signed-off-by: Zhong Li 
---
It is part of requirement from ticket #7914.

...

Hi Zhong,

I have not submitted such FFmpeg SVT-AV1 plugin patch to the community, like 
the similar one for SVT-HEVC, not just because SVT-AV1 is under development and 
not officially released, but also because the patch is NOT fully functional and 
many severe blocking issues exist, such as this 
https://github.com/OpenVisualCloud/SVT-AV1/issues/268  (~50% frames coded by 
SVT-AV1 fail to get decoded for the pkts generated by it don't fully compliant 
with AV1 spec and have confliction with the av1_metadata_bsf filter).

And in the SVT-AV1 GitHub, it's an open message that it is not ready: 
https://github.com/OpenVisualCloud/SVT-AV1/issues/259.

You (or anyone) are welcome to contribute to the SVT-AV1 project, and submit 
the FFmpeg plugin changes you'd like to make here: 
https://github.com/OpenVisualCloud/SVT-AV1/tree/master/ffmpeg_plugin, and we 
will take your commits seriously. But I have not got any code changes made by 
you in our project GitHub and it seems you haven't made any contribution to the 
project yet.

To be honest, I felt more than embarrassed that this internal work in progress 
of ours, which is only half-done, got exported to the real world, which is to 
get read and judged by all the experts on FFmpeg community.

Please do ignore this review request. It's NOT at least basically working yet. 
I am going to submit one when it is.

-- 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 v14 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-06-25 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
Eugen Hoyos
Sent: Tuesday, June 25, 2019 9:07 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v14 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper


>A minor bump is common for new codecs.

>Carl Eugen

Thanks Carl! It's modified.

Regards,
Sun, 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 v1 1/1] vaapi_encode: replace av_new_packet with ff_alloc_packet2

2019-06-03 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Monday, June 3, 2019 9:55 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v1 1/1] vaapi_encode: replace av_new_packet 
with ff_alloc_packet2

> I can't find this anywhere in the tree. Are you sure you're looking at 
> ffmpeg's libavcodec?

I am so sorry for using out-of-date code base. Please ignore this patch. 
 
Regards,
Sun, 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 v1 1/1] vaapi_encode: replace av_new_packet with ff_alloc_packet2

2019-06-03 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Saturday, June 1, 2019 3:06 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v1 1/1] vaapi_encode: replace av_new_packet 
with ff_alloc_packet2

>vaapi_encode seems to be using send/receive API, though, and not encode2.
>I see ff_vaapi_encode_receive_packet() -> vaapi_encode_output(), and the 
>former is the callback function used in all vaapi encoders as 
>AVCodec.receive_packet, so this patch in not needed.

Hi James,

vaapi_encode uses encode2 API as well, such as vaapi_h264:

AVCodec ff_h264_vaapi_encoder = {
...
.encode2= _vaapi_encode2,
...
};

Whether encoder2 or send_frame/receive_packet, the upper callers are the same 
avcodec_send_frame/avcodec_receive_packet pair, which calls 
send_frame/receive_packet if exist, or calls encode2 instead. Please correct me 
if I am wrong.

And would you please review the other patch "[PATCH v13 1/2] lavc/svt_hevc: add 
libsvt hevc encoder wrapper" for another time? I have updated it again. Thanks 
a lot in advance!

Regards,
Sun, 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 v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Friday, May 31, 2019 11:17 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v13 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>You should return 0 here. AVCodec.encode2() must not return AVERROR_EOF.
>Anything < 0 is considered an error.
>Since this can only happen after EOF, a return value of 0 and *got_packet == 0 
>will effectively signal EOF.
>Use PRId64 instead of ld.

Thanks so much for the review! Modified and please kindly review again. 

Regards,
Sun, 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 v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Friday, May 31, 2019 10:38 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v13 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>No, with the encode2 API you should be using ff_alloc_packet2() instead.
>As i said, the API user may provide it's own buffer in the avpacket passed to 
>avcodec_encode_video2(), which av_new_packet() would ignore and 
>unconditionally allocate a new one.

Thanks for the guidance! I am modifying it and will submit the modification 
soon.
 
Regards,
Sun, 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 v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-30 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Friday, May 31, 2019 11:37 AM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

Sorry I forgot to remove some debugging code lines, removed them in the just 
sent one:

-typedef struct TIME_LOG{
-unsigned int pts;
-int64_t time;
-} TIME_LOG;
-
-#define START_LOG_POS   2
-#define TOTAL_LOG_COUNT 8192
-static TIME_LOG logs[TOTAL_LOG_COUNT], sent_logs[TOTAL_LOG_COUNT];
-static unsigned int frame_count = 0, sent_frame_count = 0;
-static int64_t start_time = 0;

Regards,
Sun, 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 v13 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-30 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Thursday, May 30, 2019 11:35 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v13 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>Why the switch to encode2? All previous versions were using the send/receive 
>API, and seeing SVT also uses a decoupled input/output API, it was certainly 
>the most adequate option.
>Were you running into some issue? A quick look at v12 shows you were using 
>ff_alloc_packet2(), which afaik you shouldn't have. It's meant for the 
>encode2() API only, where user provided buffers are allowed, and it alone does 
>not ensure the packet will be reference counted, which is required for the 
>send/receive API.

Hi James,

Yes I indeed was running into an issue. Although SVT uses a decoupled 
input/output API, it calls the two by the below method:
while(not stopped) {
send_frame(one frame);
if (receive_packet(one frame’s pkt) != empty)
save_bitstream;
}
In one round, none or only one packet is receive.

However, if using v12's send_frame/receive_packet implementation, it is 
possible that multiple of receive_packet are executed in one round.
while(not stopped) {
send_frame(one frame);
while(1) {
if (receive_packet(one frame’s pkt) == empty)
break;
else
save_bitstream;
}
}

The first calling method's sequence is like:
Send 579
Receive 487
Send 580
Receive 496
Send 581
Receive 492
Send 582
Receive 490
Send 583
Receive 489
Send 584
Receive 491
Send 585
Receive 494
Send 586
Receive 493
Send 587
Receive 495
And the second one's is:
Send 579
Receive empty
Send 580
Receive 489
Receive 491
Receive 494
Receive 493
Receive 495
Receive empty
Send 581
Receive 504
Receive empty
Send 582
Receive empty
Send 583
Receive empty
Send 584
Receive 500
Receive empty
Send 585
Receive empty
Send 586
Receive empty
Send 587

When we input the source frame at the constant frequency 60, the first one's 
each second's output frames are ~60, [59, 61], while the second one's tends to 
be like 64(63) ->57(58) ->64(63) ->57(58)… 
Besides the average FPS, the stableness of each second's FPS is also important 
to us. So I changed the API to encode2, because in encode2, I can control the 
SVT's send_frame/receive_packet calling sequence, and let it not do 
receive_packet more than once in one round.

And thanks for the information on ff_alloc_packet2. I changed to use 
av_new_packet in v13 and hope it's OK.

Regards,
Sun, 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 v12 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-09 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Li, 
Zhong
Sent: Friday, May 10, 2019 1:23 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>The better solution should be: use av_malloc and just memset the padding bytes.

The memset inside av_mallocv sets the whole buffer of the size 
"avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE" to zero.

avctx->extradata_size = header_ptr->nFilledLen;
avctx->extradata = av_mallocz(avctx->extradata_size + 
AV_INPUT_BUFFER_PADDING_SIZE);

-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".
___
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 v12 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-09 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of James 
Almer
Sent: Friday, May 10, 2019 12:05 PM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>You used av_mallocz() to allocate the buffer, so it's already fully zeroed.
>In any case, it would be faster to instead use av_malloc() above, then only 
>zero the padding bytes here. Since you're copying the actual data in the line 
>below, nothing will remain uninitialized.

Hi Almer,

Thanks for the review! Indeed the explicit memset() is redundant and I have 
removed that.

void *av_mallocz(size_t size)
{
void *ptr = av_malloc(size);
if (ptr)
memset(ptr, 0, size);
return ptr;
}

-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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-06 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
Eugen Hoyos
Sent: Sunday, May 5, 2019 6:48 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

>You add a new encoder, so you have to raise MINOR in libavcodec/version.h (and 
>reset MICRO).

>Carl Eugen

Hi Carl,

I made the version change and submitted the v11 patches. Please kindly review 
if I am doing it correctly.

Regards,
Sun, 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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-05 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
Eugen Hoyos
Sent: Friday, April 26, 2019 11:28 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper

2019-04-26 8:41 GMT+02:00, Li, Zhong :
>> Is it V11 now? (Just saw several V10 and I am a litter confused.)
>> Since there is some existed software HEVC encoder, how about add a 
>> link to the SVT-HEVC writepaper in the commit message to make other 
>> easily to understand what is the advantage of SVT-HEVC and the benefit 
>> to plugin to FFmpeg?

>Without knowing the white paper, I would prefer not to add a link.
>Carl Eugen

Thanks for the review!

The whitepaper is not final, and I prefer not to add its link as well. Also 
it's quite easy to locate it in the SVT HEVC GitHub page. Is that OK not to add 
it?
For versions, I increased it if big changes were submitted and kept it the same 
if only minor changes. I am new to the community and would you please guide me 
if that strategy is all right or not? If not, I will resubmit the last with 
v11. 

Regards,
Sun, 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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-04-22 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Monday, April 1, 2019 10:38 AM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Tmar, Hassene ; Jun Zhao 

Subject: [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

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 | 482 +++
 4 files changed, 488 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..2ab5323
--- /dev/null
+++ b/libavcodec/libsvt_hevc.c
@@ -0,0 +1,482 @@
+/*
+* 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 "

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

2019-04-02 Thread Sun, Jing A
-Original Message-
From: Li, Zhong 
Sent: Friday, March 29, 2019 6:59 PM
To: FFmpeg development discussions and patches 
Cc: Sun, Jing A ; Huang, Zhengxu 
; Jun Zhao ; Tmar, Hassene 

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

> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Jing Sun
> Sent: Friday, March 29, 2019 4:22 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Jing A ; Huang, Zhengxu 
> ; Jun Zhao ; Tmar, 
> Hassene 
> Subject: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc 
> encoder wrapper
> 
> 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 | 500
> +++
>  4 files changed, 506 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..4ef06a8
> --- /dev/null
> +++ b/libavcodec/libsvt_hevc.c
> @@ -0,0 +1,500 @@
> +/*
> +* Scalable Video Technology for HEVC encoder library plugin
> +*
> +* Copyright (c) 2018 Intel Corporation

It is 2019 now.

[Jing] To be modified.

> +* This file is part of FFmpeg.
&

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

2019-03-31 Thread Sun, Jing A

-Original Message-
From: Li, Zhong 
Sent: Monday, April 1, 2019 1:21 PM
To: FFmpeg development discussions and patches 
Cc: Sun, Jing A ; Huang, Zhengxu 
; Jun Zhao ; Tmar, Hassene 

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

> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Jing Sun
> Sent: Monday, April 1, 2019 10:38 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Jing A ; Huang, Zhengxu 
> ; Jun Zhao ; Tmar, 
> Hassene 
> Subject: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc 
> encoder wrapper

>I haven't seen any of my comments was addressed. 

Thanks for your valuable comments! I am working on them.

- 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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-31 Thread Sun, Jing A
The one made the below change:

- if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
+if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10) {

No special handling for 10 bit anymore.

Regards,
SUN, 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".
___
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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-31 Thread Sun, Jing A
The one made the below change:

___
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 v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-03-31 Thread Sun, Jing A
On Fri, Mar 29, 2019 at 5:28 AM Jing Sun  wrote:
+static int config_enc_params(EB_H265_ENC_CONFIGURATION *param,
+                             AVCodecContext *avctx)
+{
+    SvtContext *svt_enc = avctx->priv_data;
+    int ret;
+
+    param->sourceWidth = avctx->width;
+    param->sourceHeight = avctx->height;
+    param->encoderBitDepth = 8;
+
+    if (avctx->pix_fmt == AV_PIX_FMT_YUV420P10LE) {
+        av_log(avctx, AV_LOG_DEBUG, "Encoder 10 bits depth input\n");
+
+        param->encoderBitDepth = 10;
+    }
+    param->encoderColorFormat = EB_YUV420;

>this patch blatantly ignores my review(s) and therefore it is rejected

>to reiterate:
>- if the encoder does not support 10 bit (or if scales down from 10 to 8 
>internally), this feature should not be present in the wrapper either (or it 
>should at least warn the user)

>- if the encoder does not support setting the color properties in the VUI, the 
>wrapper should definitely warn the user of the loss of information (or we 
>should wait until this features is present upstream)

>reagrds
>-- 
>Vittorio

--
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).
-

You said that functionality should be removed and the comment in the code is 
useless, so I removed it. The 10 bit works fine this way, no need to warn the 
users.


--
nit: excessive whitespace alignment
-- 
I have corrected the whitespace.


--
Where is the warning that notifies the lack of color properties support?
--
I was with you, so added the warning in v9, then I removed the hdr/vui 
interfaces entirely in v10, after I saw mark's review. I think you are right, 
that the SVT-HEVC's implementation of hdr/vui is not a complete one , hence the 
removal. And I have explained the removal in the former reply: to add hdr back 
once the feature is fully supported in SVT-HEVC.


--
IMO these options help text could be improved. 
--
I have improved it in v9/v10. 
+{ "aud", "Include Access Unit Delimiter", OFFSET(aud),
+  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },

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

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

2019-03-19 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Jing 
SUN
Sent: Monday, March 11, 2019 6:38 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Huang, Zhengxu 
; Jun Zhao ; Tmar, Hassene 

Subject: [FFmpeg-devel] [PATCH v7 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 
Signed-off-by: Jing SUN 
---
 configure|   4 +
 libavcodec/Makefile  |   1 +
 libavcodec/allcodecs.c   |   1 +
 libavcodec/libsvt_hevc.c | 527 +++
 4 files changed, 533 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; dif

Re: [FFmpeg-devel] [PATCH v7 2/2] doc: Add libsvt_hevc encoder docs

2019-03-19 Thread Sun, Jing A
-Original Message-
From: Sun, Jing A 
Sent: Monday, March 11, 2019 3:02 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Sun, Jing A ; Jun Zhao ; Huang, 
Zhengxu ; Tmar, Hassene 
Subject: [PATCH v7 2/2] doc: Add libsvt_hevc encoder docs

Add docs for libsvt_hevc encoder in encoders.texi and general.texi

Signed-off-by: Jun Zhao 
Signed-off-by: Huang, Zhengxu 
Signed-off-by: hassene 
Signed-off-by: Jing SUN 
---
 doc/encoders.texi | 145 ++
 doc/general.texi  |   8 +++
 2 files changed, 153 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi index 29625ba..0b30776 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1569,6 +1569,151 @@ Set maximum NAL size in bytes.
 Allow skipping frames to hit the target bitrate if set to 1.
 @end table
 
+@section libsvt_hevc
+
+Scalable Video Technology for HEVC encoder (SVT-HEVC encoder) wrapper.
+
+This encoder requires the presence of the headers and library during 
+configuration. You need to explicitly configure the build with 
+@code{--enable-libsvthevc}. The library is detected using 
+@command{pkg-config}.
+
+For more information about the library see 
+@url{https://github.com/intel/SVT-HEVC.git}.
+
+@subsection Options
+
+The following FFmpeg global options affect the configurations of the 
+libsvt_hevc encoder.
+
+@table @option
+@item b  (@emph{bitrate})
+Set the bitrate (as a number of bits per second). Default is 7M.
+
+@item g  / @option{gop_size}
+Set the GOP size. Default is -2 (unspecified).
+
+@item flags +cgop
+Enable closed GOP.
+
+@item qmin (@emph{min-q})
+Defaults 10
+
+@item qmax (@emph{max-q})
+Defaults 48
+
+Set minimum/maximum quantisation values.  Valid range is from 0 to 51 
+(Only used when bit rate control mode @option{rc} is set to 1(vbr) mode.
+Has to be qmax > = qmin).
+
+@item profile (@emph{profile})
+Set profile restrictions. Can assume one of the following possible values:
+
+Default is 2 (main10).
+
+@table @samp
+@item main
+main profile
+@item main10
+main10 profile
+@end table
+
+@item level
+
+@option{profile} sets the value of @emph{profile}.
+@option{level} sets the value of @emph{level}.
+
+The encoder also has its own specific options:
+
+@table @option
+@item vui
+Enables or disables the vui structure in the HEVC elementary bitstream. 
+0 = Off, 1 = On. Default is 0 (Off).
+
+@item aud (@emph{aud})
+Enable use of access unit delimiters when set to 1. Default is 0 (Off).
+
+@item hielevel
+Set hierarchical levels. Can assume one of the following possible values:
+
+Default is 3 (4level).
+
+@table @samp
+@item flat
+none hierarchy level
+@item 2level
+2-level hierarchy
+@item 3level
+3-level hierarchy
+@item 4level
+4-level hierarchy
+@end table
+
+@item la_depth
+Set look-ahead depth, depending on bit rate control mode @option{rc}, 
+when bit rate control mode is set to vbr it's best to set this 
+parameter to be equal to the intra period value (such is the default 
+set by the encoder), when cqp is chosen, then a look ahead is recommended. The 
range is from @var{0-256}.
+
+@item preset
+A preset defining the quality vs density tradeoff point that the 
+encoding is to be performed at.(e.g. 0 is the highest quality mode,
+12 is the highest density mode). The range is from @var{0-12}. Default is 9.
+
+@item tier
+Set @emph{general_tier_flag}.  This may affect the level chosen for the 
+stream if it is not explicitly specified. Can assume one of the following 
possible values:
+
+Default is 1 (main).
+
+@table @samp
+@item main
+main tier
+@item high
+high tier
+@end table
+
+@item rc
+Set bit rate control mode. Can assume one of the following possible values:
+
+Default is 0 (cqp).
+
+@table @samp
+@item cqp
+Constant QP (CQP) mode
+@item vbr
+Variable Bit Rate (VBR) mode
+@end table
+
+@item qp
+Initial quantization parameter for the intra pictures used when 
+@option{rc} is cqp mode. The range is from @var{0-51}. Default is 32.
+
+@item sc_detection
+Enables or disables the scene change detection algorithm. Default is 0 
(disable).
+
+@item tune
+Set quality tuning mode. Can assume one of the following possible values:
+
+Default is 1 (oq).
+
+@table @samp
+@item sq
+Visually optimized mode
+@item oq
+PSNR / SSIM optimized mode
+@item vmaf
+VMAF optimized mode
+@end table
+
+@item bl_mode
+Enables or disables Random Access Prediction. Default is 0 (disable).
+@end table
+
+@item hdr
+High dynamic range input. Default is 0 (disable).
+@end table
+
 @section libtheora
 
 libtheora Theora encoder wrapper.
diff --git a/doc/general.texi b/doc/general.texi index fe94c40..f90e188 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -234,6 +234,14 @@ FFmpeg can use the OpenJPEG libraries for 
decoding/encoding J2K videos.  Go to  instructions.  To enable using OpenJPEG 
in FFmpeg, pass @code{--enable-libopenjpeg} to  @file{./configure}.
 
+@section Scalable Video Technology for HEVC
+
+FFmpeg can make use of the SVT-HEVC library for HEVC encoding.
+
+Go to @

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

2019-03-13 Thread Sun, Jing A

On Wed, Mar 13, 2019 at 8:29 PM Sun, Jing A  wrote:

>
>
> > On Tue, Mar 12, 2019 at 11:40 PM Sun, Jing A 
> wrote:
>
> Hi Giovara,
>
>
>
> SVT HEVC has the interface to enable/disable sending a vui structure 
> in the HEVC bitstream, but supports no interface for setting the color 
> properties before encoding yet. I will be opening an issue in SVT HEVC 
> github asking if they have plans to add such feature, and will keep 
> you posted. In the meantime, I think it is not blocking the first 
> version of this plugin’s merging , is it?
>
>
>
>
>
> > It kind-of is, what is the point of setting the HDR information (or
> encoding in hevc at all) if you can't set the related color properties?
>
> > At the very least there should be a big fat warning that notifies 
> > users
> of this missing feature, when such information is lost.
>
> > --
>
> > Vittorio
>
>
>
> SVT HEVC’s HDR is also an on-off switch, please refer to 
> https://github.com/intel/SVT-HEVC/blob/master/Docs/svt-hevc_encoder_us
> er_guide.md
> .
>
>
>
> -Jing
>

>Sorry, I fail to see the logical connection between my comment and your reply.
>--
>Vittorio

The feature request is being considered: 
https://github.com/intel/SVT-HEVC/issues/148
-Jing
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2019-03-13 Thread Sun, Jing A

> On Tue, Mar 12, 2019 at 11:40 PM Sun, Jing A 
> mailto:jing.a@intel.com>> wrote:
Hi Giovara,

SVT HEVC has the interface to enable/disable sending a vui structure in the 
HEVC bitstream, but supports no interface for setting the color properties 
before encoding yet. I will be opening an issue in SVT HEVC github asking if 
they have plans to add such feature, and will keep you posted. In the meantime, 
I think it is not blocking the first version of this plugin’s merging , is it?


> It kind-of is, what is the point of setting the HDR information (or encoding 
> in hevc at all) if you can't set the related color properties?
> At the very least there should be a big fat warning that notifies users of 
> this missing feature, when such information is lost.
> --
> Vittorio

SVT HEVC’s HDR is also an on-off switch, please refer to 
https://github.com/intel/SVT-HEVC/blob/master/Docs/svt-hevc_encoder_user_guide.md.

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


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

2019-03-13 Thread Sun, Jing A
On  Monday, March 11, 2019 10:50 PM Vittorio Giovara vittorio.giov...@gmail.com 
wrote:

>On Mon, Mar 11, 2019 at 12:50 AM Sun, Jing A  wrote:
>I just searched my inbox again but failed to find that email of question you 
>mentioned.
>
>Yeah I often see my mail bounced with this message:
>
>Address not found
>Your message wasn't delivered to jun.z...@intel.com because the address 
>couldn't be found, or is unable to receive mail. 
 
>For reference this was the message on the mailing list 
>https://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/240663.html
>
>Could you please elaborate your request? What is the preservation for and how 
>is it expected to work? 
>
>Yes of course, when you encode an HEVC stream you should be able to 
>signal how the color properties of the video buffers should be 
>rendered. This is usually conveyed with three parameters, the matrix 
>coefficients, the color primaries and the transfer characteristics. Without 
>such information, the data stored in the video may be interpreted differently 
>and often incorrectly by modern video players, causing image degradation, 
>wrong rendering and off colors.

>For HEVC they are usually expressed in the stream itself, under the VUI, and 
>it is kinda expected that modern encoder allow to set them to any of the 
>applicable values.
>In ffmpeg-land, they are represented by the colorspace, color_primaries and 
>color_transfer options in AVCodecContext and carried over through the whole 
>video processing.
>--
>Vittorio

Hi Giovara,

SVT HEVC has the interface to enable/disable sending a vui structure in the 
HEVC bitstream, but supports no interface for setting the color properties 
before encoding yet. I will be opening an issue in SVT HEVC github asking if 
they have plans to add such feature, and will keep you posted. In the meantime, 
I think it is not blocking the first version of this plugin’s merging , is it?

In SVT HEVC user guide: "VideoUsabilityInfo - Enables or disables sending a vui 
structure in the HEVC Elementary bitstream. 0 = OFF, 1 = ON"

Regards,
SUN, Jing

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


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

2019-03-12 Thread Sun, Jing A
On  Monday, March 11, 2019 10:50 PM Vittorio Giovara vittorio.giov...@gmail.com 
wrote:

>On Mon, Mar 11, 2019 at 12:50 AM Sun, Jing A  wrote:
>I just searched my inbox again but failed to find that email of question you 
>mentioned.
>
>Yeah I often see my mail bounced with this message:
>
>Address not found
>Your message wasn't delivered to jun.z...@intel.com because the address 
>couldn't be found, or is unable to receive mail. 
 
>For reference this was the message on the mailing list 
>https://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/240663.html
>
>Could you please elaborate your request? What is the preservation for and how 
>is it expected to work? 
>
>Yes of course, when you encode an HEVC stream you should be able to signal how 
>the color properties of the video buffers should be rendered. This is usually 
>conveyed with three 
>parameters, the matrix coefficients, the color primaries and the transfer 
>characteristics. Without such information, the data stored in the video may be 
>interpreted differently and often 
>incorrectly by modern video players, causing image degradation, wrong 
>rendering and off colors.

>For HEVC they are usually expressed in the stream itself, under the VUI, and 
>it is kinda expected that modern encoder allow to set them to any of the 
>applicable values.
>In ffmpeg-land, they are represented by the colorspace, color_primaries and 
>color_transfer options in AVCodecContext and carried over through the whole 
>video processing.
>-- 
>Vittorio

Hi Giovara,

SVT HEVC has the interface to enable/disable sending a vui structure in the 
HEVC bitstream, but supports no interface for setting the color properties 
before encoding yet. I will be opening an issue in SVT HEVC github asking if 
they have plans to add such feature, and will keep you posted. In the meantime, 
I think it is not blocking the first version of this plugin’s merging , is it?

In SVT HEVC user guide: "VideoUsabilityInfo - Enables or disables sending a vui 
structure in the HEVC Elementary bitstream. 0 = OFF, 1 = ON"

Regards,
SUN, Jing

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


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

2019-03-12 Thread Sun, Jing A
Hi Giovara,

SVT HEVC has the interface to enable/disable sending a vui structure in the 
HEVC bitstream, but supports no interface for setting the color properties 
before encoding yet. I will be opening an issue in SVT HEVC github asking if 
they have plans to add such feature, and will keep you posted. In the meantime, 
I think it is not blocking the first version of this plugin’s merging , is it?

VideoUsabilityInfo

Enables or disables sending a vui
structure in the HEVC Elementary
bitstream. 0 = OFF, 1 = ON


Regards,
SUN, Jing

From: Vittorio Giovara [mailto:vittorio.giov...@gmail.com]
Sent: Monday, March 11, 2019 10:50 PM
To: Sun, Jing A 
Cc: FFmpeg development discussions and patches ; 
Huang, Zhengxu ; Tmar, Hassene 
Subject: Re: [FFmpeg-devel] [PATCH v7 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper.



On Mon, Mar 11, 2019 at 12:50 AM Sun, Jing A 
mailto:jing.a@intel.com>> wrote:
I just searched my inbox again but failed to find that email of question you 
mentioned.

Yeah I often see my mail bounced with this message:

Address not found
Your message wasn't delivered to jun.z...@intel.com<mailto:jun.z...@intel.com> 
because the address couldn't be found, or is unable to receive mail.


For reference this was the message on the mailing list 
https://ffmpeg.org/pipermail/ffmpeg-devel/2019-March/240663.html

Could you please elaborate your request? What is the preservation for and how 
is it expected to work?

Yes of course, when you encode an HEVC stream you should be able to signal how 
the color properties of the video buffers should be rendered. This is usually 
conveyed with three parameters, the matrix coefficients, the color primaries 
and the transfer characteristics. Without such information, the data stored in 
the video may be interpreted differently and often incorrectly by modern video 
players, causing image degradation, wrong rendering and off colors.

For HEVC they are usually expressed in the stream itself, under the VUI, and it 
is kinda expected that modern encoder allow to set them to any of the 
applicable values.
In ffmpeg-land, they are represented by the colorspace, color_primaries and 
color_transfer options in AVCodecContext and carried over through the whole 
video processing.
--
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2019-03-11 Thread Sun, Jing A

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
Eugen Hoyos
Sent: Monday, March 11, 2019 5:01 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v7 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper.

2019-03-11 9:49 GMT+01:00, Moritz Barsnick :
> On Mon, Mar 11, 2019 at 04:17:21 +0000, Sun, Jing A wrote:
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Carl Eugen Hoyos
>> > The condition is unnecessary.
>> [SUN, Jing] If av_mallocz fails, free_buffer will be called with 
>> in_data being NULL. Checking it avoids unnecessary calling to 
>> av_freep in that case.
>
> Please read the kind documentation (and the "Note" quzoted below) or 
> the source of said function, and how other uses within ffmpeg are:
>
> https://www.ffmpeg.org/doxygen/4.1/group__lavu__mem__funcs.html#ga0cc8
> 4043ea2167ad005c86e11d0bcdba
>
> void av_freep (void *ptr)
> [...]
> Note
> *ptr = NULL is safe and leads to no action.

> In other words, av_freep() already has this check.

I believe his argumentation was that he knows but that in case of oom, he wants 
to avoid extra indirections.

Carl Eugen

[SUN, Jing] Modified and thanks for the review!

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


Re: [FFmpeg-devel] [PATCH v6 2/2] doc: Add libsvt_hevc encoder docs

2019-03-11 Thread Sun, Jing A

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Wednesday, March 6, 2019 6:19 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v6 2/2] doc: Add libsvt_hevc encoder docs

On 05/03/2019 07:43, Jing SUN wrote:
> Add docs for libsvt_hevc encoder in encoders.texi and general.texi
> 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Huang, Zhengxu 
> Signed-off-by: hassene 
> Signed-off-by: Jing SUN 
> ---
>  doc/encoders.texi | 161 
> ++
>  doc/general.texi  |   8 +++
>  2 files changed, 169 insertions(+)
> 
> diff --git a/doc/encoders.texi b/doc/encoders.texi index 
> 29625ba..64ddb2f 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1569,6 +1569,167 @@ Set maximum NAL size in bytes.
>  Allow skipping frames to hit the target bitrate if set to 1.
>  @end table
>  
> +@section libsvt_hevc
> +
> +Scalable Video Technology for HEVC encoder (SVT-HEVC encoder) wrapper.
> +
> +This encoder requires the presence of the headers and library during 
> +configuration. You need to explicitly configure the build with 
> +@code{--enable-libsvthevc}. The library is detected using 
> +@command{pkg-config}.
> +
> +For more information about the library see 
> +@url{https://github.com/intel/SVT-HEVC.git}.
> +
> +@subsection Options
> +
> +The following FFmpeg global options affect the configurations of the 
> +libsvt_hevc encoder.
> +
> +@table @option
> +@item b  (@emph{bitrate})
> +Set the bitrate (as a number of bits per second). Default is 7M.
> +
> +@item refs (@emph{ref})
> +Number of reference frames each P-frame can use. The range is from 
> @var{0-16}.
> +Default is 0(disabled).

Wouldn't 0 mean that P frames can't exist, so the whole stream must be 
intra-only?
[SUN, Jing] To be modified in v7.

> +@item g  / @option{gop_size}
> +Set the GOP size. Default is 64.

This doesn't appear to match what is set in the other patch.
[SUN, Jing] To be modified in v7.

> +
> +@item flags +cgop
> +Enable closed GOP.
> +
> +@item qmin (@emph{min-q})
> +Defaults 10
> +
> +@item qmax (@emph{max-q})
> +Defaults 48
> +
> +Set minimum/maximum quantisation values.  Valid range is from 0 to 51 
> +(Only used when bit rate control mode @option{rc} is set to 0(cqp) mode.
> +Has to be qmax > = qmin).

In the other patch you only set them in VBR mode, not CQP mode.
[SUN, Jing] To be modified in v7.

> +
> +@item profile (@emph{profile})
> +Set profile restrictions. Can assume one of the following possible values:
> +
> +Default is 2 (main10).
> +
> +@table @samp
> +@item main
> +main profile
> +@item main10
> +main10 profile
> +@end table
> +
> +@item level
> +
> +@option{profile} sets the value of @emph{profile_idc} and the 
> @emph{constraint_set*_flag}s.
> +@option{level} sets the value of @emph{level_idc}.

The syntax elements named here exist only in H.264, not H.265.
[SUN, Jing] To be modified in v7.

> +
> +The encoder also has its own specific options:
> +
> +@table @option
> +@item vui
> +Enables or disables the vui structure in the HEVC elementary 
> +bitstream. 0 = Off, 1 = On. Default is 0 (Off).
> +
> +@item aud (@emph{aud})
> +Enable use of access unit delimiters when set to 1. Default is 0 (Off).
> +
> +@item hielevel
> +Set hierarchical levels. Can assume one of the following possible values:
> +
> +Default is 3 (4level).
> +
> +@table @samp
> +@item flat
> +none hierarchy level
> +@item 2level
> +2-level hierarchy
> +@item 3level
> +3-level hierarchy
> +@item 4level
> +4-level hierarchy
> +@end table
> +
> +@item la_depth
> +Set look-ahead depth, depending on bit rate control mode @option{rc}, 
> +when bit rate control mode is set to vbr it's best to set this 
> +parameter to be equal to the intra period value (such is the default 
> +set by the encoder), when cqp is chosen, then a look ahead is recommended. 
> The range is from @var{0-256}.
> +
> +@item intra_ref_type
> +Set intra refesh type. Can assume one of the following possible values:
> +
> +Default is 2 (idr).
> +
> +@table @samp
> +@item cra
> +open group of pictures
> +@item idr
> +closed group of pictures
> +@end table

This option doesn't exist in the other patch.
[SUN, Jing] To be modified in v7.

> +
> +@item preset
> +A preset defining the quality vs density tradeoff point that the 
> +encoding is to be performed at.(e.g. 0 is the highest quality mode,
> +12 is the highest density mode). The range is from @var{0-12}. Default is 9.
> +
> +@item tier
> +Set @emph{general_tier_flag}.  This may affect the level chosen for 
&

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

2019-03-10 Thread Sun, Jing A
I just searched my inbox again but failed to find that email of question you 
mentioned.
Could you please elaborate your request? What is the preservation for and how 
is it expected to work?

Regards,
SUN, Jing

From: Vittorio Giovara [mailto:vittorio.giov...@gmail.com]
Sent: Saturday, March 9, 2019 4:48 AM
To: FFmpeg development discussions and patches 
Cc: Sun, Jing A ; Huang, Zhengxu 
; Jun Zhao ; Tmar, Hassene 

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



On Fri, Mar 8, 2019 at 4:39 AM Jing SUN 
mailto:jing.a@intel.com>> wrote:
From: Jing Sun mailto:jing.a@intel.com>>

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

Apologies if i missed your reply but i think my question was not answered

Is there any way to preserve the color matrix/primary/transfer properties 
during encoding?

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


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

2019-03-10 Thread Sun, Jing A

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
Eugen Hoyos
Sent: Saturday, March 9, 2019 5:07 AM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH v7 1/2] lavc/svt_hevc: add libsvt hevc 
encoder wrapper.

2019-03-08 11:36 GMT+01:00, Jing SUN :

> +static void free_buffer(SvtContext *svt_enc) {
> +EB_H265_ENC_INPUT *in_data =
> (EB_H265_ENC_INPUT *)svt_enc->in_buf.pBuffer;

Is the cast necessary?
Or actually: Can't in_data be whatever doesn't produce a warning?
[SUN, Jing] Yes, it's necessary, because the type of pBuffer is uint8_t* in 
libsvt_hevc.

> +
> +if (in_data)
> +av_freep(_data);

The condition is unnecessary.
[SUN, Jing] If av_mallocz fails, free_buffer will be called with in_data being 
NULL. Checking it avoids unnecessary calling to av_freep in that case.

static void free_buffer(SvtContext *svt_enc)
{
...
if (in_data)
av_freep(_data);
}

static int alloc_buffer(EB_H265_ENC_CONFIGURATION *config, SvtContext *svt_enc)
{
...

in_data  = av_mallocz(sizeof(*in_data));
if (!in_data)
goto failed;
   ...

failed:
free_buffer(svt_enc);
...
}
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
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.

2019-03-08 Thread Sun, Jing A
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:
>

Re: [FFmpeg-devel] [PATCH v2 1/1] avcodec/vaapi_encode: add frame-skip func

2019-02-21 Thread Sun, Jing A
-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Thursday, February 21, 2019 5:35 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 20/02/2019 10:33, Jing SUN wrote:
> This implements app controlled frame skipping in vaapi encoding. To 
> make a frame skipped, allocate its frame side data of the newly added 
> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.
> 
> Signed-off-by: Jing SUN 
> ---
>  libavcodec/vaapi_encode.c | 112 
> --
>  libavcodec/vaapi_encode.h |   5 +++
>  libavutil/frame.c |   1 +
>  libavutil/frame.h |   5 +++
>  4 files changed, 119 insertions(+), 4 deletions(-)

Have a look at 
<https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2019-February/239989.html>, 
which tries to implement this feature in a more general way without adding any 
ad-hoc API.

- Mark
-Original Message-

Hi Mark,

I think the 239989 patch is quite a good one to implement VFR by adapting VAAPI 
frame-skip feature, but it does not fulfill the feature requirement that we 
have been asked to achieve, which is to skip the frames that are selected by 
apps, and the purpose to skip any frames is not just to control frame-rate, but 
also to skip duplicated ones, or to skip abandoned ones due to some changes 
just made, etc. Could we please keep both and let users decide which way they 
want to use?

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


Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-12-23 Thread Sun, Jing A
Hi Mark,

May I have your comments on this please?

Regards,
SUN, Jing

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Sun, 
Jing A
Sent: Tuesday, December 18, 2018 4:23 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

Hi Mark,

Such APP controlled frame-skipping feature is required by our vaapi lib users. 
Could we get it merged please?

Regards,
SUN, Jing

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Sun, 
Jing A
Sent: Monday, December 10, 2018 3:19 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

Hi Mark,

Thanks for your kind guidance, but the problem is we are not trying to control 
the output framerate by this skip-frame feature. Our purpose is to just skip 
some frames, which are being requested by the content producer. And to 
implement that, we need an interface between the app and the vaapi lib, which 
informs the latter that a frame shall be skipped. 

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Monday, December 10, 2018 2:40 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 06/12/2018 10:04, Sun, Jing A wrote:
> Hi Mark,
> 
> This patch is not trying to support VFR. Some frames, after which are just 
> produced, could be considered as not needed by theirs producer and will get 
> skipped in the encoding process. And in my opinion the existing timing 
> information is not sufficient to support the case.

A skipped frame will still have a timestamp, so if a frame is skipped before 
the encoder then no frame with that timestamp will be given to the encoder.  
For CFR content this can be detected in the encoder to reconstruct your 
skip-frames information exactly - a skip has occurred if the gap between two 
frames does not match the framerate, and the size of the gap tells you how many 
frames were skipped.  Avoiding a requirement that the gap sizes exactly match 
makes it implement a simple VFR scheme too, since skips can be inserted to keep 
the rate controller correct as long as you never have frames closer together 
than the configured framerate.

(Please avoid top-posting on this list.)

- Mark


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Mark Thompson
> Sent: Wednesday, December 5, 2018 7:50 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
> frame-skip func
> 
> On 04/12/2018 01:46, Sun, Jing A wrote:
>> Hi Mark,
>>
>> Is there any issue that I need to fix for this patch please? 
> 
> See comments in the message you quoted below?  I think the most important 
> point is that the existing timing information appears to contain all the 
> information you want for VFR, so you probably shouldn't need the ad-hoc 
> side-data type.
> 
> - Mark
> 
> 
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Sun, Jing A
>> Sent: Friday, November 23, 2018 5:37 PM
>> To: FFmpeg development discussions and patches 
>> 
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> Hi Mark,
>>
>> In some cases, that is useful. For example, an online content distributer, 
>> who keeps encoding the captured video frames by ffmpeg and sending them out. 
>> At times, there is no update of source, which makes one or several captured 
>> source frames are exactly the same as the last one, and the distributer 
>> wants to just skip such frames, without stopping the encoding process.
>>
>> Regards,
>> SUN, Jing
>>
>>
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Mark Thompson
>> Sent: Tuesday, November 20, 2018 4:07 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> On 19/11/18 09:04, Jing SUN wrote:
>>> frame-skip is required to implement network bandwidth self-adaptive 
>>> vaapi encoding.
>>> To make a frame skipped, allocate its frame side data of 
>>> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.
>>
>> So if I'm reading this correctly the idea is to implement partial VFR by 
>> having a special new side-data type which indicates where frames would have 
>> been had the input actually matched the 

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-12-18 Thread Sun, Jing A
Hi Mark,

Such APP controlled frame-skipping feature is required by our vaapi lib users. 
Could we get it merged please?

Regards,
SUN, Jing

-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Sun, 
Jing A
Sent: Monday, December 10, 2018 3:19 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

Hi Mark,

Thanks for your kind guidance, but the problem is we are not trying to control 
the output framerate by this skip-frame feature. Our purpose is to just skip 
some frames, which are being requested by the content producer. And to 
implement that, we need an interface between the app and the vaapi lib, which 
informs the latter that a frame shall be skipped. 

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Monday, December 10, 2018 2:40 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 06/12/2018 10:04, Sun, Jing A wrote:
> Hi Mark,
> 
> This patch is not trying to support VFR. Some frames, after which are just 
> produced, could be considered as not needed by theirs producer and will get 
> skipped in the encoding process. And in my opinion the existing timing 
> information is not sufficient to support the case.

A skipped frame will still have a timestamp, so if a frame is skipped before 
the encoder then no frame with that timestamp will be given to the encoder.  
For CFR content this can be detected in the encoder to reconstruct your 
skip-frames information exactly - a skip has occurred if the gap between two 
frames does not match the framerate, and the size of the gap tells you how many 
frames were skipped.  Avoiding a requirement that the gap sizes exactly match 
makes it implement a simple VFR scheme too, since skips can be inserted to keep 
the rate controller correct as long as you never have frames closer together 
than the configured framerate.

(Please avoid top-posting on this list.)

- Mark


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Mark Thompson
> Sent: Wednesday, December 5, 2018 7:50 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
> frame-skip func
> 
> On 04/12/2018 01:46, Sun, Jing A wrote:
>> Hi Mark,
>>
>> Is there any issue that I need to fix for this patch please? 
> 
> See comments in the message you quoted below?  I think the most important 
> point is that the existing timing information appears to contain all the 
> information you want for VFR, so you probably shouldn't need the ad-hoc 
> side-data type.
> 
> - Mark
> 
> 
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Sun, Jing A
>> Sent: Friday, November 23, 2018 5:37 PM
>> To: FFmpeg development discussions and patches 
>> 
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> Hi Mark,
>>
>> In some cases, that is useful. For example, an online content distributer, 
>> who keeps encoding the captured video frames by ffmpeg and sending them out. 
>> At times, there is no update of source, which makes one or several captured 
>> source frames are exactly the same as the last one, and the distributer 
>> wants to just skip such frames, without stopping the encoding process.
>>
>> Regards,
>> SUN, Jing
>>
>>
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Mark Thompson
>> Sent: Tuesday, November 20, 2018 4:07 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> On 19/11/18 09:04, Jing SUN wrote:
>>> frame-skip is required to implement network bandwidth self-adaptive 
>>> vaapi encoding.
>>> To make a frame skipped, allocate its frame side data of 
>>> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.
>>
>> So if I'm reading this correctly the idea is to implement partial VFR by 
>> having a special new side-data type which indicates where frames would have 
>> been had the input actually matched the configured CFR behaviour?
>>
>> Why is the user meant to create these special frames?  It seems to me that 
>> the existing method of looking at the timestamps would be a better way to 
>> find any gaps.
>>
>> (Or, even better, add timestamps to VAAPI so that it can support VFR 
>> in a sensible way rather than a

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-12-09 Thread Sun, Jing A
Hi Mark,

Thanks for your kind guidance, but the problem is we are not trying to control 
the output framerate by this skip-frame feature. Our purpose is to just skip 
some frames, which are being requested by the content producer. And to 
implement that, we need an interface between the app and the vaapi lib, which 
informs the latter that a frame shall be skipped. 

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Monday, December 10, 2018 2:40 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 06/12/2018 10:04, Sun, Jing A wrote:
> Hi Mark,
> 
> This patch is not trying to support VFR. Some frames, after which are just 
> produced, could be considered as not needed by theirs producer and will get 
> skipped in the encoding process. And in my opinion the existing timing 
> information is not sufficient to support the case.

A skipped frame will still have a timestamp, so if a frame is skipped before 
the encoder then no frame with that timestamp will be given to the encoder.  
For CFR content this can be detected in the encoder to reconstruct your 
skip-frames information exactly - a skip has occurred if the gap between two 
frames does not match the framerate, and the size of the gap tells you how many 
frames were skipped.  Avoiding a requirement that the gap sizes exactly match 
makes it implement a simple VFR scheme too, since skips can be inserted to keep 
the rate controller correct as long as you never have frames closer together 
than the configured framerate.

(Please avoid top-posting on this list.)

- Mark


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Mark Thompson
> Sent: Wednesday, December 5, 2018 7:50 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
> frame-skip func
> 
> On 04/12/2018 01:46, Sun, Jing A wrote:
>> Hi Mark,
>>
>> Is there any issue that I need to fix for this patch please? 
> 
> See comments in the message you quoted below?  I think the most important 
> point is that the existing timing information appears to contain all the 
> information you want for VFR, so you probably shouldn't need the ad-hoc 
> side-data type.
> 
> - Mark
> 
> 
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Sun, Jing A
>> Sent: Friday, November 23, 2018 5:37 PM
>> To: FFmpeg development discussions and patches 
>> 
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> Hi Mark,
>>
>> In some cases, that is useful. For example, an online content distributer, 
>> who keeps encoding the captured video frames by ffmpeg and sending them out. 
>> At times, there is no update of source, which makes one or several captured 
>> source frames are exactly the same as the last one, and the distributer 
>> wants to just skip such frames, without stopping the encoding process.
>>
>> Regards,
>> SUN, Jing
>>
>>
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
>> Of Mark Thompson
>> Sent: Tuesday, November 20, 2018 4:07 AM
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
>> frame-skip func
>>
>> On 19/11/18 09:04, Jing SUN wrote:
>>> frame-skip is required to implement network bandwidth self-adaptive 
>>> vaapi encoding.
>>> To make a frame skipped, allocate its frame side data of 
>>> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.
>>
>> So if I'm reading this correctly the idea is to implement partial VFR by 
>> having a special new side-data type which indicates where frames would have 
>> been had the input actually matched the configured CFR behaviour?
>>
>> Why is the user meant to create these special frames?  It seems to me that 
>> the existing method of looking at the timestamps would be a better way to 
>> find any gaps.
>>
>> (Or, even better, add timestamps to VAAPI so that it can support VFR 
>> in a sensible way rather than adding hacks like this to allow partial 
>> VFR with weird constraints.)
>>
>>> Signed-off-by: Jing SUN 
>>> ---
>>>  libavcodec/vaapi_encode.c | 142 
>>> --
>>>  libavcodec/vaapi_encode.h |   5 ++
>>>  libavutil/frame.c |   1 +
>>>  libavutil/frame.h |   5 ++
>>>  4 files changed, 14

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-12-06 Thread Sun, Jing A
Hi Mark,

This patch is not trying to support VFR. Some frames, after which are just 
produced, could be considered as not needed by theirs producer and will get 
skipped in the encoding process. And in my opinion the existing timing 
information is not sufficient to support the case.

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Wednesday, December 5, 2018 7:50 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 04/12/2018 01:46, Sun, Jing A wrote:
> Hi Mark,
> 
> Is there any issue that I need to fix for this patch please? 

See comments in the message you quoted below?  I think the most important point 
is that the existing timing information appears to contain all the information 
you want for VFR, so you probably shouldn't need the ad-hoc side-data type.

- Mark


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Sun, Jing A
> Sent: Friday, November 23, 2018 5:37 PM
> To: FFmpeg development discussions and patches 
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
> frame-skip func
> 
> Hi Mark,
> 
> In some cases, that is useful. For example, an online content distributer, 
> who keeps encoding the captured video frames by ffmpeg and sending them out. 
> At times, there is no update of source, which makes one or several captured 
> source frames are exactly the same as the last one, and the distributer wants 
> to just skip such frames, without stopping the encoding process.
> 
> Regards,
> SUN, Jing
> 
> 
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf 
> Of Mark Thompson
> Sent: Tuesday, November 20, 2018 4:07 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add 
> frame-skip func
> 
> On 19/11/18 09:04, Jing SUN wrote:
>> frame-skip is required to implement network bandwidth self-adaptive 
>> vaapi encoding.
>> To make a frame skipped, allocate its frame side data of 
>> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.
> 
> So if I'm reading this correctly the idea is to implement partial VFR by 
> having a special new side-data type which indicates where frames would have 
> been had the input actually matched the configured CFR behaviour?
> 
> Why is the user meant to create these special frames?  It seems to me that 
> the existing method of looking at the timestamps would be a better way to 
> find any gaps.
> 
> (Or, even better, add timestamps to VAAPI so that it can support VFR 
> in a sensible way rather than adding hacks like this to allow partial 
> VFR with weird constraints.)
> 
>> Signed-off-by: Jing SUN 
>> ---
>>  libavcodec/vaapi_encode.c | 142 
>> --
>>  libavcodec/vaapi_encode.h |   5 ++
>>  libavutil/frame.c |   1 +
>>  libavutil/frame.h |   5 ++
>>  4 files changed, 149 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c 
>> index 2fe8501..a401d61 100644
>> --- a/libavcodec/vaapi_encode.c
>> +++ b/libavcodec/vaapi_encode.c
>> @@ -23,6 +23,7 @@
>>  #include "libavutil/common.h"
>>  #include "libavutil/log.h"
>>  #include "libavutil/pixdesc.h"
>> +#include "libavutil/intreadwrite.h"
>>  
>>  #include "vaapi_encode.h"
>>  #include "avcodec.h"
>> @@ -103,6 +104,47 @@ static int 
>> vaapi_encode_make_param_buffer(AVCodecContext *avctx,
>>  return 0;
>>  }
>>  
>> +static int vaapi_encode_check_if_skip(AVCodecContext *avctx,
>> +  VAAPIEncodePicture *pic) {
>> +AVFrameSideData *fside = NULL;
>> +VAAPIEncodeContext *ctx = avctx->priv_data;
>> +VAAPIEncodePicture *cur = NULL;
>> +int i = 0;
>> +
>> +if (!pic || !pic->input_image)
>> +return AVERROR(EINVAL);
>> +
>> +fside = av_frame_get_side_data(pic->input_image, 
>> AV_FRAME_DATA_SKIP_FRAME);
>> +if (fside)
>> +pic->skipped_flag = AV_RL8(fside->data);
>> +else
>> +pic->skipped_flag = 0;
>> +
>> +if (0 == pic->skipped_flag)
>> +return 0;
>> +
>> +if ((pic->type == PICTURE_TYPE_IDR) || (pic->type == PICTURE_TYPE_I)) {
>> +av_log(avctx, AV_LOG_INFO, "Can't skip IDR/I pic 
>> %"PRId64"/%"PRId64".\n",
>&g

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-12-03 Thread Sun, Jing A
Hi Mark,

Is there any issue that I need to fix for this patch please? 

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Sun, 
Jing A
Sent: Friday, November 23, 2018 5:37 PM
To: FFmpeg development discussions and patches 
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

Hi Mark,

In some cases, that is useful. For example, an online content distributer, who 
keeps encoding the captured video frames by ffmpeg and sending them out. At 
times, there is no update of source, which makes one or several captured source 
frames are exactly the same as the last one, and the distributer wants to just 
skip such frames, without stopping the encoding process.

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Tuesday, November 20, 2018 4:07 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 19/11/18 09:04, Jing SUN wrote:
> frame-skip is required to implement network bandwidth self-adaptive 
> vaapi encoding.
> To make a frame skipped, allocate its frame side data of 
> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.

So if I'm reading this correctly the idea is to implement partial VFR by having 
a special new side-data type which indicates where frames would have been had 
the input actually matched the configured CFR behaviour?

Why is the user meant to create these special frames?  It seems to me that the 
existing method of looking at the timestamps would be a better way to find any 
gaps.

(Or, even better, add timestamps to VAAPI so that it can support VFR in a 
sensible way rather than adding hacks like this to allow partial VFR with weird 
constraints.)

> Signed-off-by: Jing SUN 
> ---
>  libavcodec/vaapi_encode.c | 142 
> --
>  libavcodec/vaapi_encode.h |   5 ++
>  libavutil/frame.c |   1 +
>  libavutil/frame.h |   5 ++
>  4 files changed, 149 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c 
> index 2fe8501..a401d61 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -23,6 +23,7 @@
>  #include "libavutil/common.h"
>  #include "libavutil/log.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/intreadwrite.h"
>  
>  #include "vaapi_encode.h"
>  #include "avcodec.h"
> @@ -103,6 +104,47 @@ static int vaapi_encode_make_param_buffer(AVCodecContext 
> *avctx,
>  return 0;
>  }
>  
> +static int vaapi_encode_check_if_skip(AVCodecContext *avctx,
> +  VAAPIEncodePicture *pic) {
> +AVFrameSideData *fside = NULL;
> +VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAAPIEncodePicture *cur = NULL;
> +int i = 0;
> +
> +if (!pic || !pic->input_image)
> +return AVERROR(EINVAL);
> +
> +fside = av_frame_get_side_data(pic->input_image, 
> AV_FRAME_DATA_SKIP_FRAME);
> +if (fside)
> +pic->skipped_flag = AV_RL8(fside->data);
> +else
> +pic->skipped_flag = 0;
> +
> +if (0 == pic->skipped_flag)
> +return 0;
> +
> +if ((pic->type == PICTURE_TYPE_IDR) || (pic->type == PICTURE_TYPE_I)) {
> +av_log(avctx, AV_LOG_INFO, "Can't skip IDR/I pic 
> %"PRId64"/%"PRId64".\n",
> +   pic->display_order, pic->encode_order);
> +pic->skipped_flag = 0;
> +return 0;
> +}
> +
> +for (cur = ctx->pic_start; cur; cur = cur->next) {
> +for (i=0; i < cur->nb_refs; ++i) {
> +if (cur->refs[i] == pic) {
> +av_log(avctx, AV_LOG_INFO, "Can't skip ref pic 
> %"PRId64"/%"PRId64".\n",
> +   pic->display_order, pic->encode_order);
> +pic->skipped_flag = 0;
> +return 0;
> +}
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int vaapi_encode_wait(AVCodecContext *avctx,
>   VAAPIEncodePicture *pic)  { @@ -418,6
> +460,69 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
>  }
>  }
>  
> +err = vaapi_encode_check_if_skip(avctx, pic);
> +if (err != 0)
> +av_log(avctx, AV_LOG_ERROR, "Fail to check if skip.\n");
> +
> +#ifdef VAEncMiscParameterSkipFrame
> +if (pic->skipped_flag) {
> +av_log(avctx, AV_LOG_INFO, "Skip pic %"PRId64"/%"PRId64" as 
> 

Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip func

2018-11-23 Thread Sun, Jing A
Hi Mark,

In some cases, that is useful. For example, an online content distributer, who 
keeps encoding the captured video frames by ffmpeg and sending them out. At 
times, there is no update of source, which makes one or several captured source 
frames are exactly the same as the last one, and the distributer wants to just 
skip such frames, without stopping the encoding process.

Regards,
SUN, Jing


-Original Message-
From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
Thompson
Sent: Tuesday, November 20, 2018 4:07 AM
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 1/1] avcodec/vaapi_encode: add frame-skip 
func

On 19/11/18 09:04, Jing SUN wrote:
> frame-skip is required to implement network bandwidth self-adaptive 
> vaapi encoding.
> To make a frame skipped, allocate its frame side data of 
> AV_FRAME_DATA_SKIP_FRAME type and set its value to 1.

So if I'm reading this correctly the idea is to implement partial VFR by having 
a special new side-data type which indicates where frames would have been had 
the input actually matched the configured CFR behaviour?

Why is the user meant to create these special frames?  It seems to me that the 
existing method of looking at the timestamps would be a better way to find any 
gaps.

(Or, even better, add timestamps to VAAPI so that it can support VFR in a 
sensible way rather than adding hacks like this to allow partial VFR with weird 
constraints.)

> Signed-off-by: Jing SUN 
> ---
>  libavcodec/vaapi_encode.c | 142 
> --
>  libavcodec/vaapi_encode.h |   5 ++
>  libavutil/frame.c |   1 +
>  libavutil/frame.h |   5 ++
>  4 files changed, 149 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c 
> index 2fe8501..a401d61 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -23,6 +23,7 @@
>  #include "libavutil/common.h"
>  #include "libavutil/log.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/intreadwrite.h"
>  
>  #include "vaapi_encode.h"
>  #include "avcodec.h"
> @@ -103,6 +104,47 @@ static int vaapi_encode_make_param_buffer(AVCodecContext 
> *avctx,
>  return 0;
>  }
>  
> +static int vaapi_encode_check_if_skip(AVCodecContext *avctx,
> +  VAAPIEncodePicture *pic) {
> +AVFrameSideData *fside = NULL;
> +VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAAPIEncodePicture *cur = NULL;
> +int i = 0;
> +
> +if (!pic || !pic->input_image)
> +return AVERROR(EINVAL);
> +
> +fside = av_frame_get_side_data(pic->input_image, 
> AV_FRAME_DATA_SKIP_FRAME);
> +if (fside)
> +pic->skipped_flag = AV_RL8(fside->data);
> +else
> +pic->skipped_flag = 0;
> +
> +if (0 == pic->skipped_flag)
> +return 0;
> +
> +if ((pic->type == PICTURE_TYPE_IDR) || (pic->type == PICTURE_TYPE_I)) {
> +av_log(avctx, AV_LOG_INFO, "Can't skip IDR/I pic 
> %"PRId64"/%"PRId64".\n",
> +   pic->display_order, pic->encode_order);
> +pic->skipped_flag = 0;
> +return 0;
> +}
> +
> +for (cur = ctx->pic_start; cur; cur = cur->next) {
> +for (i=0; i < cur->nb_refs; ++i) {
> +if (cur->refs[i] == pic) {
> +av_log(avctx, AV_LOG_INFO, "Can't skip ref pic 
> %"PRId64"/%"PRId64".\n",
> +   pic->display_order, pic->encode_order);
> +pic->skipped_flag = 0;
> +return 0;
> +}
> +}
> +}
> +
> +return 0;
> +}
> +
>  static int vaapi_encode_wait(AVCodecContext *avctx,
>   VAAPIEncodePicture *pic)  { @@ -418,6 
> +460,69 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
>  }
>  }
>  
> +err = vaapi_encode_check_if_skip(avctx, pic);
> +if (err != 0)
> +av_log(avctx, AV_LOG_ERROR, "Fail to check if skip.\n");
> +
> +#ifdef VAEncMiscParameterSkipFrame
> +if (pic->skipped_flag) {
> +av_log(avctx, AV_LOG_INFO, "Skip pic %"PRId64"/%"PRId64" as 
> requested.\n",
> +   pic->display_order, pic->encode_order);
> +
> +++ctx->skipped_pic_count;
> +pic->encode_issued = 1;
> +
> +return 0;
> +} else if (ctx->skipped_pic_count > 0) {
> +VABufferID skip_param_id;
> +VAEncMiscParameterBuffer *misc_param;
> +VAEncMiscParame