Log in

View Full Version : problem about x264 10bits encoding!


l35633
10th December 2014, 10:32
hello. I make a 10-bits x264 project for encoding.

profile is high10, yuv format is 4:2:0,
Y or U, V value is kept by 2 bytes.

I used the function below to allocat buffer for picture, it is ok for 8 bits.
x264_picture_t* pic,
x264_picture_alloc(pic, X264_CSP_I420, 640, 480);

Then I will copy yuv data to y,u,v plane buffer as below,
first copy to Y plane buffer.
unsigned char *p1,*p2;
p1=YUVBuf;
p2=pic->img.plane[0];
int len = 640*2;
for(int i=0;i<480;i++)
{
memcpy(p2,p1,len);
p1+=len;
p2+=len;
}

But error will happen here.when debugging, I find the size of
p1 buffer is larger than the p2,ie. img.plane
I think when allocating buffer for image, it is not 2 bytes for a Y or U or V value, still 1 bytes.
Do I forget set some parameters for encoding?

Thank you very much! Need you nice help.

MasterNobody
10th December 2014, 17:33
Do I forget set some parameters for encoding?
You forgot to specify X264_CSP_HIGH_DEPTH flag i.e. it should be
x264_picture_alloc(pic, X264_CSP_I420 | X264_CSP_HIGH_DEPTH, 640, 480);

l35633
10th December 2014, 18:29
Thank you very much! I added what you told me. The old buffer problem disappeard. But still show error message below:

"this build of x264 requires high depth input. rebuild to support 8-bit input"

Do I miss parameters when I init ?

Thank you very much!

MasterNobody
10th December 2014, 18:42
Thank you very much! I added what you told me. The old buffer problem disappeard. But still show error message below:

"this build of x264 requires high depth input. rebuild to support 8-bit input"

Do I miss parameters when I init ?

Thank you very much!
You should set param.i_csp for x264_encoder_open also with this flag (X264_CSP_HIGH_DEPTH) when you using 10-bit libx264.

l35633
10th December 2014, 19:12
Thank you! Would you please provide me details how to set flag X264_CSP_HIGH_DEPTH for x264_encoder_open?
In my code, there are two places about csp setting.
1. mParams.i_csp = X264_CSP_HIGH_DEPTH ; //change this, it not work well
x264_param_apply_profile(&mParams, mInputParams.mProfile);

2.
x264_picture_t* pic,
x264_picture_alloc(pic, X264_CSP_I420|X264_CSP_HIGH_DEPTH, 640, 480);
pic->img.i_csp = X264_CSP_HIGH_DEPTH; //change this, still not work well.

Then where to change or add?

Thank you very much!

MasterNobody
10th December 2014, 19:24
I mean that it need to be set to the same: X264_CSP_I420|X264_CSP_HIGH_DEPTH. In general param.i_csp for x264_encoder_encode and csp for x264_picture_alloc for pic_in should be equal (some colorspace layout deviations are allowed) and usually x264_picture_alloc calls are simply made with param.i_csp argument.

l35633
10th December 2014, 21:31
Thank you very much!!!