]> git.sesse.net Git - ffmpeg/commitdiff
h2645_parse: add a function for uninitializing the packet
authorAnton Khirnov <anton@khirnov.net>
Mon, 21 Mar 2016 06:33:25 +0000 (07:33 +0100)
committerAnton Khirnov <anton@khirnov.net>
Mon, 28 Mar 2016 07:43:18 +0000 (09:43 +0200)
libavcodec/h2645_parse.c
libavcodec/h2645_parse.h
libavcodec/hevc.c
libavcodec/hevc_parser.c

index 794c95459739411050d9fcd80751c0847cf8174a..0064b7d48927feebe41e370e06ba8f488b71b86f 100644 (file)
@@ -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;
+}
index 4901ccfbc1938644704c9cbb5be18e4ecb694e4a..eaf7d60917b285f9e358956b3f7c5a27f8c47e72 100644 (file)
@@ -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 */
index 69c4f26aa6ec7c5eabc36a1e75b3d496d219c198..72dea5a5894e73b2ca8dba8d23798ada0d90604b 100644 (file)
@@ -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;
 }
index 20eae54e792339f3d763145c2c9955c463f4618d..5c1fbc31d538fbee89b7fa0550973cdb750f7c21 100644 (file)
@@ -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);
 }