Opened 3 years ago

Last modified 17 months ago

#8119 reopened enhancement

mpeg2_vaapi encoder "QP" parameter for CQP

Reported by: Andreas Håkon Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: vaapi
Cc: wenbin.chen@intel.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

When using the CQP Rate Control (-c:v mpeg2_vaapi -rc_mode CQP)
the current implementation only accepts the global_quality to configure it. This value is set using the "-q:v" option, but this value isn't in the common range 0-31 (in fact, 0.09 corresponds to 10, 0.1 to 11, etc.).

However, in the H.264 VAAPI encoder (h264_vaapi) the explicit parameter "QP" exists. And this value sets the GENERIC VAAPI ENCODER value of "explicit_qp". See:

https://github.com/FFmpeg/FFmpeg/blob/f30fb5ef626140d6e286a22e4f5ca7e7f5b97c67/libavcodec/vaapi_encode_h264.c#L1258
https://github.com/FFmpeg/FFmpeg/blob/f30fb5ef626140d6e286a22e4f5ca7e7f5b97c67/libavcodec/vaapi_encode_h264.c#L1236

So, only adding this "-qp" parameter to the MPEG2 VAAPI ENCODER, then it will enable the option to use the common 0-31 range with this encoder. In fact, a very small of new source lines are required. Just copy&paste!

Regards.

Change History (5)

comment:1 by jkqxz, 3 years ago

Resolution: invalid
Status: newclosed

-global_quality:v

in reply to:  1 comment:2 by Andreas Håkon, 3 years ago

Resolution: invalid
Status: closedreopened

Replying to jkqxz:

-global_quality:v

Hi,

I writed it in my report: -global_quality:v not uses the common range 1-31.

And for this reason h264_vaapi and others have -qp. Futhermore, the GENERIC implementation of the VAAPI encoder has the explicit_qp variable. And all vaapi encoders, EXCEPT the mpeg2 uses it. The request it's to copy&paste the four lines of code from vaapi_encode_h264.c to vaapi_encode_mpeg2.c

So I reopen the ticket as it's valid.
Regards.

comment:3 by wenbin,chen, 17 months ago

According to here
https://github.com/FFmpeg/FFmpeg/blob/2367affc2cea32f18a4d309835bed57adb1baa94/libavcodec/vaapi_encode_mpeg2.c#L522
you need to use "-i_qfactor","-i_qoffset","-b_qfactor" and "-b_qoffset" to set qp for I and B frame.

And according to here
https://github.com/FFmpeg/FFmpeg/blob/2367affc2cea32f18a4d309835bed57adb1baa94/libavcodec/vaapi_encode.c#L1676
you need to use global quality to set qp for P frame.

thanks

comment:4 by wenbin,chen, 17 months ago

Cc: wenbin.chen@intel.com added

comment:5 by Carl Eugen Hoyos, 17 months ago

Keywords: vaapi added; vaapi_encode_mpeg2 cqp removed
Note: See TracTickets for help on using tickets.