Re: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-10 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Anton Khirnov
> Sent: Friday, April 10, 2020 18:57
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile
> high option support
> 
> Quoting Linjie Fu (2020-04-06 13:14:51)
> > Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention
> mode,
> > which determined by iEntropyCodingModeFlag in ParamTranscode().
> >
> >
> <https://github.com/cisco/openh264/blob/master/codec/encoder/core/inc/
> param_svc.h#L394>
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/libopenh264enc.c | 32 ++--
> >  1 file changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index f02c5fd..d331cfd 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -42,7 +42,7 @@ typedef struct SVCContext {
> >  ISVCEncoder *encoder;
> >  int slice_mode; // deprecated
> >  int loopfilter;
> > -char *profile;
> > +int profile;
> 
> Wouldn't it be better to deprecate the encoder-private option and use
> only the AVCodecContext one?
> 

If I got it correctly, the general "profile" option in 
libavcodec/options_table.h
needs values of type INT like FF_PROFILE_H264_HIGH = 100;

It also works for encoders with "-profile:v 100" to encode a bitstream with 
profile
HIGH, however maybe not straight forward enough. And it seems to be one of the
reasons that many encoders have a private option with AV_OPT_TYPE_STRING type.

- Linjie
___
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 08/10] lavc/libopenh264enc: add profile high option support

2020-04-10 Thread Anton Khirnov
Quoting Linjie Fu (2020-04-06 13:14:51)
> Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode,
> which determined by iEntropyCodingModeFlag in ParamTranscode().
> 
> 
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/libopenh264enc.c | 32 ++--
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index f02c5fd..d331cfd 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -42,7 +42,7 @@ typedef struct SVCContext {
>  ISVCEncoder *encoder;
>  int slice_mode; // deprecated
>  int loopfilter;
> -char *profile;
> +int profile;

Wouldn't it be better to deprecate the encoder-private option and use
only the AVCodecContext one?

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

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

[FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-06 Thread Linjie Fu
Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode,
which determined by iEntropyCodingModeFlag in ParamTranscode().



Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index f02c5fd..d331cfd 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -42,7 +42,7 @@ typedef struct SVCContext {
 ISVCEncoder *encoder;
 int slice_mode; // deprecated
 int loopfilter;
-char *profile;
+int profile;
 int max_nal_size;
 int skip_frames;
 int skipped;
@@ -71,7 +71,11 @@ static const AVOption options[] = {
 { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
 #endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
-{ "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
+{ "profile", "Set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, 
{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0x, VE, "profile" },
+#define PROFILE(name, value)  name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value 
}, 0, 0, VE, "profile"
+{ PROFILE("constrained_baseline", 
FF_PROFILE_H264_CONSTRAINED_BASELINE) },
+{ PROFILE("high", FF_PROFILE_H264_HIGH) },
+#undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
@@ -107,12 +111,28 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 {
 SVCContext *s = avctx->priv_data;
 
-if (s->profile && !strcmp(s->profile, "main"))
-param->iEntropyCodingModeFlag = 1; //< 0:CAVLC  1:CABAC
-else if (!s->profile && s->cabac)
+if (s->profile == FF_PROFILE_UNKNOWN)
+s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
+FF_PROFILE_H264_CONSTRAINED_BASELINE;
+
+switch (s->profile) {
+case FF_PROFILE_H264_HIGH:
 param->iEntropyCodingModeFlag = 1;
-else
+av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
+   "select EProfileIdc PRO_HIGH in libopenh264.\n");
+break;
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+case FF_PROFILE_UNKNOWN:
+param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+default:
 param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+}
 
 return 0;
 }
-- 
2.7.4

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

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

[FFmpeg-devel] [PATCH 08/10] lavc/libopenh264enc: add profile high option support

2020-04-03 Thread Linjie Fu
Add support for PRO_HIGH/PRO_BASELINE in SVC Encoding extention mode,
which determined by iEntropyCodingModeFlag in ParamTranscode().



Signed-off-by: Linjie Fu 
---
 libavcodec/libopenh264enc.c | 32 ++--
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index f02c5fd..d331cfd 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -42,7 +42,7 @@ typedef struct SVCContext {
 ISVCEncoder *encoder;
 int slice_mode; // deprecated
 int loopfilter;
-char *profile;
+int profile;
 int max_nal_size;
 int skip_frames;
 int skipped;
@@ -71,7 +71,11 @@ static const AVOption options[] = {
 { "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
 #endif
 { "loopfilter", "enable loop filter", OFFSET(loopfilter), AV_OPT_TYPE_INT, 
{ .i64 = 1 }, 0, 1, VE },
-{ "profile", "set profile restrictions", OFFSET(profile), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VE },
+{ "profile", "Set profile restrictions", OFFSET(profile), AV_OPT_TYPE_INT, 
{ .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0x, VE, "profile" },
+#define PROFILE(name, value)  name, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = value 
}, 0, 0, VE, "profile"
+{ PROFILE("constrained_baseline", 
FF_PROFILE_H264_CONSTRAINED_BASELINE) },
+{ PROFILE("high", FF_PROFILE_H264_HIGH) },
+#undef PROFILE
 { "max_nal_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 { "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
@@ -107,12 +111,28 @@ static av_cold int svc_encode_init_profile(AVCodecContext 
*avctx, SEncParamExt *
 {
 SVCContext *s = avctx->priv_data;
 
-if (s->profile && !strcmp(s->profile, "main"))
-param->iEntropyCodingModeFlag = 1; //< 0:CAVLC  1:CABAC
-else if (!s->profile && s->cabac)
+if (s->profile == FF_PROFILE_UNKNOWN)
+s->profile = s->cabac ? FF_PROFILE_H264_HIGH :
+FF_PROFILE_H264_CONSTRAINED_BASELINE;
+
+switch (s->profile) {
+case FF_PROFILE_H264_HIGH:
 param->iEntropyCodingModeFlag = 1;
-else
+av_log(avctx, AV_LOG_VERBOSE, "Using CABAC, "
+   "select EProfileIdc PRO_HIGH in libopenh264.\n");
+break;
+case FF_PROFILE_H264_CONSTRAINED_BASELINE:
+case FF_PROFILE_UNKNOWN:
+param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_VERBOSE, "Using CAVLC, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+default:
 param->iEntropyCodingModeFlag = 0;
+av_log(avctx, AV_LOG_WARNING, "Unsupported profile, "
+   "select EProfileIdc PRO_BASELINE in libopenh264.\n");
+break;
+}
 
 return 0;
 }
-- 
2.7.4

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