[FFmpeg-devel] [PATCH v4 1/2] lavc, doc, configure: add libxavs2 video encoder wrapper

Mark Thompson sw at jkqxz.net
Wed Sep 5 14:52:23 EEST 2018


On 05/09/18 08:19, Huiwen Ren wrote:
> At 2018-09-05 08:46:18, "Mark Thompson" <sw at jkqxz.net> wrote:
>> On 03/09/18 03:42, hwren wrote:
>>> Signed-off-by: hwren <hwrenx at 126.com>
>>> ---
> [...]
>>> +
>>> +    int i_lcurow_threads;
>>> +    int i_initial_qp;
>>> +    int preset_level;
>>> +    int intra_period;
>>
>> There is a common option AVCodecContext.gop_size (-g) which should probably be used rather than inventing a new private option with the same meaning.
> 
> intra_period in xavs2 seems not equals to gop_size in ffmpeg, intra period here is calculated by (actul_intra_period/gop_size).

I'm not entirely sure what you mean here.  Let me try to explain what I think this doing, please correct me if I'm getting anything wrong.

The intra frames sent in a stream are arranged something like (xxx representing any sequence of non-intra frames):

IDR xxx  I  xxx  I  xxx  I  ...  I  xxx IDR

 | <-A-> | <-A-> | <-A-> |  ...  | <-A-> |
     ^       ^ B instances of A ...  ^
 | <---------------- C ----------------> |

Both I and IDR frames are recovery points.

Then, with your naming:

A = GOP size
B = Intra period
C = what you've called "actul intra period" above and in the docs

and A * B = C

Only being able to set B, though, seems insufficient to control this?  Any one variable is determined by the other two, but you need at least two of them.


Aside: the libmfx code calls the B variable "IDR interval", which I think is slightly clearer (see <http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/qsvenc_h264.c;h=06fa0ebf065b2426b9f77aeaef3a20f41466ee1c;hb=HEAD#l109>).

>>> +    if (avctx->bit_rate > 0) {
>>> +        cae->api->opt_set2(cae->param, "RateControl",  "1");
>>> +        av_strlcatf(str_TBR, sizeof(str_TBR), "%d", avctx->bit_rate);
>>> +        cae->api->opt_set2(cae->param, "TargetBitRate", str_TBR);
>>> +    }
>>
>> What happens if there is no bitrate target?  Some sort of constant-quality mode?  Are there any parameters for that?
> 
> Rate control in xavs2 will only work if given bit_rate and the speed(preset) level is used to control quality.

Please do correct me if this is wrong, but I thought the speed/preset value was the encoding-time against quality tradeoff?  When bitrate is not set I would expect there to be a parameter for the size against quality tradeoff as well (e.g. a fixed QP value that will be used for every frame - in AVCodecContext this generally maps to global_quality, though not all encoders use it).


Thanks,

- Mark


More information about the ffmpeg-devel mailing list