summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBoyuan Zhang <[email protected]>2016-11-29 13:27:10 -0500
committerLeo Liu <[email protected]>2016-12-05 09:23:38 -0500
commit8206882392c9cc070e21d6fbc90368c94235d8cd (patch)
tree61b8eddb1b2816fd672dc142b6ddb145a78e15d0 /src
parent7b811c362a0b0cfb9a8c503cacf9be57d1ed2c7a (diff)
st/va: force to submit two consecutive single jobs
The gop_size in rate control is the budget window for internal rate control calculation, and shouldn't always equal to idr period. Define a coefficient to let budget window contains a number of idr period for proper rate control calculation. Adjust the number of i/p frame remaining accordingly. v2: fixed regression issues introduced by previous version Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=98005 Signed-off-by: Boyuan Zhang <[email protected]> Acked-by: Christian König <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/va/picture.c24
-rw-r--r--src/gallium/state_trackers/va/surface.c8
-rw-r--r--src/gallium/state_trackers/va/va_private.h2
3 files changed, 27 insertions, 7 deletions
diff --git a/src/gallium/state_trackers/va/picture.c b/src/gallium/state_trackers/va/picture.c
index a8102a4284d..592cdefc46c 100644
--- a/src/gallium/state_trackers/va/picture.c
+++ b/src/gallium/state_trackers/va/picture.c
@@ -413,7 +413,6 @@ handleVAEncPictureParameterBufferType(vlVaDriver *drv, vlVaContext *context, vlV
context->desc.h264enc.quant_i_frames = h264->pic_init_qp;
context->desc.h264enc.quant_b_frames = h264->pic_init_qp;
context->desc.h264enc.quant_p_frames = h264->pic_init_qp;
- context->desc.h264enc.frame_num_cnt++;
context->desc.h264enc.gop_cnt++;
if (context->desc.h264enc.gop_cnt == context->desc.h264enc.gop_size)
context->desc.h264enc.gop_cnt = 0;
@@ -569,18 +568,33 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
coded_buf = context->coded_buf;
getEncParamPreset(context);
+ context->desc.h264enc.frame_num_cnt++;
context->decoder->begin_frame(context->decoder, context->target, &context->desc.base);
context->decoder->encode_bitstream(context->decoder, context->target,
coded_buf->derived_surface.resource, &feedback);
- surf->frame_num_cnt = context->desc.h264enc.frame_num_cnt;
surf->feedback = feedback;
surf->coded_buf = coded_buf;
}
context->decoder->end_frame(context->decoder, context->target, &context->desc.base);
- if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE &&
- context->desc.h264enc.p_remain == 1)
- context->decoder->flush(context->decoder);
+ if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
+ surf->frame_num_cnt = context->desc.h264enc.frame_num_cnt;
+ surf->force_flushed = false;
+ if (context->first_single_submitted) {
+ context->decoder->flush(context->decoder);
+ context->first_single_submitted = false;
+ surf->force_flushed = true;
+ }
+ if (context->desc.h264enc.p_remain == 1) {
+ if ((context->desc.h264enc.frame_num_cnt % 2) != 0) {
+ context->decoder->flush(context->decoder);
+ context->first_single_submitted = true;
+ }
+ else
+ context->first_single_submitted = false;
+ surf->force_flushed = true;
+ }
+ }
pipe_mutex_unlock(drv->mutex);
return VA_STATUS_SUCCESS;
}
diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c
index f8513d93e02..38b31516adc 100644
--- a/src/gallium/state_trackers/va/surface.c
+++ b/src/gallium/state_trackers/va/surface.c
@@ -125,12 +125,16 @@ vlVaSyncSurface(VADriverContextP ctx, VASurfaceID render_target)
if (context->decoder->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE) {
int frame_diff;
- if (context->desc.h264enc.frame_num_cnt > surf->frame_num_cnt)
+ if (context->desc.h264enc.frame_num_cnt >= surf->frame_num_cnt)
frame_diff = context->desc.h264enc.frame_num_cnt - surf->frame_num_cnt;
else
frame_diff = 0xFFFFFFFF - surf->frame_num_cnt + 1 + context->desc.h264enc.frame_num_cnt;
- if (frame_diff < 2)
+ if ((frame_diff == 0) &&
+ (surf->force_flushed == false) &&
+ (context->desc.h264enc.frame_num_cnt % 2 != 0)) {
context->decoder->flush(context->decoder);
+ context->first_single_submitted = true;
+ }
context->decoder->get_feedback(context->decoder, surf->feedback, &(surf->coded_buf->coded_size));
surf->feedback = NULL;
}
diff --git a/src/gallium/state_trackers/va/va_private.h b/src/gallium/state_trackers/va/va_private.h
index c9a6a41f7d7..9e3ba038778 100644
--- a/src/gallium/state_trackers/va/va_private.h
+++ b/src/gallium/state_trackers/va/va_private.h
@@ -244,6 +244,7 @@ typedef struct {
struct vl_deint_filter *deint;
struct vlVaBuffer *coded_buf;
int target_id;
+ bool first_single_submitted;
} vlVaContext;
typedef struct {
@@ -274,6 +275,7 @@ typedef struct {
vlVaBuffer *coded_buf;
void *feedback;
unsigned int frame_num_cnt;
+ bool force_flushed;
} vlVaSurface;
// Public functions: