[FFmpeg-cvslog] h2645_parse: add a function for uninitializing the packet

Anton Khirnov git at videolan.org
Tue Apr 26 15:01:57 CEST 2016


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Mar 21 07:33:25 2016 +0100| [8229eff4b7a98ae5d85bb75f3bb072781b4a8ebe] | committer: Anton Khirnov

h2645_parse: add a function for uninitializing the packet

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8229eff4b7a98ae5d85bb75f3bb072781b4a8ebe
---

 libavcodec/h2645_parse.c |    9 +++++++++
 libavcodec/h2645_parse.h |    5 +++++
 libavcodec/hevc.c        |    5 +----
 libavcodec/hevc_parser.c |    5 +----
 4 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c
index 794c954..0064b7d 100644
--- a/libavcodec/h2645_parse.c
+++ b/libavcodec/h2645_parse.c
@@ -226,3 +226,12 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
 
     return 0;
 }
+
+void ff_h2645_packet_uninit(H2645Packet *pkt)
+{
+    int i;
+    for (i = 0; i < pkt->nals_allocated; i++)
+        av_freep(&pkt->nals[i].rbsp_buffer);
+    av_freep(&pkt->nals);
+    pkt->nals_allocated = 0;
+}
diff --git a/libavcodec/h2645_parse.h b/libavcodec/h2645_parse.h
index 4901ccf..eaf7d60 100644
--- a/libavcodec/h2645_parse.h
+++ b/libavcodec/h2645_parse.h
@@ -61,4 +61,9 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length,
 int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length,
                           AVCodecContext *avctx, int is_nalff, int nal_length_size);
 
+/**
+ * Free all the allocated memory in the packet.
+ */
+void ff_h2645_packet_uninit(H2645Packet *pkt);
+
 #endif /* AVCODEC_H2645_PARSE_H */
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 69c4f26..72dea5a 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -2798,10 +2798,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
     for (i = 0; i < FF_ARRAY_ELEMS(s->ps.pps_list); i++)
         av_buffer_unref(&s->ps.pps_list[i]);
 
-    for (i = 0; i < s->pkt.nals_allocated; i++)
-        av_freep(&s->pkt.nals[i].rbsp_buffer);
-    av_freep(&s->pkt.nals);
-    s->pkt.nals_allocated = 0;
+    ff_h2645_packet_uninit(&s->pkt);
 
     return 0;
 }
diff --git a/libavcodec/hevc_parser.c b/libavcodec/hevc_parser.c
index 20eae54..5c1fbc3 100644
--- a/libavcodec/hevc_parser.c
+++ b/libavcodec/hevc_parser.c
@@ -227,10 +227,7 @@ static void hevc_parser_close(AVCodecParserContext *s)
     for (i = 0; i < FF_ARRAY_ELEMS(ctx->ps.pps_list); i++)
         av_buffer_unref(&ctx->ps.pps_list[i]);
 
-    for (i = 0; i < ctx->pkt.nals_allocated; i++)
-        av_freep(&ctx->pkt.nals[i].rbsp_buffer);
-    av_freep(&ctx->pkt.nals);
-    ctx->pkt.nals_allocated = 0;
+    ff_h2645_packet_uninit(&ctx->pkt);
 
     av_freep(&ctx->pc.buffer);
 }



More information about the ffmpeg-cvslog mailing list