> -----Original Message----- > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf > Of Mark Thompson > Sent: Monday, February 04, 2019 5:34 PM > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avcodec/libx264: update notes to > explain the scale chosen for ROI encoding > > On 29/01/2019 10:14, Guo, Yejun wrote: > > Signed-off-by: Guo, Yejun <yejun....@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
From H264 spec: SliceQPY is in the range of −QpBdOffsetY to +51, inclusive. And lots of documents/papers says the qp range of H264 is [0, 51]. So, I chose 25 (equal with 51/2) roughly to make qpoffset to be [-25.0, 25.0]. > arbitrary? Why does the effect vary by bit depth? imo, 51 has nothing to do with bit depth, not quite understand your concern. > > 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). for example if bit_depth=8, do you mean map -1.0 to -51, and map 1.0 to 51? for example if bit_depth=10, do you mean map -1.0 to -63, and map 1.0 to 63? If so, I'm not sure if it is better or not. Imho, there is still a long way from qpoffset to the final quantization value, I would think a rough qpoffset (with range [-25, 25]) is enough. Anyway, I'm open to use whatever better method. > > - Mark > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel