2 * Copyright (C) 2006-2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
28 #include "intel_batchbuffer.h"
29 #include "i965_drv_video.h"
30 #include "i965_decoder_utils.h"
31 #include "i965_defines.h"
33 /* Set reference surface if backing store exists */
36 struct i965_driver_data *i965,
37 GenFrameStore *ref_frame,
38 VASurfaceID va_surface,
39 struct object_surface *obj_surface
42 if (va_surface == VA_INVALID_ID)
45 if (!obj_surface || !obj_surface->bo)
48 ref_frame->surface_id = va_surface;
49 ref_frame->obj_surface = obj_surface;
53 /* Check wether codec layer incorrectly fills in slice_vertical_position */
55 mpeg2_wa_slice_vertical_position(
56 struct decode_state *decode_state,
57 VAPictureParameterBufferMPEG2 *pic_param
60 unsigned int i, j, mb_height, vpos, last_vpos = 0;
62 /* Assume progressive sequence if we got a progressive frame */
63 if (pic_param->picture_coding_extension.bits.progressive_frame)
66 /* Wait for a field coded picture */
67 if (pic_param->picture_coding_extension.bits.picture_structure == MPEG_FRAME)
70 assert(decode_state && decode_state->slice_params);
72 mb_height = (pic_param->vertical_size + 31) / 32;
74 for (j = 0; j < decode_state->num_slice_params; j++) {
75 struct buffer_store * const buffer_store =
76 decode_state->slice_params[j];
78 for (i = 0; i < buffer_store->num_elements; i++) {
79 VASliceParameterBufferMPEG2 * const slice_param =
80 ((VASliceParameterBufferMPEG2 *)buffer_store->buffer) + i;
82 vpos = slice_param->slice_vertical_position;
83 if (vpos >= mb_height || vpos == last_vpos + 2) {
84 WARN_ONCE("codec layer incorrectly fills in MPEG-2 slice_vertical_position. Workaround applied\n");
93 /* Build MPEG-2 reference frames array */
95 mpeg2_set_reference_surfaces(
97 GenFrameStore ref_frames[MAX_GEN_REFERENCE_FRAMES],
98 struct decode_state *decode_state,
99 VAPictureParameterBufferMPEG2 *pic_param
102 struct i965_driver_data * const i965 = i965_driver_data(ctx);
103 VASurfaceID va_surface;
104 unsigned pic_structure, is_second_field, n = 0;
105 struct object_surface *obj_surface;
107 pic_structure = pic_param->picture_coding_extension.bits.picture_structure;
108 is_second_field = pic_structure != MPEG_FRAME &&
109 !pic_param->picture_coding_extension.bits.is_first_field;
111 ref_frames[0].surface_id = VA_INVALID_ID;
112 ref_frames[0].obj_surface = NULL;
114 /* Reference frames are indexed by frame store ID (0:top, 1:bottom) */
115 switch (pic_param->picture_coding_type) {
117 if (is_second_field && pic_structure == MPEG_BOTTOM_FIELD) {
118 va_surface = decode_state->current_render_target;
119 obj_surface = decode_state->render_object;
120 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
122 va_surface = pic_param->forward_reference_picture;
123 obj_surface = decode_state->reference_objects[0];
124 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
128 va_surface = pic_param->forward_reference_picture;
129 obj_surface = decode_state->reference_objects[0];
130 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
131 va_surface = pic_param->backward_reference_picture;
132 obj_surface = decode_state->reference_objects[1];
133 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
138 ref_frames[n].obj_surface = ref_frames[0].obj_surface;
139 ref_frames[n++].surface_id = ref_frames[0].surface_id;
142 if (pic_param->picture_coding_extension.bits.progressive_frame)
145 ref_frames[2].surface_id = VA_INVALID_ID;
146 ref_frames[2].obj_surface = NULL;
148 /* Bottom field pictures used as reference */
149 switch (pic_param->picture_coding_type) {
151 if (is_second_field && pic_structure == MPEG_TOP_FIELD) {
152 va_surface = decode_state->current_render_target;
153 obj_surface = decode_state->render_object;
154 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
156 va_surface = pic_param->forward_reference_picture;
157 obj_surface = decode_state->reference_objects[0];
158 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
162 va_surface = pic_param->forward_reference_picture;
163 obj_surface = decode_state->reference_objects[0];
164 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
165 va_surface = pic_param->backward_reference_picture;
166 obj_surface = decode_state->reference_objects[1];
167 n += set_ref_frame(i965, &ref_frames[n], va_surface, obj_surface);
172 ref_frames[n].obj_surface = ref_frames[2].obj_surface;
173 ref_frames[n++].surface_id = ref_frames[2].surface_id;
177 /* Generate flat scaling matrices for H.264 decoding */
179 avc_gen_default_iq_matrix(VAIQMatrixBufferH264 *iq_matrix)
182 memset(&iq_matrix->ScalingList4x4, 16, sizeof(iq_matrix->ScalingList4x4));
185 memset(&iq_matrix->ScalingList8x8, 16, sizeof(iq_matrix->ScalingList8x8));
188 /* Get first macroblock bit offset for BSD, minus EPB count (AVC) */
189 /* XXX: slice_data_bit_offset does not account for EPB */
191 avc_get_first_mb_bit_offset(
192 dri_bo *slice_data_bo,
193 VASliceParameterBufferH264 *slice_param,
194 unsigned int mode_flag
197 unsigned int slice_data_bit_offset = slice_param->slice_data_bit_offset;
199 if (mode_flag == ENTROPY_CABAC)
200 slice_data_bit_offset = ALIGN(slice_data_bit_offset, 0x8);
201 return slice_data_bit_offset;
204 /* Get first macroblock bit offset for BSD, with EPB count (AVC) */
205 /* XXX: slice_data_bit_offset does not account for EPB */
207 avc_get_first_mb_bit_offset_with_epb(
208 dri_bo *slice_data_bo,
209 VASliceParameterBufferH264 *slice_param,
210 unsigned int mode_flag
213 unsigned int in_slice_data_bit_offset = slice_param->slice_data_bit_offset;
214 unsigned int out_slice_data_bit_offset;
215 unsigned int i, j, n, buf_size, data_size, header_size;
219 header_size = slice_param->slice_data_bit_offset / 8;
220 data_size = slice_param->slice_data_size - slice_param->slice_data_offset;
221 buf_size = (header_size * 3 + 1) / 2; // Max possible header size (x1.5)
223 if (buf_size > data_size)
224 buf_size = data_size;
226 buf = alloca(buf_size);
227 ret = dri_bo_get_subdata(
228 slice_data_bo, slice_param->slice_data_offset,
233 for (i = 2, j = 2, n = 0; i < buf_size && j < header_size; i++, j++) {
234 if (buf[i] == 0x03 && buf[i - 1] == 0x00 && buf[i - 2] == 0x00)
238 out_slice_data_bit_offset = in_slice_data_bit_offset + n * 8;
240 if (mode_flag == ENTROPY_CABAC)
241 out_slice_data_bit_offset = ALIGN(out_slice_data_bit_offset, 0x8);
242 return out_slice_data_bit_offset;
245 static inline uint8_t
246 get_ref_idx_state_1(const VAPictureH264 *va_pic, unsigned int frame_store_id)
248 const unsigned int is_long_term =
249 !!(va_pic->flags & VA_PICTURE_H264_LONG_TERM_REFERENCE);
250 const unsigned int is_top_field =
251 !!(va_pic->flags & VA_PICTURE_H264_TOP_FIELD);
252 const unsigned int is_bottom_field =
253 !!(va_pic->flags & VA_PICTURE_H264_BOTTOM_FIELD);
255 return ((is_long_term << 6) |
256 ((is_top_field ^ is_bottom_field ^ 1) << 5) |
257 (frame_store_id << 1) |
258 ((is_top_field ^ 1) & is_bottom_field));
261 /* Fill in Reference List Entries (Gen5+: ILK, SNB, IVB) */
263 gen5_fill_avc_ref_idx_state(
265 const VAPictureH264 ref_list[32],
266 unsigned int ref_list_count,
267 const GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]
270 unsigned int i, n, frame_idx;
273 for (i = 0, n = 0; i < ref_list_count; i++) {
274 const VAPictureH264 * const va_pic = &ref_list[i];
276 if (va_pic->flags & VA_PICTURE_H264_INVALID)
280 for (frame_idx = 0; frame_idx < MAX_GEN_REFERENCE_FRAMES; frame_idx++) {
281 const GenFrameStore * const fs = &frame_store[frame_idx];
282 if (fs->surface_id != VA_INVALID_ID &&
283 fs->surface_id == va_pic->picture_id) {
290 state[n++] = get_ref_idx_state_1(va_pic, frame_idx);
292 WARN_ONCE("Invalid Slice reference frame list !!!. It is not included in DPB \n");
300 /* Emit Reference List Entries (Gen6+: SNB, IVB) */
302 gen6_send_avc_ref_idx_state_1(
303 struct intel_batchbuffer *batch,
305 const VAPictureH264 *ref_list,
306 unsigned int ref_list_count,
307 const GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]
310 uint8_t ref_idx_state[32];
312 BEGIN_BCS_BATCH(batch, 10);
313 OUT_BCS_BATCH(batch, MFX_AVC_REF_IDX_STATE | (10 - 2));
314 OUT_BCS_BATCH(batch, list);
315 gen5_fill_avc_ref_idx_state(
317 ref_list, ref_list_count,
320 intel_batchbuffer_data(batch, ref_idx_state, sizeof(ref_idx_state));
321 ADVANCE_BCS_BATCH(batch);
325 gen6_send_avc_ref_idx_state(
326 struct intel_batchbuffer *batch,
327 const VASliceParameterBufferH264 *slice_param,
328 const GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES]
331 if (slice_param->slice_type == SLICE_TYPE_I ||
332 slice_param->slice_type == SLICE_TYPE_SI)
336 gen6_send_avc_ref_idx_state_1(
338 slice_param->RefPicList0, slice_param->num_ref_idx_l0_active_minus1 + 1,
342 if (slice_param->slice_type != SLICE_TYPE_B)
346 gen6_send_avc_ref_idx_state_1(
348 slice_param->RefPicList1, slice_param->num_ref_idx_l1_active_minus1 + 1,
354 intel_update_avc_frame_store_index(VADriverContextP ctx,
355 struct decode_state *decode_state,
356 VAPictureParameterBufferH264 *pic_param,
357 GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES])
361 assert(MAX_GEN_REFERENCE_FRAMES == ARRAY_ELEMS(pic_param->ReferenceFrames));
363 for (i = 0; i < MAX_GEN_REFERENCE_FRAMES; i++) {
366 if (frame_store[i].surface_id == VA_INVALID_ID ||
367 frame_store[i].obj_surface == NULL)
370 assert(frame_store[i].frame_store_id != -1);
372 for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
373 VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[j];
374 if (ref_pic->flags & VA_PICTURE_H264_INVALID)
377 if (frame_store[i].surface_id == ref_pic->picture_id) {
383 /* remove it from the internal DPB */
385 struct object_surface *obj_surface = frame_store[i].obj_surface;
387 obj_surface->flags &= ~SURFACE_REFERENCED;
389 if ((obj_surface->flags & SURFACE_ALL_MASK) == SURFACE_DISPLAYED) {
390 dri_bo_unreference(obj_surface->bo);
391 obj_surface->bo = NULL;
392 obj_surface->flags &= ~SURFACE_REF_DIS_MASK;
395 if (obj_surface->free_private_data)
396 obj_surface->free_private_data(&obj_surface->private_data);
398 frame_store[i].surface_id = VA_INVALID_ID;
399 frame_store[i].frame_store_id = -1;
400 frame_store[i].obj_surface = NULL;
404 for (i = 0; i < MAX_GEN_REFERENCE_FRAMES; i++) {
405 VAPictureH264 *ref_pic = &pic_param->ReferenceFrames[i];
408 if (ref_pic->flags & VA_PICTURE_H264_INVALID ||
409 ref_pic->picture_id == VA_INVALID_SURFACE ||
410 decode_state->reference_objects[i] == NULL)
413 for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
414 if (frame_store[j].surface_id == ref_pic->picture_id) {
420 /* add the new reference frame into the internal DPB */
424 struct object_surface *obj_surface = decode_state->reference_objects[i];
427 * Sometimes a dummy frame comes from the upper layer library, call i965_check_alloc_surface_bo()
428 * to ake sure the store buffer is allocated for this reference frame
430 i965_check_alloc_surface_bo(ctx, obj_surface, 1, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
434 /* Find a free frame store index */
435 for (j = 0; j < MAX_GEN_REFERENCE_FRAMES; j++) {
436 if (frame_store[j].surface_id == VA_INVALID_ID ||
437 frame_store[j].obj_surface == NULL) {
446 frame_store[j].surface_id = ref_pic->picture_id;
447 frame_store[j].frame_store_id = frame_idx;
448 frame_store[j].obj_surface = obj_surface;
450 WARN_ONCE("Not free slot for DPB reference list!!!\n");
458 intel_update_vc1_frame_store_index(VADriverContextP ctx,
459 struct decode_state *decode_state,
460 VAPictureParameterBufferVC1 *pic_param,
461 GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES])
463 struct object_surface *obj_surface;
466 obj_surface = decode_state->reference_objects[0];
468 if (pic_param->forward_reference_picture == VA_INVALID_ID ||
471 frame_store[0].surface_id = VA_INVALID_ID;
472 frame_store[0].obj_surface = NULL;
474 frame_store[0].surface_id = pic_param->forward_reference_picture;
475 frame_store[0].obj_surface = obj_surface;
478 obj_surface = decode_state->reference_objects[1];
480 if (pic_param->backward_reference_picture == VA_INVALID_ID ||
483 frame_store[1].surface_id = frame_store[0].surface_id;
484 frame_store[1].obj_surface = frame_store[0].obj_surface;
486 frame_store[1].surface_id = pic_param->backward_reference_picture;
487 frame_store[1].obj_surface = obj_surface;
489 for (i = 2; i < MAX_GEN_REFERENCE_FRAMES; i++) {
490 frame_store[i].surface_id = frame_store[i % 2].surface_id;
491 frame_store[i].obj_surface = frame_store[i % 2].obj_surface;
497 intel_update_vp8_frame_store_index(VADriverContextP ctx,
498 struct decode_state *decode_state,
499 VAPictureParameterBufferVP8 *pic_param,
500 GenFrameStore frame_store[MAX_GEN_REFERENCE_FRAMES])
502 struct object_surface *obj_surface;
505 obj_surface = decode_state->reference_objects[0];
507 if (pic_param->last_ref_frame == VA_INVALID_ID ||
510 frame_store[0].surface_id = VA_INVALID_ID;
511 frame_store[0].obj_surface = NULL;
513 frame_store[0].surface_id = pic_param->last_ref_frame;
514 frame_store[0].obj_surface = obj_surface;
517 obj_surface = decode_state->reference_objects[1];
519 if (pic_param->golden_ref_frame == VA_INVALID_ID ||
522 frame_store[1].surface_id = frame_store[0].surface_id;
523 frame_store[1].obj_surface = frame_store[0].obj_surface;
525 frame_store[1].surface_id = pic_param->golden_ref_frame;
526 frame_store[1].obj_surface = obj_surface;
529 obj_surface = decode_state->reference_objects[2];
531 if (pic_param->alt_ref_frame == VA_INVALID_ID ||
534 frame_store[2].surface_id = frame_store[0].surface_id;
535 frame_store[2].obj_surface = frame_store[0].obj_surface;
537 frame_store[2].surface_id = pic_param->alt_ref_frame;
538 frame_store[2].obj_surface = obj_surface;
541 for (i = 3; i < MAX_GEN_REFERENCE_FRAMES; i++) {
542 frame_store[i].surface_id = frame_store[i % 2].surface_id;
543 frame_store[i].obj_surface = frame_store[i % 2].obj_surface;
549 intel_decoder_check_avc_parameter(VADriverContextP ctx,
550 VAProfile h264_profile,
551 struct decode_state *decode_state)
553 struct i965_driver_data *i965 = i965_driver_data(ctx);
554 VAPictureParameterBufferH264 *pic_param = (VAPictureParameterBufferH264 *)decode_state->pic_param->buffer;
555 struct object_surface *obj_surface;
558 assert(!(pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID));
559 assert(pic_param->CurrPic.picture_id != VA_INVALID_SURFACE);
561 if (pic_param->CurrPic.flags & VA_PICTURE_H264_INVALID ||
562 pic_param->CurrPic.picture_id == VA_INVALID_SURFACE)
565 assert(pic_param->CurrPic.picture_id == decode_state->current_render_target);
567 if (pic_param->CurrPic.picture_id != decode_state->current_render_target)
570 if ((h264_profile != VAProfileH264Baseline)) {
571 if (pic_param->num_slice_groups_minus1 ||
572 pic_param->pic_fields.bits.redundant_pic_cnt_present_flag) {
573 WARN_ONCE("Unsupported the FMO/ASO constraints!!!\n");
578 for (i = 0; i < 16; i++) {
579 if (pic_param->ReferenceFrames[i].flags & VA_PICTURE_H264_INVALID ||
580 pic_param->ReferenceFrames[i].picture_id == VA_INVALID_SURFACE)
583 obj_surface = SURFACE(pic_param->ReferenceFrames[i].picture_id);
589 if (!obj_surface->bo) { /* a reference frame without store buffer */
590 WARN_ONCE("Invalid reference frame!!!\n");
593 decode_state->reference_objects[i] = obj_surface;
598 decode_state->reference_objects[i] = NULL;
600 return VA_STATUS_SUCCESS;
603 return VA_STATUS_ERROR_INVALID_PARAMETER;
607 intel_decoder_check_mpeg2_parameter(VADriverContextP ctx,
608 struct decode_state *decode_state)
610 struct i965_driver_data *i965 = i965_driver_data(ctx);
611 VAPictureParameterBufferMPEG2 *pic_param = (VAPictureParameterBufferMPEG2 *)decode_state->pic_param->buffer;
612 struct object_surface *obj_surface;
615 if (pic_param->picture_coding_type == MPEG_I_PICTURE) {
616 } else if (pic_param->picture_coding_type == MPEG_P_PICTURE) {
617 obj_surface = SURFACE(pic_param->forward_reference_picture);
619 if (!obj_surface || !obj_surface->bo)
620 decode_state->reference_objects[i++] = NULL;
622 decode_state->reference_objects[i++] = obj_surface;
623 } else if (pic_param->picture_coding_type == MPEG_B_PICTURE) {
624 obj_surface = SURFACE(pic_param->forward_reference_picture);
626 if (!obj_surface || !obj_surface->bo)
627 decode_state->reference_objects[i++] = NULL;
629 decode_state->reference_objects[i++] = obj_surface;
631 obj_surface = SURFACE(pic_param->backward_reference_picture);
633 if (!obj_surface || !obj_surface->bo)
634 decode_state->reference_objects[i++] = NULL;
636 decode_state->reference_objects[i++] = obj_surface;
641 decode_state->reference_objects[i] = NULL;
643 return VA_STATUS_SUCCESS;
646 return VA_STATUS_ERROR_INVALID_PARAMETER;
650 intel_decoder_check_vc1_parameter(VADriverContextP ctx,
651 struct decode_state *decode_state)
653 struct i965_driver_data *i965 = i965_driver_data(ctx);
654 VAPictureParameterBufferVC1 *pic_param = (VAPictureParameterBufferVC1 *)decode_state->pic_param->buffer;
655 struct object_surface *obj_surface;
658 if (pic_param->picture_fields.bits.picture_type == 0 ||
659 pic_param->picture_fields.bits.picture_type == 3) {
660 } else if (pic_param->picture_fields.bits.picture_type == 1 ||
661 pic_param->picture_fields.bits.picture_type == 4) {
662 obj_surface = SURFACE(pic_param->forward_reference_picture);
664 if (!obj_surface || !obj_surface->bo)
665 decode_state->reference_objects[i++] = NULL;
667 decode_state->reference_objects[i++] = obj_surface;
668 } else if (pic_param->picture_fields.bits.picture_type == 2) {
669 obj_surface = SURFACE(pic_param->forward_reference_picture);
671 if (!obj_surface || !obj_surface->bo)
672 decode_state->reference_objects[i++] = NULL;
674 decode_state->reference_objects[i++] = obj_surface;
676 obj_surface = SURFACE(pic_param->backward_reference_picture);
678 if (!obj_surface || !obj_surface->bo)
679 decode_state->reference_objects[i++] = NULL;
681 decode_state->reference_objects[i++] = obj_surface;
686 decode_state->reference_objects[i] = NULL;
688 return VA_STATUS_SUCCESS;
691 return VA_STATUS_ERROR_INVALID_PARAMETER;
695 intel_decoder_check_vp8_parameter(VADriverContextP ctx,
696 struct decode_state *decode_state)
698 struct i965_driver_data *i965 = i965_driver_data(ctx);
699 VAPictureParameterBufferVP8 *pic_param = (VAPictureParameterBufferVP8 *)decode_state->pic_param->buffer;
700 struct object_surface *obj_surface;
703 if (pic_param->last_ref_frame != VA_INVALID_SURFACE) {
704 obj_surface = SURFACE(pic_param->last_ref_frame);
706 if (obj_surface && obj_surface->bo)
707 decode_state->reference_objects[i++] = obj_surface;
709 decode_state->reference_objects[i++] = NULL;
712 if (pic_param->golden_ref_frame != VA_INVALID_SURFACE) {
713 obj_surface = SURFACE(pic_param->golden_ref_frame);
715 if (obj_surface && obj_surface->bo)
716 decode_state->reference_objects[i++] = obj_surface;
718 decode_state->reference_objects[i++] = NULL;
721 if (pic_param->alt_ref_frame != VA_INVALID_SURFACE) {
722 obj_surface = SURFACE(pic_param->alt_ref_frame);
724 if (obj_surface && obj_surface->bo)
725 decode_state->reference_objects[i++] = obj_surface;
727 decode_state->reference_objects[i++] = NULL;
731 decode_state->reference_objects[i] = NULL;
733 return VA_STATUS_SUCCESS;
737 intel_decoder_sanity_check_input(VADriverContextP ctx,
739 struct decode_state *decode_state)
741 struct i965_driver_data *i965 = i965_driver_data(ctx);
742 struct object_surface *obj_surface;
743 VAStatus vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
745 if (decode_state->current_render_target == VA_INVALID_SURFACE)
748 obj_surface = SURFACE(decode_state->current_render_target);
753 decode_state->render_object = obj_surface;
756 case VAProfileMPEG2Simple:
757 case VAProfileMPEG2Main:
758 vaStatus = intel_decoder_check_mpeg2_parameter(ctx, decode_state);
761 case VAProfileH264ConstrainedBaseline:
762 case VAProfileH264Main:
763 case VAProfileH264High:
764 vaStatus = intel_decoder_check_avc_parameter(ctx, profile, decode_state);
767 case VAProfileVC1Simple:
768 case VAProfileVC1Main:
769 case VAProfileVC1Advanced:
770 vaStatus = intel_decoder_check_vc1_parameter(ctx, decode_state);
773 case VAProfileJPEGBaseline:
774 vaStatus = VA_STATUS_SUCCESS;
777 case VAProfileVP8Version0_3:
778 vaStatus = intel_decoder_check_vp8_parameter(ctx, decode_state);
782 vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
791 * Return the next slice paramter
794 * slice_param: the current slice
795 * *group_idx & *element_idx the current slice position in slice groups
797 * Return the next slice parameter
798 * *group_idx & *element_idx the next slice position in slice groups,
799 * if the next slice is NULL, *group_idx & *element_idx will be ignored
801 VASliceParameterBufferMPEG2 *
802 intel_mpeg2_find_next_slice(struct decode_state *decode_state,
803 VAPictureParameterBufferMPEG2 *pic_param,
804 VASliceParameterBufferMPEG2 *slice_param,
808 VASliceParameterBufferMPEG2 *next_slice_param;
809 unsigned int width_in_mbs = ALIGN(pic_param->horizontal_size, 16) / 16;
810 int j = *group_idx, i = *element_idx + 1;
812 for (; j < decode_state->num_slice_params; j++) {
813 for (; i < decode_state->slice_params[j]->num_elements; i++) {
814 next_slice_param = ((VASliceParameterBufferMPEG2 *)decode_state->slice_params[j]->buffer) + i;
816 if ((next_slice_param->slice_vertical_position * width_in_mbs + next_slice_param->slice_horizontal_position) >=
817 (slice_param->slice_vertical_position * width_in_mbs + slice_param->slice_horizontal_position)) {
821 return next_slice_param;