diff options
-rw-r--r-- | src/mpeg2.c | 32 | ||||
-rw-r--r-- | src/picture.c | 8 | ||||
-rw-r--r-- | src/surface.h | 2 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/mpeg2.c b/src/mpeg2.c index cfeae35..fc251fa 100644 --- a/src/mpeg2.c +++ b/src/mpeg2.c @@ -44,9 +44,14 @@ int mpeg2_set_controls(struct request_data *driver_data, { VAPictureParameterBufferMPEG2 *parameters = &surface_object->params.mpeg2.picture; + VAIQMatrixBufferMPEG2 *iqmatrix = + &surface_object->params.mpeg2.iqmatrix; + bool iqmatrix_set = surface_object->params.mpeg2.iqmatrix_set; struct v4l2_ctrl_mpeg2_slice_params slice_params; + struct v4l2_ctrl_mpeg2_quantization quantization; struct object_surface *forward_reference_surface; struct object_surface *backward_reference_surface; + unsigned int i; int rc; memset(&slice_params, 0, sizeof(slice_params)); @@ -105,5 +110,32 @@ int mpeg2_set_controls(struct request_data *driver_data, if (rc < 0) return VA_STATUS_ERROR_OPERATION_FAILED; + if (iqmatrix_set) { + quantization.load_intra_quantiser_matrix = + iqmatrix->load_intra_quantiser_matrix; + quantization.load_non_intra_quantiser_matrix = + iqmatrix->load_non_intra_quantiser_matrix; + quantization.load_chroma_intra_quantiser_matrix = + iqmatrix->load_chroma_intra_quantiser_matrix; + quantization.load_chroma_non_intra_quantiser_matrix = + iqmatrix->load_chroma_non_intra_quantiser_matrix; + + for (i = 0; i < 64; i++) { + quantization.intra_quantiser_matrix[i] = + iqmatrix->intra_quantiser_matrix[i]; + quantization.non_intra_quantiser_matrix[i] = + iqmatrix->non_intra_quantiser_matrix[i]; + quantization.chroma_intra_quantiser_matrix[i] = + iqmatrix->chroma_intra_quantiser_matrix[i]; + quantization.chroma_non_intra_quantiser_matrix[i] = + iqmatrix->chroma_non_intra_quantiser_matrix[i]; + } + + rc = v4l2_set_control(driver_data->video_fd, + surface_object->request_fd, + V4L2_CID_MPEG_VIDEO_MPEG2_QUANTIZATION, + &quantization, sizeof(quantization)); + } + return 0; } diff --git a/src/picture.c b/src/picture.c index f724366..696b326 100644 --- a/src/picture.c +++ b/src/picture.c @@ -109,6 +109,14 @@ static VAStatus codec_store_buffer(struct request_data *driver_data, case VAIQMatrixBufferType: switch (profile) { + case VAProfileMPEG2Simple: + case VAProfileMPEG2Main: + memcpy(&surface_object->params.mpeg2.iqmatrix, + buffer_object->data, + sizeof(surface_object->params.mpeg2.iqmatrix)); + surface_object->params.mpeg2.iqmatrix_set = true; + break; + case VAProfileH264Main: case VAProfileH264High: case VAProfileH264ConstrainedBaseline: diff --git a/src/surface.h b/src/surface.h index c5ae2f5..5f401a1 100644 --- a/src/surface.h +++ b/src/surface.h @@ -64,6 +64,8 @@ struct object_surface { union { struct { VAPictureParameterBufferMPEG2 picture; + VAIQMatrixBufferMPEG2 iqmatrix; + bool iqmatrix_set; } mpeg2; struct { VAIQMatrixBufferH264 matrix; |