[FFmpeg-devel] [PATCH 5/5] fate-api-h264-slice: use the heap for nal buffer

Peter Ross pross at xvid.org
Tue Nov 20 16:31:44 EET 2018


nal buffer is 512 kilobytes
---
 tests/api/api-h264-slice-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/api/api-h264-slice-test.c b/tests/api/api-h264-slice-test.c
index be03e80049..181bbe5a6f 100644
--- a/tests/api/api-h264-slice-test.c
+++ b/tests/api/api-h264-slice-test.c
@@ -117,9 +117,9 @@ int main(int argc, char **argv)
     unsigned int threads;
     AVPacket *pkt;
     FILE *file = NULL;
-    char nal[MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE];
+    char * nal = NULL;
     int nals = 0, ret = 0;
-    char *p = nal;
+    char *p;
 
     if (argc < 4) {
         fprintf(stderr, "Usage: %s <threads> <input file> <output file>\n", argv[0]);
@@ -139,6 +139,11 @@ int main(int argc, char **argv)
         return -1;
     }
 
+    nal = av_malloc(MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE);
+    if (!nal)
+        goto err;
+    p = nal;
+
     if (!(codec = avcodec_find_decoder(AV_CODEC_ID_H264))) {
         fprintf(stderr, "Codec not found\n");
         ret = -1;
@@ -223,6 +228,8 @@ int main(int argc, char **argv)
     ret = decode(c, frame, NULL);
 
 err:
+    if (nal)
+        av_free(nal);
     if (file)
         fclose(file);
     av_frame_free(&frame);
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181121/9a2a20e2/attachment.sig>


More information about the ffmpeg-devel mailing list