]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/fbdev.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavdevice / fbdev.c
index 70a904c5720a943d098a61090c050555db9880fb..ee5ecee89dfbb72a15d865dfe000f8cd5de2991a 100644 (file)
@@ -43,6 +43,7 @@
 #include "libavutil/parseutils.h"
 #include "libavutil/pixdesc.h"
 #include "avdevice.h"
+#include "libavformat/internal.h"
 
 struct rgb_pixfmt_map_entry {
     int bits_per_pixel;
@@ -50,7 +51,7 @@ struct rgb_pixfmt_map_entry {
     enum PixelFormat pixfmt;
 };
 
-static struct rgb_pixfmt_map_entry rgb_pixfmt_map[] = {
+static const struct rgb_pixfmt_map_entry rgb_pixfmt_map[] = {
     // bpp, red_offset,  green_offset, blue_offset, alpha_offset, pixfmt
     {  32,       0,           8,          16,           24,   PIX_FMT_RGBA  },
     {  32,      16,           8,           0,           24,   PIX_FMT_BGRA  },
@@ -65,7 +66,7 @@ static enum PixelFormat get_pixfmt_from_fb_varinfo(struct fb_var_screeninfo *var
     int i;
 
     for (i = 0; i < FF_ARRAY_ELEMS(rgb_pixfmt_map); i++) {
-        struct rgb_pixfmt_map_entry *entry = &rgb_pixfmt_map[i];
+        const struct rgb_pixfmt_map_entry *entry = &rgb_pixfmt_map[i];
         if (entry->bits_per_pixel == varinfo->bits_per_pixel &&
             entry->red_offset     == varinfo->red.offset     &&
             entry->green_offset   == varinfo->green.offset   &&
@@ -84,7 +85,7 @@ typedef struct {
     int64_t time_frame;      ///< time for the next frame to output (in 1/1000000 units)
 
     int fd;                  ///< framebuffer device file descriptor
-    int width, heigth;       ///< assumed frame resolution
+    int width, height;       ///< assumed frame resolution
     int frame_linesize;      ///< linesize of the output frame, it is assumed to be constant
     int bytes_per_pixel;
 
@@ -108,9 +109,9 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx,
         return ret;
     }
 
-    if (!(st = av_new_stream(avctx, 0)))
+    if (!(st = avformat_new_stream(avctx, NULL)))
         return AVERROR(ENOMEM);
-    av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */
+    avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */
 
     /* NONBLOCK is ignored by the fbdev driver, only set for consistency */
     if (avctx->flags & AVFMT_FLAG_NONBLOCK)
@@ -147,10 +148,10 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx,
     }
 
     fbdev->width           = fbdev->varinfo.xres;
-    fbdev->heigth          = fbdev->varinfo.yres;
+    fbdev->height          = fbdev->varinfo.yres;
     fbdev->bytes_per_pixel = (fbdev->varinfo.bits_per_pixel + 7) >> 3;
     fbdev->frame_linesize  = fbdev->width * fbdev->bytes_per_pixel;
-    fbdev->frame_size      = fbdev->frame_linesize * fbdev->heigth;
+    fbdev->frame_size      = fbdev->frame_linesize * fbdev->height;
     fbdev->time_frame      = AV_NOPTS_VALUE;
     fbdev->data = mmap(NULL, fbdev->fixinfo.smem_len, PROT_READ, MAP_SHARED, fbdev->fd, 0);
     if (fbdev->data == MAP_FAILED) {
@@ -162,15 +163,15 @@ av_cold static int fbdev_read_header(AVFormatContext *avctx,
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     st->codec->codec_id   = CODEC_ID_RAWVIDEO;
     st->codec->width      = fbdev->width;
-    st->codec->height     = fbdev->heigth;
+    st->codec->height     = fbdev->height;
     st->codec->pix_fmt    = pix_fmt;
     st->codec->time_base  = (AVRational){fbdev->framerate_q.den, fbdev->framerate_q.num};
     st->codec->bit_rate   =
-        fbdev->width * fbdev->heigth * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
+        fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
 
     av_log(avctx, AV_LOG_INFO,
            "w:%d h:%d bpp:%d pixfmt:%s fps:%d/%d bit_rate:%d\n",
-           fbdev->width, fbdev->heigth, fbdev->varinfo.bits_per_pixel,
+           fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
            av_pix_fmt_descriptors[pix_fmt].name,
            fbdev->framerate_q.num, fbdev->framerate_q.den,
            st->codec->bit_rate);
@@ -225,7 +226,7 @@ static int fbdev_read_packet(AVFormatContext *avctx, AVPacket *pkt)
                         fbdev->varinfo.yoffset * fbdev->fixinfo.line_length;
     pout = pkt->data;
 
-    for (i = 0; i < fbdev->heigth; i++) {
+    for (i = 0; i < fbdev->height; i++) {
         memcpy(pout, pin, fbdev->frame_linesize);
         pin  += fbdev->fixinfo.line_length;
         pout += fbdev->frame_linesize;
@@ -247,7 +248,7 @@ av_cold static int fbdev_read_close(AVFormatContext *avctx)
 #define OFFSET(x) offsetof(FBDevContext, x)
 #define DEC AV_OPT_FLAG_DECODING_PARAM
 static const AVOption options[] = {
-    { "framerate","", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
+    { "framerate","", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC },
     { NULL },
 };