summaryrefslogtreecommitdiff
path: root/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon@igalia.com>2017-02-07 16:17:39 +0900
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-02-07 11:48:13 +0100
commitde29f03361cd1c55195322be571582c3d4d0392b (patch)
treeb189e525ed2884b6568bb9e26f6f0c6557651a27 /gst-libs/gst/vaapi/gstvaapidecoder_h264.c
parent7f69f679b12a042d09fe22845cca5a26ae800856 (diff)
libs: decoder: h264: reduce frame number of gaps
Reduce frame num gaps so that we don't have to create unnecessary dummy pictures, just throw them away. Signed-off-by: Víctor Manuel Jáquez Leal <victorx.jaquez@intel.com> https://bugzilla.gnome.org/show_bug.cgi?id=777506
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapidecoder_h264.c')
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_h264.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
index 1d33a1f2..c349b3f6 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_h264.c
@@ -3116,6 +3116,7 @@ fill_picture_gaps (GstVaapiDecoderH264 * decoder, GstVaapiPictureH264 * picture,
GstVaapiDecoderH264Private *const priv = &decoder->priv;
GstH264SPS *const sps = get_sps (decoder);
const gint32 MaxFrameNum = 1 << (sps->log2_max_frame_num_minus4 + 4);
+ gint32 prev_frame_num;
GstVaapiFrameStore *prev_frame;
GstVaapiPicture *base_picture;
GstVaapiPictureH264 *lost_picture, *prev_picture;
@@ -3143,8 +3144,20 @@ fill_picture_gaps (GstVaapiDecoderH264 * decoder, GstVaapiPictureH264 * picture,
lost_slice_hdr.dec_ref_pic_marking.adaptive_ref_pic_marking_mode_flag = 0;
/* XXX: this process is incorrect for MVC */
- /* XXX: optimize to reduce the number of dummy pictures created */
- priv->frame_num = priv->prev_ref_frame_num;
+ /* Reduce frame num gaps so we don't have to create unnecessary
+ * dummy pictures */
+ prev_frame_num = priv->prev_ref_frame_num;
+ if (prev_frame_num > slice_hdr->frame_num)
+ prev_frame_num -= MaxFrameNum;
+
+ if ((slice_hdr->frame_num - prev_frame_num) - 1 > sps->num_ref_frames) {
+ prev_frame_num = (slice_hdr->frame_num - sps->num_ref_frames) - 1;
+
+ if (prev_frame_num < 0)
+ prev_frame_num += MaxFrameNum;
+ }
+ priv->frame_num = prev_frame_num;
+
for (;;) {
priv->prev_ref_frame_num = priv->frame_num;
priv->frame_num = (priv->prev_ref_frame_num + 1) % MaxFrameNum;