Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-09 Thread Mark Thompson
On 08/03/2020 08:28, Linjie Fu wrote:
> Use desc->log2_chroma_w/h to calculate the sps->conf_win_right/bottom_offset.
> 
> Based on Table 6-1, SubWidthC and SubHeightC depend on chroma 
> format(log2_chroma_w/h).
> 
> Based on D-28 and D-29, set the correct cropped width/height.
> 
> croppedWidth  = pic_width_in_luma_samples −
> SubWidthC * ( conf_win_right_offset + conf_win_left_offset );
> 
> croppedHeight = pic_height_in_luma_samples −
> SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: use desc->log2_chroma_w/h.
> 
>  libavcodec/vaapi_encode_h265.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index ace7696..bebb0f9 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -410,10 +410,10 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  sps->conformance_window_flag = 1;
>  sps->conf_win_left_offset   = 0;
>  sps->conf_win_right_offset  =
> -(ctx->surface_width - avctx->width) / 2;
> +(ctx->surface_width - avctx->width) >> desc->log2_chroma_w;
>  sps->conf_win_top_offset= 0;
>  sps->conf_win_bottom_offset =
> -(ctx->surface_height - avctx->height) / 2;
> +(ctx->surface_height - avctx->height) >> desc->log2_chroma_h;
>  } else {
>  sps->conformance_window_flag = 0;
>  }
> 

Yep, applied.

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-08 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Mark Thompson
> Sent: Sunday, March 8, 2020 00:35
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix
> conf_win_xxx_offset for 4:2:2/4:4:4 encoding
> 
> On 05/03/2020 07:41, Linjie Fu wrote:
> > Based on Table 6-1, set SubWidth and SubHeightC depending on chroma
> format.
> >
> > Based on D-28 and D-29, set the correct cropped width/height.
> >
> > croppedWidth  = pic_width_in_luma_samples −
> > SubWidthC * ( conf_win_right_offset + conf_win_left_offset 
> > );
> >
> > croppedHeight = pic_height_in_luma_samples −
> > SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset 
> > );
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/vaapi_encode_h265.c | 9 +++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode_h265.c
> b/libavcodec/vaapi_encode_h265.c
> > index 12f0e6f..db1bf24 100644
> > --- a/libavcodec/vaapi_encode_h265.c
> > +++ b/libavcodec/vaapi_encode_h265.c
> > @@ -268,6 +268,7 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >  VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
> >  const AVPixFmtDescriptor *desc;
> >  int chroma_format, bit_depth;
> > +int SubWidthC, SubHeightC;
> >  int i;
> >
> >  memset(vps, 0, sizeof(*vps));
> > @@ -405,15 +406,19 @@ static int
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
> >  sps->pic_width_in_luma_samples  = ctx->surface_width;
> >  sps->pic_height_in_luma_samples = ctx->surface_height;
> >
> > +// Table 6-1
> > +SubWidthC  = chroma_format == 1 || chroma_format == 2 ? 2 : 1;
> > +SubHeightC = chroma_format == 1 ? 2 : 1;
> 
> You don't need to reverse chroma format into these value - desc-
> >log2_chroma_* as used above to calculate it above is still available.

Updated, thanks for the review.

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

[FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-08 Thread Linjie Fu
Use desc->log2_chroma_w/h to calculate the sps->conf_win_right/bottom_offset.

Based on Table 6-1, SubWidthC and SubHeightC depend on chroma 
format(log2_chroma_w/h).

Based on D-28 and D-29, set the correct cropped width/height.

croppedWidth  = pic_width_in_luma_samples −
SubWidthC * ( conf_win_right_offset + conf_win_left_offset );

croppedHeight = pic_height_in_luma_samples −
SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );

Signed-off-by: Linjie Fu 
---
[v2]: use desc->log2_chroma_w/h.

 libavcodec/vaapi_encode_h265.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index ace7696..bebb0f9 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -410,10 +410,10 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 sps->conformance_window_flag = 1;
 sps->conf_win_left_offset   = 0;
 sps->conf_win_right_offset  =
-(ctx->surface_width - avctx->width) / 2;
+(ctx->surface_width - avctx->width) >> desc->log2_chroma_w;
 sps->conf_win_top_offset= 0;
 sps->conf_win_bottom_offset =
-(ctx->surface_height - avctx->height) / 2;
+(ctx->surface_height - avctx->height) >> desc->log2_chroma_h;
 } else {
 sps->conformance_window_flag = 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".

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-07 Thread Mark Thompson
On 05/03/2020 07:41, Linjie Fu wrote:
> Based on Table 6-1, set SubWidth and SubHeightC depending on chroma format.
> 
> Based on D-28 and D-29, set the correct cropped width/height.
> 
> croppedWidth  = pic_width_in_luma_samples −
> SubWidthC * ( conf_win_right_offset + conf_win_left_offset );
> 
> croppedHeight = pic_height_in_luma_samples −
> SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/vaapi_encode_h265.c | 9 +++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index 12f0e6f..db1bf24 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -268,6 +268,7 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
>  const AVPixFmtDescriptor *desc;
>  int chroma_format, bit_depth;
> +int SubWidthC, SubHeightC;
>  int i;
>  
>  memset(vps, 0, sizeof(*vps));
> @@ -405,15 +406,19 @@ static int 
> vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
>  sps->pic_width_in_luma_samples  = ctx->surface_width;
>  sps->pic_height_in_luma_samples = ctx->surface_height;
>  
> +// Table 6-1
> +SubWidthC  = chroma_format == 1 || chroma_format == 2 ? 2 : 1;
> +SubHeightC = chroma_format == 1 ? 2 : 1;

You don't need to reverse chroma format into these value - desc->log2_chroma_* 
as used above to calculate it above is still available.

> +
>  if (avctx->width  != ctx->surface_width ||
>  avctx->height != ctx->surface_height) {
>  sps->conformance_window_flag = 1;
>  sps->conf_win_left_offset   = 0;
>  sps->conf_win_right_offset  =
> -(ctx->surface_width - avctx->width) / 2;
> +(ctx->surface_width - avctx->width) / SubWidthC;

(...width) >> desc->log2_chroma_w

>  sps->conf_win_top_offset= 0;
>  sps->conf_win_bottom_offset =
> -(ctx->surface_height - avctx->height) / 2;
> +(ctx->surface_height - avctx->height) / SubHeightC;

(...height) >> desc->log2_chroma_h

>  } else {
>  sps->conformance_window_flag = 0;
>  }
> 

Thanks,

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

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-06 Thread Fu, Linjie
> From: ffmpeg-devel  On Behalf Of
> Moritz Barsnick
> Sent: Friday, March 6, 2020 18:24
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode_h265: fix
> conf_win_xxx_offset for 4:2:2/4:4:4 encoding
> 
> On Thu, Mar 05, 2020 at 15:41:17 +0800, Linjie Fu wrote:
> > +int SubWidthC, SubHeightC;
> 
> Style nit:
> ffmpeg's own variables don't use CamelCase.
> 
Will fix, thanks.

- 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] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-06 Thread Moritz Barsnick
On Thu, Mar 05, 2020 at 15:41:17 +0800, Linjie Fu wrote:
> +int SubWidthC, SubHeightC;

Style nit:
ffmpeg's own variables don't use CamelCase.

Moritz
___
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] lavc/vaapi_encode_h265: fix conf_win_xxx_offset for 4:2:2/4:4:4 encoding

2020-03-04 Thread Linjie Fu
Based on Table 6-1, set SubWidth and SubHeightC depending on chroma format.

Based on D-28 and D-29, set the correct cropped width/height.

croppedWidth  = pic_width_in_luma_samples −
SubWidthC * ( conf_win_right_offset + conf_win_left_offset );

croppedHeight = pic_height_in_luma_samples −
SubHeightC * ( conf_win_bottom_offset + conf_win_top_offset );

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_encode_h265.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 12f0e6f..db1bf24 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -268,6 +268,7 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
 const AVPixFmtDescriptor *desc;
 int chroma_format, bit_depth;
+int SubWidthC, SubHeightC;
 int i;
 
 memset(vps, 0, sizeof(*vps));
@@ -405,15 +406,19 @@ static int 
vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 sps->pic_width_in_luma_samples  = ctx->surface_width;
 sps->pic_height_in_luma_samples = ctx->surface_height;
 
+// Table 6-1
+SubWidthC  = chroma_format == 1 || chroma_format == 2 ? 2 : 1;
+SubHeightC = chroma_format == 1 ? 2 : 1;
+
 if (avctx->width  != ctx->surface_width ||
 avctx->height != ctx->surface_height) {
 sps->conformance_window_flag = 1;
 sps->conf_win_left_offset   = 0;
 sps->conf_win_right_offset  =
-(ctx->surface_width - avctx->width) / 2;
+(ctx->surface_width - avctx->width) / SubWidthC;
 sps->conf_win_top_offset= 0;
 sps->conf_win_bottom_offset =
-(ctx->surface_height - avctx->height) / 2;
+(ctx->surface_height - avctx->height) / SubHeightC;
 } else {
 sps->conformance_window_flag = 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".