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