After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665355 - [basevideodecoder] deletes frame but keeps it in list
[basevideodecoder] deletes frame but keeps it in list
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
0.11.x
Other Mac OS
: Normal major
: 0.11.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 654529 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-12-02 02:20 UTC by Matej Knopp
Modified: 2012-02-18 20:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.89 KB, patch)
2011-12-02 02:21 UTC, Matej Knopp
needs-work Details | Review
Ref codec data (1.38 KB, patch)
2011-12-02 17:00 UTC, Matej Knopp
committed Details | Review
Remove frame from list before freeing it (1.01 KB, patch)
2011-12-02 17:01 UTC, Matej Knopp
rejected Details | Review
Make GstFrameState a GstMiniObject (9.47 KB, patch)
2011-12-02 19:24 UTC, Matej Knopp
none Details | Review
Make GstFrameState a ref counted boxed type (10.67 KB, patch)
2011-12-05 18:52 UTC, Matej Knopp
committed Details | Review
Rename GstVideoFrameState to GstBaseVideoCodecFrame (27.69 KB, patch)
2011-12-05 18:52 UTC, Matej Knopp
rejected Details | Review

Description Matej Knopp 2011-12-02 02:20:48 UTC
In gst_base_video_decoder_reset the decoder frees base_video_decoder->current_frame but the frame instance remains in base_video_codec's frames list. Attached patch removes frame from the list.

I'm not quite sure however why the frames are kept in base_video_codec's frame list after flush anyway (the codec only clears the list on state change)
Comment 1 Matej Knopp 2011-12-02 02:21:40 UTC
Created attachment 202566 [details] [review]
Patch
Comment 2 Matej Knopp 2011-12-02 03:20:11 UTC
Now I realized that the patch contains fix for another issue which I haven't created bug report for.
BaseVideoDecoder doesn't increase codec_data refcount when it keeps reference to it in GstVideoState, but later gets rid of it using gst_buffer_replace, which unrefs the buffer.
Comment 3 Sebastian Dröge (slomo) 2011-12-02 08:08:59 UTC
The codec_data changes look correct but the frame one doesn't. Look at the code, there are some FIXME comments about handling of the frames list, in theory all frames should be cleared in _reset() for example but this can't be done because the subclass might still hold references to the frames.

The solution would be to introduce a new refcounted type for the frames and then clear the frames in _reset() and elsewhere.
Comment 4 Sebastian Dröge (slomo) 2011-12-02 08:09:50 UTC
Comment on attachment 202566 [details] [review]
Patch

Could you split the codec_data fix and the other one?
Comment 5 Matej Knopp 2011-12-02 14:22:19 UTC
I'll submit the patches later. I mentioned it in first comment that the fix is probably not entirely correct, but at least it fixes the crash and doesn't leave reference to deleted frame in the list. 

Perhaps the frame could be a GstMiniObject?
Comment 6 Matej Knopp 2011-12-02 17:00:45 UTC
Created attachment 202633 [details] [review]
Ref codec data
Comment 7 Matej Knopp 2011-12-02 17:01:24 UTC
Created attachment 202635 [details] [review]
Remove frame from list before freeing it
Comment 8 Matej Knopp 2011-12-02 19:24:35 UTC
Created attachment 202647 [details] [review]
Make GstFrameState a GstMiniObject
Comment 9 Matej Knopp 2011-12-02 19:26:21 UTC
Latest patch does implements counting on GstFrameState, is this better?
Comment 10 Sebastian Dröge (slomo) 2011-12-05 08:50:24 UTC
The refcounting change is also valid for GStreamer 0.10. Could you provide patches for both versions?

While we're at it, GstVideoFrameState should be renamed to GstBaseVideoCodecFrame or something like that. Also, please free all frames when resetting the decoder (and encoder), not only the current frame. Also I'm not sure if it would be better to have a simple, boxed type with refcounting instead of a mini object. Might be easier for bindings
Comment 11 Matej Knopp 2011-12-05 10:12:39 UTC
I do remove all frames in gst_base_video_decoder_clear_queues. 
+  g_list_foreach (GST_BASE_VIDEO_CODEC (dec)->frames,
+      (GFunc) gst_video_frame_state_unref, NULL);
+  g_list_free (GST_BASE_VIDEO_CODEC (dec)->frames);
+  GST_BASE_VIDEO_CODEC (dec)->frames = NULL;
I don't do it for encoder though.
Comment 12 Matej Knopp 2011-12-05 18:52:06 UTC
Created attachment 202859 [details] [review]
Make GstFrameState a ref counted boxed type

This patch does clear the stored frames in both encoder and decoder
Comment 13 Matej Knopp 2011-12-05 18:52:44 UTC
Created attachment 202860 [details] [review]
Rename GstVideoFrameState to GstBaseVideoCodecFrame
Comment 14 Matej Knopp 2011-12-05 19:03:27 UTC
I'll add a patch for 0.10 if I have time later.
Comment 15 Matej Knopp 2011-12-10 01:03:19 UTC
Review of attachment 202635 [details] [review]:

superseded by the ref-count patch.
Comment 16 Matej Knopp 2011-12-10 01:03:21 UTC
Review of attachment 202635 [details] [review]:

superseded by the ref-count patch.
Comment 17 Sebastian Dröge (slomo) 2011-12-12 13:14:46 UTC
That's your patch adapter for 0.10:

commit 70d13bbb328984469a09491808dae1ab2c16443c
Author: Matej Knopp <matej.knopp@gmail.com>
Date:   Mon Dec 5 18:57:01 2011 +0100

    basevideo: Make GstVideoFrame a reference counted boxed object
    
    ...and also clear all existing frames when resetting the decoder or encoder.
Comment 18 Sebastian Dröge (slomo) 2011-12-12 13:17:57 UTC
And this is the 0.11 version. The rename patch unfortunately doesn't make sense after looking at the 0.11 changes. It was recently renamed from GstVideoFrame to GstVideoFrameState.

commit 4342eea6371ee49eadc19924a304d6f9376da6f9
Author: Matej Knopp <matej.knopp@gmail.com>
Date:   Mon Dec 5 18:57:01 2011 +0100

    basevideo: Make framestate a reference counted boxed object
    
    ...and also clear all existing frames when resetting the decoder or encoder.
Comment 19 Sebastian Dröge (slomo) 2011-12-12 13:25:36 UTC
*** Bug 654529 has been marked as a duplicate of this bug. ***
Comment 20 Matej Knopp 2011-12-12 14:59:35 UTC
Well, I did rename it because you suggested it in previous comment
("While we're at it, GstVideoFrameState should be renamed to GstBaseVideoCodecFrame or something like that")
Comment 21 Sebastian Dröge (slomo) 2011-12-13 09:49:36 UTC
Right, sorry for that. I should've checked the 0.11 changes before