summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-07-05 20:07:15 +0200
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2016-08-10 12:20:48 +0200
commit4259d1aec7b046a992ad908804949d2167706280 (patch)
tree8699683c7148d56e669289ff4a25f96c5b130419
parentf182b8be2ba05965e6d31a4d380d6563b9b53a77 (diff)
vaapiencode: h264,h265: validate fps numerator
Validate that fps numerator is non-zero so it can be used to calculate the duration of the B frame. Also it gst_util_uint64_scale() is used instead of normal arithmetic in order to aviod overflows, underflows and loss of precision. https://bugzilla.gnome.org/show_bug.cgi?id=768458
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_h264.c8
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder_h265.c8
2 files changed, 8 insertions, 8 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
index 0b2878d5..9aa35e29 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264.c
@@ -2467,11 +2467,11 @@ reset_properties (GstVaapiEncoderH264 * encoder)
encoder->num_bframes = 0;
}
- if (encoder->num_bframes)
- encoder->cts_offset = GST_SECOND * GST_VAAPI_ENCODER_FPS_D (encoder) /
- GST_VAAPI_ENCODER_FPS_N (encoder);
+ if (encoder->num_bframes > 0 && GST_VAAPI_ENCODER_FPS_N (encoder) > 0)
+ encoder->cts_offset = gst_util_uint64_scale (GST_SECOND,
+ GST_VAAPI_ENCODER_FPS_D (encoder), GST_VAAPI_ENCODER_FPS_N (encoder));
else
- encoder->cts_offset = 0;
+ encoder->cts_offset = GST_CLOCK_TIME_NONE;
/* init max_frame_num, max_poc */
encoder->log2_max_frame_num =
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
index 739feed4..5d015baa 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder_h265.c
@@ -2030,11 +2030,11 @@ reset_properties (GstVaapiEncoderH265 * encoder)
if (encoder->num_bframes > (base_encoder->keyframe_period + 1) / 2)
encoder->num_bframes = (base_encoder->keyframe_period + 1) / 2;
- if (encoder->num_bframes)
- encoder->cts_offset = GST_SECOND * GST_VAAPI_ENCODER_FPS_D (encoder) /
- GST_VAAPI_ENCODER_FPS_N (encoder);
+ if (encoder->num_bframes > 0 && GST_VAAPI_ENCODER_FPS_N (encoder) > 0)
+ encoder->cts_offset = gst_util_uint64_scale (GST_SECOND,
+ GST_VAAPI_ENCODER_FPS_D (encoder), GST_VAAPI_ENCODER_FPS_N (encoder));
else
- encoder->cts_offset = 0;
+ encoder->cts_offset = GST_CLOCK_TIME_NONE;
/* init max_poc */
encoder->log2_max_pic_order_cnt =