videoencodex264libx264

x264: How to Correctly Use quant_offsets?


Suppose I need to encode different regions with different QPs in one frame, i.e. RoI(regions of interest) encoding. I searched all over the internet and was only told that quant_offsets can meet my demand. However, none of them told me exactly how to use it, and I can't find any official documentation about it. I read the source code of x264 and did experiments, and find it only adds an offset to the qp decision x264 has made, rather than exactly set the qp value I want.

Is there a possible way that I can have x264 encode these regions using the qp value I've explictly given instead of adding offsets based on what it decided on its own? Many thanks!


Solution

  • I finally get my answer after studying the source code of x264. I found modifying the h->mb.i_qp in the loop of slice_write() can meet my demand.

    Yet, it makes me feel frustrated that there are few people working on AV, and oftentimes I can't find any right answer on the Internet or have the opportunity to tend to professionals for my questions during my learning time.