Out of the three places where this function is called with free_rbsp=1,
only during the call from free_context() it actually does something,
it is a no-op in the other two cases.

Managing the DPB also does not logically belong in free_tables().
Therefore, clear it in free_context() itself.
---
 libavcodec/h264.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index b5dbba0..06e4de0 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -355,14 +355,6 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp)
     av_buffer_pool_uninit(&h->motion_val_pool);
     av_buffer_pool_uninit(&h->ref_index_pool);
 
-    if (free_rbsp && h->DPB) {
-        for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
-            ff_h264_unref_picture(h, &h->DPB[i]);
-        av_freep(&h->DPB);
-    }
-
-    h->cur_pic_ptr = NULL;
-
     for (i = 0; i < h->nb_slice_ctx; i++) {
         H264SliceContext *sl = &h->slice_ctx[i];
 
@@ -1756,6 +1748,14 @@ av_cold void ff_h264_free_context(H264Context *h)
 
     ff_h264_free_tables(h, 1); // FIXME cleanup init stuff perhaps
 
+    if (h->DPB) {
+        for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
+            ff_h264_unref_picture(h, &h->DPB[i]);
+        av_freep(&h->DPB);
+    }
+
+    h->cur_pic_ptr = NULL;
+
     av_freep(&h->slice_ctx);
     h->nb_slice_ctx = 0;
 
-- 
2.0.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to