summaryrefslogtreecommitdiff
path: root/ext/aom
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2018-07-26 11:19:41 -0400
committerOlivier CrĂȘte <olivier.crete@collabora.com>2018-07-26 11:19:41 -0400
commit8908260c1f14e7b3a0d2713e5165595d0513ce33 (patch)
tree85fb39c0f349733b55605057165dab2a35f080cf /ext/aom
parent576c0b2a6915ca22c5948468c8b1b46dfd54539d (diff)
av1enc: Implement latency setting
Diffstat (limited to 'ext/aom')
-rw-r--r--ext/aom/gstav1enc.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/ext/aom/gstav1enc.c b/ext/aom/gstav1enc.c
index efdb1ff1a..934638d48 100644
--- a/ext/aom/gstav1enc.c
+++ b/ext/aom/gstav1enc.c
@@ -185,12 +185,25 @@ gst_av1_enc_finalize (GObject * object)
static void
gst_av1_enc_set_latency (GstAV1Enc * av1enc)
{
- GstClockTime latency =
- gst_util_uint64_scale (av1enc->aom_cfg.g_lag_in_frames, 1 * GST_SECOND,
- 30);
+ GstClockTime latency;
+ gint fps_n, fps_d;
+
+ if (av1enc->input_state->info.fps_n && av1enc->input_state->info.fps_d) {
+ fps_n = av1enc->input_state->info.fps_n;
+ fps_d = av1enc->input_state->info.fps_d;
+ } else {
+ fps_n = 25;
+ fps_d = 1;
+ }
+
+ latency =
+ gst_util_uint64_scale (av1enc->aom_cfg.g_lag_in_frames * GST_SECOND,
+ fps_d, fps_n);
gst_video_encoder_set_latency (GST_VIDEO_ENCODER (av1enc), latency, latency);
- GST_WARNING_OBJECT (av1enc, "Latency unimplemented");
+ GST_DEBUG_OBJECT (av1enc, "Latency set to %" GST_TIME_FORMAT
+ " = %d frames at %d/%d fps ", GST_TIME_ARGS (latency),
+ av1enc->aom_cfg.g_lag_in_frames, fps_n, fps_d);
}
static const gchar *
@@ -275,8 +288,6 @@ gst_av1_enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state)
}
av1enc->input_state = gst_video_codec_state_ref (state);
- gst_av1_enc_set_latency (av1enc);
-
g_mutex_lock (&av1enc->encoder_lock);
if (aom_codec_enc_config_default (av1enc_class->codec_algo, &av1enc->aom_cfg,
0)) {
@@ -287,6 +298,7 @@ gst_av1_enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state)
GST_DEBUG_OBJECT (av1enc, "Got default encoder config");
gst_av1_enc_debug_encoder_cfg (&av1enc->aom_cfg);
+ gst_av1_enc_set_latency (av1enc);
av1enc->aom_cfg.g_w = av1enc->input_state->info.width;
av1enc->aom_cfg.g_h = av1enc->input_state->info.height;