1 /**************************************************************************
3 * Copyright 2010 Thomas Balling Sørensen & Orasanu Lucian.
4 * Copyright 2014 Advanced Micro Devices, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "pipe/p_video_codec.h"
31 #include "util/u_handle_table.h"
32 #include "util/u_video.h"
34 #include "vl/vl_vlc.h"
35 #include "vl/vl_winsys.h"
37 #include "va_private.h"
40 vlVaBeginPicture(VADriverContextP ctx
, VAContextID context_id
, VASurfaceID render_target
)
47 return VA_STATUS_ERROR_INVALID_CONTEXT
;
49 drv
= VL_VA_DRIVER(ctx
);
51 return VA_STATUS_ERROR_INVALID_CONTEXT
;
53 mtx_lock(&drv
->mutex
);
54 context
= handle_table_get(drv
->htab
, context_id
);
56 mtx_unlock(&drv
->mutex
);
57 return VA_STATUS_ERROR_INVALID_CONTEXT
;
60 if (u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_MPEG12
) {
61 context
->desc
.mpeg12
.intra_matrix
= NULL
;
62 context
->desc
.mpeg12
.non_intra_matrix
= NULL
;
65 surf
= handle_table_get(drv
->htab
, render_target
);
66 mtx_unlock(&drv
->mutex
);
67 if (!surf
|| !surf
->buffer
)
68 return VA_STATUS_ERROR_INVALID_SURFACE
;
70 context
->target_id
= render_target
;
71 surf
->ctx
= context_id
;
72 context
->target
= surf
->buffer
;
73 context
->mjpeg
.sampling_factor
= 0;
75 if (!context
->decoder
) {
78 if (context
->templat
.profile
== PIPE_VIDEO_PROFILE_UNKNOWN
&&
79 context
->target
->buffer_format
!= PIPE_FORMAT_B8G8R8A8_UNORM
&&
80 context
->target
->buffer_format
!= PIPE_FORMAT_R8G8B8A8_UNORM
&&
81 context
->target
->buffer_format
!= PIPE_FORMAT_B8G8R8X8_UNORM
&&
82 context
->target
->buffer_format
!= PIPE_FORMAT_R8G8B8X8_UNORM
&&
83 context
->target
->buffer_format
!= PIPE_FORMAT_NV12
&&
84 context
->target
->buffer_format
!= PIPE_FORMAT_P010
&&
85 context
->target
->buffer_format
!= PIPE_FORMAT_P016
)
86 return VA_STATUS_ERROR_UNIMPLEMENTED
;
88 return VA_STATUS_SUCCESS
;
91 if (context
->decoder
->entrypoint
!= PIPE_VIDEO_ENTRYPOINT_ENCODE
)
92 context
->needs_begin_frame
= true;
94 return VA_STATUS_SUCCESS
;
98 vlVaGetReferenceFrame(vlVaDriver
*drv
, VASurfaceID surface_id
,
99 struct pipe_video_buffer
**ref_frame
)
101 vlVaSurface
*surf
= handle_table_get(drv
->htab
, surface_id
);
103 *ref_frame
= surf
->buffer
;
109 handlePictureParameterBuffer(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
111 VAStatus vaStatus
= VA_STATUS_SUCCESS
;
112 enum pipe_video_format format
=
113 u_reduce_video_profile(context
->templat
.profile
);
116 case PIPE_VIDEO_FORMAT_MPEG12
:
117 vlVaHandlePictureParameterBufferMPEG12(drv
, context
, buf
);
120 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
121 vlVaHandlePictureParameterBufferH264(drv
, context
, buf
);
124 case PIPE_VIDEO_FORMAT_VC1
:
125 vlVaHandlePictureParameterBufferVC1(drv
, context
, buf
);
128 case PIPE_VIDEO_FORMAT_MPEG4
:
129 vlVaHandlePictureParameterBufferMPEG4(drv
, context
, buf
);
132 case PIPE_VIDEO_FORMAT_HEVC
:
133 vlVaHandlePictureParameterBufferHEVC(drv
, context
, buf
);
136 case PIPE_VIDEO_FORMAT_JPEG
:
137 vlVaHandlePictureParameterBufferMJPEG(drv
, context
, buf
);
140 case PIPE_VIDEO_FORMAT_VP9
:
141 vlVaHandlePictureParameterBufferVP9(drv
, context
, buf
);
148 /* Create the decoder once max_references is known. */
149 if (!context
->decoder
) {
150 if (!context
->target
)
151 return VA_STATUS_ERROR_INVALID_CONTEXT
;
153 if (context
->templat
.max_references
== 0 &&
154 format
!= PIPE_VIDEO_FORMAT_JPEG
)
155 return VA_STATUS_ERROR_INVALID_BUFFER
;
157 if (format
== PIPE_VIDEO_FORMAT_MPEG4_AVC
)
158 context
->templat
.level
= u_get_h264_level(context
->templat
.width
,
159 context
->templat
.height
, &context
->templat
.max_references
);
161 context
->decoder
= drv
->pipe
->create_video_codec(drv
->pipe
,
164 if (!context
->decoder
)
165 return VA_STATUS_ERROR_ALLOCATION_FAILED
;
167 context
->needs_begin_frame
= true;
170 if (format
== PIPE_VIDEO_FORMAT_VP9
) {
171 context
->decoder
->width
=
172 context
->desc
.vp9
.picture_parameter
.frame_width
;
173 context
->decoder
->height
=
174 context
->desc
.vp9
.picture_parameter
.frame_height
;
181 handleIQMatrixBuffer(vlVaContext
*context
, vlVaBuffer
*buf
)
183 switch (u_reduce_video_profile(context
->templat
.profile
)) {
184 case PIPE_VIDEO_FORMAT_MPEG12
:
185 vlVaHandleIQMatrixBufferMPEG12(context
, buf
);
188 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
189 vlVaHandleIQMatrixBufferH264(context
, buf
);
192 case PIPE_VIDEO_FORMAT_MPEG4
:
193 vlVaHandleIQMatrixBufferMPEG4(context
, buf
);
196 case PIPE_VIDEO_FORMAT_HEVC
:
197 vlVaHandleIQMatrixBufferHEVC(context
, buf
);
200 case PIPE_VIDEO_FORMAT_JPEG
:
201 vlVaHandleIQMatrixBufferMJPEG(context
, buf
);
210 handleSliceParameterBuffer(vlVaContext
*context
, vlVaBuffer
*buf
)
212 switch (u_reduce_video_profile(context
->templat
.profile
)) {
213 case PIPE_VIDEO_FORMAT_MPEG12
:
214 vlVaHandleSliceParameterBufferMPEG12(context
, buf
);
217 case PIPE_VIDEO_FORMAT_VC1
:
218 vlVaHandleSliceParameterBufferVC1(context
, buf
);
221 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
222 vlVaHandleSliceParameterBufferH264(context
, buf
);
225 case PIPE_VIDEO_FORMAT_MPEG4
:
226 vlVaHandleSliceParameterBufferMPEG4(context
, buf
);
229 case PIPE_VIDEO_FORMAT_HEVC
:
230 vlVaHandleSliceParameterBufferHEVC(context
, buf
);
233 case PIPE_VIDEO_FORMAT_JPEG
:
234 vlVaHandleSliceParameterBufferMJPEG(context
, buf
);
237 case PIPE_VIDEO_FORMAT_VP9
:
238 vlVaHandleSliceParameterBufferVP9(context
, buf
);
247 bufHasStartcode(vlVaBuffer
*buf
, unsigned int code
, unsigned int bits
)
249 struct vl_vlc vlc
= {0};
252 /* search the first 64 bytes for a startcode */
253 vl_vlc_init(&vlc
, 1, (const void * const*)&buf
->data
, &buf
->size
);
254 for (i
= 0; i
< 64 && vl_vlc_bits_left(&vlc
) >= bits
; ++i
) {
255 if (vl_vlc_peekbits(&vlc
, bits
) == code
)
257 vl_vlc_eatbits(&vlc
, 8);
258 vl_vlc_fillbits(&vlc
);
265 handleVASliceDataBufferType(vlVaContext
*context
, vlVaBuffer
*buf
)
267 enum pipe_video_format format
;
268 unsigned num_buffers
= 0;
269 void * const *buffers
[3];
271 static const uint8_t start_code_h264
[] = { 0x00, 0x00, 0x01 };
272 static const uint8_t start_code_h265
[] = { 0x00, 0x00, 0x01 };
273 static const uint8_t start_code_vc1
[] = { 0x00, 0x00, 0x01, 0x0d };
274 static const uint8_t eoi_jpeg
[] = { 0xff, 0xd9 };
276 format
= u_reduce_video_profile(context
->templat
.profile
);
278 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
279 if (bufHasStartcode(buf
, 0x000001, 24))
282 buffers
[num_buffers
] = (void *const)&start_code_h264
;
283 sizes
[num_buffers
++] = sizeof(start_code_h264
);
285 case PIPE_VIDEO_FORMAT_HEVC
:
286 if (bufHasStartcode(buf
, 0x000001, 24))
289 buffers
[num_buffers
] = (void *const)&start_code_h265
;
290 sizes
[num_buffers
++] = sizeof(start_code_h265
);
292 case PIPE_VIDEO_FORMAT_VC1
:
293 if (bufHasStartcode(buf
, 0x0000010d, 32) ||
294 bufHasStartcode(buf
, 0x0000010c, 32) ||
295 bufHasStartcode(buf
, 0x0000010b, 32))
298 if (context
->decoder
->profile
== PIPE_VIDEO_PROFILE_VC1_ADVANCED
) {
299 buffers
[num_buffers
] = (void *const)&start_code_vc1
;
300 sizes
[num_buffers
++] = sizeof(start_code_vc1
);
303 case PIPE_VIDEO_FORMAT_MPEG4
:
304 if (bufHasStartcode(buf
, 0x000001, 24))
307 vlVaDecoderFixMPEG4Startcode(context
);
308 buffers
[num_buffers
] = (void *)context
->mpeg4
.start_code
;
309 sizes
[num_buffers
++] = context
->mpeg4
.start_code_size
;
311 case PIPE_VIDEO_FORMAT_JPEG
:
312 vlVaGetJpegSliceHeader(context
);
313 buffers
[num_buffers
] = (void *)context
->mjpeg
.slice_header
;
314 sizes
[num_buffers
++] = context
->mjpeg
.slice_header_size
;
316 case PIPE_VIDEO_FORMAT_VP9
:
317 vlVaDecoderVP9BitstreamHeader(context
, buf
);
323 buffers
[num_buffers
] = buf
->data
;
324 sizes
[num_buffers
] = buf
->size
;
327 if (format
== PIPE_VIDEO_FORMAT_JPEG
) {
328 buffers
[num_buffers
] = (void *const)&eoi_jpeg
;
329 sizes
[num_buffers
++] = sizeof(eoi_jpeg
);
332 if (context
->needs_begin_frame
) {
333 context
->decoder
->begin_frame(context
->decoder
, context
->target
,
334 &context
->desc
.base
);
335 context
->needs_begin_frame
= false;
337 context
->decoder
->decode_bitstream(context
->decoder
, context
->target
, &context
->desc
.base
,
338 num_buffers
, (const void * const*)buffers
, sizes
);
342 handleVAEncMiscParameterTypeRateControl(vlVaContext
*context
, VAEncMiscParameterBuffer
*misc
)
344 VAStatus status
= VA_STATUS_SUCCESS
;
346 switch (u_reduce_video_profile(context
->templat
.profile
)) {
347 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
348 status
= vlVaHandleVAEncMiscParameterTypeRateControlH264(context
, misc
);
351 case PIPE_VIDEO_FORMAT_HEVC
:
352 status
= vlVaHandleVAEncMiscParameterTypeRateControlHEVC(context
, misc
);
363 handleVAEncMiscParameterTypeFrameRate(vlVaContext
*context
, VAEncMiscParameterBuffer
*misc
)
365 VAStatus status
= VA_STATUS_SUCCESS
;
367 switch (u_reduce_video_profile(context
->templat
.profile
)) {
368 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
369 status
= vlVaHandleVAEncMiscParameterTypeFrameRateH264(context
, misc
);
372 case PIPE_VIDEO_FORMAT_HEVC
:
373 status
= vlVaHandleVAEncMiscParameterTypeFrameRateHEVC(context
, misc
);
384 handleVAEncSequenceParameterBufferType(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
386 VAStatus status
= VA_STATUS_SUCCESS
;
388 switch (u_reduce_video_profile(context
->templat
.profile
)) {
389 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
390 status
= vlVaHandleVAEncSequenceParameterBufferTypeH264(drv
, context
, buf
);
393 case PIPE_VIDEO_FORMAT_HEVC
:
394 status
= vlVaHandleVAEncSequenceParameterBufferTypeHEVC(drv
, context
, buf
);
405 handleVAEncMiscParameterBufferType(vlVaContext
*context
, vlVaBuffer
*buf
)
407 VAStatus vaStatus
= VA_STATUS_SUCCESS
;
408 VAEncMiscParameterBuffer
*misc
;
411 switch (misc
->type
) {
412 case VAEncMiscParameterTypeRateControl
:
413 vaStatus
= handleVAEncMiscParameterTypeRateControl(context
, misc
);
416 case VAEncMiscParameterTypeFrameRate
:
417 vaStatus
= handleVAEncMiscParameterTypeFrameRate(context
, misc
);
428 handleVAEncPictureParameterBufferType(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
430 VAStatus status
= VA_STATUS_SUCCESS
;
432 switch (u_reduce_video_profile(context
->templat
.profile
)) {
433 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
434 status
= vlVaHandleVAEncPictureParameterBufferTypeH264(drv
, context
, buf
);
437 case PIPE_VIDEO_FORMAT_HEVC
:
438 status
= vlVaHandleVAEncPictureParameterBufferTypeHEVC(drv
, context
, buf
);
449 handleVAEncSliceParameterBufferType(vlVaDriver
*drv
, vlVaContext
*context
, vlVaBuffer
*buf
)
451 VAStatus status
= VA_STATUS_SUCCESS
;
453 switch (u_reduce_video_profile(context
->templat
.profile
)) {
454 case PIPE_VIDEO_FORMAT_MPEG4_AVC
:
455 status
= vlVaHandleVAEncSliceParameterBufferTypeH264(drv
, context
, buf
);
458 case PIPE_VIDEO_FORMAT_HEVC
:
459 status
= vlVaHandleVAEncSliceParameterBufferTypeHEVC(drv
, context
, buf
);
470 vlVaRenderPicture(VADriverContextP ctx
, VAContextID context_id
, VABufferID
*buffers
, int num_buffers
)
473 vlVaContext
*context
;
474 VAStatus vaStatus
= VA_STATUS_SUCCESS
;
479 return VA_STATUS_ERROR_INVALID_CONTEXT
;
481 drv
= VL_VA_DRIVER(ctx
);
483 return VA_STATUS_ERROR_INVALID_CONTEXT
;
485 mtx_lock(&drv
->mutex
);
486 context
= handle_table_get(drv
->htab
, context_id
);
488 mtx_unlock(&drv
->mutex
);
489 return VA_STATUS_ERROR_INVALID_CONTEXT
;
492 for (i
= 0; i
< num_buffers
; ++i
) {
493 vlVaBuffer
*buf
= handle_table_get(drv
->htab
, buffers
[i
]);
495 mtx_unlock(&drv
->mutex
);
496 return VA_STATUS_ERROR_INVALID_BUFFER
;
500 case VAPictureParameterBufferType
:
501 vaStatus
= handlePictureParameterBuffer(drv
, context
, buf
);
504 case VAIQMatrixBufferType
:
505 handleIQMatrixBuffer(context
, buf
);
508 case VASliceParameterBufferType
:
509 handleSliceParameterBuffer(context
, buf
);
512 case VASliceDataBufferType
:
513 handleVASliceDataBufferType(context
, buf
);
515 case VAProcPipelineParameterBufferType
:
516 vaStatus
= vlVaHandleVAProcPipelineParameterBufferType(drv
, context
, buf
);
519 case VAEncSequenceParameterBufferType
:
520 vaStatus
= handleVAEncSequenceParameterBufferType(drv
, context
, buf
);
523 case VAEncMiscParameterBufferType
:
524 vaStatus
= handleVAEncMiscParameterBufferType(context
, buf
);
527 case VAEncPictureParameterBufferType
:
528 vaStatus
= handleVAEncPictureParameterBufferType(drv
, context
, buf
);
531 case VAEncSliceParameterBufferType
:
532 vaStatus
= handleVAEncSliceParameterBufferType(drv
, context
, buf
);
535 case VAHuffmanTableBufferType
:
536 vlVaHandleHuffmanTableBufferType(context
, buf
);
543 mtx_unlock(&drv
->mutex
);
549 vlVaEndPicture(VADriverContextP ctx
, VAContextID context_id
)
552 vlVaContext
*context
;
553 vlVaBuffer
*coded_buf
;
556 struct pipe_screen
*screen
;
558 bool realloc
= false;
559 enum pipe_format format
;
562 return VA_STATUS_ERROR_INVALID_CONTEXT
;
564 drv
= VL_VA_DRIVER(ctx
);
566 return VA_STATUS_ERROR_INVALID_CONTEXT
;
568 mtx_lock(&drv
->mutex
);
569 context
= handle_table_get(drv
->htab
, context_id
);
570 mtx_unlock(&drv
->mutex
);
572 return VA_STATUS_ERROR_INVALID_CONTEXT
;
574 if (!context
->decoder
) {
575 if (context
->templat
.profile
!= PIPE_VIDEO_PROFILE_UNKNOWN
)
576 return VA_STATUS_ERROR_INVALID_CONTEXT
;
579 return VA_STATUS_SUCCESS
;
582 mtx_lock(&drv
->mutex
);
583 surf
= handle_table_get(drv
->htab
, context
->target_id
);
584 context
->mpeg4
.frame_num
++;
586 screen
= context
->decoder
->context
->screen
;
587 supported
= screen
->get_video_param(screen
, context
->decoder
->profile
,
588 context
->decoder
->entrypoint
,
589 surf
->buffer
->interlaced
?
590 PIPE_VIDEO_CAP_SUPPORTS_INTERLACED
:
591 PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE
);
594 surf
->templat
.interlaced
= screen
->get_video_param(screen
,
595 context
->decoder
->profile
,
596 context
->decoder
->entrypoint
,
597 PIPE_VIDEO_CAP_PREFERS_INTERLACED
);
601 format
= screen
->get_video_param(screen
, context
->decoder
->profile
,
602 PIPE_VIDEO_ENTRYPOINT_BITSTREAM
,
603 PIPE_VIDEO_CAP_PREFERED_FORMAT
);
605 if (surf
->buffer
->buffer_format
!= format
&&
606 surf
->buffer
->buffer_format
== PIPE_FORMAT_NV12
) {
607 /* check originally as NV12 only */
608 surf
->templat
.buffer_format
= format
;
612 if (u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_JPEG
&&
613 surf
->buffer
->buffer_format
== PIPE_FORMAT_NV12
) {
614 if (context
->mjpeg
.sampling_factor
== 0x211111 ||
615 context
->mjpeg
.sampling_factor
== 0x221212) {
616 surf
->templat
.buffer_format
= PIPE_FORMAT_YUYV
;
618 } else if (context
->mjpeg
.sampling_factor
!= 0x221111) {
619 /* Not NV12 either */
620 mtx_unlock(&drv
->mutex
);
621 return VA_STATUS_ERROR_INVALID_SURFACE
;
626 struct pipe_video_buffer
*old_buf
= surf
->buffer
;
628 if (vlVaHandleSurfaceAllocate(drv
, surf
, &surf
->templat
) != VA_STATUS_SUCCESS
) {
629 mtx_unlock(&drv
->mutex
);
630 return VA_STATUS_ERROR_ALLOCATION_FAILED
;
633 if (context
->decoder
->entrypoint
== PIPE_VIDEO_ENTRYPOINT_ENCODE
) {
634 if (old_buf
->interlaced
) {
635 struct u_rect src_rect
, dst_rect
;
637 dst_rect
.x0
= src_rect
.x0
= 0;
638 dst_rect
.y0
= src_rect
.y0
= 0;
639 dst_rect
.x1
= src_rect
.x1
= surf
->templat
.width
;
640 dst_rect
.y1
= src_rect
.y1
= surf
->templat
.height
;
641 vl_compositor_yuv_deint_full(&drv
->cstate
, &drv
->compositor
,
642 old_buf
, surf
->buffer
,
643 &src_rect
, &dst_rect
, VL_COMPOSITOR_WEAVE
);
645 /* Can't convert from progressive to interlaced yet */
646 mtx_unlock(&drv
->mutex
);
647 return VA_STATUS_ERROR_INVALID_SURFACE
;
651 old_buf
->destroy(old_buf
);
652 context
->target
= surf
->buffer
;
655 if (context
->decoder
->entrypoint
== PIPE_VIDEO_ENTRYPOINT_ENCODE
) {
656 coded_buf
= context
->coded_buf
;
657 if (u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_MPEG4_AVC
) {
658 getEncParamPresetH264(context
);
659 context
->desc
.h264enc
.frame_num_cnt
++;
660 } else if (u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_HEVC
)
661 getEncParamPresetH265(context
);
662 context
->decoder
->begin_frame(context
->decoder
, context
->target
, &context
->desc
.base
);
663 context
->decoder
->encode_bitstream(context
->decoder
, context
->target
,
664 coded_buf
->derived_surface
.resource
, &feedback
);
665 surf
->feedback
= feedback
;
666 surf
->coded_buf
= coded_buf
;
669 context
->decoder
->end_frame(context
->decoder
, context
->target
, &context
->desc
.base
);
670 if (context
->decoder
->entrypoint
== PIPE_VIDEO_ENTRYPOINT_ENCODE
&&
671 u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_MPEG4_AVC
) {
672 int idr_period
= context
->desc
.h264enc
.gop_size
/ context
->gop_coeff
;
673 int p_remain_in_idr
= idr_period
- context
->desc
.h264enc
.frame_num
;
674 surf
->frame_num_cnt
= context
->desc
.h264enc
.frame_num_cnt
;
675 surf
->force_flushed
= false;
676 if (context
->first_single_submitted
) {
677 context
->decoder
->flush(context
->decoder
);
678 context
->first_single_submitted
= false;
679 surf
->force_flushed
= true;
681 if (p_remain_in_idr
== 1) {
682 if ((context
->desc
.h264enc
.frame_num_cnt
% 2) != 0) {
683 context
->decoder
->flush(context
->decoder
);
684 context
->first_single_submitted
= true;
687 context
->first_single_submitted
= false;
688 surf
->force_flushed
= true;
690 } else if (context
->decoder
->entrypoint
== PIPE_VIDEO_ENTRYPOINT_ENCODE
&&
691 u_reduce_video_profile(context
->templat
.profile
) == PIPE_VIDEO_FORMAT_HEVC
)
692 context
->desc
.h265enc
.frame_num
++;
693 mtx_unlock(&drv
->mutex
);
694 return VA_STATUS_SUCCESS
;