23 #include <sys/ioctl.h>
26 #include "libavutil/pixdesc.h"
27 #include "libavutil/log.h"
28 #include "libavutil/mem.h"
29 #include "libavutil/opt.h"
30 #include "libavformat/avformat.h"
37 struct fb_var_screeninfo varinfo;
38 struct fb_fix_screeninfo fixinfo;
57 "Could not open framebuffer device '%s': %s\n",
62 if (ioctl(fbdev->
fd, FBIOGET_VSCREENINFO, &fbdev->
varinfo) < 0) {
68 if (ioctl(fbdev->
fd, FBIOGET_FSCREENINFO, &fbdev->
fixinfo) < 0) {
81 fbdev->
data = mmap(NULL, fbdev->
fixinfo.smem_len, PROT_WRITE, MAP_SHARED, fbdev->
fd, 0);
82 if (fbdev->
data == MAP_FAILED) {
103 int video_width = codec_ctx->
width;
104 int video_height = codec_ctx->
height;
106 int src_line_size = video_width * bytes_per_pixel;
109 if (ioctl(fbdev->
fd, FBIOGET_VSCREENINFO, &fbdev->
varinfo) < 0)
115 if (fb_pix_fmt != video_pix_fmt) {
122 bytes_to_copy =
FFMIN(fbdev->
varinfo.xres, video_width) * bytes_per_pixel;
126 bytes_per_pixel * fbdev->
varinfo.xoffset +
131 if (-fbdev->
xoffset >= video_width)
133 bytes_to_copy += fbdev->
xoffset * bytes_per_pixel;
134 pin -= fbdev->
xoffset * bytes_per_pixel;
138 if (diff >= video_width)
140 bytes_to_copy -= diff * bytes_per_pixel;
142 pout += bytes_per_pixel * fbdev->
xoffset;
148 if (-fbdev->
yoffset >= video_height)
151 pin -= fbdev->
yoffset * src_line_size;
155 if (diff >= video_height)
163 for (i = 0; i < disp_height; i++) {
164 memcpy(pout, pin, bytes_to_copy);
165 pout += fbdev->
fixinfo.line_length;
166 pin += src_line_size;
180 #define OFFSET(x) offsetof(FBDevContext, x)
181 #define ENC AV_OPT_FLAG_ENCODING_PARAM
183 {
"xoffset",
"set x coordinate of top left corner",
OFFSET(xoffset),
AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX,
ENC },
184 {
"yoffset",
"set y coordinate of top left corner",
OFFSET(yoffset),
AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX,
ENC },
205 .priv_class = &fbdev_class,
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
AVCodecContext * codec
Codec context associated with this stream.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
const char * av_default_item_name(void *ctx)
Return the context name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
struct fb_var_screeninfo varinfo
variable info;
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
enum AVPixelFormat pix_fmt
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
const OptionDef options[]
AVOutputFormat ff_fbdev_muxer
#define av_err2str(errnum)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * priv_data
Format private data.
char filename[1024]
input or output filename
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
AVPixelFormat
Pixel format.
struct fb_fix_screeninfo fixinfo
fixed info;
unsigned int nb_streams
A list of all streams in the file.
int yoffset
y coordinate of top left corner
int width
picture width / height.
static int write_trailer(AVFormatContext *s1)
static av_cold int fbdev_write_header(AVFormatContext *h)
int xoffset
x coordinate of top left corner
static av_cold int fbdev_write_trailer(AVFormatContext *h)
enum AVMediaType codec_type
main external API structure.
static void close(AVCodecParserContext *s)
Describe the class of an AVClass context structure.
static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
enum AVPixelFormat ff_get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *varinfo)
static const AVClass fbdev_class
static void write_header(FFV1Context *f)
uint8_t * data
framebuffer data
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
int fd
framebuffer device file descriptor