diff options
author | Clément Bœsch <u@pkh.me> | 2017-03-29 15:20:25 +0300 |
---|---|---|
committer | Clément Bœsch <u@pkh.me> | 2017-03-29 15:21:52 +0300 |
commit | 58f24adc05b0ea47c3f7ed5cb9e8d5774e2fbaaf (patch) | |
tree | ef1924ac088b8787bf74f508dd789af8725b3a12 /doc/examples/encode_video.c | |
parent | 944e5ce3ec7d4d9cf36e3f5c628b4e71186fa93a (diff) | |
parent | 5b4d7ac7ae5d821cfa6ab89f8eab4d31851ef32c (diff) |
Merge commit '5b4d7ac7ae5d821cfa6ab89f8eab4d31851ef32c'
* commit '5b4d7ac7ae5d821cfa6ab89f8eab4d31851ef32c':
examples/encode_video: use the AVFrame API for allocating the frame
Merged-by: Clément Bœsch <u@pkh.me>
Diffstat (limited to 'doc/examples/encode_video.c')
-rw-r--r-- | doc/examples/encode_video.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/doc/examples/encode_video.c b/doc/examples/encode_video.c index ba6f2bf0e8..fc576e01d2 100644 --- a/doc/examples/encode_video.c +++ b/doc/examples/encode_video.c @@ -112,12 +112,9 @@ int main(int argc, char **argv) frame->width = c->width; frame->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(frame->data, frame->linesize, c->width, c->height, - c->pix_fmt, 32); + ret = av_frame_get_buffer(frame, 32); if (ret < 0) { - fprintf(stderr, "Could not allocate raw picture buffer\n"); + fprintf(stderr, "Could not allocate the video frame data\n"); exit(1); } @@ -128,6 +125,12 @@ int main(int argc, char **argv) pkt.size = 0; fflush(stdout); + + /* make sure the frame data is writable */ + ret = av_frame_make_writable(frame); + if (ret < 0) + exit(1); + /* prepare a dummy image */ /* Y */ for (y = 0; y < c->height; y++) { @@ -182,7 +185,6 @@ int main(int argc, char **argv) fclose(f); avcodec_free_context(&c); - av_freep(&frame->data[0]); av_frame_free(&frame); return 0; |