nal buffer is 512 kilobytes
Unified · Split
| @@ -117,9 +117,9 @@ int main(int argc, char **argv) · 116 unmodified lines | |||
| 117 | unsigned int threads; | 117 | unsigned int threads; |
| 118 | AVPacket *pkt; | 118 | AVPacket *pkt; |
| 119 | FILE *file = NULL; | 119 | FILE *file = NULL; |
| 120 | char nal[MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE]; | 120 | char * nal = NULL; |
| 121 | int nals = 0, ret = 0; | 121 | int nals = 0, ret = 0; |
| 122 | char *p = nal; | 122 | char *p; |
| 123 | 123 | ||
| 124 | if (argc < 4) { | 124 | if (argc < 4) { |
| 125 | fprintf(stderr, "Usage: %s <threads> <input file> <output file>\n", argv[0]); | 125 | fprintf(stderr, "Usage: %s <threads> <input file> <output file>\n", argv[0]); |
| @@ -139,6 +139,11 @@ int main(int argc, char **argv) · 13 unmodified lines | |||
| 139 | return -1; | 139 | return -1; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | nal = av_malloc(MAX_SLICES * UINT16_MAX + AV_INPUT_BUFFER_PADDING_SIZE); | ||
| 143 | if (!nal) | ||
| 144 | goto err; | ||
| 145 | p = nal; | ||
| 146 | |||
| 142 | if (!(codec = avcodec_find_decoder(AV_CODEC_ID_H264))) { | 147 | if (!(codec = avcodec_find_decoder(AV_CODEC_ID_H264))) { |
| 143 | fprintf(stderr, "Codec not found\n"); | 148 | fprintf(stderr, "Codec not found\n"); |
| 144 | ret = -1; | 149 | ret = -1; |
| @@ -223,6 +228,8 @@ int main(int argc, char **argv) · 78 unmodified lines | |||
| 223 | ret = decode(c, frame, NULL); | 228 | ret = decode(c, frame, NULL); |
| 224 | 229 | ||
| 225 | err: | 230 | err: |
| 231 | if (nal) | ||
| 232 | av_free(nal); | ||
| 226 | if (file) | 233 | if (file) |
| 227 | fclose(file); | 234 | fclose(file); |
| 228 | av_frame_free(&frame); | 235 | av_frame_free(&frame); |