[FFmpeg-devel] [PATCH] avcodec/libx264: update notes to explain the scale chosen for ROI encoding

Mark Thompson sw at jkqxz.net
Mon Feb 4 11:33:55 EET 2019


On 29/01/2019 10:14, Guo, Yejun wrote:
> Signed-off-by: Guo, Yejun <yejun.guo at intel.com>
> ---
>  libavcodec/libx264.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index a3493f3..8c96728 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -383,7 +383,9 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame,
>                          qoffset = roi->qoffset.num * 1.0f / roi->qoffset.den;
>                          qoffset = av_clipf(qoffset, -1.0f, 1.0f);
>  
> -                        // 25 is a number that I think it is a possible proper scale value.
> +                        /* qp range of x264 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;
>  
>                          for (int y = starty; y < endy; y++) {
> 

I'm not understanding where this number has come from at all.  Is 25 purely arbitrary?  Why does the effect vary by bit depth?

>From the docs explaining the best/worst behaviour on the range, I would expect this to map 0 to 0 and 1 to 3 + 6 * bit_depth (positive or negative).

- Mark


More information about the ffmpeg-devel mailing list