context->target_id = render_target;
surf->ctx = context_id;
context->target = surf->buffer;
+ context->mjpeg.sampling_factor = 0;
if (!context->decoder) {
vlVaHandlePictureParameterBufferHEVC(drv, context, buf);
break;
+ case PIPE_VIDEO_FORMAT_JPEG:
+ vlVaHandlePictureParameterBufferMJPEG(drv, context, buf);
+ break;
+
default:
break;
}
/* Create the decoder once max_references is known. */
if (!context->decoder) {
+ enum pipe_video_format format =
+ u_reduce_video_profile(context->templat.profile);
+
if (!context->target)
return VA_STATUS_ERROR_INVALID_CONTEXT;
- if (context->templat.max_references == 0)
+ if (context->templat.max_references == 0 &&
+ format != PIPE_VIDEO_FORMAT_JPEG)
return VA_STATUS_ERROR_INVALID_BUFFER;
- if (u_reduce_video_profile(context->templat.profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC)
+ if (format == PIPE_VIDEO_FORMAT_MPEG4_AVC)
context->templat.level = u_get_h264_level(context->templat.width,
context->templat.height, &context->templat.max_references);
vlVaHandleIQMatrixBufferHEVC(context, buf);
break;
+ case PIPE_VIDEO_FORMAT_JPEG:
+ vlVaHandleIQMatrixBufferMJPEG(context, buf);
+ break;
+
default:
break;
}
vlVaHandleSliceParameterBufferHEVC(context, buf);
break;
+ case PIPE_VIDEO_FORMAT_JPEG:
+ vlVaHandleSliceParameterBufferMJPEG(context, buf);
+ break;
+
default:
break;
}
vlVaDecoderFixMPEG4Startcode(context);
buffers[num_buffers] = (void *)context->mpeg4.start_code;
sizes[num_buffers++] = context->mpeg4.start_code_size;
+ case PIPE_VIDEO_FORMAT_JPEG:
+ /* TODO */
+ break;
default:
break;
}
vaStatus = handleVAEncSliceParameterBufferType(drv, context, buf);
break;
+ case VAHuffmanTableBufferType:
+ vlVaHandleHuffmanTableBufferType(context, buf);
+ break;
+
default:
break;
}
vlVaBuffer *coded_buf;
vlVaSurface *surf;
void *feedback;
+ struct pipe_screen *screen;
+ bool interlaced;
+ bool realloc = false;
+ enum pipe_format format;
if (!ctx)
return VA_STATUS_ERROR_INVALID_CONTEXT;
surf = handle_table_get(drv->htab, context->target_id);
context->mpeg4.frame_num++;
+ screen = context->decoder->context->screen;
+ interlaced = screen->get_video_param(screen, context->decoder->profile,
+ PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ PIPE_VIDEO_CAP_SUPPORTS_INTERLACED);
+
+ if (surf->buffer->interlaced != interlaced) {
+ surf->templat.interlaced = screen->get_video_param(screen, context->decoder->profile,
+ PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ PIPE_VIDEO_CAP_PREFERS_INTERLACED);
+ realloc = true;
+ }
+
+ format = screen->get_video_param(screen, context->decoder->profile,
+ PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
+ PIPE_VIDEO_CAP_PREFERED_FORMAT);
+
+ if (surf->buffer->buffer_format != format &&
+ surf->buffer->buffer_format == PIPE_FORMAT_NV12) {
+ /* check originally as NV12 only */
+ surf->templat.buffer_format = format;
+ realloc = true;
+ }
+
+ if (u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_JPEG &&
+ surf->buffer->buffer_format == PIPE_FORMAT_NV12) {
+ if (context->mjpeg.sampling_factor == 0x211111 ||
+ context->mjpeg.sampling_factor == 0x221212) {
+ surf->templat.buffer_format = PIPE_FORMAT_YUYV;
+ realloc = true;
+ } else if (context->mjpeg.sampling_factor != 0x221111) {
+ /* Not NV12 either */
+ mtx_unlock(&drv->mutex);
+ return VA_STATUS_ERROR_INVALID_SURFACE;
+ }
+ }
+
+ if (realloc) {
+ surf->buffer->destroy(surf->buffer);
+
+ if (vlVaHandleSurfaceAllocate(ctx, surf, &surf->templat) != VA_STATUS_SUCCESS) {
+ mtx_unlock(&drv->mutex);
+ return VA_STATUS_ERROR_ALLOCATION_FAILED;
+ }
+
+ context->target = surf->buffer;
+ }
+
if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
coded_buf = context->coded_buf;
getEncParamPreset(context);