aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2015-04-06 21:00:42 +0200
committerAnton Khirnov <anton@khirnov.net>2015-04-29 05:52:58 +0200
commit11f024ef0ab923ed8680fc35a087d576e549c849 (patch)
tree61c061aa49fa78c2aa3e366ea027d69c69f21dfa
parentee62b364be0c30cba83b5ff10a3ca8c3e866ade6 (diff)
downloadffmpeg-11f024ef0ab923ed8680fc35a087d576e549c849.tar.gz
h264: move freeing the escaped RBSP buffer to free_context()
It does not logically belong in free_tables(), since it's not allocated in alloc_tables() and its size has nothing to do with the frame size.
-rw-r--r--libavcodec/h264.c15
-rw-r--r--libavcodec/h264.h2
-rw-r--r--libavcodec/h264_slice.c2
3 files changed, 8 insertions, 11 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 4a3da24502..0d8ff40e8c 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -332,7 +332,7 @@ static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
return 0;
}
-void ff_h264_free_tables(H264Context *h, int free_rbsp)
+void ff_h264_free_tables(H264Context *h)
{
int i;
@@ -372,11 +372,6 @@ void ff_h264_free_tables(H264Context *h, int free_rbsp)
sl->edge_emu_buffer_allocated = 0;
sl->top_borders_allocated[0] = 0;
sl->top_borders_allocated[1] = 0;
-
- if (free_rbsp) {
- av_freep(&sl->rbsp_buffer);
- sl->rbsp_buffer_size = 0;
- }
}
}
@@ -433,7 +428,7 @@ int ff_h264_alloc_tables(H264Context *h)
return 0;
fail:
- ff_h264_free_tables(h, 1);
+ ff_h264_free_tables(h);
return AVERROR(ENOMEM);
}
@@ -1065,7 +1060,7 @@ static void flush_dpb(AVCodecContext *avctx)
h->mb_y = 0;
- ff_h264_free_tables(h, 1);
+ ff_h264_free_tables(h);
h->context_initialized = 0;
}
@@ -1701,7 +1696,7 @@ av_cold void ff_h264_free_context(H264Context *h)
{
int i;
- ff_h264_free_tables(h, 1); // FIXME cleanup init stuff perhaps
+ ff_h264_free_tables(h); // FIXME cleanup init stuff perhaps
if (h->DPB) {
for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
@@ -1711,6 +1706,8 @@ av_cold void ff_h264_free_context(H264Context *h)
h->cur_pic_ptr = NULL;
+ for (i = 0; i < h->nb_slice_ctx; i++)
+ av_freep(&h->slice_ctx[i].rbsp_buffer);
av_freep(&h->slice_ctx);
h->nb_slice_ctx = 0;
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
index 9ca4edac3d..ca26e616ba 100644
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -1084,6 +1084,6 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
void ff_h264_flush_change(H264Context *h);
-void ff_h264_free_tables(H264Context *h, int free_rbsp);
+void ff_h264_free_tables(H264Context *h);
#endif /* AVCODEC_H264_H */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index da394d19e4..4623dd99fa 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -994,7 +994,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
}
if (reinit)
- ff_h264_free_tables(h, 0);
+ ff_h264_free_tables(h);
h->first_field = 0;
h->prev_interlaced_frame = 1;