Log in

View Full Version : X264 Horizontal Rips on i_threads> 1


KAnthony
18th August 2015, 17:10
I'm trying to write an x264 encoder. However, I cannot set i_threads to anything greater then 1 and still get a usable picture out.

My Settings

Preset : veryfast
Tune : zerolatency
Profile : high
i_width : 1920
i_height : 1080
i_fps_num : 25
i_fps_den : 1
i_timebase_num : 1
i_timebase_den : 1000
i_keyint_max : 32
b_repeat_headers : 1
b_annexb : 1
b_intra_refresh : 1
b_aud : 1
b_open_gop : 1

RC:
i_rc_method : X264_RC_ABR
i_bitrate : 5120
i_vbv_buffer_size : 5120
i_vbv_max_bitrate : 5120 * 1.1
i_qp_constant : 20
f_qblur : .5
f_complexity_blur : 20

Analyse:
i_me_method : X264_ME_UMH
i_subpel_refine : 7
i_me_range : 16
b_psnr : 0
b_ssim : 0
i_noise_reduction : 2
inter : X264_ANALYSE_I4x4 | X264_ANALYSE_I8x8 | X264_ANALYSE_PSUB16x16




i_threads = 1:
http://tinypic.com/player.php?v=14xdpqv%3E&s=8#.VdNUyPlVhBc

i_threads = 2:
http://tinypic.com/player.php?v=b7exib%3E&s=8#.VdNWyvlVhBc

What could be causing this?

foxyshadis
18th August 2015, 20:02
How are you calling x264? Via command-line or via API, and what exact arguments? What input are you giving it and how? Hopefully that can help narrow it down.

KAnthony
18th August 2015, 20:12
API's, the input is a bitmap buffer I fill manually every 5 frames
That is exactly the parameters I am using.


static int count = 0;
static int one;
if (count % (TARGET_FPS / 2) == 0) {
one = rand() % 8;
}
int two, three;
do {
two = rand() % 8;
} while (two == one);
do {
three = rand() % 8;
} while (three == one || three == two);
COLORREF* colorBuffer = reinterpret_cast<COLORREF*>(buffer);
COLORREF background = GetColor(one);
COLORREF lineOneInnerColor = GetColor(two);
COLORREF lineOneOuterColor = GetColor(three);
COLORREF lineTwoColor = GetColor(three);
COLORREF lineThreeColor = GetColor(three);
if (count % (TARGET_FPS / 5) == 0) {
for (int i = 0; i < DEFAULT_WIDTH * DEFAULT_HEIGHT; ++i) {
colorBuffer[i] = background;
}
for (int i = 0; i < LineOneOuterLength; ++i) {
PIXELLOCATION p = LineOneOuter[i];
int index = p.Y * DEFAULT_WIDTH + p.X;
colorBuffer[index] = lineOneOuterColor;
}
for (int i = 0; i < LineOneInnerLength; ++i) {
PIXELLOCATION p = LineOneInner[i];
int index = p.Y * DEFAULT_WIDTH + p.X;
colorBuffer[index] = lineOneInnerColor;
}
for (int i = 0; i < LineTwoLength; ++i) {
PIXELLOCATION p = LineTwo[i];
int index = p.Y * DEFAULT_WIDTH + p.X;
colorBuffer[index] = lineTwoColor;
}
for (int i = 0; i < LineThreeLength; ++i) {
PIXELLOCATION p = LineThree[i];
int index = p.Y * DEFAULT_WIDTH + p.X;
colorBuffer[index] = lineThreeColor;
}
}
count++;


and this is how i'm encoding the picture

::avpicture_fill(&picRaw, static_cast<uint8_t*>(bufferIn), AV_PIX_FMT_RGB32, iWidthIn, iHeightIn);
::sws_scale(sws, picRaw.data, picRaw.linesize, 0, iHeightIn, picIn.img.plane, picIn.img.i_stride);
picIn.i_pts = static_cast<int64_t>(mi_pts);
picIn.i_type = X264_TYPE_AUTO;

::x264_encoder_encode(pEncoder, &pNals, &iNalCount, picIn, &picOut);
memcpy(bufferOut, pNals[0].p_payload, i_frame_size);


I stripped out a lot of the error checking