Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding
@ 2023-04-18 15:33 Jun Zhao
  2023-04-18 15:33 ` [FFmpeg-devel] [PATCH 2/2] lavc/libopenh264: refine the code Jun Zhao
  2023-04-20 11:27 ` [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding "zhilizhao(赵志立)"
  0 siblings, 2 replies; 4+ messages in thread
From: Jun Zhao @ 2023-04-18 15:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jun Zhao, Jun Zhao

Support full range videos when transcoding, enabled the
YUVJ420P to avoid auto scale from YUVJ420P to YUV420P

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/libopenh264enc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 8b4755f5ba..cccc11fbb7 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -311,10 +311,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
 
 #if OPENH264_VER_AT_LEAST(1, 6)
     param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
+
     if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
         param.sSpatialLayers[0].bVideoSignalTypePresent = true;
         param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
-    }
+    }  else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
+        param.sSpatialLayers[0].bFullRange = 1;
 
     if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED      ||
         avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
@@ -443,6 +445,7 @@ const FFCodec ff_libopenh264_encoder = {
     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
                       FF_CODEC_CAP_AUTO_THREADS,
     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
+                                                    AV_PIX_FMT_YUVJ420P,
                                                     AV_PIX_FMT_NONE },
     .defaults       = svc_enc_defaults,
     .p.priv_class   = &class,
-- 
2.25.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] lavc/libopenh264: refine the code
  2023-04-18 15:33 [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding Jun Zhao
@ 2023-04-18 15:33 ` Jun Zhao
  2023-04-20 11:27 ` [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding "zhilizhao(赵志立)"
  1 sibling, 0 replies; 4+ messages in thread
From: Jun Zhao @ 2023-04-18 15:33 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jun Zhao, Jun Zhao

refine the code

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/libopenh264enc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index cccc11fbb7..3c605fe8ea 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -313,7 +313,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
     param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
 
     if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
-        param.sSpatialLayers[0].bVideoSignalTypePresent = true;
         param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
     }  else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
         param.sSpatialLayers[0].bFullRange = 1;
@@ -321,7 +320,6 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
     if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED      ||
         avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
         avctx->color_trc != AVCOL_TRC_UNSPECIFIED) {
-        param.sSpatialLayers[0].bVideoSignalTypePresent = true;
         param.sSpatialLayers[0].bColorDescriptionPresent = true;
     }
 
@@ -331,6 +329,9 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
         param.sSpatialLayers[0].uiColorPrimaries = avctx->color_primaries;
     if (avctx->color_trc != AVCOL_TRC_UNSPECIFIED)
         param.sSpatialLayers[0].uiTransferCharacteristics = avctx->color_trc;
+
+    param.sSpatialLayers[0].bVideoSignalTypePresent =
+        (param.sSpatialLayers[0].bFullRange || param.sSpatialLayers[0].bColorDescriptionPresent);
 #endif
 
     if ((*s->encoder)->InitializeExt(s->encoder, &param) != cmResultSuccess) {
-- 
2.25.1

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

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding
  2023-04-18 15:33 [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding Jun Zhao
  2023-04-18 15:33 ` [FFmpeg-devel] [PATCH 2/2] lavc/libopenh264: refine the code Jun Zhao
@ 2023-04-20 11:27 ` "zhilizhao(赵志立)"
  2023-04-20 11:51   ` mypopy
  1 sibling, 1 reply; 4+ messages in thread
From: "zhilizhao(赵志立)" @ 2023-04-20 11:27 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Apr 18, 2023, at 23:33, Jun Zhao <mypopydev@gmail.com> wrote:
> 
> Support full range videos when transcoding, enabled the
> YUVJ420P to avoid auto scale from YUVJ420P to YUV420P


According to "Towards YUVJ removal"
http://ffmpeg.org/pipermail/ffmpeg-devel/2022-December/304718.html

> So, as was discussed at the last meeting, we should move towards
removing YUVJ.

However, it looks like there is no much progress since then.

> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavcodec/libopenh264enc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> index 8b4755f5ba..cccc11fbb7 100644
> --- a/libavcodec/libopenh264enc.c
> +++ b/libavcodec/libopenh264enc.c
> @@ -311,10 +311,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
> 
> #if OPENH264_VER_AT_LEAST(1, 6)
>     param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
> +
>     if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
>         param.sSpatialLayers[0].bVideoSignalTypePresent = true;
>         param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
> -    }
> +    }  else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
> +        param.sSpatialLayers[0].bFullRange = 1;
> 
>     if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED      ||
>         avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
> @@ -443,6 +445,7 @@ const FFCodec ff_libopenh264_encoder = {
>     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
>                       FF_CODEC_CAP_AUTO_THREADS,
>     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
> +                                                    AV_PIX_FMT_YUVJ420P,
>                                                     AV_PIX_FMT_NONE },
>     .defaults       = svc_enc_defaults,
>     .p.priv_class   = &class,
> -- 
> 2.25.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding
  2023-04-20 11:27 ` [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding "zhilizhao(赵志立)"
@ 2023-04-20 11:51   ` mypopy
  0 siblings, 0 replies; 4+ messages in thread
From: mypopy @ 2023-04-20 11:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Thu, Apr 20, 2023 at 7:27 PM "zhilizhao(赵志立)" <quinkblack@foxmail.com> wrote:
>
>
>
> > On Apr 18, 2023, at 23:33, Jun Zhao <mypopydev@gmail.com> wrote:
> >
> > Support full range videos when transcoding, enabled the
> > YUVJ420P to avoid auto scale from YUVJ420P to YUV420P
>
>
> According to "Towards YUVJ removal"
> http://ffmpeg.org/pipermail/ffmpeg-devel/2022-December/304718.html
>
> > So, as was discussed at the last meeting, we should move towards
> removing YUVJ.
>
> However, it looks like there is no much progress since then.
>
Yes, I know the plan we will remove YUVJ, but now when we transcoding,
ffmpeg auto-inserts swscaler to convert from full range to limited
range when input video with full range, I can't find a full solution
in this case, So until YUVJ is removed, I add the YUVJ format support
for this case.

> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> > libavcodec/libopenh264enc.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
> > index 8b4755f5ba..cccc11fbb7 100644
> > --- a/libavcodec/libopenh264enc.c
> > +++ b/libavcodec/libopenh264enc.c
> > @@ -311,10 +311,12 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
> >
> > #if OPENH264_VER_AT_LEAST(1, 6)
> >     param.sSpatialLayers[0].uiVideoFormat = VF_UNDEF;
> > +
> >     if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED) {
> >         param.sSpatialLayers[0].bVideoSignalTypePresent = true;
> >         param.sSpatialLayers[0].bFullRange = (avctx->color_range == AVCOL_RANGE_JPEG);
> > -    }
> > +    }  else if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P)
> > +        param.sSpatialLayers[0].bFullRange = 1;
> >
> >     if (avctx->colorspace != AVCOL_SPC_UNSPECIFIED      ||
> >         avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
> > @@ -443,6 +445,7 @@ const FFCodec ff_libopenh264_encoder = {
> >     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
> >                       FF_CODEC_CAP_AUTO_THREADS,
> >     .p.pix_fmts     = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,
> > +                                                    AV_PIX_FMT_YUVJ420P,
> >                                                     AV_PIX_FMT_NONE },
> >     .defaults       = svc_enc_defaults,
> >     .p.priv_class   = &class,
> > --
> > 2.25.1
> >
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-20 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 15:33 [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding Jun Zhao
2023-04-18 15:33 ` [FFmpeg-devel] [PATCH 2/2] lavc/libopenh264: refine the code Jun Zhao
2023-04-20 11:27 ` [FFmpeg-devel] [PATCH 1/2] lavc/libopenh264: Support full range videos in transcoding "zhilizhao(赵志立)"
2023-04-20 11:51   ` mypopy

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git