mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 23:58:17 +00:00
codecs: h264decoder: Fix possible GstH264Picture leak and small cleanup
Don't leak pictures when dpb is full unexpectedly. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1527>
This commit is contained in:
parent
95e007ac49
commit
25c87a1315
1 changed files with 7 additions and 7 deletions
|
@ -1351,7 +1351,7 @@ gst_h264_decoder_handle_memory_management_opt (GstH264Decoder * self,
|
||||||
GstH264Picture * picture)
|
GstH264Picture * picture)
|
||||||
{
|
{
|
||||||
GstH264DecoderPrivate *priv = self->priv;
|
GstH264DecoderPrivate *priv = self->priv;
|
||||||
gint i;
|
gint i, j;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (picture->dec_ref_pic_marking.ref_pic_marking);
|
for (i = 0; i < G_N_ELEMENTS (picture->dec_ref_pic_marking.ref_pic_marking);
|
||||||
i++) {
|
i++) {
|
||||||
|
@ -1410,14 +1410,13 @@ gst_h264_decoder_handle_memory_management_opt (GstH264Decoder * self,
|
||||||
|
|
||||||
case 4:{
|
case 4:{
|
||||||
GArray *pictures = gst_h264_dpb_get_pictures_all (priv->dpb);
|
GArray *pictures = gst_h264_dpb_get_pictures_all (priv->dpb);
|
||||||
gint i;
|
|
||||||
|
|
||||||
/* Unmark all reference pictures with long_term_frame_idx over new max */
|
/* Unmark all reference pictures with long_term_frame_idx over new max */
|
||||||
priv->max_long_term_frame_idx =
|
priv->max_long_term_frame_idx =
|
||||||
ref_pic_marking->max_long_term_frame_idx_plus1 - 1;
|
ref_pic_marking->max_long_term_frame_idx_plus1 - 1;
|
||||||
|
|
||||||
for (i = 0; i < pictures->len; i++) {
|
for (j = 0; j < pictures->len; j++) {
|
||||||
GstH264Picture *pic = g_array_index (pictures, GstH264Picture *, i);
|
GstH264Picture *pic = g_array_index (pictures, GstH264Picture *, j);
|
||||||
if (pic->long_term &&
|
if (pic->long_term &&
|
||||||
pic->long_term_frame_idx > priv->max_long_term_frame_idx)
|
pic->long_term_frame_idx > priv->max_long_term_frame_idx)
|
||||||
pic->ref = FALSE;
|
pic->ref = FALSE;
|
||||||
|
@ -1436,13 +1435,12 @@ gst_h264_decoder_handle_memory_management_opt (GstH264Decoder * self,
|
||||||
|
|
||||||
case 6:{
|
case 6:{
|
||||||
GArray *pictures = gst_h264_dpb_get_pictures_all (priv->dpb);
|
GArray *pictures = gst_h264_dpb_get_pictures_all (priv->dpb);
|
||||||
gint i;
|
|
||||||
|
|
||||||
/* Replace long term reference pictures with current picture.
|
/* Replace long term reference pictures with current picture.
|
||||||
* First unmark if any existing with this long_term_frame_idx... */
|
* First unmark if any existing with this long_term_frame_idx... */
|
||||||
|
|
||||||
for (i = 0; i < pictures->len; i++) {
|
for (j = 0; j < pictures->len; j++) {
|
||||||
GstH264Picture *pic = g_array_index (pictures, GstH264Picture *, i);
|
GstH264Picture *pic = g_array_index (pictures, GstH264Picture *, j);
|
||||||
|
|
||||||
if (pic->long_term &&
|
if (pic->long_term &&
|
||||||
pic->long_term_frame_idx == ref_pic_marking->long_term_frame_idx)
|
pic->long_term_frame_idx == ref_pic_marking->long_term_frame_idx)
|
||||||
|
@ -1693,6 +1691,8 @@ gst_h264_decoder_finish_picture (GstH264Decoder * self,
|
||||||
/* If we haven't managed to output anything to free up space in DPB
|
/* If we haven't managed to output anything to free up space in DPB
|
||||||
* to store this picture, it's an error in the stream */
|
* to store this picture, it's an error in the stream */
|
||||||
GST_WARNING_OBJECT (self, "Could not free up space in DPB");
|
GST_WARNING_OBJECT (self, "Could not free up space in DPB");
|
||||||
|
|
||||||
|
g_array_set_size (not_outputted, 0);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue