* commit '8229eff4b7a98ae5d85bb75f3bb072781b4a8ebe':
h2645_parse: add a function for uninitializing the packet
Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
... | ... |
@@ -295,3 +295,13 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, |
295 | 295 |
return 0; |
296 | 296 |
} |
297 | 297 |
|
298 |
+void ff_h2645_packet_uninit(H2645Packet *pkt) |
|
299 |
+{ |
|
300 |
+ int i; |
|
301 |
+ for (i = 0; i < pkt->nals_allocated; i++) { |
|
302 |
+ av_freep(&pkt->nals[i].rbsp_buffer); |
|
303 |
+ av_freep(&pkt->nals[i].skipped_bytes_pos); |
|
304 |
+ } |
|
305 |
+ av_freep(&pkt->nals); |
|
306 |
+ pkt->nals_allocated = 0; |
|
307 |
+} |
... | ... |
@@ -65,4 +65,9 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length, |
65 | 65 |
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, |
66 | 66 |
AVCodecContext *avctx, int is_nalff, int nal_length_size); |
67 | 67 |
|
68 |
+/** |
|
69 |
+ * Free all the allocated memory in the packet. |
|
70 |
+ */ |
|
71 |
+void ff_h2645_packet_uninit(H2645Packet *pkt); |
|
72 |
+ |
|
68 | 73 |
#endif /* AVCODEC_H2645_PARSE_H */ |
... | ... |
@@ -3111,12 +3111,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) |
3111 | 3111 |
s->HEVClc = NULL; |
3112 | 3112 |
av_freep(&s->HEVClcList[0]); |
3113 | 3113 |
|
3114 |
- for (i = 0; i < s->pkt.nals_allocated; i++) { |
|
3115 |
- av_freep(&s->pkt.nals[i].rbsp_buffer); |
|
3116 |
- av_freep(&s->pkt.nals[i].skipped_bytes_pos); |
|
3117 |
- } |
|
3118 |
- av_freep(&s->pkt.nals); |
|
3119 |
- s->pkt.nals_allocated = 0; |
|
3114 |
+ ff_h2645_packet_uninit(&s->pkt); |
|
3120 | 3115 |
|
3121 | 3116 |
return 0; |
3122 | 3117 |
} |
... | ... |
@@ -472,12 +472,7 @@ static void hevc_parser_close(AVCodecParserContext *s) |
472 | 472 |
|
473 | 473 |
ctx->ps.sps = NULL; |
474 | 474 |
|
475 |
- for (i = 0; i < ctx->pkt.nals_allocated; i++) { |
|
476 |
- av_freep(&ctx->pkt.nals[i].rbsp_buffer); |
|
477 |
- av_freep(&ctx->pkt.nals[i].skipped_bytes_pos); |
|
478 |
- } |
|
479 |
- av_freep(&ctx->pkt.nals); |
|
480 |
- ctx->pkt.nals_allocated = 0; |
|
475 |
+ ff_h2645_packet_uninit(&ctx->pkt); |
|
481 | 476 |
|
482 | 477 |
av_freep(&ctx->pc.buffer); |
483 | 478 |
} |