summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@intel.com>2021-07-28 22:48:21 +0800
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2021-09-13 06:37:28 +0000
commit56269d127ff08c4648b168ec7b5a634b31efa4a2 (patch)
tree726a87ea77a7cf72a5bdd48b85f734bf59b83651 /gst-libs
parent3c975ed918808d7d38b1b7a045f679c15b088262 (diff)
downloadgstreamer-plugins-bad-56269d127ff08c4648b168ec7b5a634b31efa4a2.tar.gz
codecs: h264: Change the low_latency to an enum for dpb_needs_bump().
The bool parameter of low_latency is not enough. We have multi policies for low latency bumping, from the safest to something radical. So we need an enum to represent the proper latency requirement. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2432>
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/codecs/gsth264picture.c36
-rw-r--r--gst-libs/gst/codecs/gsth264picture.h17
2 files changed, 34 insertions, 19 deletions
diff --git a/gst-libs/gst/codecs/gsth264picture.c b/gst-libs/gst/codecs/gsth264picture.c
index 544e1d219..a687e338e 100644
--- a/gst-libs/gst/codecs/gsth264picture.c
+++ b/gst-libs/gst/codecs/gsth264picture.c
@@ -698,7 +698,7 @@ gst_h264_dpb_get_lowest_output_needed_picture (GstH264Dpb * dpb,
* gst_h264_dpb_needs_bump:
* @dpb: a #GstH264Dpb
* @to_insert: the current #GstH264Picture to insert to dpb.
- * @low_latency: %TRUE if low-latency bumping is required
+ * @latency_mode: The required #GstH264DpbBumpMode for bumping.
*
* Returns: %TRUE if bumping is required
*
@@ -706,7 +706,7 @@ gst_h264_dpb_get_lowest_output_needed_picture (GstH264Dpb * dpb,
*/
gboolean
gst_h264_dpb_needs_bump (GstH264Dpb * dpb, GstH264Picture * to_insert,
- gboolean low_latency)
+ GstH264DpbBumpMode latency_mode)
{
GstH264Picture *picture = NULL;
gint32 lowest_poc;
@@ -727,7 +727,7 @@ gst_h264_dpb_needs_bump (GstH264Dpb * dpb, GstH264Picture * to_insert,
goto normal_bump;
}
- if (low_latency) {
+ if (latency_mode >= GST_H264_DPB_BUMP_LOW_LATENCY) {
/* If low latency, we should not wait for the DPB becoming full.
We try to bump the picture as soon as possible without the
frames disorder. The policy is from the safe to some risk. */
@@ -809,22 +809,22 @@ gst_h264_dpb_needs_bump (GstH264Dpb * dpb, GstH264Picture * to_insert,
return TRUE;
}
- /* PicOrderCnt increment by <=2. Not all streams meet this, but in
- practice this condition can be used.
- For stream with 2 poc increment like:
- 0(IDR), 2(P), 4(P), 6(P), 12(P), 8(B), 10(B)....
- This can work well, but for streams with 1 poc increment like:
- 0(IDR), 2(P), 4(P), 1(B), 3(B) ...
- This can cause picture disorder. Most stream in practice has the
- 2 poc increment, but this may have risk and be careful. */
-#if 0
- if (lowest_poc > dpb->last_output_poc
- && lowest_poc - dpb->last_output_poc <= 2) {
- GST_TRACE ("lowest-poc: %d, last-output-poc: %d, bumping for"
- " low-latency", lowest_poc, dpb->last_output_poc);
- return TRUE;
+ if (latency_mode >= GST_H264_DPB_BUMP_VERY_LOW_LATENCY) {
+ /* PicOrderCnt increment by <=2. Not all streams meet this, but in
+ practice this condition can be used.
+ For stream with 2 poc increment like:
+ 0(IDR), 2(P), 4(P), 6(P), 12(P), 8(B), 10(B)....
+ This can work well, but for streams with 1 poc increment like:
+ 0(IDR), 2(P), 4(P), 1(B), 3(B) ...
+ This can cause picture disorder. Most stream in practice has the
+ 2 poc increment, but this may have risk and be careful. */
+ if (lowest_poc > dpb->last_output_poc
+ && lowest_poc - dpb->last_output_poc <= 2) {
+ GST_TRACE ("lowest-poc: %d, last-output-poc: %d, diff <= 2, "
+ "bumping for very-low-latency", lowest_poc, dpb->last_output_poc);
+ return TRUE;
+ }
}
-#endif
}
normal_bump:
diff --git a/gst-libs/gst/codecs/gsth264picture.h b/gst-libs/gst/codecs/gsth264picture.h
index d0b914f2c..a028c00b1 100644
--- a/gst-libs/gst/codecs/gsth264picture.h
+++ b/gst-libs/gst/codecs/gsth264picture.h
@@ -164,6 +164,21 @@ struct _GstH264Picture
GDestroyNotify notify;
};
+/**
+ * GstH264DpbBumpMode:
+ * @GST_H264_DPB_BUMP_NORMAL_LATENCY: No latency requirement for DBP bumping.
+ * @GST_H264_DPB_BUMP_LOW_LATENCY: Low-latency requirement for DBP bumping.
+ * @GST_H264_DPB_BUMP_VERY_LOW_LATENCY: Very low-latency requirement for DBP bumping.
+ *
+ * Since: 1.20
+ */
+typedef enum
+{
+ GST_H264_DPB_BUMP_NORMAL_LATENCY,
+ GST_H264_DPB_BUMP_LOW_LATENCY,
+ GST_H264_DPB_BUMP_VERY_LOW_LATENCY
+} GstH264DpbBumpMode;
+
GST_CODECS_API
GType gst_h264_picture_get_type (void);
@@ -290,7 +305,7 @@ gboolean gst_h264_dpb_has_empty_frame_buffer (GstH264Dpb * dpb);
GST_CODECS_API
gboolean gst_h264_dpb_needs_bump (GstH264Dpb * dpb,
GstH264Picture * to_insert,
- gboolean low_latency);
+ GstH264DpbBumpMode latency_mode);
GST_CODECS_API
GstH264Picture * gst_h264_dpb_bump (GstH264Dpb * dpb,