Allocate an AVFrame object
| 2033 | |
| 2034 | // Allocate an AVFrame object |
| 2035 | AVFrame *FFmpegWriter::allocate_avframe(PixelFormat pix_fmt, int width, int height, int *buffer_size, uint8_t *new_buffer) { |
| 2036 | // Create an RGB AVFrame |
| 2037 | AVFrame *new_av_frame = NULL; |
| 2038 | |
| 2039 | // Allocate an AVFrame structure |
| 2040 | new_av_frame = AV_ALLOCATE_FRAME(); |
| 2041 | if (new_av_frame == NULL) |
| 2042 | throw OutOfMemory("Could not allocate AVFrame", path); |
| 2043 | |
| 2044 | // Determine required buffer size and allocate buffer |
| 2045 | *buffer_size = AV_GET_IMAGE_SIZE(pix_fmt, width, height); |
| 2046 | |
| 2047 | // Create buffer (if not provided) |
| 2048 | if (!new_buffer) { |
| 2049 | // New Buffer |
| 2050 | new_buffer = (uint8_t *) av_malloc(*buffer_size * sizeof(uint8_t)); |
| 2051 | // Attach buffer to AVFrame |
| 2052 | AV_COPY_PICTURE_DATA(new_av_frame, new_buffer, pix_fmt, width, height); |
| 2053 | new_av_frame->width = width; |
| 2054 | new_av_frame->height = height; |
| 2055 | new_av_frame->format = pix_fmt; |
| 2056 | } |
| 2057 | |
| 2058 | // return AVFrame |
| 2059 | return new_av_frame; |
| 2060 | } |
| 2061 | |
| 2062 | // process video frame |
| 2063 | void FFmpegWriter::process_video_packet(std::shared_ptr<Frame> frame) { |
nothing calls this directly
no test coverage detected