Re: [FFmpeg-devel] [PATCH v2 4/6] libx265: Update ROI behaviour to match documentation

2019-03-13 Thread Michael Niedermayer
On Wed, Mar 13, 2019 at 04:44:29PM +0100, Michael Niedermayer wrote:
> On Wed, Mar 13, 2019 at 12:17:46AM +, Mark Thompson wrote:
> > Equivalent to the previous patch for libx264.
> > ---
> >  libavcodec/libx265.c | 42 +-
> >  1 file changed, 21 insertions(+), 21 deletions(-)
> 
> breaks build
> 
> CClibavcodec/vaapi_encode.o
> libavcodec/vaapi_encode.c: In function ‘vaapi_encode_issue’:
> libavcodec/vaapi_encode.c:566:18: error: ‘VAAPIEncodePicture’ has no member 
> named ‘roi’
>  av_freep(>roi);
>   ^
> libavcodec/vaapi_encode.c: In function ‘vaapi_encode_free’:
> libavcodec/vaapi_encode.c:701:18: error: ‘VAAPIEncodePicture’ has no member 
> named ‘roi’
>  av_freep(>roi);
>   ^
> make: *** [libavcodec/vaapi_encode.o] Error 1

wrong commit this is caused by "vaapi_encode: Add ROI support"

sorry

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 4/6] libx265: Update ROI behaviour to match documentation

2019-03-13 Thread Michael Niedermayer
On Wed, Mar 13, 2019 at 12:17:46AM +, Mark Thompson wrote:
> Equivalent to the previous patch for libx264.
> ---
>  libavcodec/libx265.c | 42 +-
>  1 file changed, 21 insertions(+), 21 deletions(-)

breaks build

CC  libavcodec/vaapi_encode.o
libavcodec/vaapi_encode.c: In function ‘vaapi_encode_issue’:
libavcodec/vaapi_encode.c:566:18: error: ‘VAAPIEncodePicture’ has no member 
named ‘roi’
 av_freep(>roi);
  ^
libavcodec/vaapi_encode.c: In function ‘vaapi_encode_free’:
libavcodec/vaapi_encode.c:701:18: error: ‘VAAPIEncodePicture’ has no member 
named ‘roi’
 av_freep(>roi);
  ^
make: *** [libavcodec/vaapi_encode.o] Error 1


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2 4/6] libx265: Update ROI behaviour to match documentation

2019-03-12 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Wednesday, March 13, 2019 8:18 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2 4/6] libx265: Update ROI behaviour to
> match documentation
> 
> Equivalent to the previous patch for libx264.
> ---
>  libavcodec/libx265.c | 42 +-
>  1 file changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index c2c1f8b9bc..a580d113b9 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -304,27 +304,34 @@ static av_cold int
> libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
>  int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;
>  int mbx = (frame->width + mb_size - 1) / mb_size;
>  int mby = (frame->height + mb_size - 1) / mb_size;
> +int qp_range = 51 + 6 * (pic->bitDepth - 8);
>  int nb_rois;
> -AVRegionOfInterest *roi;
> +const AVRegionOfInterest *roi;
>  float *qoffsets; /* will be freed after encode is 
> called. */
> +
> +roi = (const AVRegionOfInterest*)sd->data;
> +if (!roi->self_size || sd->size % roi->self_size != 0) {
> +av_log(ctx, AV_LOG_ERROR, "Invalid
> AVRegionOfInterest.self_size.\n");
> +return AVERROR(EINVAL);
> +}
> +nb_rois = sd->size / roi->self_size;
> +
>  qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
>  if (!qoffsets)
>  return AVERROR(ENOMEM);
> 
> -nb_rois = sd->size / sizeof(AVRegionOfInterest);
> -roi = (AVRegionOfInterest*)sd->data;
> -for (int count = 0; count < nb_rois; count++) {
> -int starty = av_clip(roi->y / mb_size, 0, mby);
> -int endy   = av_clip((roi->y + roi->height + mb_size - 1) / 
> mb_size, 0,
> mby);
> -int startx = av_clip(roi->x / mb_size, 0, mbx);
> -int endx   = av_clip((roi->x + roi->width  + mb_size - 1) / 
> mb_size, 0,
> mbx);
> +// This list must be iterated in reverse because the first
> +// region in the list applies when regions overlap.
> +for (int i = nb_rois - 1; i >= 0; i--) {
> +int startx, endx, starty, endy;
>  float qoffset;
> 
> -if (roi->self_size == 0) {
> -av_free(qoffsets);
> -av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.self_size 
> must
> be set to sizeof(AVRegionOfInterest).\n");
> -return AVERROR(EINVAL);
> -}
> +roi = (const AVRegionOfInterest*)(sd->data + roi->self_size 
> * i);

same comment as libx264

> +
> +starty = av_clip(roi->y / mb_size, 0, mby);
> +endy   = av_clip((roi->y + roi->height + mb_size - 1) / 
> mb_size, 0,
> mby);
> +startx = av_clip(roi->x / mb_size, 0, mbx);
> +endx   = av_clip((roi->x + roi->width  + mb_size - 1) / 
> mb_size, 0,
> mbx);
> 
>  if (roi->qoffset.den == 0) {
>  av_free(qoffsets);
> @@ -332,18 +339,11 @@ static av_cold int
> libx265_encode_set_roi(libx265Context *ctx, const AVFrame *fr
>  return AVERROR(EINVAL);
>  }
>  qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
> -qoffset = av_clipf(qoffset, -1.0f, 1.0f);
> -
> -/* qp range of x265 is from 0 to 51, just choose 25 as the 
> scale value,
> - * so the range of final qoffset is [-25.0, 25.0].
> - */
> -qoffset = qoffset * 25;
> +qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range);
> 
>  for (int y = starty; y < endy; y++)
>  for (int x = startx; x < endx; x++)
>  qoffsets[x + y*mbx] = qoffset;
> -
> -roi = (AVRegionOfInterest*)((char*)roi + roi->self_size);
>  }
> 
>  pic->quantOffsets = qoffsets;
> --
> 2.19.2
> 
> ___
> 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


[FFmpeg-devel] [PATCH v2 4/6] libx265: Update ROI behaviour to match documentation

2019-03-12 Thread Mark Thompson
Equivalent to the previous patch for libx264.
---
 libavcodec/libx265.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index c2c1f8b9bc..a580d113b9 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -304,27 +304,34 @@ static av_cold int libx265_encode_set_roi(libx265Context 
*ctx, const AVFrame *fr
 int mb_size = (ctx->params->rc.qgSize == 8) ? 8 : 16;
 int mbx = (frame->width + mb_size - 1) / mb_size;
 int mby = (frame->height + mb_size - 1) / mb_size;
+int qp_range = 51 + 6 * (pic->bitDepth - 8);
 int nb_rois;
-AVRegionOfInterest *roi;
+const AVRegionOfInterest *roi;
 float *qoffsets; /* will be freed after encode is called. 
*/
+
+roi = (const AVRegionOfInterest*)sd->data;
+if (!roi->self_size || sd->size % roi->self_size != 0) {
+av_log(ctx, AV_LOG_ERROR, "Invalid 
AVRegionOfInterest.self_size.\n");
+return AVERROR(EINVAL);
+}
+nb_rois = sd->size / roi->self_size;
+
 qoffsets = av_mallocz_array(mbx * mby, sizeof(*qoffsets));
 if (!qoffsets)
 return AVERROR(ENOMEM);
 
-nb_rois = sd->size / sizeof(AVRegionOfInterest);
-roi = (AVRegionOfInterest*)sd->data;
-for (int count = 0; count < nb_rois; count++) {
-int starty = av_clip(roi->y / mb_size, 0, mby);
-int endy   = av_clip((roi->y + roi->height + mb_size - 1) / 
mb_size, 0, mby);
-int startx = av_clip(roi->x / mb_size, 0, mbx);
-int endx   = av_clip((roi->x + roi->width  + mb_size - 1) / 
mb_size, 0, mbx);
+// This list must be iterated in reverse because the first
+// region in the list applies when regions overlap.
+for (int i = nb_rois - 1; i >= 0; i--) {
+int startx, endx, starty, endy;
 float qoffset;
 
-if (roi->self_size == 0) {
-av_free(qoffsets);
-av_log(ctx, AV_LOG_ERROR, "AVRegionOfInterest.self_size 
must be set to sizeof(AVRegionOfInterest).\n");
-return AVERROR(EINVAL);
-}
+roi = (const AVRegionOfInterest*)(sd->data + roi->self_size * 
i);
+
+starty = av_clip(roi->y / mb_size, 0, mby);
+endy   = av_clip((roi->y + roi->height + mb_size - 1) / 
mb_size, 0, mby);
+startx = av_clip(roi->x / mb_size, 0, mbx);
+endx   = av_clip((roi->x + roi->width  + mb_size - 1) / 
mb_size, 0, mbx);
 
 if (roi->qoffset.den == 0) {
 av_free(qoffsets);
@@ -332,18 +339,11 @@ static av_cold int libx265_encode_set_roi(libx265Context 
*ctx, const AVFrame *fr
 return AVERROR(EINVAL);
 }
 qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
-qoffset = av_clipf(qoffset, -1.0f, 1.0f);
-
-/* qp range of x265 is from 0 to 51, just choose 25 as the 
scale value,
- * so the range of final qoffset is [-25.0, 25.0].
- */
-qoffset = qoffset * 25;
+qoffset = av_clipf(qoffset * qp_range, -qp_range, +qp_range);
 
 for (int y = starty; y < endy; y++)
 for (int x = startx; x < endx; x++)
 qoffsets[x + y*mbx] = qoffset;
-
-roi = (AVRegionOfInterest*)((char*)roi + roi->self_size);
 }
 
 pic->quantOffsets = qoffsets;
-- 
2.19.2

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