frontends/va: Fix some small coverity issues
* 1547216 Operands don't affect result
- PRESET_MODE_HIGH_QUALITY is maximum value
* 1255678 Dereference after null check
- no need to check against NULL because the data can
only be NULL when the array is empty (size == 0)
* 1619397 Unsigned compared against 0
- check >= 0 is always true in vlVaAddRawHeader
* 1468885 Dereference null return value
- add NULL check for buffers in vlVaRenderPicture
Acked-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31622>
This commit is contained in:
@@ -218,8 +218,7 @@ vlVaHandleVAEncMiscParameterTypeQualityLevel(struct pipe_enc_quality_modes *p, v
|
||||
p->pre_encode_mode = PREENCODING_MODE_DEFAULT;
|
||||
p->vbaq_mode = VBAQ_AUTO;
|
||||
} else {
|
||||
p->preset_mode = in->preset_mode > PRESET_MODE_HIGH_QUALITY
|
||||
? PRESET_MODE_HIGH_QUALITY : in->preset_mode;
|
||||
p->preset_mode = in->preset_mode;
|
||||
p->pre_encode_mode = in->pre_encode_mode;
|
||||
p->vbaq_mode = in->vbaq_mode;
|
||||
}
|
||||
@@ -1004,6 +1003,10 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
||||
|
||||
for (i = 0; i < num_buffers && vaStatus == VA_STATUS_SUCCESS; ++i) {
|
||||
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
|
||||
if (!buf) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_BUFFER;
|
||||
}
|
||||
|
||||
switch (buf->type) {
|
||||
case VAPictureParameterBufferType:
|
||||
@@ -1402,7 +1405,7 @@ vlVaAddRawHeader(struct util_dynarray *headers, uint8_t type, uint32_t size,
|
||||
memcpy(header.buffer, buf, emulation_bytes_start);
|
||||
for (uint32_t i = emulation_bytes_start; i < size; i++) {
|
||||
uint8_t byte = buf[i];
|
||||
if (num_zeros >= 2 && byte >= 0x00 && byte <= 0x03) {
|
||||
if (num_zeros >= 2 && byte <= 0x03) {
|
||||
header.buffer[pos++] = 0x03;
|
||||
num_zeros = 0;
|
||||
}
|
||||
|
||||
@@ -345,9 +345,6 @@ vlVaPutSubpictures(vlVaSurface *surf, vlVaDriver *drv,
|
||||
vlVaSubpicture *sub;
|
||||
int i;
|
||||
|
||||
if (!(surf->subpics.data || surf->subpics.size))
|
||||
return VA_STATUS_SUCCESS;
|
||||
|
||||
for (i = 0; i < surf->subpics.size/sizeof(vlVaSubpicture *); i++) {
|
||||
struct pipe_blend_state blend;
|
||||
void *blend_state;
|
||||
|
||||
Reference in New Issue
Block a user