mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
va: vp9enc: Set preferred_output_delay value to increase performance
Also calculate the correct latency. In live mode, preferred_output_delay is disabled. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4359>
This commit is contained in:
parent
47db542689
commit
ba2b053444
1 changed files with 23 additions and 1 deletions
|
@ -2096,13 +2096,15 @@ gst_va_vp9_enc_reconfig (GstVaBaseEnc * base)
|
||||||
VAProfile profile;
|
VAProfile profile;
|
||||||
gboolean do_renegotiation = TRUE, do_reopen, need_negotiation;
|
gboolean do_renegotiation = TRUE, do_reopen, need_negotiation;
|
||||||
guint max_ref_frames, max_surfaces = 0,
|
guint max_ref_frames, max_surfaces = 0,
|
||||||
rt_format, depth = 0, chrome = 0, codedbuf_size;
|
rt_format, depth = 0, chrome = 0, codedbuf_size, latency_num;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
GstClockTime latency;
|
||||||
|
|
||||||
width = GST_VIDEO_INFO_WIDTH (&base->in_info);
|
width = GST_VIDEO_INFO_WIDTH (&base->in_info);
|
||||||
height = GST_VIDEO_INFO_HEIGHT (&base->in_info);
|
height = GST_VIDEO_INFO_HEIGHT (&base->in_info);
|
||||||
format = GST_VIDEO_INFO_FORMAT (&base->in_info);
|
format = GST_VIDEO_INFO_FORMAT (&base->in_info);
|
||||||
codedbuf_size = base->codedbuf_size;
|
codedbuf_size = base->codedbuf_size;
|
||||||
|
latency_num = base->preferred_output_delay + self->gop.gf_group_size - 1;
|
||||||
|
|
||||||
need_negotiation =
|
need_negotiation =
|
||||||
!gst_va_encoder_get_reconstruct_pool_config (base->encoder, &reconf_caps,
|
!gst_va_encoder_get_reconstruct_pool_config (base->encoder, &reconf_caps,
|
||||||
|
@ -2135,6 +2137,13 @@ gst_va_vp9_enc_reconfig (GstVaBaseEnc * base)
|
||||||
|
|
||||||
gst_va_base_enc_reset_state (base);
|
gst_va_base_enc_reset_state (base);
|
||||||
|
|
||||||
|
if (base->is_live) {
|
||||||
|
base->preferred_output_delay = 0;
|
||||||
|
} else {
|
||||||
|
/* FIXME: An experience value for most of the platforms. */
|
||||||
|
base->preferred_output_delay = 4;
|
||||||
|
}
|
||||||
|
|
||||||
base->profile = profile;
|
base->profile = profile;
|
||||||
base->rt_format = rt_format;
|
base->rt_format = rt_format;
|
||||||
self->depth = depth;
|
self->depth = depth;
|
||||||
|
@ -2168,7 +2177,20 @@ gst_va_vp9_enc_reconfig (GstVaBaseEnc * base)
|
||||||
if (!_vp9_init_packed_headers (self))
|
if (!_vp9_init_packed_headers (self))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
/* Let the downstream know the new latency. */
|
||||||
|
if (latency_num != base->preferred_output_delay + self->gop.gf_group_size - 1) {
|
||||||
|
need_negotiation = TRUE;
|
||||||
|
latency_num = base->preferred_output_delay + self->gop.gf_group_size - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the latency */
|
||||||
|
latency = gst_util_uint64_scale (latency_num,
|
||||||
|
GST_VIDEO_INFO_FPS_D (&base->input_state->info) * GST_SECOND,
|
||||||
|
GST_VIDEO_INFO_FPS_N (&base->input_state->info));
|
||||||
|
gst_video_encoder_set_latency (venc, latency, latency);
|
||||||
|
|
||||||
max_ref_frames = GST_VP9_REF_FRAMES + 3 /* scratch frames */ ;
|
max_ref_frames = GST_VP9_REF_FRAMES + 3 /* scratch frames */ ;
|
||||||
|
max_ref_frames += base->preferred_output_delay;
|
||||||
|
|
||||||
/* second check after calculations */
|
/* second check after calculations */
|
||||||
do_reopen |=
|
do_reopen |=
|
||||||
|
|
Loading…
Reference in a new issue