<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - amdgpu hevc encoding problems: segment fault and contents of garbage"
href="https://bugs.freedesktop.org/show_bug.cgi?id=110673">110673</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>amdgpu hevc encoding problems: segment fault and contents of garbage
</td>
</tr>
<tr>
<th>Product</th>
<td>Mesa
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>Other
</td>
</tr>
<tr>
<th>Assignee</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mfk530@gmail.com
</td>
</tr>
<tr>
<th>QA Contact</th>
<td>mesa-dev@lists.freedesktop.org
</td>
</tr></table>
<p>
<div>
<pre>I have tested amdgpu hevc encoding via libva few days ago.
And I found two problems.
Hardware: R5 2400g(VCN), rx580/vega64(UVD_ENC)
1. intra_period must >= 8 otherwise segment fault in mesa.
I found these codes in mesa using gdb:
radeon_uvd_enc.c/radeon_vcn_enc.c:
enc->enc_pic.max_poc = pic->seq.intra_period;
for (int i = enc->enc_pic.max_poc; i != 0; enc->enc_pic.log2_max_poc++)
i = (i >> 1);
radeon_uvd_enc_1_1.c/radeon_vcn_enc_1_2.c:
radeon_uvd_enc_code_ue(enc, enc->enc_pic.log2_max_poc - 4);
radeon_enc_code_ue(enc, enc->enc_pic.log2_max_poc - 4);
If intra_period < 8, (enc->enc_pic.log2_max_poc - 4) is negative.
cs array will overflow in radeon_uvd_enc_code_ue or radeon_enc_code_ue.
ffmpeg can reproduce this problem by changing "-g" parameter value.
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.avi -vf
'format=nv12,hwupload' -c:v hevc_vaapi -bf 0 -g 7 output.mp4
2. Hevc encoding only works correctly in CQP mode.
I have tested CBR and VBR, both of them produce contents of garbageļ¼ green or
black mostly.
ffmpeg can reproduce this problem.
ffmpeg -vaapi_device /dev/dri/renderD128 -i input.avi -vf
'format=nv12,hwupload' -c:v hevc_vaapi -bf 0 -b:v 5M output.mp4</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug.</li>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>