Showing the changes to doc/examples/decoding_encoding.c (1 of 1 file). Show all
Unified · Split
| @@ -121,6 +121,10 @@ static void audio_encode_example(const char *filename) · 120 unmodified lines | ||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | c = avcodec_alloc_context3(codec); |
| 124 | + if (!c) { | |
| 125 | + fprintf(stderr, "Could not allocate audio codec context\n"); | |
| 126 | + exit(1); | |
| 127 | + } | |
| 124 | 128 | |
| 125 | 129 | /* put sample parameters */ |
| 126 | 130 | c->bit_rate = 64000; |
| @@ -252,6 +256,10 @@ static void audio_decode_example(const char *outfilename, const char *filename) · 125 unmodified lines | ||
| 252 | 256 | } |
| 253 | 257 | |
| 254 | 258 | c = avcodec_alloc_context3(codec); |
| 259 | + if (!c) { | |
| 260 | + fprintf(stderr, "Could not allocate audio codec context\n"); | |
| 261 | + exit(1); | |
| 262 | + } | |
| 255 | 263 | |
| 256 | 264 | /* open it */ |
| 257 | 265 | if (avcodec_open2(c, codec, NULL) < 0) { |
| @@ -346,6 +354,10 @@ static void video_encode_example(const char *filename, int codec_id) · 88 unmodified lines | ||
| 346 | 354 | } |
| 347 | 355 | |
| 348 | 356 | c = avcodec_alloc_context3(codec); |
| 357 | + if (!c) { | |
| 358 | + fprintf(stderr, "Could not allocate video codec context\n"); | |
| 359 | + exit(1); | |
| 360 | + } | |
| 349 | 361 | |
| 350 | 362 | /* put sample parameters */ |
| 351 | 363 | c->bit_rate = 400000; |
| @@ -501,6 +513,11 @@ static void video_decode_example(const char *outfilename, const char *filename) · 149 unmodified lines | ||
| 501 | 513 | } |
| 502 | 514 | |
| 503 | 515 | c = avcodec_alloc_context3(codec); |
| 516 | + if (!c) { | |
| 517 | + fprintf(stderr, "Could not allocate video codec context\n"); | |
| 518 | + exit(1); | |
| 519 | + } | |
| 520 | + | |
| 504 | 521 | if(codec->capabilities&CODEC_CAP_TRUNCATED) |
| 505 | 522 | c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ |
| 506 | 523 | |