- templat.profile = config_id;
- templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
- templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
- templat.width = picture_width;
- templat.height = picture_height;
- templat.max_references = num_render_targets;
- templat.expect_chunked_decode = true;
-
- if (u_reduce_video_profile(templat.profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC)
- templat.level = u_get_h264_level(templat.width, templat.height,
- &templat.max_references);
-
- context->decoder = drv->pipe->create_video_codec(drv->pipe, &templat);
- if (!context->decoder) {
- FREE(context);
- return VA_STATUS_ERROR_ALLOCATION_FAILED;
- }
-
- if (u_reduce_video_profile(context->decoder->profile) ==
- PIPE_VIDEO_FORMAT_MPEG4_AVC) {
+ context->templat.profile = config_id;
+ context->templat.entrypoint = PIPE_VIDEO_ENTRYPOINT_BITSTREAM;
+ context->templat.chroma_format = PIPE_VIDEO_CHROMA_FORMAT_420;
+ context->templat.width = picture_width;
+ context->templat.height = picture_height;
+ context->templat.expect_chunked_decode = true;
+
+ switch (u_reduce_video_profile(context->templat.profile)) {
+ case PIPE_VIDEO_FORMAT_MPEG12:
+ case PIPE_VIDEO_FORMAT_VC1:
+ case PIPE_VIDEO_FORMAT_MPEG4:
+ context->templat.max_references = 2;
+ break;
+
+ case PIPE_VIDEO_FORMAT_MPEG4_AVC:
+ context->templat.max_references = 0;