}
c = avcodec_alloc_context3(codec);
- picture= avcodec_alloc_frame();
/* put sample parameters */
c->bit_rate = 400000;
exit(1);
}
+ picture = avcodec_alloc_frame();
+ if (!picture) {
+ fprintf(stderr, "Could not allocate video frame\n");
+ exit(1);
+ }
+ picture->format = c->pix_fmt;
+ picture->width = c->width;
+ picture->height = c->height;
+
/* the image can be allocated by any means and av_image_alloc() is
* just the most convenient way if av_malloc() is to be used */
ret = av_image_alloc(picture->data, picture->linesize, c->width, c->height,
exit(1);
}
- picture->format = c->pix_fmt;
- picture->width = c->width;
- picture->height = c->height;
-
/* encode 1 second of video */
for(i=0;i<25;i++) {
av_init_packet(&pkt);
}
c = avcodec_alloc_context3(codec);
- picture= avcodec_alloc_frame();
-
if(codec->capabilities&CODEC_CAP_TRUNCATED)
c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
exit(1);
}
+ picture = avcodec_alloc_frame();
+ if (!picture) {
+ fprintf(stderr, "Could not allocate video frame\n");
+ exit(1);
+ }
+
frame = 0;
for(;;) {
avpkt.size = fread(inbuf, 1, INBUF_SIZE, f);