35 #include "ffmpeg_image.h"
38 #include <libavutil/pixfmt.h>
45 FFmpegImage::FFmpegImage(int64_t pts)
47 auto const width = size().width;
48 auto const height = size().height;
50 _frame = av_frame_alloc();
52 throw std::bad_alloc();
55 _frame->buf[0] = av_buffer_alloc(width * height);
56 _frame->buf[1] = av_buffer_alloc(width * height / 4);
57 _frame->buf[2] = av_buffer_alloc(width * height / 4);
59 _frame->linesize[0] = width;
60 _frame->linesize[1] = width / 2;
61 _frame->linesize[2] = width / 2;
63 for (
auto i = 0; i < 3; ++i) {
64 _frame->data[i] = _frame->buf[i]->data;
67 _frame->width = width;
68 _frame->height = height;
69 _frame->format = AV_PIX_FMT_YUV420P;
75 FFmpegImage::set_pts(int64_t pts)
84 return _frame->data[0];
89 FFmpegImage::y_stride()
const
91 return _frame->linesize[0];
98 return _frame->data[1];
103 FFmpegImage::u_stride()
const
105 return _frame->linesize[1];
112 return _frame->data[2];
117 FFmpegImage::v_stride()
const
119 return _frame->linesize[2];
Namespace for everything in libdcp.