Log in

View Full Version : Setting Initial Qp in H264 Encoder


sabeelmk
4th March 2010, 10:10
Hi All

Is there any logic/algo behind setting a initial QP for encoding in a h264 encoder.

thanks

sabeelmk
5th March 2010, 06:43
Surprising,No response for 2 days..

Hasnt anyone worked on Rate control here??

Hi All

Is there any logic/algo behind setting a initial QP for encoding in a h264 encoder.

thanks

kypec
5th March 2010, 10:48
Surprising,No response for 2 days..

Even more surprising is your lack of basic math skills. Your first post was made on March 4 at 10:10. Your second post was made only 20 hours and 33 minutes later which you can hardly call 2 days. Or maybe you're living on another planet where days last shorter than 24 hours (standard Earth hours)? :confused:

Audionut
5th March 2010, 10:57
http://forum.doom9.org/forum-rules.htm
12) How NOT to post on this forum:

5 minutes after your initial post you reply to your own post writing something like "Why is nobody helping me? I'm sure you know the answer".

sabeelmk
5th March 2010, 11:34
Guys

lets Stick to the subject,

Hope someone is out there in this forum,who has worked on Rate control.

Wishbringer
5th March 2010, 12:38
Maybe we don't understand the meaning of your question.

http://mewiki.project357.com/wiki/X264_Settings
see 1.3 Ratecontrol

What is the meaning of the world, the universe and all other...?!

Logic behind initial QP is to archieve a given set of quality.

Dark Shikari
5th March 2010, 12:42
Maybe we don't understand the meaning of your question.

http://mewiki.project357.com/wiki/X264_Settings
see 1.3 Ratecontrol

What is the meaning of the world, the universe and all other...?!

Logic behind initial QP is to archieve a given set of quality.x264 doesn't have a parameter for initial QP. It calculates it as a guess in ABR mode.

Wishbringer
5th March 2010, 12:44
x264 doesn't have a parameter for initial QP.

Not even in --qp mode?

So I am sorry to gave wrong statement.

sabeelmk
5th March 2010, 12:49
Guys

Let me clear up the confusion

I am talking in a general H264 encoder,not X264,the value of QP used is arbitary or a guess,based upon the BitsperPixel in the frame.

I am looking at alternatives other than that,such some kind of complexity measure which can assist me determining the initial QP to be used for encoding in development of a Rate control of a general h264 encoder

Hopefully the complexity measure is not very complex,as cycles may increase.

regards

Shevach
10th March 2010, 12:19
Initial SliceQp makes sense when QP is restricted to be constant within the whole picture.
The simplest Rate Control can be conceptually outlined as follows:
1. For the very first picture set SliceQp=25 (middle value).

2. For each picture determine bit-budget according to picture type (for I-picture more bits should be granted than for P-picture and for P-picture more bits should be granted than fro B-picture).

3. Encode a picture with pre-defined SliceQP.
If actual bit-budget exceeds the expected one then decrease SliceQP.
If actual bit-budget is less than the expected one then increase SliceQP.

sabeelmk
11th March 2010, 10:58
Initial SliceQp makes sense when QP is restricted to be constant within the whole picture.
The simplest Rate Control can be conceptually outlined as follows:
1. For the very first picture set SliceQp=25 (middle value).



Shevach

Thanks for your reply,

In ur response,u suggest to make the Inital Slice Qp= 25(constant) that for very first picture

But my question is directly on this same very point,that i Dont want to use a constant,i was to use a logic that gives me a initial value of Qp for the very first picture to be encoded,as i do not want to use a constant

I know there is a logic based on BitsperPixel of the first picture,but is there any other logic other this,to set the initial Qp for the very first picture

thanks

Shevach
11th March 2010, 15:48
Sabeelmk

I am familiar with this method of the calculation of InitialQp basing on bpp (Bits per Pixel) although I don't advocate it. You can find this method in JM Reference Encoder.
Here I simply outline it:

bpp = bit_rate /(img_width*img_height)

if (img->width == 176)
{
L1 = 0.1;
L2 = 0.3;
L3 = 0.6;
}else if (img->width == 352)
{
L1 = 0.2;
L2 = 0.6;
L3 = 1.2;
}else
{
L1 = 0.6;
L2 = 1.4;
L3 = 2.4;
}

if(bpp<= L1)
InitialQp = 35;
else
if(bpp<=L2)
InitialQp = 25;
else
if(bpp<=L3)
InitialQp = 20;
else
InitialQp =10;

sabeelmk
12th March 2010, 13:11
Shevach

thanks for the response,

I am aware of that method in JM,

But i hope & am sure u are aware that my question is different,which is,wether i can replace the same very method in JM,with some other logic/algorithm to calculate the initial Qp,
as my aim is to NOT use the constant Qp as initial Qp for the very first picture.

hence i am looking for "any other algorithm",which makes sense,to be used for calculation of initial Qp for the very first picture

thanks

Shevach
14th March 2010, 08:25
My guess:
Because the very first picture in a stream is I-picture you can estimate its complexity by summing VARs of all 8x8 blocks.
You can use the total VAR and the predefined bit-rate to compute initial Qp.

Unfortunately the methods which I know are proprietary. I am afraid you have to derive the logic for optimal calculation of Initial QP by yourself.

Mr VacBob
14th March 2010, 08:45
Macroblock-tree isn't proprietary.

Dark Shikari
14th March 2010, 08:48
Macroblock-tree isn't proprietary.Well then clearly he doesn't know of it ;)